summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-05-28 22:43:19 +0200
committerTannin <devnull@localhost>2013-05-28 22:43:19 +0200
commitd8cb9a4e3710b1a09ac2795541c6b792a917e3a1 (patch)
tree1e69347e9659bf3408b794976791048b2b05d181 /src
parent3c21d1884a499066785e70dc44a869cb8b2d589d (diff)
- bugfixes in hookdll related to path-rerouting
- bugfix: expanding modlist groups after changes to modlist works now - bugfix: sorting grouped modlist was broken
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp3
-rw-r--r--src/mainwindow.cpp30
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/modlist.cpp14
-rw-r--r--src/modlist.h2
-rw-r--r--src/modlistsortproxy.cpp14
-rw-r--r--src/qtgroupingproxy.cpp2
7 files changed, 44 insertions, 23 deletions
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<QWidgetAction*>(action);
if (widgetAction != NULL) {
QCheckBox *checkbox = qobject_cast<QCheckBox*>(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);
+ QVariant leftPrio = left.data();
+ if (!leftPrio.isValid()) leftPrio = left.data(Qt::UserRole);
+ QVariant rightPrio = right.data();
+ if (!rightPrio.isValid()) rightPrio = right.data(Qt::UserRole);
- lt = leftPrio < rightPrio;
- } else {
- lt = leftMod->name() < rightMod->name();
- }
+ 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();
}