33 #include <QVBoxLayout>
35 #include <boost/polymorphic_cast.hpp>
37 using boost::polymorphic_downcast;
41 , m_treeView(new QTreeView)
42 , m_tuningWidget(nullptr)
43 , m_createFitParAction(nullptr)
44 , m_removeFromFitParAction(nullptr)
45 , m_removeFitParAction(nullptr)
46 , m_fitParameterModel(nullptr)
50 auto* layout =
new QVBoxLayout(
this);
53 layout->setSpacing(0);
56 m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
57 m_treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
58 m_treeView->setContextMenuPolicy(Qt::CustomContextMenu);
61 m_treeView->setDragDropMode(QAbstractItemView::DragDrop);
64 m_treeView->setStyleSheet(
"alternate-background-color: #EFF0F1;");
66 connect(
m_treeView, &QTreeView::customContextMenuRequested,
this,
109 QMenu* addToFitParMenu = menu.addMenu(
"Add to existing fit parameter");
110 addToFitParMenu->setEnabled(
true);
112 const bool allow_one_fit_parameter_to_have_more_than_one_link =
true;
113 if (allow_one_fit_parameter_to_have_more_than_one_link) {
116 addToFitParMenu->setEnabled(
false);
117 for (
int i = 0; i < fitParNames.count(); ++i) {
118 auto* action =
new QAction(QString(
"to ").append(fitParNames.at(i)), addToFitParMenu);
120 addToFitParMenu->addAction(action);
138 if (
jobItem()->fitParameterContainerItem()->isEmpty())
143 menu.exec(
m_treeView->viewport()->mapToGlobal(point));
151 if (selection.indexes().isEmpty())
154 for (
auto index : selection.indexes()) {
158 QString link = polymorphic_downcast<FitParameterLinkItem*>(item->
parentItem())->link();
160 jobItem()->parameterContainerItem()->findParameterItem(link));
170 if (!
jobItem()->fitParameterContainerItem()->fitParameterItem(item))
192 for (
const auto& link : linksToRemove)
194 fitParItem->removeLink(link);
201 for (
auto* item : itemsToRemove)
202 container->
model()->removeRow(item->index().row(), item->index().parent());
251 jobItem()->fitParameterContainerItem()->model());
269 for (
auto* item : selected) {
270 if (
jobItem()->fitParameterContainerItem()->fitParameterItem(item) ==
nullptr)
282 for (
auto* item : selected) {
283 if (
jobItem()->fitParameterContainerItem()->fitParameterItem(item))
302 QVector<FitParameterItem*> result;
303 QModelIndexList indexes =
m_treeView->selectionModel()->selectedIndexes();
304 for (
auto index : indexes) {
309 result.push_back(fitParItem);
320 QVector<FitParameterItem*> result;
321 for (
auto* fitParItem :
jobItem()->fitParameterContainerItem()->fitParameterItems())
322 if (fitParItem->linkItems().empty())
323 result.push_back(fitParItem);
333 QModelIndexList indexes =
m_treeView->selectionModel()->selectedIndexes();
334 for (QModelIndex index : indexes) {
339 result.push_back(fitParItem->link());
353 if (!parameter.isValid())
356 if (childRowCount > 0) {
357 for (
int j = 0; j < childRowCount; j++)
358 m_treeView->setFirstColumnSpanned(j, parameter,
true);
375 connect(
m_treeView->selectionModel(), &QItemSelectionModel::selectionChanged,
this,
378 disconnect(
m_treeView->selectionModel(), &QItemSelectionModel::selectionChanged,
this,
Defines classes releted to event filtering.
Defines class FitParameterContainerItem.
Defines class FitParameterDelegate.
Defines namespace FitParameterHelper.
Defines class FitParameterItem.
Defines class FitParameterLinkItem.
Defines class FitParameterModel.
Defines class FitSuiteItem.
@ Fitting
the job is busy fitting
Defines class OverlayLabelController.
Defines classes for ParameterTreeItems.
Lisens for press-del-key events.
The FitParameterContainerItem class is a collection of all defined fit parameters in JobItem.
QStringList fitParameterNames() const
Returns list of fit parameter display names.
void removeLink(const ParameterItem *parameterItem)
void createFitParameter(ParameterItem *parameterItem)
Creates fit parameter from given ParameterItem, sets starting value to the value of ParameterItem,...
QVector< FitParameterItem * > fitParameterItems() const
void addToFitParameter(ParameterItem *parameterItem, const QString &fitParName)
Adds given parameterItem to the existing fit parameter with display name fitParName....
The FitParameterDelegate class presents the content of SessionModel items in standard QTreeView....
FitParameterItems is a collection of items to define fit parameters in GUI.
The FitParameterLinkItem class holds a link to ParameterItem in tuning tree.
Model to show items from FitParameterContainer in 5 column tree view.
int rowCount(const QModelIndex &parent) const override
SessionItem * itemForIndex(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent) const override
FitParameterContainerItem * fitParameterContainerItem()
The OverlayLabelController class controlls appearance of InfoLabelWidget (position,...
void setArea(QAbstractScrollArea *area)
void setText(const QString &text)
void setShown(bool shown)
Shows/removes a label from the controlled widget.
Base class for a GUI data item.
bool hasModelType() const
SessionModel * model() const
Returns model of this item.
SessionItem * parentItem() const
Returns parent of this item.
Defines namespace GUI::Constants.