mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
TaskListModel: expand view's item when dropping onto it
This commit is contained in:
parent
fc9ca1b624
commit
c516a537f5
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <ros/console.h>
|
#include <ros/console.h>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <qevent.h>
|
||||||
|
|
||||||
namespace moveit_rviz_plugin {
|
namespace moveit_rviz_plugin {
|
||||||
|
|
||||||
@ -524,6 +525,21 @@ void TaskListModelPrivate::_q_sourceDataChanged(const QModelIndex &topLeft, cons
|
|||||||
q_ptr->dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight), roles);
|
q_ptr->dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight), roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TaskListView::TaskListView(QWidget *parent)
|
||||||
|
: QTreeView(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// dropping onto an item, should expand this item
|
||||||
|
void TaskListView::dropEvent(QDropEvent *event)
|
||||||
|
{
|
||||||
|
QModelIndex index = indexAt(event->pos());
|
||||||
|
QTreeView::dropEvent(event);
|
||||||
|
if (event->isAccepted())
|
||||||
|
expand(index);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_task_list_model.cpp"
|
#include "moc_task_list_model.cpp"
|
||||||
|
|||||||
@ -44,12 +44,14 @@
|
|||||||
#include <moveit_task_constructor/Solution.h>
|
#include <moveit_task_constructor/Solution.h>
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
#include <QTreeView>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace moveit_rviz_plugin {
|
namespace moveit_rviz_plugin {
|
||||||
|
|
||||||
/** Base class to represent a single local or remote Task as a Qt model. */
|
/** Base class to represent a single local or remote Task as a Qt model. */
|
||||||
class BaseTaskModel : public QAbstractItemModel {
|
class BaseTaskModel : public QAbstractItemModel {
|
||||||
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
unsigned int flags_ = 0;
|
unsigned int flags_ = 0;
|
||||||
|
|
||||||
@ -140,4 +142,13 @@ private:
|
|||||||
MOVEIT_CLASS_FORWARD(TaskListModel)
|
MOVEIT_CLASS_FORWARD(TaskListModel)
|
||||||
typedef std::weak_ptr<TaskListModel> TaskListModelWeakPtr;
|
typedef std::weak_ptr<TaskListModel> TaskListModelWeakPtr;
|
||||||
|
|
||||||
|
|
||||||
|
class TaskListView : public QTreeView {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TaskListView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void dropEvent(QDropEvent *event) override;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="tasks_view">
|
<widget class="moveit_rviz_plugin::TaskListView" name="tasks_view">
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::ActionsContextMenu</enum>
|
<enum>Qt::ActionsContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -92,6 +92,11 @@
|
|||||||
<extends>QTreeView</extends>
|
<extends>QTreeView</extends>
|
||||||
<header location="global">rviz/properties/property_tree_widget.h</header>
|
<header location="global">rviz/properties/property_tree_widget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>moveit_rviz_plugin::TaskListView</class>
|
||||||
|
<extends>QTreeView</extends>
|
||||||
|
<header>task_list_model.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user