mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-16 02:41:29 +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
|
"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)
|
const char **getEnumNames (CSMWorld::Columns::ColumnId column)
|
||||||
{
|
{
|
||||||
switch (column)
|
switch (column)
|
||||||
|
@ -265,6 +270,7 @@ namespace
|
||||||
case CSMWorld::Columns::ColumnId_CreatureType: return sCreatureTypes;
|
case CSMWorld::Columns::ColumnId_CreatureType: return sCreatureTypes;
|
||||||
case CSMWorld::Columns::ColumnId_WeaponType: return sWeaponTypes;
|
case CSMWorld::Columns::ColumnId_WeaponType: return sWeaponTypes;
|
||||||
case CSMWorld::Columns::ColumnId_Modification: return sModificationEnums;
|
case CSMWorld::Columns::ColumnId_Modification: return sModificationEnums;
|
||||||
|
case CSMWorld::Columns::ColumnId_ValueType: return sVarTypeEnums;
|
||||||
|
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
|
#include "../../model/world/columns.hpp"
|
||||||
|
|
||||||
void CSVWorld::VarTypeDelegate::addCommands (QAbstractItemModel *model, const QModelIndex& index, int type)
|
void CSVWorld::VarTypeDelegate::addCommands (QAbstractItemModel *model, const QModelIndex& index, int type)
|
||||||
const
|
const
|
||||||
|
@ -75,29 +76,11 @@ CSVWorld::CommandDelegate *CSVWorld::VarTypeDelegateFactory::makeDelegate (QUndo
|
||||||
|
|
||||||
void CSVWorld::VarTypeDelegateFactory::add (ESM::VarType type)
|
void CSVWorld::VarTypeDelegateFactory::add (ESM::VarType type)
|
||||||
{
|
{
|
||||||
struct Name
|
std::vector<std::string> enums =
|
||||||
{
|
CSMWorld::Columns::getEnums (CSMWorld::Columns::ColumnId_ValueType);
|
||||||
ESM::VarType mType;
|
|
||||||
const char *mName;
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i=0; sNames[i].mName; ++i)
|
|
||||||
if (sNames[i].mType==type)
|
|
||||||
{
|
|
||||||
mValues.push_back (std::make_pair (type, sNames[i].mName));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (type<0 && type>=enums.size())
|
||||||
throw std::logic_error ("Unsupported variable type");
|
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
|
enum VarType
|
||||||
{
|
{
|
||||||
VT_Unknown,
|
VT_Unknown = 0,
|
||||||
VT_None,
|
VT_None,
|
||||||
VT_Short, // stored as a float, kinda
|
VT_Short, // stored as a float, kinda
|
||||||
VT_Int,
|
VT_Int,
|
||||||
|
|
Loading…
Reference in a new issue