diff --git a/Models/MultiObjectPropertyModel.cc b/Models/MultiObjectPropertyModel.cc index 0c5eaabe7c73666be6fdc6865f9c66833a45dc31..d58bc6e9d8c239d193b453db9c9bf1d863f99e87 100644 --- a/Models/MultiObjectPropertyModel.cc +++ b/Models/MultiObjectPropertyModel.cc @@ -74,7 +74,7 @@ QVariant MultiObjectPropertyModel::data(const QModelIndex & index, int role) con case Qt::DisplayRole: return QVariant(propNames[index.row()]); default: - return QVariant::Invalid; + return QVariant{}; } } @@ -85,7 +85,13 @@ int MultiObjectPropertyModel::rowCount(const QModelIndex & parent) const QVariant MultiObjectPropertyModel::headerData(int section, Qt::Orientation orientation, int role) const { - return QVariant::Invalid; + return QVariant{}; +} + +QModelIndex MultiObjectPropertyModel::index(int row, int column, const QModelIndex &parent) const +{ + (void)parent; + return createIndex(row, column); } void MultiObjectPropertyModel::objectUpdated() diff --git a/Models/MultiObjectPropertyModel.hh b/Models/MultiObjectPropertyModel.hh index cc3c8abe064c4fed105b2acd3c608ffc32b1ce10..909e8b43f9a628149848be6e40005411d8910be3 100644 --- a/Models/MultiObjectPropertyModel.hh +++ b/Models/MultiObjectPropertyModel.hh @@ -43,6 +43,7 @@ #pragma once #include "PropertyModel.hh" +#include "PropertyVisualizer/PropertyVisualizer.hh" class PropertyVisualizer; @@ -52,6 +53,14 @@ class MultiObjectPropertyModel: public PropertyModel { Q_OBJECT +signals: + void log(Logtype _type, QString _message); + void log(QString _message); + +private slots: + void slotLog(Logtype _type, QString _message){ emit log(_type, _message); } + void slotLog(QString _message){ emit log(_message);} + public: MultiObjectPropertyModel(const QStringList& res, QObject *parent = 0); virtual ~MultiObjectPropertyModel(); @@ -59,6 +68,7 @@ public: virtual int rowCount(const QModelIndex & parent = QModelIndex()) const override; virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + virtual QModelIndex index(int row, int column, QModelIndex const & parent = QModelIndex()) const override; /// Revisualizes visualized properties. virtual void objectUpdated() override; diff --git a/Models/PropertyModel.hh b/Models/PropertyModel.hh index 8e615b6e6639c0a92b11cfbe85ce720ecaa7e569..2b4669d7d5a7f89d20cf39fd8d48ed30d305129f 100644 --- a/Models/PropertyModel.hh +++ b/Models/PropertyModel.hh @@ -63,6 +63,8 @@ public: virtual int rowCount(const QModelIndex & parent = QModelIndex()) const = 0; virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const = 0; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const = 0; + virtual QModelIndex index(int row, int column, QModelIndex const & parent = QModelIndex()) const = 0; + /// Revisualizes visualized properties. virtual void objectUpdated() = 0; diff --git a/Models/SingleObjectPropertyModel.cc b/Models/SingleObjectPropertyModel.cc index bce4ab92dd1974a3f2e5aa1bfe833ecbaedd8c7a..676ddb9bf52830f3978ad2718e8ec1689dee4f67 100644 --- a/Models/SingleObjectPropertyModel.cc +++ b/Models/SingleObjectPropertyModel.cc @@ -174,7 +174,8 @@ QVariant SingleObjectPropertyModel::data(const QModelIndex & index, int role) co case Qt::DisplayRole: return propertyVisualizers[index.row()]->getName(); default: - return QVariant::Invalid; +// return QVariant::Invalid; + return QVariant{}; } } @@ -188,6 +189,12 @@ QVariant SingleObjectPropertyModel::headerData(int section, Qt::Orientation orie } } +QModelIndex SingleObjectPropertyModel::index(int row, int column, const QModelIndex &parent) const +{ + (void)parent; + return createIndex(row, column, propertyVisualizers[row]); +} + void SingleObjectPropertyModel::objectUpdated() { for (unsigned int i = 0; i < currentlyVisualizedIndices.size(); i++) @@ -339,4 +346,4 @@ QScriptValue SingleObjectPropertyModel::getScriptObject(const QModelIndex index, PropertyVisualizer* vis = propertyVisualizers[index.row()]; return createSettingsScriptObject(ctx, vis->getWidget()); } -#endif \ No newline at end of file +#endif diff --git a/Models/SingleObjectPropertyModel.hh b/Models/SingleObjectPropertyModel.hh index 85ac110775c77d9008750d9fa6cbdf1769b9bd8a..a76c1eb8146fbbc769bc45adf82eddfb40ac196d 100644 --- a/Models/SingleObjectPropertyModel.hh +++ b/Models/SingleObjectPropertyModel.hh @@ -42,7 +42,7 @@ #pragma once -#include "Models/PropertyModel.hh" +#include "PropertyModel.hh" #include "PropertyVisualizer/PropertyVisualizer.hh" #include @@ -95,6 +95,7 @@ public: virtual int rowCount(const QModelIndex & parent = QModelIndex()) const override; virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + virtual QModelIndex index(int row, int column, QModelIndex const & parent = QModelIndex()) const override; /// Revisualizes visualized properties. virtual void objectUpdated() override; diff --git a/PropertyVisPlugin.cc b/PropertyVisPlugin.cc index 28823d2509419b7da6b144b6eeca674861e2e936..e7ee2b84926c337e3723cb6b439ece0accea25e5 100644 --- a/PropertyVisPlugin.cc +++ b/PropertyVisPlugin.cc @@ -68,6 +68,8 @@ #define PROP_VIS "PropertyVisualization" +#include + PropertyVisPlugin::PropertyVisPlugin() : tool_(0), propertyModel_(0) @@ -190,7 +192,7 @@ QScriptValue PropertyVisPlugin::getPropertyVisualizer(int _id, const QString &_p void PropertyVisPlugin::slotPickModeChanged( const std::string& _mode) { - if (propertyModel_ != 0) + if (propertyModel_) propertyModel_->pickModeChanged(_mode); } @@ -200,7 +202,7 @@ void PropertyVisPlugin::slotAllCleared() { using namespace PluginFunctions; - if (propertyModel_ != 0) + if (propertyModel_) { QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes(); propertyModel_->clear(selectedIndices); @@ -265,7 +267,7 @@ void PropertyVisPlugin::updateGUI() void PropertyVisPlugin::propertySelectionChanged() { - if (propertyModel_ != 0) + if (propertyModel_) { QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes(); propertyModel_->updateWidget(selectedIndices); @@ -292,26 +294,26 @@ void PropertyVisPlugin::setNewPropertyModel(int id) disconnect(propertyModel_, SIGNAL(log(QString)), this, SLOT(slotLog(QString))); } propertyModel_ = PropertyModelFactory::Instance().getModel(id); - if (propertyModel_ != 0) + if (propertyModel_) { - tool_->propertyName_lv->setModel(propertyModel_); + tool_->propertyName_lv->setModel(propertyModel_); connect(propertyModel_, SIGNAL( modelReset() ), this, SLOT( propertySelectionChanged() )); - connect(tool_->propertyName_lv->selectionModel(), + connect(tool_->propertyName_lv->selectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), this, - SLOT( propertySelectionChanged() )); + SLOT( propertySelectionChanged() )); QWidget* widget = propertyModel_->getWidget(); tool_->propertyWidgets->addWidget(widget); widget->show(); propertyModel_->gatherProperties(); connect(propertyModel_, SIGNAL(log(Logtype,QString)), this, SLOT(slotLog(Logtype,QString))); connect(propertyModel_, SIGNAL(log(QString)), this, SLOT(slotLog(QString))); - } - else + } + else { tool_->propertyName_lv->setModel(0); - } + } } //----------------------------------------------------------------------------- @@ -329,7 +331,7 @@ void PropertyVisPlugin::slotVisualize() using namespace PluginFunctions; // return if nothing is selected - if (propertyModel_ == 0) return; + if (propertyModel_ == nullptr) return; int selectedId = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt(); QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes(); @@ -358,7 +360,7 @@ void PropertyVisPlugin::slotVisualize() //----------------------------------------------------------------------------- void PropertyVisPlugin::slotMouseEvent( QMouseEvent* _event ) { - if (propertyModel_ != 0) + if (propertyModel_) propertyModel_->mouseEvent(_event); } @@ -368,7 +370,7 @@ void PropertyVisPlugin::slotDuplicateProperty() { using namespace PluginFunctions; - if (propertyModel_ != 0) + if (propertyModel_) { QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes(); propertyModel_->duplicateProperty(selectedIndices); @@ -397,7 +399,7 @@ void PropertyVisPlugin::slotRemoveProperty() { using namespace PluginFunctions; - if (propertyModel_ != 0) + if (propertyModel_) { QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes(); propertyModel_->removeProperty(selectedIndices);