forked from qt-creator/qt-creator
BaseTreeView: add convenience function to get selected or current rows
Change-Id: I3239c52ad2d1eb725e4c10aeb93ee2e73ad5c0b6 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -153,4 +153,16 @@ void BaseTreeView::reset()
|
|||||||
resizeColumnsToContents();
|
resizeColumnsToContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QModelIndexList BaseTreeView::activeRows() const
|
||||||
|
{
|
||||||
|
QItemSelectionModel *selection = selectionModel();
|
||||||
|
QModelIndexList indices = selection->selectedRows();
|
||||||
|
if (indices.isEmpty()) {
|
||||||
|
QModelIndex current = selection->currentIndex();
|
||||||
|
if (current.isValid())
|
||||||
|
indices.append(current);
|
||||||
|
}
|
||||||
|
return indices;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public:
|
|||||||
void setAlwaysAdjustColumnsAction(QAction *action);
|
void setAlwaysAdjustColumnsAction(QAction *action);
|
||||||
virtual void addBaseContextActions(QMenu *menu);
|
virtual void addBaseContextActions(QMenu *menu);
|
||||||
bool handleBaseContextAction(QAction *action);
|
bool handleBaseContextAction(QAction *action);
|
||||||
|
QModelIndexList activeRows() const;
|
||||||
|
|
||||||
void setModel(QAbstractItemModel *model);
|
void setModel(QAbstractItemModel *model);
|
||||||
virtual void rowActivated(const QModelIndex &) {}
|
virtual void rowActivated(const QModelIndex &) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user