From eb26120332433c73716531e6eaae798aeae33c1b Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 31 Oct 2018 14:53:24 -0500 Subject: Add send to top/bottom options for the mod list --- src/modlist.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/modlist.h') diff --git a/src/modlist.h b/src/modlist.h index 15376ed5..caad8c61 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -106,6 +106,7 @@ public: static QString getColumnName(int column); void changeModPriority(int sourceIndex, int newPriority); + void changeModPriority(std::vector sourceIndices, int newPriority); void setOverwriteMarkers(const std::set &overwrite, const std::set &overwritten); void setPluginContainer(PluginContainer *pluginContainer); @@ -266,8 +267,6 @@ private: bool testValid(const QString &modDir); - void changeModPriority(std::vector sourceIndices, int newPriority); - QVariant getOverwriteData(int column, int role) const; QString getFlagText(ModInfo::EFlag flag, ModInfo::Ptr modInfo) const; -- cgit v1.3.1 From 2c57899cf611056a8c5bae1f7f27c9a157df6f41 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Thu, 1 Nov 2018 17:58:49 -0500 Subject: Fix matching highlights for mod and plugin selections The selectionChanged event used before requires subtractive/additive logic to work correctly. A separate event is fired for each row and each column for each row that is selected or deselected. The previous logic assumed all of the selection was passed in at once. The logic has been changed to recalculate all highlights each time the event is fired. This is poorly optimized in regards to performance but makes the function work. --- src/mainwindow.cpp | 4 ++-- src/modlist.cpp | 5 +++-- src/modlist.h | 2 +- src/pluginlist.cpp | 11 +++++++---- src/pluginlist.h | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/modlist.h') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5b257977..752c5c76 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2341,13 +2341,13 @@ void MainWindow::modlistSelectionChanged(const QModelIndex ¤t, const QMode void MainWindow::modlistSelectionsChanged(const QItemSelection &selected) { - m_OrganizerCore.pluginList()->highlightPlugins(selected, *m_OrganizerCore.directoryStructure(), *m_OrganizerCore.currentProfile()); + m_OrganizerCore.pluginList()->highlightPlugins(ui->modList->selectionModel(), *m_OrganizerCore.directoryStructure(), *m_OrganizerCore.currentProfile()); ui->espList->verticalScrollBar()->repaint(); } void MainWindow::esplistSelectionsChanged(const QItemSelection &selected) { - m_OrganizerCore.modList()->highlightMods(selected, *m_OrganizerCore.directoryStructure()); + m_OrganizerCore.modList()->highlightMods(ui->espList->selectionModel(), *m_OrganizerCore.directoryStructure()); ui->modList->verticalScrollBar()->repaint(); } diff --git a/src/modlist.cpp b/src/modlist.cpp index 3f8fa0c0..539ba6fc 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -24,6 +24,7 @@ along with Mod Organizer. If not, see . #include "qtgroupingproxy.h" #include "viewmarkingscrollbar.h" #include "modlistsortproxy.h" +#include "pluginlist.h" #include "settings.h" #include "modinforegular.h" #include @@ -768,12 +769,12 @@ int ModList::timeElapsedSinceLastChecked() const return m_LastCheck.elapsed(); } -void ModList::highlightMods(const QItemSelection &selected, const MOShared::DirectoryEntry &directoryEntry) +void ModList::highlightMods(const QItemSelectionModel *selection, const MOShared::DirectoryEntry &directoryEntry) { for (unsigned int i = 0; i < ModInfo::getNumMods(); ++i) { ModInfo::getByIndex(i)->setPluginSelected(false); } - for (QModelIndex idx : selected.indexes()) { + for (QModelIndex idx : selection->selectedRows(PluginList::COL_NAME)) { QString modName = idx.data().toString(); const MOShared::FileEntry::Ptr fileEntry = directoryEntry.findFile(modName.toStdWString()); diff --git a/src/modlist.h b/src/modlist.h index caad8c61..8de08da3 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -118,7 +118,7 @@ public: int timeElapsedSinceLastChecked() const; - void highlightMods(const QItemSelection &selected, const MOShared::DirectoryEntry &directoryEntry); + void highlightMods(const QItemSelectionModel *selection, const MOShared::DirectoryEntry &directoryEntry); public: diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index d56a4bde..21e716d3 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -21,6 +21,7 @@ along with Mod Organizer. If not, see . #include "settings.h" #include "scopeguard.h" #include "modinfo.h" +#include "modlist.h" #include "viewmarkingscrollbar.h" #include #include @@ -119,14 +120,16 @@ QString PluginList::getColumnToolTip(int column) } } -void PluginList::highlightPlugins(const QItemSelection &selected, const MOShared::DirectoryEntry &directoryEntry, const Profile &profile) +void PluginList::highlightPlugins(const QItemSelectionModel *selection, const MOShared::DirectoryEntry &directoryEntry, const Profile &profile) { for (auto &esp : m_ESPs) { esp.m_ModSelected = false; } - for (QModelIndex idx : selected.indexes()) { - ModInfo::Ptr selectedMod = ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt()); - if (!selectedMod.isNull() && profile.modEnabled(idx.data(Qt::UserRole + 1).toInt())) { + for (QModelIndex idx : selection->selectedRows(ModList::COL_PRIORITY)) { + int modPriority = idx.data().toInt(); + int modIndex = profile.modIndexByPriority(modPriority); + ModInfo::Ptr selectedMod = ModInfo::getByIndex(modIndex); + if (!selectedMod.isNull() && profile.modEnabled(modIndex)) { QDir dir(selectedMod->absolutePath()); QStringList plugins = dir.entryList(QStringList() << "*.esp" << "*.esm" << "*.esl"); MOShared::FilesOrigin origin = directoryEntry.getOriginByName(selectedMod->internalName().toStdWString()); diff --git a/src/pluginlist.h b/src/pluginlist.h index 009c9153..f7817c37 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -206,7 +206,7 @@ public: static QString getColumnName(int column); static QString getColumnToolTip(int column); - void highlightPlugins(const QItemSelection &selected, const MOShared::DirectoryEntry &directoryEntry, const Profile &profile); + void highlightPlugins(const QItemSelectionModel *selection, const MOShared::DirectoryEntry &directoryEntry, const Profile &profile); void refreshLoadOrder(); -- cgit v1.3.1 From c501b5cca081e1b3697904a3b4e1e236ea9c4e69 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Sat, 8 Dec 2018 10:37:46 -0600 Subject: Add notes column to mod list --- src/mainwindow.cpp | 4 ++++ src/modinfo.cpp | 2 +- src/modinfo.h | 17 ++++++++++++++--- src/modinfodialog.cpp | 2 ++ src/modinfodialog.ui | 25 ++++++++++++++++++++++++- src/modinfoforeign.h | 2 ++ src/modinfooverwrite.h | 2 ++ src/modinforegular.cpp | 17 +++++++++++++++-- src/modinforegular.h | 12 ++++++++++++ src/modlist.cpp | 24 ++++++++++++++++++++++-- src/modlist.h | 3 ++- 11 files changed, 100 insertions(+), 10 deletions(-) (limited to 'src/modlist.h') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 84b77945..9a40ce2e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -299,6 +299,7 @@ MainWindow::MainWindow(QSettings &initSettings ui->modList->header()->setSectionHidden(ModList::COL_MODID, true); ui->modList->header()->setSectionHidden(ModList::COL_GAME, true); ui->modList->header()->setSectionHidden(ModList::COL_INSTALLTIME, true); + ui->modList->header()->setSectionHidden(ModList::COL_NOTES, true); } ui->modList->header()->setSectionHidden(ModList::COL_NAME, false); // prevent the name-column from being hidden @@ -1726,6 +1727,9 @@ void MainWindow::processUpdates() { lastHidden = hidden; } } + if (lastVersion < QVersionNumber(2,1,6)) { + ui->modList->header()->setSectionHidden(ModList::COL_NOTES, true); + } } if (currentVersion > lastVersion) diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 4c41a114..1c6139f6 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -104,7 +104,7 @@ QString ModInfo::getContentTypeName(int contentType) case CONTENT_SOUND: return tr("Sound Effects"); case CONTENT_SCRIPT: return tr("Scripts"); case CONTENT_SKSE: return tr("Script Extender"); - case CONTENT_SKSEFILES: return tr("Script Extender Files"); + case CONTENT_SKSEFILES: return tr("Script Extender Files"); case CONTENT_SKYPROC: return tr("SkyProc Tools"); case CONTENT_MCM: return tr("MCM Data"); case CONTENT_INI: return tr("INI files"); diff --git a/src/modinfo.h b/src/modinfo.h index 235fb50c..5a69185d 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -44,7 +44,7 @@ namespace MOShared { class DirectoryEntry; } /** * @brief Represents meta information about a single mod. - * + * * Represents meta information about a single mod. The class interface is used * to manage the mod collection * @@ -85,7 +85,7 @@ public: CONTENT_SOUND, CONTENT_SCRIPT, CONTENT_SKSE, - CONTENT_SKSEFILES, + CONTENT_SKSEFILES, CONTENT_SKYPROC, CONTENT_MCM, CONTENT_INI, @@ -268,6 +268,12 @@ public: **/ virtual void setCategory(int categoryID, bool active) = 0; + /** + * @brief changes the comments (manually set information displayed in the mod list) for this mod + * @param comments new comments + */ + virtual void setComments(const QString &comments) = 0; + /** * @brief change the notes (manually set information) for this mod * @param notes new notes @@ -495,6 +501,11 @@ public: */ virtual QString getDescription() const = 0; + /** + * @return comments for this mod + */ + virtual QString comments() const = 0; + /** * @return notes for this mod */ @@ -526,7 +537,7 @@ public: virtual QStringList archives() const = 0; /* - *@return the color choosen by the user for the mod/separator + *@return the color choosen by the user for the mod/separator */ virtual QColor getColor() { return QColor(); } diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index 54910e41..416eca58 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -112,6 +112,7 @@ ModInfoDialog::ModInfoDialog(ModInfo::Ptr modInfo, const DirectoryEntry *directo } ui->sourceGameEdit->setCurrentIndex(ui->sourceGameEdit->findData(gameName)); + ui->commentsEdit->setText(modInfo->comments()); ui->notesEdit->setText(modInfo->notes()); ui->descriptionView->setPage(new DescriptionPage); @@ -189,6 +190,7 @@ ModInfoDialog::ModInfoDialog(ModInfo::Ptr modInfo, const DirectoryEntry *directo ModInfoDialog::~ModInfoDialog() { + m_ModInfo->setComments(ui->commentsEdit->text()); m_ModInfo->setNotes(ui->notesEdit->toPlainText()); saveCategories(ui->categoriesTree->invisibleRootItem()); saveIniTweaks(); // ini tweaks are written to the ini file directly. This is the only information not managed by ModInfo diff --git a/src/modinfodialog.ui b/src/modinfodialog.ui index b3873bf3..671c7f31 100644 --- a/src/modinfodialog.ui +++ b/src/modinfodialog.ui @@ -782,7 +782,30 @@ p, li { white-space: pre-wrap; } - + + + Enter comments about the mod here. These are displayed in the notes column of the mod list. + + + Enter comments about the mod here. These are displayed in the notes column of the mod list. + + + Enter comments about the mod here. These are displayed in the notes column of the mod list. + + + + + + + Enter notes about the mod here. These can be viewed in the mod list by hovering over the notes column or the flags column. + + + Enter notes about the mod here. These can be viewed in the mod list by hovering over the notes column or the flags column. + + + Enter notes about the mod here. These can be viewed in the mod list by hovering over the notes column or the flags column. + + diff --git a/src/modinfoforeign.h b/src/modinfoforeign.h index 0d7b3847..93061294 100644 --- a/src/modinfoforeign.h +++ b/src/modinfoforeign.h @@ -18,6 +18,7 @@ public: virtual bool updateNXMInfo() { return false; } virtual void setCategory(int, bool) {} virtual bool setName(const QString&) { return false; } + virtual void setComments(const QString&) {} virtual void setNotes(const QString&) {} virtual void setGameName(QString) {} virtual void setNexusID(int) {} @@ -33,6 +34,7 @@ public: virtual bool isEmpty() const { return false; } virtual QString name() const; virtual QString internalName() const { return name(); } + virtual QString comments() const { return ""; } virtual QString notes() const { return ""; } virtual QDateTime creationTime() const; virtual QString absolutePath() const; diff --git a/src/modinfooverwrite.h b/src/modinfooverwrite.h index 5681dc6f..4b98d715 100644 --- a/src/modinfooverwrite.h +++ b/src/modinfooverwrite.h @@ -20,6 +20,7 @@ public: virtual bool updateNXMInfo() { return false; } virtual void setCategory(int, bool) {} virtual bool setName(const QString&) { return false; } + virtual void setComments(const QString&) {} virtual void setNotes(const QString&) {} virtual void setGameName(QString) {} virtual void setNexusID(int) {} @@ -35,6 +36,7 @@ public: virtual bool alwaysEnabled() const { return true; } virtual bool isEmpty() const; virtual QString name() const { return "Overwrite"; } + virtual QString comments() const { return ""; } virtual QString notes() const { return ""; } virtual QDateTime creationTime() const { return QDateTime(); } virtual QString absolutePath() const; diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index d0f56a52..6a52d3df 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -76,6 +76,7 @@ bool ModInfoRegular::isEmpty() const void ModInfoRegular::readMeta() { QSettings metaFile(m_Path + "/meta.ini", QSettings::IniFormat); + m_Comments = metaFile.value("comments", "").toString(); m_Notes = metaFile.value("notes", "").toString(); QString tempGameName = metaFile.value("gameName", m_GameName).toString(); if (tempGameName.size()) m_GameName = tempGameName; @@ -148,6 +149,7 @@ void ModInfoRegular::saveMeta() metaFile.setValue("repository", m_Repository); metaFile.setValue("gameName", m_GameName); metaFile.setValue("modid", m_NexusID); + metaFile.setValue("comments", m_Comments); metaFile.setValue("notes", m_Notes); metaFile.setValue("nexusDescription", m_NexusDescription); metaFile.setValue("url", m_URL); @@ -324,6 +326,12 @@ bool ModInfoRegular::setName(const QString &name) return true; } +void ModInfoRegular::setComments(const QString &comments) +{ + m_Comments = comments; + m_MetaInfoChanged = true; +} + void ModInfoRegular::setNotes(const QString ¬es) { m_Notes = notes; @@ -405,7 +413,7 @@ void ModInfoRegular::setColor(QColor color) m_MetaInfoChanged = true; } -QColor ModInfoRegular::getColor() +QColor ModInfoRegular::getColor() { return m_Color; } @@ -510,7 +518,7 @@ std::vector ModInfoRegular::getContents() const if (sePluginDir.entryList(QStringList() << "*.dll").size() > 0) { m_CachedContent.push_back(CONTENT_SKSE); } - } + } } if (dir.exists("textures") || dir.exists("icons") || dir.exists("bookart")) m_CachedContent.push_back(CONTENT_TEXTURE); @@ -567,6 +575,11 @@ QString ModInfoRegular::getDescription() const } } +QString ModInfoRegular::comments() const +{ + return m_Comments; +} + QString ModInfoRegular::notes() const { return m_Notes; diff --git a/src/modinforegular.h b/src/modinforegular.h index 78a6e58a..33b26998 100644 --- a/src/modinforegular.h +++ b/src/modinforegular.h @@ -90,6 +90,12 @@ public: **/ bool setName(const QString &name); + /** + * @brief changes the comments (manually set information displayed in the mod list) for this mod + * @param comments new comments + */ + void setComments(const QString &comments); + /** * @brief change the notes (manually set information) for this mod * @param notes new notes @@ -279,6 +285,11 @@ public: */ virtual QString getDescription() const; + /** + * @return comments for this mod + */ + virtual QString comments() const; + /** * @return manually set notes for this mod */ @@ -353,6 +364,7 @@ private: QString m_Name; QString m_Path; QString m_InstallationFile; + QString m_Comments; QString m_Notes; QString m_NexusDescription; QString m_Repository; diff --git a/src/modlist.cpp b/src/modlist.cpp index 7ca0667a..547cc853 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -150,7 +150,14 @@ QString ModList::getFlagText(ModInfo::EFlag flag, ModInfo::Ptr modInfo) const case ModInfo::FLAG_SEPARATOR: return tr("Separator"); case ModInfo::FLAG_INVALID: return tr("No valid game data"); case ModInfo::FLAG_NOTENDORSED: return tr("Not endorsed yet"); - case ModInfo::FLAG_NOTES: return QString("%1").arg(modInfo->notes().replace("\n", "
")); + case ModInfo::FLAG_NOTES: { + QStringList output; + if (!modInfo->comments().isEmpty()) + output << QString("%1").arg(modInfo->comments()); + if (!modInfo->notes().isEmpty()) + output << QString("%1").arg(modInfo->notes()).replace("\n", "
"); + return output.join("
"); + } case ModInfo::FLAG_CONFLICT_OVERWRITE: return tr("Overwrites files"); case ModInfo::FLAG_CONFLICT_OVERWRITTEN: return tr("Overwritten files"); case ModInfo::FLAG_CONFLICT_MIXED: return tr("Overwrites & Overwritten"); @@ -276,6 +283,8 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const } else { return QVariant(); } + } else if (column == COL_NOTES) { + return modInfo->comments(); } else { return tr("invalid"); } @@ -295,6 +304,8 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const } } else if (column == COL_VERSION) { return QVariant(Qt::AlignRight | Qt::AlignVCenter); + } else if (column == COL_NOTES) { + return QVariant(Qt::AlignLeft | Qt::AlignVCenter); } else { return QVariant(Qt::AlignCenter | Qt::AlignVCenter); } @@ -443,6 +454,8 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const } return ToQString(categoryString.str()); + } else if (column == COL_NOTES) { + return getFlagText(ModInfo::FLAG_NOTES, modInfo); } else { return QVariant(); } @@ -559,6 +572,10 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role) result = false; } } break; + case COL_NOTES: { + info->setComments(value.toString()); + result = true; + } break; default: { qWarning("edit on column \"%s\" not supported", getColumnName(index.column()).toUtf8().constData()); @@ -625,7 +642,8 @@ Qt::ItemFlags ModList::flags(const QModelIndex &modelIndex) const (modelIndex.column() == COL_MODID)) { result |= Qt::ItemIsEditable; } - if ((modelIndex.column() == COL_NAME) + if (((modelIndex.column() == COL_NAME) || + (modelIndex.column() == COL_NOTES)) && (std::find(flags.begin(), flags.end(), ModInfo::FLAG_FOREIGN) == flags.end())) { result |= Qt::ItemIsEditable; } @@ -1147,6 +1165,7 @@ QString ModList::getColumnName(int column) case COL_GAME: return tr("Source Game"); case COL_MODID: return tr("Nexus ID"); case COL_INSTALLTIME: return tr("Installation"); + case COL_NOTES: return tr("Notes"); default: return tr("unknown"); } } @@ -1182,6 +1201,7 @@ QString ModList::getColumnToolTip(int column) ""); case COL_INSTALLTIME: return tr("Time this mod was installed"); + case COL_NOTES: return tr("User notes about the mod"); default: return tr("unknown"); } } diff --git a/src/modlist.h b/src/modlist.h index 8de08da3..42269386 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -65,8 +65,9 @@ public: COL_VERSION, COL_INSTALLTIME, COL_PRIORITY, + COL_NOTES, - COL_LASTCOLUMN = COL_PRIORITY + COL_LASTCOLUMN = COL_NOTES }; typedef boost::signals2::signal SignalModStateChanged; -- cgit v1.3.1