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;
|
||||
}
|
||||
|
||||
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*>
|
||||
MetaTaskListModel::getTaskListModel(const QModelIndex &index) const
|
||||
{
|
||||
|
||||
@ -69,7 +69,7 @@ class MetaTaskListModel : public utils::TreeMergeProxyModel {
|
||||
// hide this, as we want to offer another API
|
||||
using utils::TreeMergeProxyModel::insertModel;
|
||||
|
||||
private Q_SLOTS:
|
||||
private Q_SLOTS:
|
||||
void onRowsRemoved(const QModelIndex &parent, int first, int last);
|
||||
void onDisplayNameChanged(const QString &name);
|
||||
|
||||
@ -80,6 +80,7 @@ public:
|
||||
bool insertModel(TaskListModel* model, TaskDisplay* display);
|
||||
|
||||
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
|
||||
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
|
||||
d_ptr->actionAddLocalTask->setEnabled(current.isValid() &&
|
||||
(!current.parent().isValid() || !current.parent().parent().isValid()));
|
||||
// removing stuff is allowed if there is any selection / any curren item
|
||||
d_ptr->actionRemoveTaskTreeRows->setEnabled(current.isValid());
|
||||
// removing stuff is allowed any valid selection except top-level items
|
||||
d_ptr->actionRemoveTaskTreeRows->setEnabled(current.isValid() && current.parent().isValid());
|
||||
|
||||
BaseTaskModel *task;
|
||||
QModelIndex task_index;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user