Skip to content

Commit

Permalink
Work on tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasKroes committed Dec 2, 2024
1 parent a159191 commit 413a81d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ExampleActions/src/ExampleActionsPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <QDebug>
#include <QSplitter>
#include <QHeaderView>

Q_PLUGIN_METADATA(IID "studio.manivault.ExampleActionsPlugin")

Expand All @@ -27,6 +28,18 @@ ExampleActionsPlugin::ExampleActionsPlugin(const PluginFactory* factory) :
if (!hierarchyWidget)
return;

auto& treeView = hierarchyWidget->getTreeView();

//treeView.setRootIsDecorated(false);
treeView.setTextElideMode(Qt::ElideMiddle);

treeView.setColumnHidden(static_cast<int>(ExampleActionsTreeModel::Column::ClassName), true);

auto treeViewHeader = treeView.header();

treeViewHeader->setSectionResizeMode(static_cast<int>(ExampleActionsTreeModel::Column::Name), QHeaderView::Stretch);
treeViewHeader->setSectionResizeMode(static_cast<int>(ExampleActionsTreeModel::Column::Description), QHeaderView::Stretch);

auto selectionModel = hierarchyWidget->getTreeView().selectionModel();

connect(selectionModel, &QItemSelectionModel::selectionChanged, hierarchyWidget, [this, selectionModel](const QItemSelection& selected, const QItemSelection& deselected) -> void {
Expand Down Expand Up @@ -54,7 +67,7 @@ ExampleActionsPlugin::ExampleActionsPlugin(const PluginFactory* factory) :

verticalGroupAction->setDefaultWidgetFlag(VerticalGroupAction::WidgetFlag::NoMargins);
verticalGroupAction->setShowLabels(false);
verticalGroupAction->addAction(new ExampleProxyAction(verticalGroupAction, "", action));
verticalGroupAction->addAction(new ExampleProxyAction(verticalGroupAction, "ExampleProxy", action));

_examplesGroupsAction.addGroupAction(verticalGroupAction);
}
Expand Down
7 changes: 7 additions & 0 deletions ExampleActions/src/ExampleActionsTreeModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ ExampleActionsTreeModel::ExampleActionsTreeModel(QObject* parent /*= nullptr*/)
appendRow(CategoryRow("Miscellaneous", {
{ "Dataset picker", "For picking datasets", "mv::gui::DatasetPickerAction" }
}));

appendRow(CategoryRow("Numerical", {
{ "Integral", "For configuring an integral value", "mv::gui::IntegralAction" },
{ "IntegralRange", "For configuring an integral range", "mv::gui::IntegralRangeAction" },
{ "Decimal", "For configuring a decimal value", "mv::gui::DecimalAction" },
{ "DecimalRange", "For configuring a decimal range", "mv::gui::DecimalRangeAction" },
}));
}

QVariant ExampleActionsTreeModel::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/) const
Expand Down

0 comments on commit 413a81d

Please sign in to comment.