diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-31 12:34:17 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:38:17 +0100 |
| commit | a105e4c8c881ac720c41ef342769adee14caca47 (patch) | |
| tree | 7556c6f01803e8379153eb1a07659e7839f8d7cb /src/modlistview.cpp | |
| parent | fcf0aff98b43c9cb3b64c01cd03693e55f82fba7 (diff) | |
Move more stuff from MainWindow. Minor improvements for prev/next button in ModInfoDialog.
Diffstat (limited to 'src/modlistview.cpp')
| -rw-r--r-- | src/modlistview.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 40959e6d..f2b83beb 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -128,7 +128,7 @@ ModListViewActions& ModListView::actions() const return *m_actions;
}
-int ModListView::nextMod(int modIndex) const
+std::optional<unsigned int> ModListView::nextMod(unsigned int modIndex) const
{
const QModelIndex start = indexModelToView(m_core->modList()->index(modIndex, 0));
@@ -156,10 +156,10 @@ int ModListView::nextMod(int modIndex) const return modIndex;
}
- return -1;
+ return {};
}
-int ModListView::prevMod(int modIndex) const
+std::optional<unsigned int> ModListView::prevMod(unsigned int modIndex) const
{
const QModelIndex start = indexModelToView(m_core->modList()->index(modIndex, 0));
@@ -187,7 +187,7 @@ int ModListView::prevMod(int modIndex) const return modIndex;
}
- return -1;
+ return {};
}
void ModListView::enableAllVisible()
@@ -730,6 +730,7 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, FilterLis m_byPriorityProxy->refreshExpandedItems();
}
});
+ connect(selectionModel(), &QItemSelectionModel::selectionChanged, this, &ModListView::onSelectionChanged);
}
void ModListView::setModel(QAbstractItemModel* model)
@@ -848,6 +849,17 @@ void ModListView::onDoubleClicked(const QModelIndex& index) }
}
+void ModListView::onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
+{
+ if (hasCollapsibleSeparators()) {
+ for (auto& idx : selected.indexes()) {
+ if (idx.parent().isValid() && !isExpanded(idx.parent())) {
+ setExpanded(idx.parent(), true);
+ }
+ }
+ }
+}
+
void ModListView::dragEnterEvent(QDragEnterEvent* event)
{
emit dragEntered(event->mimeData());
|
