From 16bda49e0667f77f4ebe1d8fa2682abf57aa6765 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 25 May 2013 12:24:48 +0200 Subject: - bugfix: mod priority ordering could become incorrect - bugfix: when grouping is enabled, newly installed mods broke grouping - bugfix: syncing overwrite didn't clean up emptied directory --- src/qtgroupingproxy.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/qtgroupingproxy.cpp') diff --git a/src/qtgroupingproxy.cpp b/src/qtgroupingproxy.cpp index 4e066f65..3ecb2a72 100644 --- a/src/qtgroupingproxy.cpp +++ b/src/qtgroupingproxy.cpp @@ -57,6 +57,7 @@ QtGroupingProxy::QtGroupingProxy(QAbstractItemModel *model, QModelIndex rootNode connect( sourceModel(), SIGNAL(layoutChanged()), SLOT(buildTree()) ); connect( sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(modelDataChanged(QModelIndex,QModelIndex)) ); + connect( sourceModel(), SIGNAL(modelReset()), this, SLOT(resetModel()) ); if( groupedColumn != -1 ) setGroupedColumn( groupedColumn ); @@ -984,6 +985,12 @@ QtGroupingProxy::modelRowsRemoved( const QModelIndex &parent, int start, int end endRemoveRows(); } +void +QtGroupingProxy::resetModel() +{ + buildTree(); +} + void QtGroupingProxy::modelDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight ) { -- cgit v1.3.1 From d8cb9a4e3710b1a09ac2795541c6b792a917e3a1 Mon Sep 17 00:00:00 2001 From: Tannin Date: Tue, 28 May 2013 22:43:19 +0200 Subject: - bugfixes in hookdll related to path-rerouting - bugfix: expanding modlist groups after changes to modlist works now - bugfix: sorting grouped modlist was broken --- src/main.cpp | 3 --- src/mainwindow.cpp | 30 +++++++++++++++++++++++++----- src/mainwindow.h | 2 ++ src/modlist.cpp | 14 ++++++++++---- src/modlist.h | 2 +- src/modlistsortproxy.cpp | 16 ++++++---------- src/qtgroupingproxy.cpp | 2 +- 7 files changed, 45 insertions(+), 24 deletions(-) (limited to 'src/qtgroupingproxy.cpp') diff --git a/src/main.cpp b/src/main.cpp index 7146f4d1..3f8ea46f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -94,8 +94,6 @@ void removeOldLogfiles() // set up required folders (for a first install or after an update or to fix a broken installation) bool bootstrap() { - qDebug("bootstapping"); - GameInfo &gameInfo = GameInfo::instance(); // remove the temporary backup directory in case we're restarting after an update @@ -150,7 +148,6 @@ bool bootstrap() } // verify the hook-dll exists - qDebug("checking dll"); QString dllName = qApp->applicationDirPath() + "/" + ToQString(AppConfig::hookDLLName()); HMODULE dllMod = ::LoadLibraryW(ToWString(dllName).c_str()); if (dllMod == NULL) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4ac883e9..5cbfa72a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -610,6 +610,19 @@ void MainWindow::downloadFilterChanged(const QString &filter) } } +void MainWindow::expandModList(const QModelIndex &index) +{ + QAbstractItemModel *model = ui->modList->model(); +#pragma message("why is this so complicated? mapping the index doesn't work, probably a bug in QtGroupingProxy?") + for (int i = 0; i < model->rowCount(); ++i) { + QModelIndex targetIdx = model->index(i, 0); + if (model->data(targetIdx).toString() == index.data().toString()) { + ui->modList->expand(targetIdx); + break; + } + } +} + bool MainWindow::saveCurrentLists() { if (m_DirectoryUpdate) { @@ -2702,7 +2715,6 @@ void MainWindow::displayModInformation(const QString &modName, int tab) void MainWindow::displayModInformation(int row, int tab) { ModInfo::Ptr modInfo = ModInfo::getByIndex(row); -qDebug("%d - %s", row, qPrintable(modInfo->name())); displayModInformation(modInfo, row, tab); } @@ -2909,7 +2921,6 @@ bool MainWindow::addCategories(QMenu *menu, int targetID) void MainWindow::saveCategoriesFromMenu(QMenu *menu, int modRow) { ModInfo::Ptr modInfo = ModInfo::getByIndex(modRow); -qDebug("%d - %s", modRow, qPrintable(modInfo->name())); foreach (QAction* action, menu->actions()) { if (action->menu() != NULL) { saveCategoriesFromMenu(action->menu(), modRow); @@ -2917,7 +2928,6 @@ qDebug("%d - %s", modRow, qPrintable(modInfo->name())); QWidgetAction *widgetAction = qobject_cast(action); if (widgetAction != NULL) { QCheckBox *checkbox = qobject_cast(widgetAction->defaultWidget()); -qDebug("%s - %d", qPrintable(modInfo->name()), widgetAction->data().toInt()); modInfo->setCategory(widgetAction->data().toInt(), checkbox->isChecked()); } } @@ -2934,12 +2944,22 @@ void MainWindow::saveCategories() } QModelIndexList selected = ui->modList->selectionModel()->selectedRows(); + if (selected.size() > 0) { + int min = INT_MAX; + int max = INT_MIN; + for (int i = 0; i < selected.size(); ++i) { - saveCategoriesFromMenu(menu, m_ModListSortProxy->mapToSource(selected.at(i)).row()); + QModelIndex temp = mapToModel(&m_ModList, selected.at(i)); + if (temp.row() < min) min = temp.row(); + if (temp.row() > max) max = temp.row(); + saveCategoriesFromMenu(menu, mapToModel(&m_ModList, selected.at(i)).row()); } + //m_ModList.notifyChange(min, max); + refreshModList(); } else { saveCategoriesFromMenu(menu, m_ContextRow); + m_ModList.notifyChange(m_ContextRow); } refreshFilters(); @@ -4268,7 +4288,7 @@ void MainWindow::on_groupCombo_currentIndexChanged(int index) m_ModListSortProxy->setSourceModel(newModel); connect(ui->modList, SIGNAL(expanded(QModelIndex)),newModel, SLOT(expanded(QModelIndex))); connect(ui->modList, SIGNAL(collapsed(QModelIndex)), newModel, SLOT(collapsed(QModelIndex))); - connect(newModel, SIGNAL(expandItem(QModelIndex)), ui->modList, SLOT(expand(QModelIndex))); + connect(newModel, SIGNAL(expandItem(QModelIndex)), this, SLOT(expandModList(QModelIndex))); } else { m_ModListSortProxy->setSourceModel(&m_ModList); diff --git a/src/mainwindow.h b/src/mainwindow.h index 9626c5ba..7a1e1bc2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -420,6 +420,8 @@ private slots: void espFilterChanged(const QString &filter); void downloadFilterChanged(const QString &filter); + void expandModList(const QModelIndex &index); + private slots: // ui slots // actions void on_actionAdd_Profile_triggered(); diff --git a/src/modlist.cpp b/src/modlist.cpp index 3fc8ae23..f87687bb 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -203,7 +203,12 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const return QVariant(); } } else if (column == COL_PRIORITY) { - return m_Profile->getModPriority(modIndex); + int priority = modInfo->getFixedPriority(); + if (priority != INT_MIN) { + return priority; + } else { + return m_Profile->getModPriority(modIndex); + } } else { return modInfo->getNexusID(); } @@ -648,13 +653,14 @@ void ModList::removeRow(int row, const QModelIndex&) } -void ModList::notifyChange(int row) +void ModList::notifyChange(int rowStart, int rowEnd) { - if (row < 0) { + if (rowStart < 0) { beginResetModel(); endResetModel(); } else { - emit dataChanged(this->index(row, 0), this->index(row, this->columnCount() - 1)); + if (rowEnd == -1) rowEnd = rowStart; + emit dataChanged(this->index(rowStart, 0), this->index(rowEnd, this->columnCount() - 1)); } } diff --git a/src/modlist.h b/src/modlist.h index a0b6e841..99f43b5c 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -91,7 +91,7 @@ public: */ void removeRowForce(int row); - void notifyChange(int row); + void notifyChange(int rowStart, int rowEnd = -1); static QString getColumnName(int column); diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index 17dca5fc..ede83659 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -157,16 +157,12 @@ bool ModListSortProxy::lessThan(const QModelIndex &left, case ModList::COL_MODID: lt = leftMod->getNexusID() < rightMod->getNexusID(); break; case ModList::COL_VERSION: lt = leftMod->getVersion() < rightMod->getVersion(); break; case ModList::COL_PRIORITY: { - if (m_Profile != NULL) { - int leftPrio = leftMod->getFixedPriority(); - int rightPrio = rightMod->getFixedPriority(); - if (leftPrio == INT_MIN) leftPrio = m_Profile->getModPriority(leftIndex); - if (rightPrio == INT_MIN) rightPrio = m_Profile->getModPriority(rightIndex); - - lt = leftPrio < rightPrio; - } else { - lt = leftMod->name() < rightMod->name(); - } + QVariant leftPrio = left.data(); + if (!leftPrio.isValid()) leftPrio = left.data(Qt::UserRole); + QVariant rightPrio = right.data(); + if (!rightPrio.isValid()) rightPrio = right.data(Qt::UserRole); + + return leftPrio.toInt() < rightPrio.toInt(); } break; } return lt; diff --git a/src/qtgroupingproxy.cpp b/src/qtgroupingproxy.cpp index 3ecb2a72..3891cc12 100644 --- a/src/qtgroupingproxy.cpp +++ b/src/qtgroupingproxy.cpp @@ -488,7 +488,7 @@ QtGroupingProxy::data( const QModelIndex &index, int role ) const default: { QModelIndex parentIndex = this->index( row, 0, index.parent() ); if (m_groupHash.value( row ).count() > 0) { - return this->index(0, 0, parentIndex).data(role); + return this->index(0, column, parentIndex).data(role); } else { return QVariant(); } -- cgit v1.3.1