24 #include <QApplication>
25 #include <QStyledItemDelegate>
27 #include <QToolButton>
29 #include <QVBoxLayout>
37 class SessionModelDelegate :
public QStyledItemDelegate {
39 SessionModelDelegate(QObject* parent)
40 : QStyledItemDelegate(parent)
44 void paint(QPainter* painter,
const QStyleOptionViewItem& option,
45 const QModelIndex& index)
const override
50 QStyledItemDelegate::paint(painter, option, index);
54 void paintCustomLabel(QPainter* painter,
const QStyleOptionViewItem& option,
55 const QModelIndex& index,
const QString& text)
const
57 QStyleOptionViewItem opt = option;
58 initStyleOption(&opt, index);
59 opt.text = displayText(text, option.locale);
60 const QWidget* widget = opt.widget;
61 QStyle* style = widget ? widget->style() : QApplication::style();
62 style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget);
71 auto* layout =
new QVBoxLayout(
this);
74 auto* tabs =
new QTabWidget(
this);
75 auto* m_expandButton =
new QToolButton(
this);
76 m_expandButton->setText(
"Expand tree");
77 m_expandButton->setIcon(QIcon(
":/images/toolbar_expand_collapse_tree.svg"));
78 m_expandButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
79 connect(m_expandButton, &QToolButton::clicked, [=]() {
80 auto* tree =
static_cast<QTreeView*
>(tabs->widget(tabs->currentIndex()));
82 tree->resizeColumnToContents(0);
83 tree->resizeColumnToContents(1);
86 auto* m_collapseButton =
new QToolButton(
this);
87 m_collapseButton->setText(
"Collapse tree");
88 m_collapseButton->setIcon(QIcon(
":/images/toolbar_expand_collapse_tree.svg"));
89 m_collapseButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
90 connect(m_collapseButton, &QToolButton::clicked, [=]() {
91 auto* tree =
static_cast<QTreeView*
>(tabs->widget(tabs->currentIndex()));
95 auto* toolbar =
new QToolBar;
96 toolbar->addWidget(m_expandButton);
97 toolbar->addWidget(m_collapseButton);
98 layout->addWidget(toolbar);
99 layout->addWidget(tabs);
103 for (
auto* model : models) {
104 auto* treeView =
new QTreeView(
this);
106 treeView->setItemDelegate(
new SessionModelDelegate(
this));
108 treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
109 tabs->addTab(treeView, model->getModelTag());
Defines class ComboProperty.
Defines abstract item with a material property.
Defines class MaterialItems.
Defines class ProjectManager.
Defines class RealDataModel.
Defines class SessionDecorationModel.
Defines class SessionModelView.
Defines GUI::StyleUtils namespace.
Custom property to define list of string values with multiple selections. Intended for QVariant.
QString label() const
Returns the label to show.
Project document class handles all data related to the opened project (sample, job,...
JobModel * jobModel() const
RealDataModel * realDataModel() const
Provides decorations (text color, icons, etc) for SessionModel in SessionModelView context....
SessionModelView(QWidget *parent, ProjectDocument *document)
void setPropertyStyle(QTreeView *tree)
Sets style for the tree to use in property editors.