forked from mirror/openmw-tes3mp
Sort cell id column by numerical order.
This commit is contained in:
parent
0cccdfd114
commit
a161ad3cd5
2 changed files with 27 additions and 2 deletions
|
@ -47,4 +47,25 @@ void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr<CSMFilter::
|
||||||
mFilter = filter;
|
mFilter = filter;
|
||||||
updateColumnMap();
|
updateColumnMap();
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSMWorld::IdTableProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||||
|
{
|
||||||
|
if(headerData(left.column(), Qt::Horizontal).toString() != "ID")
|
||||||
|
return QSortFilterProxyModel::lessThan(left, right);
|
||||||
|
|
||||||
|
QRegExp cellPattern = QRegExp("^#(\\D?\\d+) +(\\D?\\d+)");
|
||||||
|
|
||||||
|
int leftResult = cellPattern.indexIn(sourceModel()->data(left).toString());
|
||||||
|
int leftX = cellPattern.cap(1).toInt();
|
||||||
|
int leftY = cellPattern.cap(2).toInt();
|
||||||
|
|
||||||
|
int rightResult = cellPattern.indexIn(sourceModel()->data(right).toString());
|
||||||
|
int rightX = cellPattern.cap(1).toInt();
|
||||||
|
int rightY = cellPattern.cap(2).toInt();
|
||||||
|
|
||||||
|
if(leftResult != -1 && rightResult != -1)
|
||||||
|
return(leftX < rightX) || (leftX == rightX && leftY <= rightY);
|
||||||
|
else
|
||||||
|
return QSortFilterProxyModel::lessThan(left, right);
|
||||||
|
}
|
||||||
|
|
|
@ -33,7 +33,11 @@ namespace CSMWorld
|
||||||
virtual QModelIndex getModelIndex (const std::string& id, int column) const;
|
virtual QModelIndex getModelIndex (const std::string& id, int column) const;
|
||||||
|
|
||||||
void setFilter (const boost::shared_ptr<CSMFilter::Node>& filter);
|
void setFilter (const boost::shared_ptr<CSMFilter::Node>& filter);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue