summaryrefslogtreecommitdiff
path: root/src/organizercore.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-05-28 10:14:15 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-05-28 10:14:15 -0400
commitadb5ace7997c4cf8ed5e0bee726478c8e1593524 (patch)
tree5201005514cb268f7d66fdecdaf63eff7d849732 /src/organizercore.cpp
parent2d52299743d056ae6da3c98ca9dc34abca3138bf (diff)
added selectedOrigin to previewFileWithAlternatives()
this is so that an origin other than the primary can be shown first and is used from previewDataFile() in ModInfoDialog since showing a preview for a conflicting file could initially show the file from the wrong mod removed unused, uninitialized and dangerous ModInfoDialog::m_OriginID
Diffstat (limited to 'src/organizercore.cpp')
-rw-r--r--src/organizercore.cpp41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 19b53b8d..00292e32 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1319,7 +1319,7 @@ bool OrganizerCore::executeFileVirtualized(
}
bool OrganizerCore::previewFileWithAlternatives(
- QWidget* parent, QString fileName)
+ QWidget* parent, QString fileName, int selectedOrigin)
{
// what we have is an absolute path to the file in its actual location (for the primary origin)
// what we want is the path relative to the virtual data directory
@@ -1370,9 +1370,42 @@ bool OrganizerCore::previewFileWithAlternatives(
}
};
- addFunc(file->getOrigin());
- for (auto alt : file->getAlternatives()) {
- addFunc(alt.first);
+ if (selectedOrigin == -1) {
+ // 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);
+ }
+ } else {
+ std::vector<int> origins;
+
+ // start with the primary origin
+ origins.push_back(file->getOrigin());
+
+ // 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);
+ } else {
+ origins.push_back(alt.first);
+ }
+ }
+
+ // can't be empty; either the primary origin was the selected one, or it
+ // was one of the alternatives, which got inserted in front
+
+ if (origins[0] != selectedOrigin) {
+ // sanity check, this shouldn't happen unless the caller passed an
+ // incorrect id
+
+ qWarning().nospace()
+ << "selected preview origin " << selectedOrigin << " not found in "
+ << "list of alternatives";
+ }
+
+ for (int id : origins) {
+ addFunc(id);
+ }
}
if (preview.numVariants() > 0) {