openscenarioview.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarXCore::core
19  * @author Cedric Seehausen (usdnr at kit dot edu)
20  * @date 2016
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #include "openscenarioview.h"
27 
28 #include <ArmarXGui/gui-plugins/ScenarioManager/gui/ui_openscenarioview.h>
29 
31  QDialog(parent),
32  ui(new Ui::OpenScenarioView),
34 {
35  ui->setupUi(this);
36  // ui->treeView->setModel(model.get());
37  ui->treeView->setSortingEnabled(true);
38 
39  ui->treeView->setItemDelegateForColumn(2, &openButtonDelegate);
40  QObject::connect(&openButtonDelegate,
41  SIGNAL(buttonClicked(int, int, QModelIndex)),
42  this,
43  SLOT(openButtonClicked(int, int, QModelIndex)));
44 }
45 
47 {
48  delete ui;
49 }
50 
51 void
53 {
54  // TODO: this is not handled well, as the same smart_ptr is send back and forth between the View and Controller
55  this->model = model_ptr;
56  ui->treeView->setModel(model_ptr.get());
57  ui->treeView->setColumnWidth(0, 200);
58  ui->treeView->setColumnWidth(1, 300);
59 }
60 
61 void
62 OpenScenarioView::openButtonClicked(int row, int column, QModelIndex parent)
63 {
64  emit openScenario(row, column, parent);
65  accept();
66 }
67 
68 void
69 OpenScenarioView::on_lineEdit_textEdited(const QString& text)
70 {
71  model->setFilterRegExp(QRegExp(text, Qt::CaseInsensitive, QRegExp::FixedString));
72  ui->treeView->expandAll();
73 }
74 
75 void
76 OpenScenarioView::on_treeView_doubleClicked(const QModelIndex& index)
77 {
78  emit openScenario(index.row(), index.column(), index.parent());
79 }
80 
81 void
82 OpenScenarioView::on_openPackageButton_clicked()
83 {
84  emit showAddPackageDialog();
85 }
index
uint8_t index
Definition: EtherCATFrame.h:59
OpenScenarioView::OpenScenarioView
OpenScenarioView(QWidget *parent=0)
Constructor that sets up the UI and delegates.
Definition: openscenarioview.cpp:30
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
FilterableTreeModelSortFilterProxyModelPtr
std::shared_ptr< FilterableTreeModelSortFilterProxyModel > FilterableTreeModelSortFilterProxyModelPtr
Definition: filterabletreemodelsortfilterproxymodel.h:68
FilterableTreeModelSortFilterProxyModel
Model of the FilterableTreeView.
Definition: filterabletreemodelsortfilterproxymodel.h:43
OpenScenarioView::openScenario
void openScenario(int row, int column, QModelIndex parent)
OpenScenarioView::~OpenScenarioView
~OpenScenarioView() override
Definition: openscenarioview.cpp:46
OpenScenarioView::setModel
void setModel(FilterableTreeModelSortFilterProxyModelPtr model)
Sets the model of this view.
Definition: openscenarioview.cpp:52
OpenScenarioView::showAddPackageDialog
void showAddPackageDialog()
armarx::RemoteGui::buttonClicked
bool buttonClicked(RemoteGui::ValueMap const &newValues, RemoteGui::ValueMap const &oldValues, std::string const &name)
Definition: Storage.cpp:7
openscenarioview.h
OpenScenarioView
View that allows to open a previously saved scenario.
Definition: openscenarioview.h:43