mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-19 15:09:41 +00:00
allow the use of value types in string filters
This commit is contained in:
parent
f2e86e860e
commit
9332684335
3 changed files with 13 additions and 24 deletions
|
@ -252,6 +252,11 @@ namespace
|
|||
"Base", "Modified", "Added", "Deleted", "Deleted", 0
|
||||
};
|
||||
|
||||
static const char *sVarTypeEnums[] =
|
||||
{
|
||||
"unknown", "none", "short", "integer", "long", "float", "string", 0
|
||||
};
|
||||
|
||||
const char **getEnumNames (CSMWorld::Columns::ColumnId column)
|
||||
{
|
||||
switch (column)
|
||||
|
@ -265,6 +270,7 @@ namespace
|
|||
case CSMWorld::Columns::ColumnId_CreatureType: return sCreatureTypes;
|
||||
case CSMWorld::Columns::ColumnId_WeaponType: return sWeaponTypes;
|
||||
case CSMWorld::Columns::ColumnId_Modification: return sModificationEnums;
|
||||
case CSMWorld::Columns::ColumnId_ValueType: return sVarTypeEnums;
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QUndoStack>
|
||||
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/world/columns.hpp"
|
||||
|
||||
void CSVWorld::VarTypeDelegate::addCommands (QAbstractItemModel *model, const QModelIndex& index, int type)
|
||||
const
|
||||
|
@ -75,29 +76,11 @@ CSVWorld::CommandDelegate *CSVWorld::VarTypeDelegateFactory::makeDelegate (QUndo
|
|||
|
||||
void CSVWorld::VarTypeDelegateFactory::add (ESM::VarType type)
|
||||
{
|
||||
struct Name
|
||||
{
|
||||
ESM::VarType mType;
|
||||
const char *mName;
|
||||
};
|
||||
std::vector<std::string> enums =
|
||||
CSMWorld::Columns::getEnums (CSMWorld::Columns::ColumnId_ValueType);
|
||||
|
||||
static const Name sNames[] =
|
||||
{
|
||||
{ ESM::VT_None, "empty" },
|
||||
{ ESM::VT_Short, "short" },
|
||||
{ ESM::VT_Int, "integer" },
|
||||
{ ESM::VT_Long, "long" },
|
||||
{ ESM::VT_Float, "float" },
|
||||
{ ESM::VT_String, "string" },
|
||||
{ ESM::VT_Unknown, 0 } // end marker
|
||||
};
|
||||
if (type<0 && type>=enums.size())
|
||||
throw std::logic_error ("Unsupported variable type");
|
||||
|
||||
for (int i=0; sNames[i].mName; ++i)
|
||||
if (sNames[i].mType==type)
|
||||
{
|
||||
mValues.push_back (std::make_pair (type, sNames[i].mName));
|
||||
return;
|
||||
}
|
||||
|
||||
throw std::logic_error ("Unsupported variable type");
|
||||
mValues.push_back (std::make_pair (type, QString::fromUtf8 (enums[type].c_str())));
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace ESM
|
|||
|
||||
enum VarType
|
||||
{
|
||||
VT_Unknown,
|
||||
VT_Unknown = 0,
|
||||
VT_None,
|
||||
VT_Short, // stored as a float, kinda
|
||||
VT_Int,
|
||||
|
|
Loading…
Reference in a new issue