From 8fafcce33f1d5633cf1cb1acbb067fd485869bbf Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 13:22:20 +0100 Subject: Add send to last conflict action for modlist. --- src/modlistview.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index ae905a6e..ad75631c 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -396,11 +396,23 @@ void ModListView::setSelected(const QModelIndex& current, const QModelIndexList& } void ModListView::scrollToAndSelect(const QModelIndex& index) +{ + scrollToAndSelect(QModelIndexList{index}); +} + +void ModListView::scrollToAndSelect(const QModelIndexList& indexes, const QModelIndex& current) { // focus, scroll to and select - scrollTo(index); - setCurrentIndex(index); - selectionModel()->select(index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); + if (!current.isValid() && indexes.isEmpty()) { + return; + } + scrollTo(current.isValid() ? current : indexes.first()); + setCurrentIndex(current.isValid() ? current : indexes.first()); + QItemSelection selection; + for (auto& idx : indexes) { + selection.select(idx, idx); + } + selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows); QTimer::singleShot(50, [=] { setFocus(); }); } -- cgit v1.3.1 From 65c9c695685b005656fd4d89b457b4d964dcf65e Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 13:29:55 +0100 Subject: Fix priority foreground color on colored separators. --- src/modlistview.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index ad75631c..3c32d02a 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -89,14 +89,13 @@ public: // but the mod list view uses alternate color so we need to find the // right color auto bg = opt.palette.base().color(); - auto vrow = (opt.rect.y() - m_view->verticalOffset()) / opt.rect.height(); - if (vrow % 2 == 1) { + if (opt.features & QStyleOptionViewItem::Alternate) { bg = opt.palette.alternateBase().color(); } // compute ideal foreground color for some rows if (color.isValid()) { - if ((index.column() == ModList::COL_NAME + if (((index.column() == ModList::COL_NAME || index.column() == ModList::COL_PRIORITY) && ModInfo::getByIndex(index.data(ModList::IndexRole).toInt())->isSeparator()) || index.column() == ModList::COL_NOTES) { -- cgit v1.3.1 From a2ed9b9ba924672093f6f620cb59a54920b89c57 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 14:57:15 +0100 Subject: Fix archive overwritten marker. --- src/modlistview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 3c32d02a..94f55098 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -1095,7 +1095,7 @@ QColor ModListView::markerColor(const QModelIndex& index) const bool highligth = m_markers.highlight.find(modIndex) != m_markers.highlight.end(); bool overwrite = m_markers.overwrite.find(modIndex) != m_markers.overwrite.end(); bool archiveOverwrite = m_markers.archiveOverwrite.find(modIndex) != m_markers.archiveOverwrite.end(); - bool archiveLooseOverwrite = m_markers.archiveOverwritten.find(modIndex) != m_markers.archiveOverwritten.end(); + bool archiveLooseOverwrite = m_markers.archiveLooseOverwrite.find(modIndex) != m_markers.archiveLooseOverwrite.end(); bool overwritten = m_markers.overwritten.find(modIndex) != m_markers.overwritten.end(); bool archiveOverwritten = m_markers.archiveOverwritten.find(modIndex) != m_markers.archiveOverwritten.end(); bool archiveLooseOverwritten = m_markers.archiveLooseOverwritten.find(modIndex) != m_markers.archiveLooseOverwritten.end(); -- cgit v1.3.1 From 54f7df9fbd8946626b974ed212b5f12dd5c28e93 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 16:14:46 +0100 Subject: Maintain selection after drag&drop. Fix update of conflicts (visual) after priority change. --- src/modlistview.cpp | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 94f55098..c40b4752 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -451,34 +451,31 @@ void ModListView::onModPrioritiesChanged(const QModelIndexList& indices) m_core->currentProfile()->writeModlist(); m_core->directoryStructure()->getFileRegister()->sortOrigins(); - { // refresh selection - QModelIndex current = currentIndex(); - if (current.isValid()) { - ModInfo::Ptr modInfo = ModInfo::getByIndex(current.data(ModList::IndexRole).toInt()); - // clear caches on all mods conflicting with the moved mod - for (int i : modInfo->getModOverwrite()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModOverwritten()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModArchiveOverwrite()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModArchiveOverwritten()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModArchiveLooseOverwrite()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModArchiveLooseOverwritten()) { - ModInfo::getByIndex(i)->clearCaches(); - } - // update conflict check on the moved mod - modInfo->doConflictCheck(); - setOverwriteMarkers(selectionModel()->selectedRows()); + for (auto& idx : indices) { + ModInfo::Ptr modInfo = ModInfo::getByIndex(idx.data(ModList::IndexRole).toInt()); + // clear caches on all mods conflicting with the moved mod + for (int i : modInfo->getModOverwrite()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModOverwritten()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModArchiveOverwrite()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModArchiveOverwritten()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModArchiveLooseOverwrite()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModArchiveLooseOverwritten()) { + ModInfo::getByIndex(i)->clearCaches(); } + // update conflict check on the moved mod + modInfo->doConflictCheck(); } + setOverwriteMarkers(selectionModel()->selectedRows()); } void ModListView::onModInstalled(const QString& modName) @@ -1349,9 +1346,11 @@ void ModListView::dropEvent(QDropEvent* event) emit dropEntered(event->mimeData(), isExpanded(index), static_cast(dropIndicatorPosition())); // see selectedIndexes() + auto [current, selected] = this->selected(); m_inDragMoveEvent = true; QTreeView::dropEvent(event); m_inDragMoveEvent = false; + setSelected(current, selected); } void ModListView::timerEvent(QTimerEvent* event) -- cgit v1.3.1 From d73d9307035ce751da442484cd6e23c8167393b7 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 16:21:59 +0100 Subject: Maintain selection when changing priority manually. --- src/modlistview.cpp | 13 +++++++++++++ src/modlistview.h | 2 ++ 2 files changed, 15 insertions(+) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index c40b4752..243e78a4 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -906,6 +906,19 @@ void ModListView::drawBranches(QPainter* painter, const QRect& rect, const QMode QTreeView::drawBranches(painter, r, index); } +void ModListView::commitData(QWidget* editor) +{ + // maintain the selection when changing priority + if (currentIndex().column() == ModList::COL_PRIORITY) { + auto [current, selected] = this->selected(); + QTreeView::commitData(editor); + setSelected(current, selected); + } + else { + QTreeView::commitData(editor); + } +} + QModelIndexList ModListView::selectedIndexes() const { // during drag&drop events, we fake the return value of selectedIndexes() diff --git a/src/modlistview.h b/src/modlistview.h index 122bf2f1..39099cf7 100644 --- a/src/modlistview.h +++ b/src/modlistview.h @@ -182,6 +182,8 @@ protected slots: void onFiltersCriteria(const std::vector& filters); void onProfileChanged(Profile* oldProfile, Profile* newProfile); + void commitData(QWidget* editor) override; + private: friend class ModConflictIconDelegate; -- cgit v1.3.1 From e6d1f5500bfa41e20f12d88ab0c6d7d4717c8465 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 21:52:52 +0100 Subject: Only maintain selection after drag&drop of mods. --- src/modlistview.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 243e78a4..cb1d2842 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -1358,12 +1358,17 @@ void ModListView::dropEvent(QDropEvent* event) // is no way to deduce this except using dropIndicatorPosition()) emit dropEntered(event->mimeData(), isExpanded(index), static_cast(dropIndicatorPosition())); + ModListDropInfo dropInfo(event->mimeData(), *m_core); + // see selectedIndexes() auto [current, selected] = this->selected(); m_inDragMoveEvent = true; QTreeView::dropEvent(event); m_inDragMoveEvent = false; - setSelected(current, selected); + + if (dropInfo.isModDrop()) { + setSelected(current, selected); + } } void ModListView::timerEvent(QTimerEvent* event) -- cgit v1.3.1 From f46962686a0648abe06bea699365740546107a70 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 22:06:20 +0100 Subject: Fix drag&drop in manual installer after drag&drop of download/external archive in mod list. --- src/modlistview.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index cb1d2842..526e9c33 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -829,13 +829,16 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, MainWindo // prevent the name-column from being hidden header()->setSectionHidden(ModList::COL_NAME, false); - connect(m_core->modList(), &ModList::downloadArchiveDropped, [=](int row, int priority) { + // we need QueuedConnection for the download/archive dropped otherwise the + // installation starts within the drop-event and it's not possible to drag&drop + // in the manual installer + connect(m_core->modList(), &ModList::downloadArchiveDropped, this, [=](int row, int priority) { m_core->installDownload(row, priority); - }); - connect(m_core->modList(), &ModList::externalArchiveDropped, [=](const QUrl& url, int priority) { + }, Qt::QueuedConnection); + connect(m_core->modList(), &ModList::externalArchiveDropped, this, [=](const QUrl& url, int priority) { setWindowState(Qt::WindowActive); m_core->installArchive(url.toLocalFile(), priority, false, nullptr); - }); + }, Qt::QueuedConnection); connect(m_core->modList(), &ModList::externalFolderDropped, this, &ModListView::onExternalFolderDropped); connect(selectionModel(), &QItemSelectionModel::selectionChanged, [=] { m_refreshMarkersTimer.start(); }); -- cgit v1.3.1