summaryrefslogtreecommitdiff
path: root/src/modlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modlist.cpp')
-rw-r--r--src/modlist.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/modlist.cpp b/src/modlist.cpp
index 1d5db5a0..84e76b75 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -121,6 +121,7 @@ QString ModList::getFlagText(ModInfo::EFlag flag, ModInfo::Ptr modInfo) const
QVariant ModList::data(const QModelIndex &modelIndex, int role) const
{
if (m_Profile == NULL) return QVariant();
+ if (!modelIndex.isValid()) return QVariant();
unsigned int modIndex = modelIndex.row();
int column = modelIndex.column();
@@ -196,6 +197,8 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const
}
} else if (role == Qt::UserRole) {
return modInfo->getNexusID();
+ } else if (role == Qt::UserRole + 1) {
+ return modIndex;
} else if (role == Qt::FontRole) {
QFont result;
if (column == COL_NAME) {
@@ -632,10 +635,20 @@ bool ModList::eventFilter(QObject *obj, QEvent *event)
(keyEvent->modifiers() == Qt::ControlModifier) &&
((keyEvent->key() == Qt::Key_Up) || (keyEvent->key() == Qt::Key_Down))) {
QItemSelectionModel *selectionModel = itemView->selectionModel();
- const QSortFilterProxyModel *proxyModel = qobject_cast<const QSortFilterProxyModel*>(selectionModel->model());
+ const QAbstractProxyModel *proxyModel = qobject_cast<const QAbstractProxyModel*>(selectionModel->model());
+ const QSortFilterProxyModel *filterModel = NULL;
+ while ((filterModel == NULL) && (proxyModel != NULL)) {
+ filterModel = qobject_cast<const QSortFilterProxyModel*>(proxyModel);
+ if (filterModel == NULL) {
+ proxyModel = qobject_cast<const QAbstractProxyModel*>(proxyModel->sourceModel());
+ }
+ }
+ if (filterModel == NULL) {
+ return true;
+ }
int diff = -1;
- if (((keyEvent->key() == Qt::Key_Up) && (proxyModel->sortOrder() == Qt::DescendingOrder)) ||
- ((keyEvent->key() == Qt::Key_Down) && (proxyModel->sortOrder() == Qt::AscendingOrder))) {
+ if (((keyEvent->key() == Qt::Key_Up) && (filterModel->sortOrder() == Qt::DescendingOrder)) ||
+ ((keyEvent->key() == Qt::Key_Down) && (filterModel->sortOrder() == Qt::AscendingOrder))) {
diff = 1;
}
QModelIndexList rows = selectionModel->selectedRows();
@@ -645,8 +658,8 @@ bool ModList::eventFilter(QObject *obj, QEvent *event)
}
}
foreach (QModelIndex idx, rows) {
- if (proxyModel != NULL) {
- idx = proxyModel->mapToSource(idx);
+ if (filterModel != NULL) {
+ idx = filterModel->mapToSource(idx);
}
int newPriority = m_Profile->getModPriority(idx.row()) + diff;
if ((newPriority >= 0) && (newPriority < static_cast<int>(m_Profile->numRegularMods()))) {