From d1594798e6e78bb329e744a72e92d3f292f38a20 Mon Sep 17 00:00:00 2001 From: Tannin Date: Fri, 1 Nov 2013 14:59:25 +0100 Subject: - added a new diagnosis to detect potential problems in regards to esp vs. asset ordering (not fully functional yet) - new plugin interfaces to the mod list - plugins can now query the origin (mod) of a esp/esm - bugfix: potential access to profile before one was activated - bugfix: regression in previous (not-yet-released) commit prevented changes to bsa list from being saved --- src/mainwindow.cpp | 18 +++++++++++++--- src/mainwindow.h | 4 +++- src/modlist.cpp | 40 +++++++++++++++++++++++++++++++++++ src/modlist.h | 15 ++++++++++++- src/pluginlist.cpp | 9 ++++++++ src/pluginlist.h | 1 + src/problemsdialog.ui | 58 +++++++++++++++++++++++++-------------------------- 7 files changed, 110 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 967a3842..774c99f5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -246,7 +246,7 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget connect(ui->espFilterEdit, SIGNAL(textChanged(QString)), this, SLOT(espFilterChanged(QString))); connect(&m_PluginList, SIGNAL(saveTimer()), this, SLOT(savePluginList())); - connect(ui->bsaList, SIGNAL(itemsMoved()), this, SLOT(on_bsaList_itemMoved())); + connect(ui->bsaList, SIGNAL(itemsMoved()), this, SLOT(bsaList_itemMoved())); connect(ui->bsaWarning, SIGNAL(linkActivated(QString)), this, SLOT(linkClicked(QString))); @@ -1673,7 +1673,7 @@ void MainWindow::refreshSaveList() void MainWindow::refreshLists() { - if (m_DirectoryStructure->isPopulated()) { + if ((m_CurrentProfile != NULL) && m_DirectoryStructure->isPopulated()) { refreshESPList(); refreshBSAList(); } // no point in refreshing lists if no files have been added to the directory tree @@ -2104,6 +2104,11 @@ IPluginList *MainWindow::pluginList() return &m_PluginList; } +IModList *MainWindow::modList() +{ + return &m_ModList; +} + HANDLE MainWindow::startApplication(const QString &executable, const QStringList &args, const QString &cwd, const QString &profile) { QFileInfo binary; @@ -4650,13 +4655,19 @@ void MainWindow::on_bsaList_customContextMenuRequested(const QPoint &pos) menu.exec(ui->bsaList->mapToGlobal(pos)); } -void MainWindow::on_bsaList_itemMoved() +void MainWindow::bsaList_itemMoved() { saveArchiveList(); m_CheckBSATimer.start(500); } +void MainWindow::on_bsaList_itemChanged(QTreeWidgetItem*, int) +{ + saveArchiveList(); + m_CheckBSATimer.start(500); +} + void MainWindow::on_actionProblems_triggered() { // QString problemDescription; @@ -4836,3 +4847,4 @@ void MainWindow::on_showHiddenBox_toggled(bool checked) { m_DownloadManager.setShowHidden(checked); } + diff --git a/src/mainwindow.h b/src/mainwindow.h index 93a6af80..cf97d4f9 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -137,6 +137,7 @@ public: virtual QStringList findFiles(const QString &path, const std::function &filter) const; virtual MOBase::IDownloadManager *downloadManager(); virtual MOBase::IPluginList *pluginList(); + virtual MOBase::IModList *modList(); virtual HANDLE startApplication(const QString &executable, const QStringList &args = QStringList(), const QString &cwd = "", const QString &profile = ""); virtual bool onAboutToRun(const std::function &func); @@ -510,7 +511,7 @@ private slots: // ui slots void on_actionEndorseMO_triggered(); void on_bsaList_customContextMenuRequested(const QPoint &pos); - void on_bsaList_itemMoved(); + void bsaList_itemMoved(); void on_btnRefreshData_clicked(); void on_categoriesList_customContextMenuRequested(const QPoint &pos); void on_compactBox_toggled(bool checked); @@ -531,6 +532,7 @@ private slots: // ui slots void on_categoriesList_itemSelectionChanged(); void on_linkButton_pressed(); void on_showHiddenBox_toggled(bool checked); + void on_bsaList_itemChanged(QTreeWidgetItem *item, int column); }; #endif // MAINWINDOW_H diff --git a/src/modlist.cpp b/src/modlist.cpp index 0fdcf6fa..541e1e6e 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -551,6 +551,46 @@ void ModList::changeModPriority(int sourceIndex, int newPriority) emit modorder_changed(); } +IModList::ModState ModList::state(const QString &name) const +{ + unsigned int modIndex = ModInfo::getIndex(name); + if (modIndex == UINT_MAX) { + return IModList::STATE_MISSING; + } else { + ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex); + if (modInfo->canBeEnabled()) { + return m_Profile->modEnabled(modIndex) ? IModList::STATE_ACTIVE : IModList::STATE_INACTIVE; + } else { + return IModList::STATE_NOTOPTIONAL; + } + } +} + +int ModList::priority(const QString &name) const +{ + unsigned int modIndex = ModInfo::getIndex(name); + if (modIndex == UINT_MAX) { + return -1; + } else { + return m_Profile->getModPriority(modIndex); + } +} + +bool ModList::setPriority(const QString &name, int newPriority) +{ + if ((newPriority < 0) || (newPriority >= static_cast(m_Profile->numRegularMods()))) { + return false; + } + + unsigned int modIndex = ModInfo::getIndex(name); + if (modIndex == UINT_MAX) { + return false; + } else { + m_Profile->setModPriority(modIndex, newPriority); + notifyChange(modIndex); + return true; + } +} bool ModList::dropURLs(const QMimeData *mimeData, int row, const QModelIndex &parent) { diff --git a/src/modlist.h b/src/modlist.h index 7e76d677..cdaa24ca 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -26,6 +26,8 @@ along with Mod Organizer. If not, see . #include "modinfo.h" #include "profile.h" +#include + #include #include #include @@ -41,7 +43,7 @@ along with Mod Organizer. If not, see . * This is used in a view in the main window of MO. It combines general information about * the mods from ModInfo with status information from the Profile **/ -class ModList : public QAbstractItemModel +class ModList : public QAbstractItemModel, public MOBase::IModList { Q_OBJECT @@ -92,6 +94,17 @@ public: void changeModPriority(int sourceIndex, int newPriority); +public: + + /// \copydoc MOBase::IModList::state + virtual ModState state(const QString &name) const; + + /// \copydoc MOBase::IModList::priority + virtual int priority(const QString &name) const; + + /// \copydoc MOBase::IModList::setPriority + virtual bool setPriority(const QString &name, int newPriority); + public: // implementation of virtual functions of QAbstractItemModel virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 74aa6ff3..456d29ee 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -611,6 +611,15 @@ bool PluginList::isMaster(const QString &name) const } } +QString PluginList::origin(const QString &name) const +{ + auto iter = m_ESPsByName.find(name.toLower()); + if (iter == m_ESPsByName.end()) { + return false; + } else { + return m_ESPs[iter->second].m_OriginName; + } +} void PluginList::updateIndices() { diff --git a/src/pluginlist.h b/src/pluginlist.h index 2ad54d6d..4da7be4b 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -140,6 +140,7 @@ public: virtual int priority(const QString &name) const; virtual int loadOrder(const QString &name) const; virtual bool isMaster(const QString &name) const; + virtual QString origin(const QString &name) const; public: // implementation of the QAbstractTableModel interface diff --git a/src/problemsdialog.ui b/src/problemsdialog.ui index b194bf31..d3a0d959 100644 --- a/src/problemsdialog.ui +++ b/src/problemsdialog.ui @@ -49,54 +49,52 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + - buttonBox - accepted() + closeButton + clicked() ProblemsDialog accept() - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - ProblemsDialog - reject() - - - 316 - 260 + 526 + 354 286 - 274 + 187 -- cgit v1.3.1