mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
renamed TaskListModelCache -> MetaTaskListModel
This commit is contained in:
parent
9dd9bd5ac4
commit
eb1569efc3
@ -7,7 +7,7 @@ add_library(${MOVEIT_LIB_NAME}
|
|||||||
local_task_model.cpp
|
local_task_model.cpp
|
||||||
remote_task_model.cpp
|
remote_task_model.cpp
|
||||||
task_list_model.cpp
|
task_list_model.cpp
|
||||||
task_list_model_cache.cpp
|
meta_task_list_model.cpp
|
||||||
task_panel.cpp
|
task_panel.cpp
|
||||||
task_panel_p.h
|
task_panel_p.h
|
||||||
task_display.cpp
|
task_display.cpp
|
||||||
|
|||||||
@ -34,25 +34,25 @@
|
|||||||
|
|
||||||
/* Author: Robert Haschke */
|
/* Author: Robert Haschke */
|
||||||
|
|
||||||
#include "task_list_model_cache.h"
|
#include "meta_task_list_model.h"
|
||||||
#include "task_list_model.h"
|
#include "task_list_model.h"
|
||||||
#include "task_display.h"
|
#include "task_display.h"
|
||||||
|
|
||||||
namespace moveit_rviz_plugin {
|
namespace moveit_rviz_plugin {
|
||||||
|
|
||||||
TaskListModelCache::TaskListModelCache()
|
MetaTaskListModel::MetaTaskListModel()
|
||||||
{
|
{
|
||||||
connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)),
|
connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)),
|
||||||
this, SLOT(onRowsRemoved(QModelIndex,int,int)));
|
this, SLOT(onRowsRemoved(QModelIndex,int,int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskListModelCache &TaskListModelCache::instance()
|
MetaTaskListModel &MetaTaskListModel::instance()
|
||||||
{
|
{
|
||||||
static TaskListModelCache instance_;
|
static MetaTaskListModel instance_;
|
||||||
return instance_;
|
return instance_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskListModelCache::insertModel(TaskListModel *model, TaskDisplay *display)
|
bool MetaTaskListModel::insertModel(TaskListModel *model, TaskDisplay *display)
|
||||||
{
|
{
|
||||||
if (!model || !display)
|
if (!model || !display)
|
||||||
return false;
|
return false;
|
||||||
@ -67,14 +67,14 @@ bool TaskListModelCache::insertModel(TaskListModel *model, TaskDisplay *display)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskListModelCache::onRowsRemoved(const QModelIndex &parent, int first, int last)
|
void MetaTaskListModel::onRowsRemoved(const QModelIndex &parent, int first, int last)
|
||||||
{
|
{
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
display_.remove(first, last-first+1);
|
display_.remove(first, last-first+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskListModelCache::onDisplayNameChanged(const QString &name)
|
void MetaTaskListModel::onDisplayNameChanged(const QString &name)
|
||||||
{
|
{
|
||||||
int row = display_.indexOf(static_cast<TaskDisplay*>(sender()));
|
int row = display_.indexOf(static_cast<TaskDisplay*>(sender()));
|
||||||
if (row < 0) return;
|
if (row < 0) return;
|
||||||
@ -86,7 +86,7 @@ void TaskListModelCache::onDisplayNameChanged(const QString &name)
|
|||||||
setData(idx, name, Qt::EditRole);
|
setData(idx, name, Qt::EditRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskListModelCache::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool MetaTaskListModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
bool result = TreeMergeProxyModel::setData(index, value, role);
|
bool result = TreeMergeProxyModel::setData(index, value, role);
|
||||||
if (result && isGroupItem(index)) {
|
if (result && isGroupItem(index)) {
|
||||||
@ -96,7 +96,7 @@ bool TaskListModelCache::setData(const QModelIndex &index, const QVariant &value
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<TaskListModel*, TaskDisplay*>
|
std::pair<TaskListModel*, TaskDisplay*>
|
||||||
TaskListModelCache::getTaskListModel(const QModelIndex &index) const
|
MetaTaskListModel::getTaskListModel(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QAbstractItemModel *m = getModel(index).first;
|
QAbstractItemModel *m = getModel(index).first;
|
||||||
if (!m) return std::make_pair(nullptr, nullptr);
|
if (!m) return std::make_pair(nullptr, nullptr);
|
||||||
@ -106,7 +106,7 @@ TaskListModelCache::getTaskListModel(const QModelIndex &index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<BaseTaskModel*, QModelIndex>
|
std::pair<BaseTaskModel*, QModelIndex>
|
||||||
TaskListModelCache::getTaskModel(const QModelIndex &index) const
|
MetaTaskListModel::getTaskModel(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return std::make_pair(nullptr, QModelIndex());
|
return std::make_pair(nullptr, QModelIndex());
|
||||||
@ -46,7 +46,7 @@ MOVEIT_CLASS_FORWARD(BaseTaskModel)
|
|||||||
MOVEIT_CLASS_FORWARD(TaskListModel)
|
MOVEIT_CLASS_FORWARD(TaskListModel)
|
||||||
MOVEIT_CLASS_FORWARD(TaskDisplay)
|
MOVEIT_CLASS_FORWARD(TaskDisplay)
|
||||||
|
|
||||||
/** TaskListModelCache maintains a model of multiple registered TaskListModels,
|
/** MetaTaskListModel maintains a model of multiple registered TaskListModels,
|
||||||
* which are grouped in a hierarchical fashion according to the name of the
|
* which are grouped in a hierarchical fashion according to the name of the
|
||||||
* associated display.
|
* associated display.
|
||||||
*
|
*
|
||||||
@ -55,16 +55,16 @@ MOVEIT_CLASS_FORWARD(TaskDisplay)
|
|||||||
*
|
*
|
||||||
* This is a singleton instance.
|
* This is a singleton instance.
|
||||||
*/
|
*/
|
||||||
class TaskListModelCache : public utils::TreeMergeProxyModel {
|
class MetaTaskListModel : public utils::TreeMergeProxyModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// 1:1 correspondence of displays to models
|
// 1:1 correspondence of displays to models
|
||||||
QVector<TaskDisplay*> display_;
|
QVector<TaskDisplay*> display_;
|
||||||
|
|
||||||
/// class is singleton
|
/// class is singleton
|
||||||
TaskListModelCache();
|
MetaTaskListModel();
|
||||||
TaskListModelCache(const TaskListModelCache&) = delete;
|
MetaTaskListModel(const MetaTaskListModel&) = delete;
|
||||||
void operator=(const TaskListModelCache&) = delete;
|
void operator=(const MetaTaskListModel&) = delete;
|
||||||
|
|
||||||
// hide this, as we want to offer another API
|
// hide this, as we want to offer another API
|
||||||
using utils::TreeMergeProxyModel::insertModel;
|
using utils::TreeMergeProxyModel::insertModel;
|
||||||
@ -74,7 +74,7 @@ class TaskListModelCache : public utils::TreeMergeProxyModel {
|
|||||||
void onDisplayNameChanged(const QString &name);
|
void onDisplayNameChanged(const QString &name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TaskListModelCache& instance();
|
static MetaTaskListModel& instance();
|
||||||
|
|
||||||
/// insert a new TaskListModel together with it's associated display
|
/// insert a new TaskListModel together with it's associated display
|
||||||
bool insertModel(TaskListModel* model, TaskDisplay* display);
|
bool insertModel(TaskListModel* model, TaskDisplay* display);
|
||||||
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include "task_display.h"
|
#include "task_display.h"
|
||||||
#include "task_list_model.h"
|
#include "task_list_model.h"
|
||||||
#include "task_list_model_cache.h"
|
#include "meta_task_list_model.h"
|
||||||
#include <moveit/task_constructor/introspection.h>
|
#include <moveit/task_constructor/introspection.h>
|
||||||
#include <moveit/visualization_tools/task_solution_visualization.h>
|
#include <moveit/visualization_tools/task_solution_visualization.h>
|
||||||
#include <moveit_task_constructor_msgs/GetSolution.h>
|
#include <moveit_task_constructor_msgs/GetSolution.h>
|
||||||
@ -56,7 +56,7 @@ namespace moveit_rviz_plugin
|
|||||||
TaskDisplay::TaskDisplay() : Display()
|
TaskDisplay::TaskDisplay() : Display()
|
||||||
{
|
{
|
||||||
task_list_model_.reset(new TaskListModel);
|
task_list_model_.reset(new TaskListModel);
|
||||||
TaskListModelCache::instance().insertModel(task_list_model_.get(), this);
|
MetaTaskListModel::instance().insertModel(task_list_model_.get(), this);
|
||||||
|
|
||||||
connect(task_list_model_.get(), SIGNAL(rowsInserted(QModelIndex,int,int)),
|
connect(task_list_model_.get(), SIGNAL(rowsInserted(QModelIndex,int,int)),
|
||||||
this, SLOT(onTasksInserted(QModelIndex,int,int)));
|
this, SLOT(onTasksInserted(QModelIndex,int,int)));
|
||||||
|
|||||||
@ -144,7 +144,7 @@ TaskListModel::TaskListModel(QObject *parent)
|
|||||||
|
|
||||||
TaskListModel::~TaskListModel() {
|
TaskListModel::~TaskListModel() {
|
||||||
ROS_DEBUG_NAMED(LOGNAME, "destroying TaskListModel: %p", this);
|
ROS_DEBUG_NAMED(LOGNAME, "destroying TaskListModel: %p", this);
|
||||||
// inform TaskListModelCache that we will remove our stuff
|
// inform MetaTaskListModel that we will remove our stuff
|
||||||
removeRows(0, rowCount());
|
removeRows(0, rowCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "task_panel_p.h"
|
#include "task_panel_p.h"
|
||||||
#include "task_list_model_cache.h"
|
#include "meta_task_list_model.h"
|
||||||
#include "local_task_model.h"
|
#include "local_task_model.h"
|
||||||
#include "factory_model.h"
|
#include "factory_model.h"
|
||||||
#include "pluginlib_factory.h"
|
#include "pluginlib_factory.h"
|
||||||
@ -98,7 +98,7 @@ TaskPanelPrivate::TaskPanelPrivate(TaskPanel *q_ptr)
|
|||||||
{
|
{
|
||||||
setupUi(q_ptr);
|
setupUi(q_ptr);
|
||||||
// init tasks view
|
// init tasks view
|
||||||
tasks_view->setModel(&TaskListModelCache::instance());
|
tasks_view->setModel(&MetaTaskListModel::instance());
|
||||||
|
|
||||||
tasks_view->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
tasks_view->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
tasks_view->setAcceptDrops(true);
|
tasks_view->setAcceptDrops(true);
|
||||||
@ -123,14 +123,14 @@ void TaskPanelPrivate::initSettings(rviz::Property* root)
|
|||||||
std::pair<TaskListModel*, TaskDisplay*>
|
std::pair<TaskListModel*, TaskDisplay*>
|
||||||
TaskPanelPrivate::getTaskListModel(const QModelIndex &index) const
|
TaskPanelPrivate::getTaskListModel(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
auto *meta_model = static_cast<TaskListModelCache*>(tasks_view->model());
|
auto *meta_model = static_cast<MetaTaskListModel*>(tasks_view->model());
|
||||||
return meta_model->getTaskListModel(index);
|
return meta_model->getTaskListModel(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<BaseTaskModel*, QModelIndex>
|
std::pair<BaseTaskModel*, QModelIndex>
|
||||||
TaskPanelPrivate::getTaskModel(const QModelIndex &index) const
|
TaskPanelPrivate::getTaskModel(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
auto *meta_model = static_cast<TaskListModelCache*>(tasks_view->model());
|
auto *meta_model = static_cast<MetaTaskListModel*>(tasks_view->model());
|
||||||
return meta_model->getTaskModel(index);
|
return meta_model->getTaskModel(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user