19 #include <QItemSelection>
24 : QItemSelectionModel(view_model, parent)
27 connect(view_model, &ModelView::ViewModel::modelAboutToBeReset, [
this]() { clearSelection(); });
34 QModelIndexList indexes;
35 for (
auto item : items)
43 QItemSelection selection(indexes.front(), indexes.back());
44 auto flags = QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows;
45 select(selection, flags);
62 const QModelIndexList& selection = selectedRows();
63 if (selection.empty())
66 std::vector<ModelView::SessionItem*> result;
67 for (
const auto& index : selection)
68 if (
auto item =
viewModel()->sessionItemFromIndex(index); item)
69 result.push_back(item->parent());
83 const QModelIndexList& selection = selectedRows();
84 for (
const auto& index : selection) {
94 const QModelIndexList& selection = selectedRows();
95 for (
const auto& index : selection) {
96 if (index.row() ==
viewModel()->rowCount() - 1)
The main object representing an editable/displayable/serializable entity.
Main class to represent content of SessionModel in Qt's trees and tables.
QModelIndexList indexOfSessionItem(const SessionItem *item) const
Returns list of model indices representing given SessionItem.
static const std::string P_NAME
bool firstSelected() const
Checks if the first row is presen in the selection.
bool lastSelected() const
checks if the last row is present in the selection
const ModelView::ViewModel * viewModel() const
Return the casted view model.
void selectItems(std::vector< ModelView::SessionItem * > items)
Selects all rows corresponding to given items.
LayerSelectionModel(ModelView::ViewModel *view_model, QObject *parent=nullptr)
void selectItem(ModelView::SessionItem *item)
Selects whole row corresponding to given item.
std::vector< ModelView::SessionItem * > selectedItems() const
Returns vector of selected layers or multilayers.
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.