diff --git a/GUI/coregui/Models/SampleViewProxyModel.cpp b/GUI/coregui/Models/FilterPropertyProxy.cpp similarity index 54% rename from GUI/coregui/Models/SampleViewProxyModel.cpp rename to GUI/coregui/Models/FilterPropertyProxy.cpp index ca6667d6a2579a4da46ef52d76757938797b8dd1..2d79e53dd6d05dc185654120ca218456ff93c553 100644 --- a/GUI/coregui/Models/SampleViewProxyModel.cpp +++ b/GUI/coregui/Models/FilterPropertyProxy.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file coregui/Models/SampleViewProxyModel.cpp -//! @brief Implements class SampleViewProxyModel +//! @file coregui/Models/FilterPropertyProxy.cpp +//! @brief Implements class FilterPropertyProxy //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -14,18 +14,23 @@ // // ************************************************************************** // -#include "SampleViewProxyModel.h" +#include "FilterPropertyProxy.h" +#include "SessionModel.h" -int SampleViewProxyModel::columnCount(const QModelIndex &parent) const +int FilterPropertyProxy::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent); - return 1; + return m_columns; } -bool SampleViewProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +bool FilterPropertyProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, 1, sourceParent); if (!sourceParent.isValid()) return true; - return !sourceModel()->data(index, Qt::DisplayRole).isValid(); + const QString modelType = index.data(SessionModel::ModelTypeRole).toString(); + if (modelType == Constants::PropertyType || modelType == Constants::GroupItemType) + return false; + + return true;//!sourceModel()->data(index, Qt::DisplayRole).isValid(); } diff --git a/GUI/coregui/Models/SampleViewProxyModel.h b/GUI/coregui/Models/FilterPropertyProxy.h similarity index 68% rename from GUI/coregui/Models/SampleViewProxyModel.h rename to GUI/coregui/Models/FilterPropertyProxy.h index ce90f9e412a4cc91e3d3007efd69e6c9709fa8f1..d40d68860407a76dfeb38a939e67b9b621633b57 100644 --- a/GUI/coregui/Models/SampleViewProxyModel.h +++ b/GUI/coregui/Models/FilterPropertyProxy.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file coregui/Models/SampleViewProxyModel.h -//! @brief Defines class SampleViewProxyModel +//! @file coregui/Models/FilterPropertyProxy.h +//! @brief Defines class FilterPropertyProxy //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -13,23 +13,27 @@ //! @authors Walter Van Herck, Joachim Wuttke // // ************************************************************************** // -#ifndef SAMPLEVIEWPROXYMODEL_H -#define SAMPLEVIEWPROXYMODEL_H +#ifndef FILTERPROPERTYPROXY_H +#define FILTERPROPERTYPROXY_H #include "WinDllMacros.h" #include <QSortFilterProxyModel> -class BA_CORE_API_ SampleViewProxyModel : public QSortFilterProxyModel +class BA_CORE_API_ FilterPropertyProxy : public QSortFilterProxyModel { Q_OBJECT public: - SampleViewProxyModel(QObject *parent = 0) : QSortFilterProxyModel(parent) {} + FilterPropertyProxy(int columns, QObject *parent = 0) : QSortFilterProxyModel(parent) + , m_columns(columns) {} int columnCount(const QModelIndex &parent) const; protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + +private: + int m_columns; }; #endif diff --git a/GUI/coregui/Models/ModelPath.cpp b/GUI/coregui/Models/ModelPath.cpp index 37c0188e2f2ce13ede888678c64746c31c74e396..dbb95c91fec9c2d951600693f4a2e24eb41b651c 100644 --- a/GUI/coregui/Models/ModelPath.cpp +++ b/GUI/coregui/Models/ModelPath.cpp @@ -19,6 +19,7 @@ #include "GroupProperty.h" #include "GroupItem.h" #include "ParticleItem.h" +#include "SessionModel.h" #include <QModelIndex> #include <QStringList> #include <sstream> @@ -127,6 +128,24 @@ QString ModelPath::getPathFromIndex(const QModelIndex &index) return QString(); } +QModelIndex ModelPath::getIndexFromPath(const SessionModel *model, const QString &path) +{ + if (model) { + QStringList parts = path.split("/"); + SessionItem *t = model->rootItem(); + for(int i = 0; i < parts.length(); i++) { + for (int j = 0; j < t->rowCount(); j++) { + if (t->childAt(j)->itemName() == parts[i]) { + t = t->childAt(j); + break; + } + } + } + return t->index(); + } + return QModelIndex(); +} + QStringList ModelPath::splitParameterName(const QString &par_name) { QStringList result; diff --git a/GUI/coregui/Models/ModelPath.h b/GUI/coregui/Models/ModelPath.h index da10ca56d9a2482d3d6bc06910e6e47af63f561f..e357f4845fb384d7f83949d20c6246f62300ba53 100644 --- a/GUI/coregui/Models/ModelPath.h +++ b/GUI/coregui/Models/ModelPath.h @@ -27,6 +27,7 @@ class SessionItem; class QString; class QStringList; class QModelIndex; +class SessionModel; class BA_CORE_API_ ModelPath { @@ -46,6 +47,8 @@ public: static QString getPathFromIndex(const QModelIndex &index); + static QModelIndex getIndexFromPath(const SessionModel *model, const QString &path); + private: static QStringList splitParameterName(const QString& par_name); diff --git a/GUI/coregui/Models/ParameterModelBuilder.cpp b/GUI/coregui/Models/ParameterModelBuilder.cpp index 01702109d271f3402301bd4afb3a3a65d3ef24e6..b044b1450d51674bc6d74c91d5f61e721f00f981 100644 --- a/GUI/coregui/Models/ParameterModelBuilder.cpp +++ b/GUI/coregui/Models/ParameterModelBuilder.cpp @@ -32,6 +32,7 @@ #include "GroupItem.h" #include "JobItem.h" #include "ModelPath.h" +#include "ParameterTreeItems.h" #include <QStandardItem> #include <QStandardItemModel> #include <QDebug> @@ -190,6 +191,10 @@ void ParameterTreeBuilder::handleItem(SessionItem *tree, SessionItem *source) } } else if (tree->modelType() == Constants::ParameterType) { tree->setDisplayName(source->itemName()); + tree->setValue(source->value()); + tree->setDecimals(source->decimals()); + tree->setLimits(source->limits()); + tree->setItemValue(ParameterItem::P_LINK, ModelPath::getPathFromIndex(source->index())); return; } else { return; @@ -202,8 +207,11 @@ void ParameterTreeBuilder::handleItem(SessionItem *tree, SessionItem *source) handleItem(branch, child); } } else if (child->modelType() == Constants::GroupItemType) { - SessionItem *branch = tree->model()->insertNewItem(Constants::ParameterLabelType, tree->index()); - handleItem(branch, dynamic_cast<GroupItem*>(child)->group()->getCurrentItem()); + SessionItem *currentItem = dynamic_cast<GroupItem*>(child)->group()->getCurrentItem(); + if (currentItem && currentItem->rowCount() > 0) { + SessionItem *branch = tree->model()->insertNewItem(Constants::ParameterLabelType, tree->index()); + handleItem(branch, currentItem); + } } else { SessionItem *branch = tree->model()->insertNewItem(Constants::ParameterLabelType, tree->index()); handleItem(branch, child); diff --git a/GUI/coregui/Models/ParameterTreeItems.cpp b/GUI/coregui/Models/ParameterTreeItems.cpp index b73aabfde6173f2b3652b288a56a2231f1a5b3e9..943c7b8c3ab974f5cc6a9e202fd6967781ef7877 100644 --- a/GUI/coregui/Models/ParameterTreeItems.cpp +++ b/GUI/coregui/Models/ParameterTreeItems.cpp @@ -15,6 +15,8 @@ // ************************************************************************** // #include "ParameterTreeItems.h" +#include "ModelPath.h" +#include "SessionModel.h" ParameterLabelItem::ParameterLabelItem() : SessionItem(Constants::ParameterLabelType) @@ -24,8 +26,9 @@ ParameterLabelItem::ParameterLabelItem() setDefaultTag(T_CHILDREN); } +const QString ParameterItem::P_LINK = "Link"; ParameterItem::ParameterItem() : SessionItem(Constants::ParameterType) { - + addProperty(P_LINK, ""); } diff --git a/GUI/coregui/Models/ParameterTreeItems.h b/GUI/coregui/Models/ParameterTreeItems.h index aeec9ee005c5eb215ccd2e2523fc0c0da136a569..833c3f718e566402d7793bb2c1bd9b7522ba8bee 100644 --- a/GUI/coregui/Models/ParameterTreeItems.h +++ b/GUI/coregui/Models/ParameterTreeItems.h @@ -28,6 +28,7 @@ public: class BA_CORE_API_ ParameterItem : public SessionItem { public: + static const QString P_LINK; ParameterItem(); }; diff --git a/GUI/coregui/Models/SessionModel.cpp b/GUI/coregui/Models/SessionModel.cpp index 40c86ac6d372032e4ab0370cc660f10ea816b370..be1a6bd2c7f249582d04bbcfbd3c74e69f95e05b 100644 --- a/GUI/coregui/Models/SessionModel.cpp +++ b/GUI/coregui/Models/SessionModel.cpp @@ -94,6 +94,8 @@ QVariant SessionModel::data(const QModelIndex &index, int role) const return item->itemName(); } else if (role == Qt::DecorationRole && m_iconProvider) { return m_iconProvider->icon(item); + } else { + return item->data(role); } } return QVariant(); diff --git a/GUI/coregui/Views/JobWidgets/ModelTuningDelegate.cpp b/GUI/coregui/Views/JobWidgets/ModelTuningDelegate.cpp index 7914ebcf8c7a406cef5beaec65ff53adfe615f82..219439cf0df0ab7a14c7ae0ea84359249be5feea 100644 --- a/GUI/coregui/Views/JobWidgets/ModelTuningDelegate.cpp +++ b/GUI/coregui/Views/JobWidgets/ModelTuningDelegate.cpp @@ -17,6 +17,10 @@ #include "ModelTuningDelegate.h" #include "ItemLink.h" #include "GUIHelpers.h" +#include "ParameterTreeItems.h" +#include "FilterPropertyProxy.h" +#include "ModelPath.h" +#include "SessionModel.h" #include <QDebug> #include <QPainter> #include <QPaintDevice> @@ -134,17 +138,20 @@ QWidget *ModelTuningDelegate::createEditor(QWidget *parent, double value = index.model()->data(index, Qt::EditRole).toDouble(); - m_current_link = index.model()->data(index, Qt::UserRole).value<ItemLink>(); +// m_current_link = index.model()->data(index, Qt::UserRole).value<ItemLink>(); - SessionItem *item = m_current_link.getItem(); - AttLimits limits = item->getItem(m_current_link.getPropertyName())->limits(); + auto proxy = dynamic_cast<FilterPropertyProxy*>(const_cast<QAbstractItemModel*>(index.model())); + + SessionItem *item = static_cast<SessionItem*>(proxy->mapToSource(index).internalPointer());//m_current_link.getItem(); + AttLimits limits = item->limits();//item->getItem(m_current_link.getPropertyName())->limits(); + m_currentItem = item; // initializing value box m_valueBox = new QDoubleSpinBox(); m_valueBox->setKeyboardTracking(false); m_valueBox->setFixedWidth(80); - m_valueBox->setDecimals(item->getItem(m_current_link.getPropertyName())->decimals()); - m_valueBox->setSingleStep(1./std::pow(10.,item->getItem(m_current_link.getPropertyName())->decimals()-1)); + m_valueBox->setDecimals(item->decimals()); + m_valueBox->setSingleStep(1./std::pow(10.,item->decimals()-1)); if(limits.hasLowerLimit()) { m_valueBox->setMinimum(limits.getLowerLimit()); @@ -240,15 +247,18 @@ void ModelTuningDelegate::setModelData(QWidget *editor, if (index.column() == m_valueColumn) { model->setData(index, m_valueBox->value()); - ItemLink link = model->data(index, Qt::UserRole).value<ItemLink>(); - - if(link.getItem() != nullptr) - { - qDebug() << "SampleTuningDelegate::setModelData() -> setting property " << link.getPropertyName(); - //link.getItem()->setRegisteredProperty(link.getPropertyName(), m_valueBox->value()); - link.setValue(m_valueBox->value()); - link.updateItem(); - } + + + + //ItemLink link = model->data(index, Qt::UserRole).value<ItemLink>(); + +// if(link.getItem() != nullptr) +// { +// qDebug() << "SampleTuningDelegate::setModelData() -> setting property " << link.getPropertyName(); +// //link.getItem()->setRegisteredProperty(link.getPropertyName(), m_valueBox->value()); +// link.setValue(m_valueBox->value()); +// link.updateItem(); +// } } else { QItemDelegate::setModelData(editor, model, index); @@ -258,11 +268,15 @@ void ModelTuningDelegate::setModelData(QWidget *editor, void ModelTuningDelegate::emitSignals(double value) { - if(m_current_link.getItem()) { - m_current_link.setValue(value); + if(m_currentItem) { + m_currentItem->setValue(value); + QString link = m_currentItem->getItemValue(ParameterItem::P_LINK).toString(); + SessionItem *item = m_currentItem->model()->itemForIndex(ModelPath::getIndexFromPath(m_currentItem->model(), link)); + if (item) + item->setValue(m_currentItem->value()); //qDebug() << "SampleTuningDelegate::editorValueChanged() -> Working on item " << m_current_link.getItem()->modelType() << m_current_link.getPropertyName(); //m_current_link.getItem()->setRegisteredProperty(m_current_link.getPropertyName(), m_valueBox->value()); - emit currentLinkChanged(m_current_link); + emit currentLinkChanged(m_currentItem); } } diff --git a/GUI/coregui/Views/JobWidgets/ModelTuningDelegate.h b/GUI/coregui/Views/JobWidgets/ModelTuningDelegate.h index 3d9b6f2e06cb251e5f352d8e9b5594b619f3c5b2..6c172b782d4441247f0bc4fcb7a3204174d62239 100644 --- a/GUI/coregui/Views/JobWidgets/ModelTuningDelegate.h +++ b/GUI/coregui/Views/JobWidgets/ModelTuningDelegate.h @@ -65,7 +65,7 @@ public: void setValueColumn(int valueColumn) { m_valueColumn = valueColumn; } signals: - void currentLinkChanged(ItemLink link); + void currentLinkChanged(SessionItem *item); private slots: void sliderValueChanged(int position); @@ -81,6 +81,7 @@ private: mutable QWidget *m_contentWidget; mutable QHBoxLayout * m_contentLayout; mutable ItemLink m_current_link; + mutable SessionItem *m_currentItem; mutable SliderData m_slider_data; }; diff --git a/GUI/coregui/Views/JobWidgets/ModelTuningWidget.cpp b/GUI/coregui/Views/JobWidgets/ModelTuningWidget.cpp index 0430327fb06bbbfd82a794eae6eba22c8f7d89fe..7b500d8dfe28ec838edecaf6da375b8277ab769c 100644 --- a/GUI/coregui/Views/JobWidgets/ModelTuningWidget.cpp +++ b/GUI/coregui/Views/JobWidgets/ModelTuningWidget.cpp @@ -27,6 +27,7 @@ #include "IntensityDataItem.h" #include "DesignerHelper.h" #include "WarningSignWidget.h" +#include "FilterPropertyProxy.h" #include <QLabel> #include <QVBoxLayout> #include <QTreeView> @@ -71,8 +72,8 @@ ModelTuningWidget::ModelTuningWidget(JobModel *jobModel, QWidget *parent) "QTreeView::branch:open:has-children:has-siblings {border-image: none;image: " "url(:/images/treeview-branch-open.png);}"); -// m_treeView->setItemDelegate(m_delegate); - connect(m_delegate, SIGNAL(currentLinkChanged(ItemLink)), this, SLOT(onCurrentLinkChanged(ItemLink))); + m_treeView->setItemDelegate(m_delegate); + connect(m_delegate, SIGNAL(currentLinkChanged(SessionItem*)), this, SLOT(onCurrentLinkChanged(SessionItem*))); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setMargin(0); @@ -116,7 +117,7 @@ void ModelTuningWidget::setCurrentItem(JobItem *item) } -void ModelTuningWidget::onCurrentLinkChanged(ItemLink link) +void ModelTuningWidget::onCurrentLinkChanged(SessionItem *item) { qDebug() << "ModelTuningWidget::onCurrentLinkChanged"; Q_ASSERT(m_currentJobItem); @@ -124,10 +125,10 @@ void ModelTuningWidget::onCurrentLinkChanged(ItemLink link) if(m_currentJobItem->isRunning()) return; - if (link.getItem()) { - qDebug() << "ModelTuningWidget::onCurrentLinkChanged() -> Starting to tune model" - << link.getItem()->modelType() << link.getPropertyName(); - link.updateItem(); + if (item) { + qDebug() << "ModelTuningWidget::onCurrentLinkChanged() -> Starting to tune model"; +// << link.getItem()->modelType() << link.getPropertyName(); +// link.updateItem(); m_jobModel->getJobQueueData()->runJob(m_currentJobItem); } } @@ -163,8 +164,10 @@ void ModelTuningWidget::updateParameterModel() m_parameterModel = ParameterModelBuilder::createParameterModel(m_jobModel, m_currentJobItem); - m_treeView->setModel(m_jobModel); - m_treeView->setRootIndex(m_currentJobItem->getItem(JobItem::T_PARAMETER_TREE)->index()); + FilterPropertyProxy *proxy = new FilterPropertyProxy(2, this); + proxy->setSourceModel(m_jobModel); + m_treeView->setModel(proxy); + m_treeView->setRootIndex(proxy->mapFromSource(m_currentJobItem->getItem(JobItem::T_PARAMETER_TREE)->index())); m_treeView->setColumnWidth(0, 240); m_treeView->expandAll(); } diff --git a/GUI/coregui/Views/JobWidgets/ModelTuningWidget.h b/GUI/coregui/Views/JobWidgets/ModelTuningWidget.h index 5b1feef3db59a653673cae284964290a754eb805..554e4df127cb86a24f3b0f90efb5e61de9cd40b8 100644 --- a/GUI/coregui/Views/JobWidgets/ModelTuningWidget.h +++ b/GUI/coregui/Views/JobWidgets/ModelTuningWidget.h @@ -42,7 +42,7 @@ public: void setCurrentItem(JobItem *item); public slots: - void onCurrentLinkChanged(ItemLink link); + void onCurrentLinkChanged(SessionItem* item); void onSliderValueChanged(double value); void onLockZValueChanged(bool value); void restoreModelsOfCurrentJobItem(); diff --git a/GUI/coregui/Views/SampleDesigner/DesignerScene.cpp b/GUI/coregui/Views/SampleDesigner/DesignerScene.cpp index bd2f455a0a17fd13c47162dd58d42823ce70ce81..30e4d9b042e2b2874d03e2c8bcd3e1eb5e7ee2a6 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerScene.cpp +++ b/GUI/coregui/Views/SampleDesigner/DesignerScene.cpp @@ -34,7 +34,7 @@ #include "ParticleLayoutItem.h" #include "ParticleCoreShellItem.h" #include "ParticleCompositionItem.h" -#include "SampleViewProxyModel.h" +#include "FilterPropertyProxy.h" #include <QItemSelection> #include <QDebug> @@ -100,7 +100,7 @@ void DesignerScene::setInstrumentModel(InstrumentModel *instrumentModel) m_instrumentModel = instrumentModel; } -void DesignerScene::setSelectionModel(QItemSelectionModel *model, SampleViewProxyModel *proxy) +void DesignerScene::setSelectionModel(QItemSelectionModel *model, FilterPropertyProxy *proxy) { Q_ASSERT(model); diff --git a/GUI/coregui/Views/SampleDesigner/DesignerScene.h b/GUI/coregui/Views/SampleDesigner/DesignerScene.h index a0638947eb49147ddb2299df65387b4300f5de0a..8a07583d0dbee610f5e5daa5686da3c7f9e874ed 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerScene.h +++ b/GUI/coregui/Views/SampleDesigner/DesignerScene.h @@ -33,7 +33,7 @@ class NodeEditorConnection; class DesignerMimeData; class SampleViewAligner; class NodeEditor; -class SampleViewProxyModel; +class FilterPropertyProxy; //! Main class which represents SessionModel on graphics scene @@ -47,7 +47,7 @@ public: void setSampleModel(SampleModel *sampleModel); void setInstrumentModel(InstrumentModel *instrumentModel); - void setSelectionModel(QItemSelectionModel *model, SampleViewProxyModel *proxy); + void setSelectionModel(QItemSelectionModel *model, FilterPropertyProxy *proxy); SampleModel *getSampleModel() { return m_sampleModel; } @@ -101,7 +101,7 @@ private: SampleModel *m_sampleModel; InstrumentModel *m_instrumentModel; QItemSelectionModel *m_selectionModel; - SampleViewProxyModel *m_proxy; + FilterPropertyProxy *m_proxy; bool m_block_selection; QMap<SessionItem *, IView *> m_ItemToView; diff --git a/GUI/coregui/Views/SampleDesigner/SampleDesigner.cpp b/GUI/coregui/Views/SampleDesigner/SampleDesigner.cpp index dd97177ef070c1a9244c2fff2be04f1c964cb4ba..4b7815913d94ecfea9c3ad1ec3156b6db5749c78 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleDesigner.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleDesigner.cpp @@ -18,7 +18,7 @@ #include "DesignerScene.h" #include "DesignerView.h" #include "MultiLayerView.h" -#include "SampleViewProxyModel.h" +#include "FilterPropertyProxy.h" #include "ISample.h" #include <QDebug> @@ -48,7 +48,7 @@ void SampleDesigner::setInstrumentModel(InstrumentModel *instrumentModel) } -void SampleDesigner::setSelectionModel(QItemSelectionModel *model, SampleViewProxyModel *proxy) +void SampleDesigner::setSelectionModel(QItemSelectionModel *model, FilterPropertyProxy *proxy) { if(model) m_designerScene->setSelectionModel(model, proxy); } diff --git a/GUI/coregui/Views/SampleDesigner/SampleDesigner.h b/GUI/coregui/Views/SampleDesigner/SampleDesigner.h index 15be2ee69f63004d77a63cceb51572a745855831..b082834f499205c02850e26355896c6fbaf4305d 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleDesigner.h +++ b/GUI/coregui/Views/SampleDesigner/SampleDesigner.h @@ -26,7 +26,7 @@ class DesignerScene; class DesignerWidgetFactory; class InstrumentModel; class SampleModel; -class SampleViewProxyModel; +class FilterPropertyProxy; //! sample designer interface class BA_CORE_API_ SampleDesignerInterface : public QObject @@ -59,7 +59,7 @@ public: void setSampleModel(SampleModel *sampleModel); void setInstrumentModel(InstrumentModel *instrumentModel); - void setSelectionModel(QItemSelectionModel *model, SampleViewProxyModel *proxy); + void setSelectionModel(QItemSelectionModel *model, FilterPropertyProxy *proxy); public slots: void onSmartAlign(); diff --git a/GUI/coregui/Views/SampleView.cpp b/GUI/coregui/Views/SampleView.cpp index 3085688436049b323fcb2cd19cef164cfcbf54fe..5bf8259d43d62f2deda841f36e95bcbb7f8ab70c 100644 --- a/GUI/coregui/Views/SampleView.cpp +++ b/GUI/coregui/Views/SampleView.cpp @@ -22,7 +22,7 @@ #include "SamplePropertyWidget.h" #include "InfoWidget.h" #include "ItemFactory.h" -#include "SampleViewProxyModel.h" +#include "FilterPropertyProxy.h" #include <QDockWidget> #include <QAbstractItemView> #include <QToolBar> @@ -103,7 +103,7 @@ void SampleView::initSubWindows() m_sampleDesigner->setSampleModel(m_sampleModel); m_sampleDesigner->setInstrumentModel(m_instrumentModel); - m_sampleDesigner->setSelectionModel(m_tree_view->selectionModel(), dynamic_cast<SampleViewProxyModel*>(const_cast<QAbstractItemModel*>(m_tree_view->model()))); + m_sampleDesigner->setSelectionModel(m_tree_view->selectionModel(), dynamic_cast<FilterPropertyProxy*>(const_cast<QAbstractItemModel*>(m_tree_view->model()))); } void SampleView::initSelectionModel() @@ -151,7 +151,7 @@ void SampleView::addItem(const QString &item_name) { QModelIndex currentIndex = getTreeView()->currentIndex(); - SampleViewProxyModel *model = dynamic_cast<SampleViewProxyModel*>(const_cast<QAbstractItemModel*>(currentIndex.model())); + FilterPropertyProxy *model = dynamic_cast<FilterPropertyProxy*>(const_cast<QAbstractItemModel*>(currentIndex.model())); if (model) currentIndex = model->mapToSource(currentIndex); @@ -170,7 +170,7 @@ void SampleView::deleteItem() QModelIndex currentIndex = getTreeView()->currentIndex(); - SampleViewProxyModel *model = dynamic_cast<SampleViewProxyModel*>(const_cast<QAbstractItemModel*>(currentIndex.model())); + FilterPropertyProxy *model = dynamic_cast<FilterPropertyProxy*>(const_cast<QAbstractItemModel*>(currentIndex.model())); if (model) currentIndex = model->mapToSource(currentIndex); @@ -229,7 +229,7 @@ void SampleView::showContextMenu(const QPoint &pnt) QMenu add_menu(QString("Add")); QVector<QString> addItemNames; QModelIndex parent_index = getTreeView()->indexAt(pnt); - SampleViewProxyModel *model = dynamic_cast<SampleViewProxyModel*>(const_cast<QAbstractItemModel*>(parent_index.model())); + FilterPropertyProxy *model = dynamic_cast<FilterPropertyProxy*>(const_cast<QAbstractItemModel*>(parent_index.model())); if (model) parent_index = model->mapToSource(parent_index); getTreeView()->setCurrentIndex(parent_index); diff --git a/GUI/coregui/Views/SampleViewComponents.cpp b/GUI/coregui/Views/SampleViewComponents.cpp index b575ca766b9abe7d805c7cb3cbed758f30d72cd3..7d08233f1e66044a98a060a5261b882112cbddd3 100644 --- a/GUI/coregui/Views/SampleViewComponents.cpp +++ b/GUI/coregui/Views/SampleViewComponents.cpp @@ -17,7 +17,7 @@ #include "SampleViewComponents.h" #include "widgetbox.h" #include "SampleDesigner.h" -#include "SampleViewProxyModel.h" +#include "FilterPropertyProxy.h" SampleWidgetBox *SampleViewComponents::createWidgetBox( @@ -30,7 +30,7 @@ ItemTreeView *SampleViewComponents::createTreeView( SampleModel *sampleModel, QWidget *parent) { ItemTreeView *tree_view = new ItemTreeView(parent); - SampleViewProxyModel *proxy = new SampleViewProxyModel(parent); + FilterPropertyProxy *proxy = new FilterPropertyProxy(1, parent); proxy->setSourceModel(sampleModel); tree_view->setModel(proxy); return tree_view;