27 #include <ArmarXGui/gui-plugins/ScenarioManager/gui/ui_scenariolistview.h>
36 using namespace Data_Structure;
43 startButtonDelegate(this),
44 stopButtonDelegate(this),
45 restartButtonDelegate(this),
46 removeAction(
"Remove", &contextMenu)
50 ui->treeView->setModel(model.get());
51 ui->treeView->setSortingEnabled(
true);
52 ui->treeView->setItemDelegateForColumn(1, &startButtonDelegate);
53 ui->treeView->setItemDelegateForColumn(2, &stopButtonDelegate);
54 ui->treeView->setItemDelegateForColumn(3, &restartButtonDelegate);
57 contextMenu.setParent(ui->treeView);
58 ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
59 QObject::connect(ui->treeView, SIGNAL(customContextMenuRequested(
const QPoint&)),
this, SLOT(onCustomContextMenu(
const QPoint&)));
61 ui->treeView->addAction(&removeAction);
63 ui->treeView->setDragEnabled(
true);
64 ui->treeView->setDefaultDropAction(Qt::CopyAction);
65 ui->treeView->setAcceptDrops(
true);
66 ui->treeView->setDropIndicatorShown(
true);
68 QObject::connect(&removeAction, SIGNAL(triggered()),
69 this, SLOT(removeItemTriggered()));
71 QObject::connect(&startButtonDelegate, SIGNAL(
buttonClicked(
int,
int, QModelIndex)),
72 this, SLOT(startButtonClicked(
int,
int, QModelIndex)));
75 QObject::connect(&stopButtonDelegate, SIGNAL(
buttonClicked(
int,
int, QModelIndex)),
76 this, SLOT(stopButtonClicked(
int,
int, QModelIndex)));
78 QObject::connect(&restartButtonDelegate, SIGNAL(
buttonClicked(
int,
int, QModelIndex)),
79 this, SLOT(restartButtonClicked(
int,
int, QModelIndex)));
89 this->model = treeModel;
90 ui->treeView->setModel(model.get());
92 ui->treeView->setColumnWidth(0, 200);
93 ui->treeView->setColumnWidth(1, 90);
94 ui->treeView->setColumnWidth(2, 50);
95 ui->treeView->setColumnWidth(3, 60);
99 void ScenarioListView::on_searchBar_textEdited(
const QString& text)
101 model->setFilterRegExp(QRegExp(text, Qt::CaseInsensitive, QRegExp::FixedString));
102 ui->treeView->expandAll();
105 void ScenarioListView::startButtonClicked(
int row,
int column, QModelIndex parent)
110 void ScenarioListView::stopButtonClicked(
int row,
int column, QModelIndex parent)
115 void ScenarioListView::restartButtonClicked(
int row,
int column, QModelIndex parent)
120 void ScenarioListView::on_newButton_clicked()
125 void ScenarioListView::on_openButton_clicked()
130 void ScenarioListView::removeItemTriggered()
132 QModelIndex
index = ui->treeView->currentIndex();
136 void ScenarioListView::on_treeView_clicked(
const QModelIndex&
index)
141 void ScenarioListView::onCustomContextMenu(
const QPoint& point)
143 QModelIndex
index = ui->treeView->currentIndex();
145 removeAction.setText(
"Remove " +
index.data().toString());
147 QList<QAction*> actions;
148 actions.append(&removeAction);
150 QMenu::exec(actions, ui->treeView->mapToGlobal(point));