From 42d2344f0b81cb1cf8dbe83e8f480b84ed0c3114 Mon Sep 17 00:00:00 2001 From: Al12rs Date: Sun, 28 Oct 2018 02:16:20 +0200 Subject: Added modlist Separators feature: *New modType separator. *Bold, italic and centralized name without _separator at the end. *Added "create separator" option to context menu. *Added "rename separator" option. *Fixed rename separator issue with priority resetting. --- src/modlist.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/modlist.cpp') diff --git a/src/modlist.cpp b/src/modlist.cpp index c7f6a53b..31ef9ddc 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -45,6 +45,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include @@ -145,6 +146,7 @@ QString ModList::getFlagText(ModInfo::EFlag flag, ModInfo::Ptr modInfo) const { switch (flag) { case ModInfo::FLAG_BACKUP: return tr("Backup"); + 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", "
")); @@ -203,7 +205,13 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const || (column == COL_CONTENT)) { return QVariant(); } else if (column == COL_NAME) { - return modInfo->name(); + auto flags = modInfo->getFlags(); + if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_SEPARATOR) != flags.end()) + { + return modInfo->name().replace("_separator", ""); + } + else + return modInfo->name(); } else if (column == COL_VERSION) { VersionInfo verInfo = modInfo->getVersion(); QString version = verInfo.displayString(); @@ -277,6 +285,7 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const return QVariant(); } } else if (role == Qt::TextAlignmentRole) { + auto flags = modInfo->getFlags(); if (column == COL_NAME) { if (modInfo->getHighlight() & ModInfo::HIGHLIGHT_CENTER) { return QVariant(Qt::AlignCenter | Qt::AlignVCenter); @@ -327,8 +336,15 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const return modInfo->getGameName(); } else if (role == Qt::FontRole) { QFont result; + auto flags = modInfo->getFlags(); if (column == COL_NAME) { - if (modInfo->getHighlight() & ModInfo::HIGHLIGHT_INVALID) { + if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_SEPARATOR) != flags.end()) + { + //result.setCapitalization(QFont::AllUppercase); + result.setItalic(true); + //result.setUnderline(true); + result.setBold(true); + } else if (modInfo->getHighlight() & ModInfo::HIGHLIGHT_INVALID) { result.setItalic(true); } } else if ((column == COL_CATEGORY) && (modInfo->hasFlag(ModInfo::FLAG_FOREIGN))) { @@ -476,6 +492,7 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role) ModInfo::Ptr info = ModInfo::getByIndex(modID); IModList::ModStates oldState = state(modID); + bool result = false; emit aboutToChangeData(); @@ -493,7 +510,13 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role) } else if (role == Qt::EditRole) { switch (index.column()) { case COL_NAME: { - result = renameMod(modID, value.toString()); + auto flags = info->getFlags(); + if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_SEPARATOR) != flags.end()) + { + result = renameMod(modID, value.toString() + "_separator"); + } + else + result = renameMod(modID, value.toString()); } break; case COL_PRIORITY: { bool ok = false; -- cgit v1.3.1