mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
MetaTaskListModel: don't remove top-level items
This commit is contained in:
parent
1f6bea9438
commit
3ce0bc7dee
@ -95,6 +95,13 @@ bool MetaTaskListModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MetaTaskListModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
if (!parent.isValid()) // forbid removal of top-level items (displays)
|
||||||
|
return false;
|
||||||
|
TreeMergeProxyModel::removeRows(row, count, parent);
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<TaskListModel*, TaskDisplay*>
|
std::pair<TaskListModel*, TaskDisplay*>
|
||||||
MetaTaskListModel::getTaskListModel(const QModelIndex &index) const
|
MetaTaskListModel::getTaskListModel(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class MetaTaskListModel : public utils::TreeMergeProxyModel {
|
|||||||
// 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;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onRowsRemoved(const QModelIndex &parent, int first, int last);
|
void onRowsRemoved(const QModelIndex &parent, int first, int last);
|
||||||
void onDisplayNameChanged(const QString &name);
|
void onDisplayNameChanged(const QString &name);
|
||||||
|
|
||||||
@ -80,6 +80,7 @@ public:
|
|||||||
bool insertModel(TaskListModel* model, TaskDisplay* display);
|
bool insertModel(TaskListModel* model, TaskDisplay* display);
|
||||||
|
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
|
bool removeRows(int row, int count, const QModelIndex &parent) override;
|
||||||
|
|
||||||
/// retrieve TaskListModel and TaskDisplay corresponding to given index
|
/// retrieve TaskListModel and TaskDisplay corresponding to given index
|
||||||
std::pair<TaskListModel*, TaskDisplay*> getTaskListModel(const QModelIndex &index) const;
|
std::pair<TaskListModel*, TaskDisplay*> getTaskListModel(const QModelIndex &index) const;
|
||||||
|
|||||||
@ -245,8 +245,8 @@ void TaskView::onCurrentStageChanged(const QModelIndex ¤t, const QModelInd
|
|||||||
// adding task is allowed on top-level items and sub-top-level items
|
// adding task is allowed on top-level items and sub-top-level items
|
||||||
d_ptr->actionAddLocalTask->setEnabled(current.isValid() &&
|
d_ptr->actionAddLocalTask->setEnabled(current.isValid() &&
|
||||||
(!current.parent().isValid() || !current.parent().parent().isValid()));
|
(!current.parent().isValid() || !current.parent().parent().isValid()));
|
||||||
// removing stuff is allowed if there is any selection / any curren item
|
// removing stuff is allowed any valid selection except top-level items
|
||||||
d_ptr->actionRemoveTaskTreeRows->setEnabled(current.isValid());
|
d_ptr->actionRemoveTaskTreeRows->setEnabled(current.isValid() && current.parent().isValid());
|
||||||
|
|
||||||
BaseTaskModel *task;
|
BaseTaskModel *task;
|
||||||
QModelIndex task_index;
|
QModelIndex task_index;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user