22 #include <QVBoxLayout>
25 : QWidget(parent), m_treeView(new
ItemTreeView), m_sampleModel(model)
27 setWindowTitle(
"Sample Tree");
28 setObjectName(QLatin1String(
"SampleTreeWidget"));
30 auto mainLayout =
new QVBoxLayout;
31 mainLayout->setMargin(0);
32 mainLayout->setSpacing(0);
33 mainLayout->setContentsMargins(0, 0, 0, 0);
35 setLayout(mainLayout);
40 m_treeView->setAttribute(Qt::WA_MacShowFocusRect,
false);
42 connect(
m_treeView, &ItemTreeView::customContextMenuRequested,
this,
50 connect(
m_treeView->model(), &QAbstractItemModel::rowsInserted,
this,
51 [
this]() { m_treeView->expandAll(); });
62 QMenu add_menu(
"Add");
63 QVector<QString> addItemNames;
65 treeView()->setCurrentIndex(parent_index);
66 if (!parent_index.isValid()) {
71 if (addItemNames.size() > 0) {
72 for (QString item_name : addItemNames) {
73 QAction* add_action =
nullptr;
77 add_action =
new QAction(item_name,
this);
79 connect(add_action, &QAction::triggered, [=] {
addItem(item_name); });
81 add_menu.addAction(add_action);
83 menu.addMenu(&add_menu);
85 if (parent_index.isValid()) {
88 if (!menu.isEmpty()) {
89 menu.exec(
treeView()->mapToGlobal(pnt));
109 if (!currentIndex.isValid())
112 int row = currentIndex.row();
113 if (currentIndex.isValid()) {
120 if (index.isValid()) {
127 if (index == QModelIndex() || index.column() == 0)
Defines class FilterPropertyProxy.
Defines class ItemFactory.
Defines class ItemTreeView.
Defines class SampleModel.
The FilterPropertyProxy class filters out all PropertyItem's and similar from SessionModel to have on...
static QModelIndex toSourceIndex(QModelIndex index)
Main model to hold sample items.
virtual QModelIndex parent(const QModelIndex &child) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
virtual bool removeRows(int row, int count, const QModelIndex &parent)
SessionItem * insertNewItem(QString model_type, SessionItem *parent_item=nullptr, int row=-1, QString tag="")
QVector< QString > acceptableDefaultItemTypes(const QModelIndex &parent) const
QModelIndex indexOfItem(SessionItem *item) const
QStringList ValidTopItemTypes()
retrieve list of all possible item types suitable for