GH-2550 soring of mods by enabled status, cascade sorting to name and version
This commit is contained in:
parent
bafcf93eb1
commit
930d39b5f2
@ -67,22 +67,37 @@ protected:
|
|||||||
// we are now guaranteed to have two valid indexes in the same column... we love the provided invariants unconditionally and proceed.
|
// we are now guaranteed to have two valid indexes in the same column... we love the provided invariants unconditionally and proceed.
|
||||||
|
|
||||||
auto column = (SimpleModList::Columns) source_left.column();
|
auto column = (SimpleModList::Columns) source_left.column();
|
||||||
|
bool invert = false;
|
||||||
switch(column) {
|
switch(column) {
|
||||||
|
// GH-2550 - sort by enabled/disabled
|
||||||
|
case SimpleModList::ActiveColumn: {
|
||||||
|
auto dataL = source_left.data(Qt::CheckStateRole).toBool();
|
||||||
|
auto dataR = source_right.data(Qt::CheckStateRole).toBool();
|
||||||
|
if(dataL != dataR) {
|
||||||
|
return dataL > dataR;
|
||||||
|
}
|
||||||
|
// fallthrough
|
||||||
|
invert = sortOrder() == Qt::DescendingOrder;
|
||||||
|
}
|
||||||
// GH-2722 - sort mod names in a way that discards "The" prefixes
|
// GH-2722 - sort mod names in a way that discards "The" prefixes
|
||||||
case SimpleModList::NameColumn: {
|
case SimpleModList::NameColumn: {
|
||||||
auto dataL = source_left.data(Qt::DisplayRole).toString();
|
auto dataL = model->data(model->index(source_left.row(), SimpleModList::NameColumn)).toString();
|
||||||
RemoveThePrefix(dataL);
|
RemoveThePrefix(dataL);
|
||||||
auto dataR = source_right.data(Qt::DisplayRole).toString();
|
auto dataR = model->data(model->index(source_right.row(), SimpleModList::NameColumn)).toString();
|
||||||
RemoveThePrefix(dataR);
|
RemoveThePrefix(dataR);
|
||||||
|
|
||||||
auto less = dataL.compare(dataR, sortCaseSensitivity()) < 0;
|
auto less = dataL.compare(dataR, sortCaseSensitivity());
|
||||||
return less;
|
if(less != 0) {
|
||||||
|
return invert ? (less > 0) : (less < 0);
|
||||||
|
}
|
||||||
|
// fallthrough
|
||||||
|
invert = sortOrder() == Qt::DescendingOrder;
|
||||||
}
|
}
|
||||||
// GH-2762 - sort versions by parsing them as versions
|
// GH-2762 - sort versions by parsing them as versions
|
||||||
case SimpleModList::VersionColumn: {
|
case SimpleModList::VersionColumn: {
|
||||||
auto dataL = Version(source_left.data(Qt::DisplayRole).toString());
|
auto dataL = Version(model->data(model->index(source_left.row(), SimpleModList::VersionColumn)).toString());
|
||||||
auto dataR = Version(source_right.data(Qt::DisplayRole).toString());
|
auto dataR = Version(model->data(model->index(source_right.row(), SimpleModList::VersionColumn)).toString());
|
||||||
return dataL < dataR;
|
return invert ? (dataL > dataR) : (dataL < dataR);
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user