summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAL <26797547+Al12rs@users.noreply.github.com>2020-10-31 20:58:07 +0100
committerAL <26797547+Al12rs@users.noreply.github.com>2020-11-02 20:35:05 +0100
commitb7935aedec70dd4f0c40dbe948dba9a80a56a75a (patch)
tree358266669f9163a883dcc4fabf3fcc67f8b80fa0
parent88475677d29a275fd9d25f452f58d3d745720124 (diff)
Change Alternatives vector to use a struct
-rw-r--r--src/filetree.cpp8
-rw-r--r--src/filetreemodel.cpp8
-rw-r--r--src/modinfodialogconflicts.cpp24
-rw-r--r--src/modinfowithconflictinfo.cpp37
-rw-r--r--src/modlist.cpp24
-rw-r--r--src/organizercore.cpp14
-rw-r--r--src/pluginlist.cpp4
-rw-r--r--src/shared/fileentry.cpp56
-rw-r--r--src/shared/fileentry.h6
-rw-r--r--src/shared/fileregister.cpp2
-rw-r--r--src/shared/fileregisterfwd.h33
-rw-r--r--src/syncoverwritedialog.cpp6
12 files changed, 117 insertions, 105 deletions
diff --git a/src/filetree.cpp b/src/filetree.cpp
index 1dadfaad..230d7d7e 100644
--- a/src/filetree.cpp
+++ b/src/filetree.cpp
@@ -591,16 +591,16 @@ bool FileTree::showShellMenu(QPoint pos)
}
for (auto&& alt : alts) {
- auto itor = menus.find(alt.first);
+ auto itor = menus.find(alt.originID);
if (itor == menus.end()) {
- itor = menus.emplace(alt.first, mw).first;
+ itor = menus.emplace(alt.originID, mw).first;
}
- const auto fullPath = file->getFullPath(alt.first);
+ const auto fullPath = file->getFullPath(alt.originID);
if (fullPath.empty()) {
log::error(
"file {} not found in origin {}",
- item->dataRelativeFilePath(), alt.first);
+ item->dataRelativeFilePath(), alt.originID);
continue;
}
diff --git a/src/filetreemodel.cpp b/src/filetreemodel.cpp
index 59025479..af2cac44 100644
--- a/src/filetreemodel.cpp
+++ b/src/filetreemodel.cpp
@@ -1129,8 +1129,8 @@ std::wstring FileTreeModel::makeModName(
std::wstring name = origin.getName();
const auto& archive = file.getArchive();
- if (!archive.first.empty()) {
- name += L" (" + archive.first + L")";
+ if (!archive.name.empty()) {
+ name += L" (" + archive.name + L")";
}
return name;
@@ -1183,8 +1183,8 @@ QString FileTreeModel::makeTooltip(const FileTreeItem& item) const
const auto alternatives = file->getAlternatives();
QStringList list;
- for (auto&& alt : file->getAlternatives()) {
- const auto& origin = m_core.directoryStructure()->getOriginByID(alt.first);
+ for (auto&& alt : alternatives) {
+ const auto& origin = m_core.directoryStructure()->getOriginByID(alt.originID);
list.push_back(QString::fromStdWString(origin.getName()));
}
diff --git a/src/modinfodialogconflicts.cpp b/src/modinfodialogconflicts.cpp
index f11b31c1..205d807b 100644
--- a/src/modinfodialogconflicts.cpp
+++ b/src/modinfodialogconflicts.cpp
@@ -520,7 +520,7 @@ std::vector<QAction*> ConflictsTab::createGotoActions(const ConflictItem* item)
// add all alternatives
for (const auto& alt : file->getAlternatives()) {
- const auto& o = ds.getOriginByID(alt.first);
+ const auto& o = ds.getOriginByID(alt.originID);
if (o.getID() != origin()->getID()) {
mods.push_back(ToQString(o.getName()));
}
@@ -683,7 +683,7 @@ bool GeneralConflictsTab::update()
auto currId = m_tab->origin()->getID();
auto currModAlt = std::find_if(alternatives.begin(), alternatives.end(),
[&currId](auto const& alt) {
- return currId == alt.first;
+ return currId == alt.originID;
});
if (currModAlt == alternatives.end()) {
@@ -691,7 +691,7 @@ bool GeneralConflictsTab::update()
continue;
}
- bool currModFileArchive = currModAlt->second.first.size() > 0;
+ bool currModFileArchive = currModAlt->isFromArchive();
m_overwrittenModel->add(createOverwrittenItem(
file->getIndex(), fileOrigin, archive,
@@ -731,10 +731,10 @@ ConflictItem GeneralConflictsTab::createOverwriteItem(
altString += L", ";
}
- altString += ds.getOriginByID(alt.first).getName();
+ altString += ds.getOriginByID(alt.originID).getName();
}
- auto origin = ToQString(ds.getOriginByID(alternatives.back().first).getName());
+ auto origin = ToQString(ds.getOriginByID(alternatives.back().originID).getName());
return ConflictItem(
ToQString(altString), std::move(relativeName), QString(), index,
@@ -1005,7 +1005,7 @@ std::optional<ConflictItem> AdvancedConflictsTab::createItem(
if (showAllAlts) {
for (const auto& alt : alternatives)
{
- const auto& altOrigin = ds.getOriginByID(alt.first);
+ const auto& altOrigin = ds.getOriginByID(alt.originID);
if (!before.empty()) {
before += L", ";
}
@@ -1015,7 +1015,7 @@ std::optional<ConflictItem> AdvancedConflictsTab::createItem(
}
else {
// only add nearest, which is the last element of alternatives
- const auto& altOrigin = ds.getOriginByID(alternatives.back().first);
+ const auto& altOrigin = ds.getOriginByID(alternatives.back().originID);
before += altOrigin.getName();
}
@@ -1028,7 +1028,7 @@ std::optional<ConflictItem> AdvancedConflictsTab::createItem(
auto currModIter = std::find_if(alternatives.begin(), alternatives.end(),
[&currOrgId](auto const& alt) {
- return currOrgId == alt.first;
+ return currOrgId == alt.originID;
});
if (currModIter == alternatives.end()) {
@@ -1036,7 +1036,7 @@ std::optional<ConflictItem> AdvancedConflictsTab::createItem(
return {};
}
- isCurrOrigArchive = currModIter->second.first.size() > 0;
+ isCurrOrigArchive = currModIter->isFromArchive();
if (showAllAlts) {
// fills 'before' and 'after' with all the alternatives that come
@@ -1045,7 +1045,7 @@ std::optional<ConflictItem> AdvancedConflictsTab::createItem(
for (auto iter = alternatives.begin(); iter != alternatives.end(); iter++) {
- const auto& altOrigin = ds.getOriginByID(iter->first);
+ const auto& altOrigin = ds.getOriginByID(iter->originID);
if (iter < currModIter) {
// mod comes before current
@@ -1080,13 +1080,13 @@ std::optional<ConflictItem> AdvancedConflictsTab::createItem(
// before
if (currModIter > alternatives.begin()) {
- auto previousOrigId = (currModIter-1)->first;
+ auto previousOrigId = (currModIter-1)->originID;
before += ds.getOriginByID(previousOrigId).getName();
}
// after
if (currModIter < (alternatives.end() - 1)) {
- auto followingOrigId = (currModIter + 1)->first;
+ auto followingOrigId = (currModIter + 1)->originID;
after += ds.getOriginByID(followingOrigId).getName();
}
else {
diff --git a/src/modinfowithconflictinfo.cpp b/src/modinfowithconflictinfo.cpp
index 70f9b3f1..b1765669 100644
--- a/src/modinfowithconflictinfo.cpp
+++ b/src/modinfowithconflictinfo.cpp
@@ -145,19 +145,18 @@ void ModInfoWithConflictInfo::doConflictCheck() const
}
auto alternatives = file->getAlternatives();
- if ((alternatives.size() == 0) || (alternatives.back().first == dataID)) {
+ if ((alternatives.size() == 0) || (alternatives.back().originID == dataID)) {
// no alternatives -> no conflict
providesAnything = true;
} else {
// Get the archive data for the current mod
- bool found = file->getOrigin() == origin.getID();
- std::pair<std::wstring, int> archiveData;
- if (found)
+ DataArchiveOrigin archiveData;
+ if (file->getOrigin() == origin.getID())
archiveData = file->getArchive();
else {
- for (auto alts : alternatives) {
- if (alts.first == origin.getID()) {
- archiveData = alts.second;
+ for (auto alt : alternatives) {
+ if (alt.originID == origin.getID()) {
+ archiveData = alt.archive;
break;
}
}
@@ -167,25 +166,27 @@ void ModInfoWithConflictInfo::doConflictCheck() const
if (file->getOrigin() != origin.getID()) {
FilesOrigin &altOrigin = (*m_DirectoryStructure)->getOriginByID(file->getOrigin());
unsigned int altIndex = ModInfo::getIndex(ToQString(altOrigin.getName()));
- if (file->getArchive().first.size() == 0)
- if (archiveData.first.size() == 0)
+ if (!file->isFromArchive()) {
+ if (!archiveData.isValid())
m_OverwrittenList.insert(altIndex);
else
m_ArchiveLooseOverwrittenList.insert(altIndex);
- else
- m_ArchiveOverwrittenList.insert(altIndex);
+ }
+ else {
+ m_ArchiveOverwrittenList.insert(altIndex);
+ }
} else {
providesAnything = true;
}
// Sort out the alternatives
for (auto altInfo : alternatives) {
- if ((altInfo.first != dataID) && (altInfo.first != origin.getID())) {
- FilesOrigin &altOrigin = (*m_DirectoryStructure)->getOriginByID(altInfo.first);
+ if ((altInfo.originID != dataID) && (altInfo.originID != origin.getID())) {
+ FilesOrigin &altOrigin = (*m_DirectoryStructure)->getOriginByID(altInfo.originID);
QString altOriginName = ToQString(altOrigin.getName());
unsigned int altIndex = ModInfo::getIndex(altOriginName);
- if (altInfo.second.first.size() == 0) {
- if (archiveData.first.size() == 0) {
+ if (!altInfo.isFromArchive()) {
+ if (!archiveData.isValid()) {
if (origin.getPriority() > altOrigin.getPriority()) {
m_OverwriteList.insert(altIndex);
} else {
@@ -195,12 +196,12 @@ void ModInfoWithConflictInfo::doConflictCheck() const
m_ArchiveLooseOverwrittenList.insert(altIndex);
}
} else {
- if (archiveData.first.size() == 0) {
+ if (!archiveData.isValid()) {
m_ArchiveLooseOverwriteList.insert(altIndex);
} else {
- if (archiveData.second > altInfo.second.second) {
+ if (archiveData.order > altInfo.archive.order) {
m_ArchiveOverwriteList.insert(altIndex);
- } else if (archiveData.second < altInfo.second.second) {
+ } else if (archiveData.order < altInfo.archive.order) {
m_ArchiveOverwrittenList.insert(altIndex);
}
}
diff --git a/src/modlist.cpp b/src/modlist.cpp
index f4c034dc..1f845999 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -854,25 +854,15 @@ void ModList::highlightMods(const QItemSelectionModel *selection, const MOShared
ModInfo::getByIndex(i)->setPluginSelected(false);
}
for (QModelIndex idx : selection->selectedRows(PluginList::COL_NAME)) {
- QString modName = idx.data().toString();
+ QString pluginName = idx.data().toString();
- const MOShared::FileEntryPtr fileEntry = directoryEntry.findFile(modName.toStdWString());
+ const MOShared::FileEntryPtr fileEntry = directoryEntry.findFile(pluginName.toStdWString());
if (fileEntry.get() != nullptr) {
- bool archive = false;
- std::vector<std::pair<int, std::pair<std::wstring, int>>> origins;
- {
- std::vector<std::pair<int, std::pair<std::wstring, int>>> alternatives = fileEntry->getAlternatives();
- origins.insert(origins.end(), std::pair<int, std::pair<std::wstring, int>>(fileEntry->getOrigin(archive), fileEntry->getArchive()));
- }
- for (auto originInfo : origins) {
- MOShared::FilesOrigin& origin = directoryEntry.getOriginByID(originInfo.first);
- for (unsigned int i = 0; i < ModInfo::getNumMods(); ++i) {
- if (ModInfo::getByIndex(i)->internalName() == QString::fromStdWString(origin.getName())) {
- ModInfo::getByIndex(i)->setPluginSelected(true);
- break;
- }
- }
- }
+
+ QString originName = QString::fromStdWString(directoryEntry.getOriginByID(fileEntry->getOrigin()).getName());
+
+ auto modInfo = ModInfo::getByName(originName);
+ modInfo->setPluginSelected(true);
}
}
notifyChange(0, rowCount() - 1);
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 92433f5e..df47c75d 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -921,7 +921,7 @@ QStringList OrganizerCore::getFileOrigins(const QString &fileName) const
m_DirectoryStructure->getOriginByID(file->getOrigin()).getName()));
foreach (auto i, file->getAlternatives()) {
result.append(
- ToQString(m_DirectoryStructure->getOriginByID(i.first).getName()));
+ ToQString(m_DirectoryStructure->getOriginByID(i.originID).getName()));
}
}
return result;
@@ -945,10 +945,10 @@ QList<MOBase::IOrganizer::FileInfo> OrganizerCore::findFileInfos(
info.origins.append(ToQString(
m_DirectoryStructure->getOriginByID(file->getOrigin(fromArchive))
.getName()));
- info.archive = fromArchive ? ToQString(file->getArchive().first) : "";
+ info.archive = fromArchive ? ToQString(file->getArchive().name) : "";
foreach (auto idx, file->getAlternatives()) {
info.origins.append(
- ToQString(m_DirectoryStructure->getOriginByID(idx.first).getName()));
+ ToQString(m_DirectoryStructure->getOriginByID(idx.originID).getName()));
}
if (filter(info)) {
@@ -1049,7 +1049,7 @@ bool OrganizerCore::previewFileWithAlternatives(
// don't bother with the vector of origins, just add them as they come
addFunc(file->getOrigin());
for (auto alt : file->getAlternatives()) {
- addFunc(alt.first);
+ addFunc(alt.originID);
}
} else {
std::vector<int> origins;
@@ -1059,10 +1059,10 @@ bool OrganizerCore::previewFileWithAlternatives(
// add other origins, push to front if it's the selected one
for (auto alt : file->getAlternatives()) {
- if (alt.first == selectedOrigin) {
- origins.insert(origins.begin(), alt.first);
+ if (alt.originID == selectedOrigin) {
+ origins.insert(origins.begin(), alt.originID);
} else {
- origins.push_back(alt.first);
+ origins.push_back(alt.originID);
}
}
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp
index 8dd12cdf..e45326c6 100644
--- a/src/pluginlist.cpp
+++ b/src/pluginlist.cpp
@@ -153,8 +153,8 @@ void PluginList::highlightPlugins(const QItemSelectionModel *selection, const MO
for (auto plugin : plugins) {
MOShared::FileEntryPtr file = directoryEntry.findFile(plugin.toStdWString());
if (file && file->getOrigin() != origin.getID()) {
- const std::vector<std::pair<int, std::pair<std::wstring, int>>> alternatives = file->getAlternatives();
- if (std::find_if(alternatives.begin(), alternatives.end(), [&](const std::pair<int, std::pair<std::wstring, int>>& element) { return element.first == origin.getID(); }) == alternatives.end())
+ const auto alternatives = file->getAlternatives();
+ if (std::find_if(alternatives.begin(), alternatives.end(), [&](const FileAlternative& element) { return element.originID == origin.getID(); }) == alternatives.end())
continue;
}
std::map<QString, int>::iterator iter = m_ESPsByName.find(plugin.toLower());
diff --git a/src/shared/fileentry.cpp b/src/shared/fileentry.cpp
index e57c3cc5..3e354bc9 100644
--- a/src/shared/fileentry.cpp
+++ b/src/shared/fileentry.cpp
@@ -31,12 +31,12 @@ void FileEntry::addOrigin(
// alternatives
m_Origin = origin;
m_FileTime = fileTime;
- m_Archive = std::pair<std::wstring, int>(std::wstring(archive.begin(), archive.end()), order);
+ m_Archive = DataArchiveOrigin(std::wstring(archive.begin(), archive.end()), order);
}
else if (
(m_Parent != nullptr) && (
(m_Parent->getOriginByID(origin).getPriority() > m_Parent->getOriginByID(m_Origin).getPriority()) ||
- (archive.size() == 0 && m_Archive.first.size() > 0 ))
+ (archive.size() == 0 && m_Archive.isValid()))
) {
// If this mod has a higher priority than the origin mod OR
// this mod has a loose file and the origin mod has an archived file,
@@ -44,7 +44,7 @@ void FileEntry::addOrigin(
auto itor = std::find_if(
m_Alternatives.begin(), m_Alternatives.end(),
- [&](auto&& i) { return i.first == m_Origin; });
+ [&](auto&& i) { return i.originID == m_Origin; });
if (itor == m_Alternatives.end()) {
m_Alternatives.push_back({m_Origin, m_Archive});
@@ -52,7 +52,7 @@ void FileEntry::addOrigin(
m_Origin = origin;
m_FileTime = fileTime;
- m_Archive = std::pair<std::wstring, int>(std::wstring(archive.begin(), archive.end()), order);
+ m_Archive = DataArchiveOrigin(std::wstring(archive.begin(), archive.end()), order);
}
else {
// This mod is just an alternative
@@ -64,13 +64,13 @@ void FileEntry::addOrigin(
}
for (auto iter = m_Alternatives.begin(); iter != m_Alternatives.end(); ++iter) {
- if (iter->first == origin) {
+ if (iter->originID == origin) {
// already an origin
return;
}
if ((m_Parent != nullptr) &&
- (m_Parent->getOriginByID(iter->first).getPriority() < m_Parent->getOriginByID(origin).getPriority())) {
+ (m_Parent->getOriginByID(iter->originID).getPriority() < m_Parent->getOriginByID(origin).getPriority())) {
m_Alternatives.insert(iter, {origin, {std::wstring(archive.begin(), archive.end()), order}});
found = true;
break;
@@ -92,23 +92,23 @@ bool FileEntry::removeOrigin(OriginID origin)
// find alternative with the highest priority
auto currentIter = m_Alternatives.begin();
for (auto iter = m_Alternatives.begin(); iter != m_Alternatives.end(); ++iter) {
- if (iter->first != origin) {
+ if (iter->originID != origin) {
//Both files are not from archives.
- if (!iter->second.first.size() && !currentIter->second.first.size()) {
- if ((m_Parent->getOriginByID(iter->first).getPriority() > m_Parent->getOriginByID(currentIter->first).getPriority())) {
+ if (!iter->isFromArchive() && !currentIter->isFromArchive()) {
+ if ((m_Parent->getOriginByID(iter->originID).getPriority() > m_Parent->getOriginByID(currentIter->originID).getPriority())) {
currentIter = iter;
}
}
else {
//Both files are from archives
- if (iter->second.first.size() && currentIter->second.first.size()) {
- if (iter->second.second > currentIter->second.second) {
+ if (iter->isFromArchive() && currentIter->isFromArchive()) {
+ if (iter->archive.order > currentIter->archive.order) {
currentIter = iter;
}
}
else {
//Only one of the two is an archive, so we change currentIter only if he is the archive one.
- if (currentIter->second.first.size()) {
+ if (currentIter->isFromArchive()) {
currentIter = iter;
}
}
@@ -116,20 +116,20 @@ bool FileEntry::removeOrigin(OriginID origin)
}
}
- OriginID currentID = currentIter->first;
- m_Archive = currentIter->second;
+ OriginID currentID = currentIter->originID;
+ m_Archive = currentIter->archive;
m_Alternatives.erase(currentIter);
m_Origin = currentID;
} else {
m_Origin = -1;
- m_Archive = std::pair<std::wstring, int>(L"", -1);
+ m_Archive = DataArchiveOrigin(L"", -1);
return true;
}
} else {
auto newEnd = std::remove_if(
m_Alternatives.begin(), m_Alternatives.end(),
- [&](auto &i) { return i.first == origin; });
+ [&](auto &i) { return i.originID == origin; });
if (newEnd != m_Alternatives.end()) {
m_Alternatives.erase(newEnd, m_Alternatives.end());
@@ -145,13 +145,13 @@ void FileEntry::sortOrigins()
m_Alternatives.push_back({m_Origin, m_Archive});
std::sort(m_Alternatives.begin(), m_Alternatives.end(), [&](auto&& LHS, auto&& RHS) {
- if (!LHS.second.first.size() && !RHS.second.first.size()) {
- int l = m_Parent->getOriginByID(LHS.first).getPriority();
+ if (!LHS.isFromArchive() && !RHS.isFromArchive()) {
+ int l = m_Parent->getOriginByID(LHS.originID).getPriority();
if (l < 0) {
l = INT_MAX;
}
- int r = m_Parent->getOriginByID(RHS.first).getPriority();
+ int r = m_Parent->getOriginByID(RHS.originID).getPriority();
if (r < 0) {
r = INT_MAX;
}
@@ -159,14 +159,14 @@ void FileEntry::sortOrigins()
return l < r;
}
- if (LHS.second.first.size() && RHS.second.first.size()) {
- int l = LHS.second.second; if (l < 0) l = INT_MAX;
- int r = RHS.second.second; if (r < 0) r = INT_MAX;
+ if (LHS.isFromArchive() && RHS.isFromArchive()) {
+ int l = LHS.archive.order; if (l < 0) l = INT_MAX;
+ int r = RHS.archive.order; if (r < 0) r = INT_MAX;
return l < r;
}
- if (RHS.second.first.size()) {
+ if (RHS.isFromArchive()) {
return false;
}
@@ -174,8 +174,8 @@ void FileEntry::sortOrigins()
});
if (!m_Alternatives.empty()) {
- m_Origin = m_Alternatives.back().first;
- m_Archive = m_Alternatives.back().second;
+ m_Origin = m_Alternatives.back().originID;
+ m_Archive = m_Alternatives.back().archive;
m_Alternatives.pop_back();
}
}
@@ -185,15 +185,15 @@ bool FileEntry::isFromArchive(std::wstring archiveName) const
std::scoped_lock lock(m_OriginsMutex);
if (archiveName.length() == 0) {
- return m_Archive.first.length() != 0;
+ return m_Archive.isValid();
}
- if (m_Archive.first.compare(archiveName) == 0) {
+ if (m_Archive.name.compare(archiveName) == 0) {
return true;
}
for (auto alternative : m_Alternatives) {
- if (alternative.second.first.compare(archiveName) == 0) {
+ if (alternative.archive.name.compare(archiveName) == 0) {
return true;
}
}
diff --git a/src/shared/fileentry.h b/src/shared/fileentry.h
index aceeec57..31655bb1 100644
--- a/src/shared/fileentry.h
+++ b/src/shared/fileentry.h
@@ -54,11 +54,11 @@ public:
OriginID getOrigin(bool &archive) const
{
- archive = (m_Archive.first.length() != 0);
+ archive = m_Archive.isValid();
return m_Origin;
}
- const std::pair<std::wstring, int> &getArchive() const
+ const DataArchiveOrigin &getArchive() const
{
return m_Archive;
}
@@ -107,7 +107,7 @@ private:
FileIndex m_Index;
std::wstring m_Name;
OriginID m_Origin;
- std::pair<std::wstring, int> m_Archive;
+ DataArchiveOrigin m_Archive;
AlternativesVector m_Alternatives;
DirectoryEntry *m_Parent;
mutable FILETIME m_FileTime;
diff --git a/src/shared/fileregister.cpp b/src/shared/fileregister.cpp
index b56599d1..d5a23a7a 100644
--- a/src/shared/fileregister.cpp
+++ b/src/shared/fileregister.cpp
@@ -172,7 +172,7 @@ void FileRegister::unregisterFile(FileEntryPtr file)
const auto& alternatives = file->getAlternatives();
for (auto iter = alternatives.begin(); iter != alternatives.end(); ++iter) {
- m_OriginConnection->getByID(iter->first).removeFile(file->getIndex());
+ m_OriginConnection->getByID(iter->originID).removeFile(file->getIndex());
}
// unregister from directory
diff --git a/src/shared/fileregisterfwd.h b/src/shared/fileregisterfwd.h
index 720e6e30..a3cf8132 100644
--- a/src/shared/fileregisterfwd.h
+++ b/src/shared/fileregisterfwd.h
@@ -42,15 +42,36 @@ using OriginID = int;
constexpr FileIndex InvalidFileIndex = UINT_MAX;
constexpr OriginID InvalidOriginID = -1;
-
-// a vector of {originId, {archiveName, order}}
-//
-// if a file is in an archive, archiveName is the name of the bsa and order
+// if a file is in an archive, name is the name of the bsa and order
// is the order of the associated plugin in the plugins list
-//
// is a file is not in an archive, archiveName is empty and order is usually
// -1
-using AlternativesVector = std::vector<std::pair<OriginID, std::pair<std::wstring, int>>>;
+struct DataArchiveOrigin
+{
+ std::wstring name = L"";
+ int order = -1;
+
+ bool isValid() const {
+ return name.size() > 0;
+ }
+
+ DataArchiveOrigin(std::wstring pname, int porder)
+ : name(pname), order(porder) {}
+
+ DataArchiveOrigin() {}
+};
+
+struct FileAlternative
+{
+ OriginID originID = -1;
+ DataArchiveOrigin archive;
+
+ bool isFromArchive() const {
+ return archive.isValid();
+ }
+};
+
+using AlternativesVector = std::vector<FileAlternative>;
struct DirectoryStats
{
diff --git a/src/syncoverwritedialog.cpp b/src/syncoverwritedialog.cpp
index 0afb1121..9d99f586 100644
--- a/src/syncoverwritedialog.cpp
+++ b/src/syncoverwritedialog.cpp
@@ -102,9 +102,9 @@ void SyncOverwriteDialog::readTree(const QString &path, DirectoryEntry *director
bool ignore;
int origin = entry->getOrigin(ignore);
addToComboBox(combo, ToQString(m_DirectoryStructure->getOriginByID(origin).getName()), origin);
- const std::vector<std::pair<int, std::pair<std::wstring, int>>> &alternatives = entry->getAlternatives();
- for (std::vector<std::pair<int, std::pair<std::wstring, int>>>::const_iterator iter = alternatives.begin(); iter != alternatives.end(); ++iter) {
- addToComboBox(combo, ToQString(m_DirectoryStructure->getOriginByID(iter->first).getName()), iter->first);
+ const auto &alternatives = entry->getAlternatives();
+ for (auto iter = alternatives.begin(); iter != alternatives.end(); ++iter) {
+ addToComboBox(combo, ToQString(m_DirectoryStructure->getOriginByID(iter->originID).getName()), iter->originID);
}
combo->setCurrentIndex(combo->count() - 1);
} else {