diff options
| author | Al <gabriel.cortesi@outlook.com> | 2019-05-29 14:34:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-29 14:34:24 +0200 |
| commit | 41f8da011d1df7a368e3fb73f972cee1f4efd0c0 (patch) | |
| tree | 0f8ca16fd068efb54a0cb20a68ddeee43db0cb71 /src/organizercore.cpp | |
| parent | 1e3a10c8b22ac1362b1455de6f9d9f8ba739883b (diff) | |
| parent | ee92fa9fc89ab047a63716c48e13d3d0a76af4fb (diff) | |
Merge pull request #739 from isanae/hide-conflict-items
Share context menu between conflict lists
Diffstat (limited to 'src/organizercore.cpp')
| -rw-r--r-- | src/organizercore.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/organizercore.cpp b/src/organizercore.cpp index bd64e1bc..3ad4e586 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) { |
