diff options
| author | Tannin <devnull@localhost> | 2013-06-07 18:16:52 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-06-07 18:16:52 +0200 |
| commit | 50d05236226d04d3854008073420282b8d21f614 (patch) | |
| tree | 67f4916017f52f1d1b8d746c81b19de808a3568a /src | |
| parent | 97111de1409a59eea9e7ab5050ab70f4d01ddb8e (diff) | |
- locking/unlocking esps can now be done for the whole selection
- bugfix: MO crashed if the locked index file is borked. This shouldn't happen
anymore so I'm not sure how that file breaks to begin with
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 45 | ||||
| -rw-r--r-- | src/mainwindow.h | 2 | ||||
| -rw-r--r-- | src/pluginlist.cpp | 31 | ||||
| -rw-r--r-- | src/pluginlist.h | 5 |
4 files changed, 62 insertions, 21 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fb88bbad..64a3d0de 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1588,7 +1588,6 @@ void MainWindow::refreshESPList() m_CurrentProfile->getPluginsFileName(), m_CurrentProfile->getLoadOrderFileName(), m_CurrentProfile->getLockedOrderFileName()); - //m_PluginList.readFrom(m_CurrentProfile->getPluginsFileName()); } @@ -2520,6 +2519,9 @@ void MainWindow::modlistChanged(const QModelIndex &index, int role) if (enabled > 1) { MessageDialog::showMessage(tr("Multiple esps activated, please check that they don't conflict."), this); } + m_PluginList.refreshLoadOrder(); + // immediately save plugin list + savePluginList(); } } } @@ -4234,14 +4236,28 @@ void MainWindow::on_categoriesList_customContextMenuRequested(const QPoint &pos) } +void MainWindow::updateESPLock(bool locked) +{ + QItemSelection currentSelection = ui->espList->selectionModel()->selection(); + if (currentSelection.count() == 0) { + // this path is probably useless + m_PluginList.lockESPIndex(m_ContextRow, locked); + } else { + Q_FOREACH (const QModelIndex &idx, currentSelection.indexes()) { + m_PluginList.lockESPIndex(mapToModel(&m_PluginList, idx).row(), locked); + } + } +} + + void MainWindow::lockESPIndex() { - m_PluginList.lockESPIndex(m_ContextRow, true); + updateESPLock(true); } void MainWindow::unlockESPIndex() { - m_PluginList.lockESPIndex(m_ContextRow, false); + updateESPLock(false); } @@ -4253,14 +4269,27 @@ void MainWindow::on_espList_customContextMenuRequested(const QPoint &pos) menu.addAction(tr("Enable all"), &m_PluginList, SLOT(enableAll())); menu.addAction(tr("Disable all"), &m_PluginList, SLOT(disableAll())); - if ((m_ContextRow != -1) && m_PluginList.isEnabled(m_ContextRow)) { - if (m_PluginList.isESPLocked(m_ContextRow)) { - menu.addAction(tr("Unlock index"), this, SLOT(unlockESPIndex())); - } else { - menu.addAction(tr("Lock index"), this, SLOT(lockESPIndex())); + QItemSelection currentSelection = ui->espList->selectionModel()->selection(); + bool hasLocked = false; + bool hasUnlocked = false; + Q_FOREACH (const QModelIndex &idx, currentSelection.indexes()) { + int row = m_PluginListSortProxy->mapToSource(idx).row(); + if (m_PluginList.isEnabled(row)) { + if (m_PluginList.isESPLocked(row)) { + hasLocked = true; + } else { + hasUnlocked = true; + } } } + if (hasLocked) { + menu.addAction(tr("Unlock load order"), this, SLOT(unlockESPIndex())); + } + if (hasUnlocked) { + menu.addAction(tr("Lock load order"), this, SLOT(lockESPIndex())); + } + try { menu.exec(ui->espList->mapToGlobal(pos)); } catch (const std::exception &e) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 7a1e1bc2..73d174c2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -230,6 +230,8 @@ private: QIcon iconForExecutable(const QString &filePath); + void updateESPLock(bool locked); + private: Ui::MainWindow *ui; diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index b5bb483b..20bdbee0 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -717,20 +717,29 @@ void PluginList::setPluginPriority(int row, int &newPriority) } } - int oldPriority = m_ESPs[row].m_Priority; - if (newPriorityTemp > oldPriority) { - // priority is higher than the old, so the gap we left is in lower priorities - for (int i = oldPriority + 1; i <= newPriorityTemp; ++i) { - --m_ESPs[m_ESPsByPriority[i]].m_Priority; - } - } else { - for (int i = newPriorityTemp; i < oldPriority; ++i) { - ++m_ESPs[m_ESPsByPriority[i]].m_Priority; + // enforce valid range + if (newPriorityTemp < 0) newPriorityTemp = 0; + else if (newPriorityTemp >= static_cast<int>(m_ESPsByPriority.size())) newPriorityTemp = m_ESPsByPriority.size() - 1; + + try { + int oldPriority = m_ESPs.at(row).m_Priority; + if (newPriorityTemp > oldPriority) { + // priority is higher than the old, so the gap we left is in lower priorities + for (int i = oldPriority + 1; i <= newPriorityTemp; ++i) { + --m_ESPs.at(m_ESPsByPriority.at(i)).m_Priority; + } + } else { + for (int i = newPriorityTemp; i < oldPriority; ++i) { + ++m_ESPs.at(m_ESPsByPriority.at(i)).m_Priority; + } + ++newPriority; } - ++newPriority; + + m_ESPs.at(row).m_Priority = newPriorityTemp; + } catch (const std::out_of_range&) { + reportError(tr("failed to restore load order for %1").arg(m_ESPs[row].m_Name)); } - m_ESPs[row].m_Priority = newPriorityTemp; updateIndices(); } diff --git a/src/pluginlist.h b/src/pluginlist.h index d2d699d5..bba775dc 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -130,6 +130,8 @@ public: static QString getColumnName(int column); static QString getColumnToolTip(int column); + void refreshLoadOrder(); + public: // implementation of the QAbstractTableModel interface virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; @@ -141,7 +143,6 @@ public: // implementation of the QAbstractTableModel interface virtual Qt::DropActions supportedDropActions() const { return Qt::MoveAction; } virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); - void syncLoadOrder(); public slots: /** @@ -170,7 +171,7 @@ signals: private: - void refreshLoadOrder(); + void syncLoadOrder(); void updateIndices(); void writePlugins(const QString &fileName, bool writeUnchecked) const; |
