ApplicationDatabaseController.h
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 #pragma once
27 
28 #include <memory>
29 #include <vector>
30 
31 #include <QObject>
32 
35 
36 #include "../gui/applicationdatabasemodel.h"
37 #include "../gui/filterabletreemodelsortfilterproxymodel.h"
38 #include "../gui/treeitem.h"
39 
41 {
42  /**
43  * @class ApplicationDatabaseController
44  * @ingroup controller
45  * @brief This Controller manages the signals and model of the ApplicationDatabaseView.
46  * Item click signals in the ApplicationDatabaseView need to be connected to the on_itemClicked() slot.
47  * When an item gets clicked, this controller finds out whether an Application or a Package was clicked and
48  * specifically which Application or Package it was. It then sends a signal with a pointer to the clicked object.
49  */
50  class ApplicationDatabaseController : public QObject
51  {
52  Q_OBJECT
53  public:
54  /**
55  * Constructor that takes the data structure this controller operates on and optionally the parent object.
56  * @param packages list of packages. Need to contain the Packages and Applications displayed in the ApplicationDatabaseView.
57  * @param executor executor used to start, stop and update status of the Applications and Scenarios.
58  * @param parent standard QT option to specify a parent
59  */
61  Exec::ExecutorPtr executor,
62  QObject* parent = 0);
64 
65  /**
66  * Returns the model used by the ApplicationDatabaseView and managed by this controller.
67  * @return managed model
68  */
70 
71  signals:
72  /**
73  * Gets emitted after an Application has been clicked in the ApplicationDatabaseView.
74  * @param app clicked Application
75  */
77 
78  /**
79  * Gets emitted after a Package gets clicked in the ApplicationDatabaseView.
80  * @param package clicked Package
81  */
83 
84 
86 
87  public slots:
88 
89  /**
90  * Finds out whether an Application or a Scenario has been clicked and sends a signal with
91  * the corresponding object.
92  * @param index model-index of the clicked object
93  */
94  void on_itemClicked(const QModelIndex& index);
95 
96  /**
97  * Updates the packages displayed in the ApplicationDatabaseView by reloading all packages
98  * and applications into the model.
99  */
100  void updatePackages();
101 
102  private:
103  ApplicationDatabaseModel treemodel;
106  Exec::ExecutorPtr executor;
107  };
108 } // namespace ScenarioManager::Controller
ScenarioManager::Controller::ApplicationDatabaseController::modelUpdated
void modelUpdated(FilterableTreeModelSortFilterProxyModelPtr model)
index
uint8_t index
Definition: EtherCATFrame.h:59
ScenarioManager::Controller::ApplicationDatabaseController::updatePackages
void updatePackages()
Updates the packages displayed in the ApplicationDatabaseView by reloading all packages and applicati...
Definition: ApplicationDatabaseController.cpp:67
ScenarioManager::Data_Structure::ApplicationPtr
std::shared_ptr< Application > ApplicationPtr
Definition: Application.h:121
ScenarioManager::Controller
Definition: ApplicationDatabaseController.h:40
ScenarioManager::Controller::ApplicationDatabaseController::getModel
FilterableTreeModelSortFilterProxyModelPtr getModel()
Returns the model used by the ApplicationDatabaseView and managed by this controller.
Definition: ApplicationDatabaseController.cpp:61
ScenarioManager::Exec::ExecutorPtr
std::shared_ptr< Executor > ExecutorPtr
Definition: Executor.h:175
ScenarioManager::Data_Structure::PackageVectorPtr
std::shared_ptr< std::vector< ScenarioManager::Data_Structure::PackagePtr > > PackageVectorPtr
Definition: Package.h:124
ScenarioManager::Controller::ApplicationDatabaseController::packageClicked
void packageClicked(Data_Structure::PackagePtr package)
Gets emitted after a Package gets clicked in the ApplicationDatabaseView.
ScenarioManager::Controller::ApplicationDatabaseController::~ApplicationDatabaseController
~ApplicationDatabaseController() override
Definition: ApplicationDatabaseController.cpp:56
Package.h
ScenarioManager::Data_Structure::PackagePtr
std::shared_ptr< Package > PackagePtr
Definition: Package.h:122
ScenarioManager::Controller::ApplicationDatabaseController::on_itemClicked
void on_itemClicked(const QModelIndex &index)
Finds out whether an Application or a Scenario has been clicked and sends a signal with the correspon...
Definition: ApplicationDatabaseController.cpp:101
Executor.h
ScenarioManager::Controller::ApplicationDatabaseController
This Controller manages the signals and model of the ApplicationDatabaseView. Item click signals in t...
Definition: ApplicationDatabaseController.h:50
FilterableTreeModelSortFilterProxyModelPtr
std::shared_ptr< FilterableTreeModelSortFilterProxyModel > FilterableTreeModelSortFilterProxyModelPtr
Definition: filterabletreemodelsortfilterproxymodel.h:68
ScenarioManager::Controller::ApplicationDatabaseController::ApplicationDatabaseController
ApplicationDatabaseController(Data_Structure::PackageVectorPtr packages, Exec::ExecutorPtr executor, QObject *parent=0)
Constructor that takes the data structure this controller operates on and optionally the parent objec...
Definition: ApplicationDatabaseController.cpp:40
ApplicationDatabaseModel
Model underlying the ApplicationDatabaseView.
Definition: applicationdatabasemodel.h:39
ScenarioManager::Controller::ApplicationDatabaseController::applicationClicked
void applicationClicked(Data_Structure::ApplicationPtr app)
Gets emitted after an Application has been clicked in the ApplicationDatabaseView.