mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-01-17 15:42:10 +00:00
GUI: fix withSelectedIndexes not to skip rows in hierarchies
This commit is contained in:
parent
c5c8dd5671
commit
f911c28809
@ -62,14 +62,20 @@ resizeViewColumnsToContents(QTreeView *view) {
|
||||
void
|
||||
withSelectedIndexes(QAbstractItemView *view,
|
||||
std::function<void(QModelIndex const &)> worker) {
|
||||
auto rowsSeen = QSet<int>{};
|
||||
for (auto const &range : view->selectionModel()->selection())
|
||||
withSelectedIndexes(view->selectionModel(), worker);
|
||||
}
|
||||
|
||||
void
|
||||
withSelectedIndexes(QItemSelectionModel *selectionModel,
|
||||
std::function<void(QModelIndex const &)> worker) {
|
||||
auto rowsSeen = QMap< std::pair<QModelIndex, int>, bool >{};
|
||||
for (auto const &range : selectionModel->selection())
|
||||
for (auto const &index : range.indexes()) {
|
||||
auto row = index.row();
|
||||
if (rowsSeen.contains(row))
|
||||
auto seenIdx = std::make_pair(index.parent(), index.row());
|
||||
if (rowsSeen[seenIdx])
|
||||
continue;
|
||||
rowsSeen << row;
|
||||
worker(index.sibling(row, 0));
|
||||
rowsSeen[seenIdx] = true;
|
||||
worker(index.sibling(index.row(), 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ class QAbstractItemView;
|
||||
class QComboBox;
|
||||
class QDateTime;
|
||||
class QIcon;
|
||||
class QItemSelectionModel;
|
||||
class QModelIndex;
|
||||
class QTreeView;
|
||||
class QString;
|
||||
@ -40,6 +41,7 @@ enum MtxGuiRoles {
|
||||
};
|
||||
|
||||
void resizeViewColumnsToContents(QTreeView *view);
|
||||
void withSelectedIndexes(QItemSelectionModel *selectionModel, std::function<void(QModelIndex const &)> worker);
|
||||
void withSelectedIndexes(QAbstractItemView *view, std::function<void(QModelIndex const &)> worker);
|
||||
|
||||
// String stuff
|
||||
|
Loading…
Reference in New Issue
Block a user