diff --git a/visualization/motion_planning_tasks/task_list_model.cpp b/visualization/motion_planning_tasks/task_list_model.cpp index 0f685073..9cda1664 100644 --- a/visualization/motion_planning_tasks/task_list_model.cpp +++ b/visualization/motion_planning_tasks/task_list_model.cpp @@ -144,6 +144,8 @@ public: } private: + void _q_sourceDestroyed(QObject* object); + void _q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end); void _q_sourceRowsInserted(const QModelIndex &parent, int start, int end); void _q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); @@ -151,7 +153,11 @@ private: void _q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); void _q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); +#if Q_VERSION < 0x050000 + void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); +#else void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); +#endif }; @@ -325,8 +331,9 @@ void TaskListModel::insertTask(BaseTaskModel* model, int row) { // notice destruction of task if (model->parent() != this) - connect(model, &BaseTaskModel::destroyed, - [this](QObject* o) { removeTask(static_cast(o), false); }); + connect(model, SIGNAL(destroyed(QObject*)), + this, SLOT(_q_sourceDestroyed(QObject*))); + connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int))); @@ -340,8 +347,13 @@ void TaskListModel::insertTask(BaseTaskModel* model, int row) { this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))); +#if Q_VERSION < 0x050000 + connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); +#else connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector)), this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex,QVector))); +#endif } bool TaskListModel::removeTask(BaseTaskModel* model, bool disconnect_signals) { @@ -372,12 +384,21 @@ bool TaskListModel::removeTask(BaseTaskModel* model, bool disconnect_signals) { this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); disconnect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))); +#if Q_VERSION < 0x050000 + disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); +#else disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector)), this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex,QVector))); +#endif } return true; } +void TaskListModelPrivate::_q_sourceDestroyed(QObject* o){ + q_ptr->removeTask(static_cast(o), false); +} + void TaskListModelPrivate::_q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end) { q_ptr->beginInsertRows(mapFromSource(parent), start, end); @@ -419,10 +440,17 @@ void TaskListModelPrivate::_q_sourceRowsRemoved(const QModelIndex &parent, int s q_ptr->endRemoveRows(); } +#if Q_VERSION < 0x050000 +void TaskListModelPrivate::_q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + q_ptr->dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight)); +} +#else void TaskListModelPrivate::_q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) { q_ptr->dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight), roles); } +#endif } diff --git a/visualization/motion_planning_tasks/task_list_model.h b/visualization/motion_planning_tasks/task_list_model.h index 61e7a688..9dc602e9 100644 --- a/visualization/motion_planning_tasks/task_list_model.h +++ b/visualization/motion_planning_tasks/task_list_model.h @@ -102,6 +102,8 @@ public: bool removeTask(BaseTaskModel* model, bool disconnect_signals = true); private: + Q_PRIVATE_SLOT(d_func(), void _q_sourceDestroyed(QObject*)) + Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(QModelIndex,int,int)) Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(QModelIndex,int,int)) Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)) @@ -109,7 +111,11 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)) Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)) +#if Q_VERSION < 0x050000 + Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex,QModelIndex)) +#else Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex,QModelIndex,QVector)) +#endif }; MOVEIT_CLASS_FORWARD(TaskListModel) typedef std::weak_ptr TaskListModelWeakPtr; diff --git a/visualization/motion_planning_tasks/task_list_model_cache.cpp b/visualization/motion_planning_tasks/task_list_model_cache.cpp index 42840178..98e0a937 100644 --- a/visualization/motion_planning_tasks/task_list_model_cache.cpp +++ b/visualization/motion_planning_tasks/task_list_model_cache.cpp @@ -64,10 +64,10 @@ TaskListModelPtr TaskListModelCache::getModel(const QString &task_monitor_topic, model = result = TaskListModelPtr(new TaskListModel()); // connect newly created TaskListModel to global model - connect(result.get(), &TaskListModel::rowsInserted, - this, &TaskListModelCache::onInsertTasks); - connect(result.get(), &TaskListModel::rowsAboutToBeRemoved, - this, &TaskListModelCache::onRemoveTasks); + connect(result.get(), SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(onInsertTasks(QModelIndex,int,int))); + connect(result.get(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(onRemoveTasks(QModelIndex,int,int))); } else result = model.lock(); diff --git a/visualization/motion_planning_tasks/task_panel.cpp b/visualization/motion_planning_tasks/task_panel.cpp index 52e9639e..14c640ce 100644 --- a/visualization/motion_planning_tasks/task_panel.cpp +++ b/visualization/motion_planning_tasks/task_panel.cpp @@ -81,9 +81,9 @@ TaskPanel::TaskPanel(QWidget* parent) { Q_D(TaskPanel); // connect signals - connect(d->actionNewTask, &QAction::triggered, this, &TaskPanel::onAddTask); - connect(d->actionNewStage, &QAction::triggered, this, &TaskPanel::onAddStage); - connect(d->actionRemoveStages, &QAction::triggered, this, &TaskPanel::onRemoveStages); + connect(d->actionNewTask, SIGNAL(triggered()), this, SLOT(onAddTask())); + connect(d->actionNewStage, SIGNAL(triggered()), this, SLOT(onAddStage())); + connect(d->actionRemoveStages, SIGNAL(triggered()), this, SLOT(onRemoveStages())); } TaskPanel::~TaskPanel()