dealing with unset attribute fields

This commit is contained in:
Marc Zinnschlag 2013-04-02 14:15:22 +02:00
parent ec6bdbeb40
commit 384c88182d
4 changed files with 16 additions and 9 deletions

View File

@ -61,7 +61,7 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
new CSVWorld::EnumDelegateFactory (sSpecialisations)); new CSVWorld::EnumDelegateFactory (sSpecialisations));
mDelegateFactories->add (CSMWorld::ColumnBase::Display_Attribute, mDelegateFactories->add (CSMWorld::ColumnBase::Display_Attribute,
new CSVWorld::EnumDelegateFactory (sAttributes)); new CSVWorld::EnumDelegateFactory (sAttributes, true));
} }
CSVDoc::ViewManager::~ViewManager() CSVDoc::ViewManager::~ViewManager()

View File

@ -92,10 +92,13 @@ void CSVWorld::EnumDelegate::paint (QPainter *painter, const QStyleOptionViewIte
CSVWorld::EnumDelegateFactory::EnumDelegateFactory() {} CSVWorld::EnumDelegateFactory::EnumDelegateFactory() {}
CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const char **names) CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const char **names, bool allowNone)
{ {
assert (names); assert (names);
if (allowNone)
add (-1, "");
for (int i=0; names[i]; ++i) for (int i=0; names[i]; ++i)
add (i, names[i]); add (i, names[i]);
} }

View File

@ -47,8 +47,9 @@ namespace CSVWorld
EnumDelegateFactory(); EnumDelegateFactory();
EnumDelegateFactory (const char **names); EnumDelegateFactory (const char **names, bool allowNone = false);
///< \param names Array of char pointer with a 0-pointer as end mark ///< \param names Array of char pointer with a 0-pointer as end mark
/// \param allowNone Use value of -1 for "none selected" (empty string)
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const; virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
///< The ownership of the returned CommandDelegate is transferred to the caller. ///< The ownership of the returned CommandDelegate is transferred to the caller.

View File

@ -127,15 +127,18 @@ void Skill::save(ESMWriter &esm)
{ {
std::ostringstream stream; std::ostringstream stream;
stream << "#"; if (index!=-1)
{
stream << "#";
if (index<10) if (index<10)
stream << "0"; stream << "0";
stream << index; stream << index;
if (index>=0 && index<Length) if (index>=0 && index<Length)
stream << sSkillNameIds[index].substr (6); stream << sSkillNameIds[index].substr (6);
}
return stream.str(); return stream.str();
} }