23 #include <QStandardItemModel>
28 , m_tree(new QTreeView)
31 , m_placeHolderModel(new QStandardItemModel(this))
34 , m_show_root_item(false)
36 auto layout =
new QVBoxLayout;
39 layout->setSpacing(0);
44 QStringList labels = {
"Name",
"Value"};
48 m_tree->setRootIsDecorated(
false);
53 m_tree->setEditTriggers(QAbstractItemView::AllEditTriggers);
57 m_tree->setContextMenuPolicy(Qt::CustomContextMenu);
58 connect(
m_tree, &QTreeView::customContextMenuRequested,
this,
91 if (QWidget* editor =
m_tree->indexWidget(
m_tree->currentIndex()))
92 m_delegate->closeEditor(editor, QAbstractItemDelegate::NoHint);
101 m_tree->setHeaderHidden(!show);
111 auto point =
m_tree->mapToGlobal(pos);
112 auto treeIndex =
m_tree->indexAt(pos);
113 if (!treeIndex.isValid())
119 if (item->
value().type() != QVariant::Double)
#define ASSERT(condition)
Defines class ComponentProxyModel.
Defines class ComponentTreeActions.
Defines class ComponentTreeView.
Defines classes releted to event filtering.
Defines class SessionModelDelegate.
Defines class SessionModel.
DefinesStyleUtils namespace.
Proxy model to adjust SessionModel for component editor (right bottom corner of SampleView and simila...
void setRootIndex(const QModelIndex &sourceRootIndex)
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
QModelIndex mapToSource(const QModelIndex &proxyIndex) const
void setSessionModel(SessionModel *model)
Additional action for ComponentTreeView.
void onCustomContextMenuRequested(const QPoint &point, SessionItem &item)
Creates right-mouse-click context menu on top of ComponentTreeView which will allow user to switch be...
SessionModelDelegate * m_delegate
std::unique_ptr< RightMouseButtonEater > m_eventFilter
ComponentTreeView(QWidget *parent=nullptr)
void setItem(SessionItem *item)
bool m_show_root_item
Tree will starts from item itself, if true.
QStandardItemModel * m_placeHolderModel
void setModel(SessionModel *model)
ComponentProxyModel * m_proxyModel
void setRootIndex(const QModelIndex &index, bool show_root_item=true)
void setShowRootItem(bool show)
void onCustomContextMenuRequested(const QPoint &pos)
ComponentTreeActions * m_actions
void setShowHeader(bool show)
Base class for ComponentTreeView and ComponentFlatView.
QVariant value() const
Get value.
SessionModel * model() const
Returns model of this item.
QModelIndex index() const
Returns model index of this item.
The SessionModelDelegate class presents the content of SessionModel items in standard QTreeView.
void setPropertyStyle(QTreeView *tree)
Sets style for the tree to use in property editors.