forked from mirror/openmw-tes3mp
Correct comparison of enum values in IdTableProxyModel
This commit is contained in:
parent
06f170a8e1
commit
8da9eecea7
1 changed files with 15 additions and 1 deletions
|
@ -5,6 +5,18 @@
|
||||||
|
|
||||||
#include "idtablebase.hpp"
|
#include "idtablebase.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::string getEnumValue(const std::vector<std::string> &values, int index)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= static_cast<int>(values.size()))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return values[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSMWorld::IdTableProxyModel::updateColumnMap()
|
void CSMWorld::IdTableProxyModel::updateColumnMap()
|
||||||
{
|
{
|
||||||
Q_ASSERT(mSourceModel != NULL);
|
Q_ASSERT(mSourceModel != NULL);
|
||||||
|
@ -93,7 +105,9 @@ bool CSMWorld::IdTableProxyModel::lessThan(const QModelIndex &left, const QModel
|
||||||
|
|
||||||
if (valuesIt != mEnumColumnCache.end())
|
if (valuesIt != mEnumColumnCache.end())
|
||||||
{
|
{
|
||||||
return valuesIt->second[left.data().toInt()] < valuesIt->second[right.data().toInt()];
|
std::string first = getEnumValue(valuesIt->second, left.data().toInt());
|
||||||
|
std::string second = getEnumValue(valuesIt->second, right.data().toInt());
|
||||||
|
return first < second;
|
||||||
}
|
}
|
||||||
return QSortFilterProxyModel::lessThan(left, right);
|
return QSortFilterProxyModel::lessThan(left, right);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue