summaryrefslogtreecommitdiff
path: root/src/modlistsortproxy.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-05-10 11:00:09 +0200
committerTannin <devnull@localhost>2013-05-10 11:00:09 +0200
commitfc3753dcc5b7d55bf99674e7d17962f477053921 (patch)
tree54fef6cd5b57533fd84f04cc58259c242600efed /src/modlistsortproxy.cpp
parent4fbfc9aa54ed4499f54eb7b3cd942337f6b49e58 (diff)
parent9bc123e8e2dbd17508a68e4afc2eb881873601bd (diff)
Merge
Diffstat (limited to 'src/modlistsortproxy.cpp')
-rw-r--r--src/modlistsortproxy.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index a61ba2de..17dca5fc 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -57,21 +57,20 @@ void ModListSortProxy::setCategoryFilter(const std::vector<int> &categories)
this->invalidate();
}
-
Qt::ItemFlags ModListSortProxy::flags(const QModelIndex &modelIndex) const
{
Qt::ItemFlags flags = sourceModel()->flags(mapToSource(modelIndex));
if (sortColumn() != ModList::COL_PRIORITY) {
flags &= ~Qt::ItemIsDragEnabled;
}
+
return flags;
}
-
void ModListSortProxy::displayColumnSelection(const QPoint &pos)
{
- QMenu menu;
+ QMenu menu;
for (int i = 0; i <= ModList::COL_LASTCOLUMN; ++i) {
QCheckBox *checkBox = new QCheckBox(&menu);
@@ -105,7 +104,7 @@ void ModListSortProxy::enableAllVisible()
if (m_Profile == NULL) return;
for (int i = 0; i < this->rowCount(); ++i) {
- int modID = mapToSource(index(i, 0)).row();
+ int modID = mapToSource(index(i, 0)).data(Qt::UserRole + 1).toInt();
m_Profile->setModEnabled(modID, true);
}
invalidate();
@@ -115,18 +114,25 @@ void ModListSortProxy::enableAllVisible()
void ModListSortProxy::disableAllVisible()
{
if (m_Profile == NULL) return;
+
for (int i = 0; i < this->rowCount(); ++i) {
- int modID = mapToSource(index(i, 0)).row();
+ int modID = mapToSource(index(i, 0)).data(Qt::UserRole + 1).toInt();
m_Profile->setModEnabled(modID, false);
}
+ invalidate();
}
bool ModListSortProxy::lessThan(const QModelIndex &left,
const QModelIndex &right) const
{
- int leftIndex = left.row();
- int rightIndex = right.row();
+ bool lOk, rOk;
+ int leftIndex = left.data(Qt::UserRole + 1).toInt(&lOk);
+ int rightIndex = right.data(Qt::UserRole + 1).toInt(&rOk);
+ if (!lOk || !rOk) {
+ return false;
+ }
+
ModInfo::Ptr leftMod = ModInfo::getByIndex(leftIndex);
ModInfo::Ptr rightMod = ModInfo::getByIndex(rightIndex);