ShortcutTableModel.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-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 MemoryX::gui-plugins::SceneEditor
19  * @date 2015
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 #include <QAbstractTableModel>
27 #include <QHash>
28 #include <QKeySequence>
29 
30 namespace gui
31 {
32  class ShortcutTableModel : public QAbstractTableModel
33  {
34  Q_OBJECT
35 
36  public:
37  /**
38  * A constructor.
39  * Creates a new Instance of ShortcutTableModel with a given parent.
40  *
41  * @param parent Parent QObject
42  */
43  explicit ShortcutTableModel(QObject* parent = 0);
44  /**
45  * A constructor.
46  * Creates a new Instance of ShortcutTableModel with a predefined Shortcuts-Hash and a given parent.
47  *
48  * @param Shortcuts QHash of predefined Shortcuts-Hash
49  * @param parent Parent QObject
50  */
51  explicit ShortcutTableModel(QHash<QString, QKeySequence> Shortcuts, QObject* parent = 0);
52 
53  /**
54  * Sets a predefined Shortcuts-Hash as new Hash of this ShortcutTableModel.
55  *
56  * @param Shortcuts QHash of predefined Shortcuts-Hash
57  */
58  void setShortcutHashTable(QHash<QString, QKeySequence> Shortcuts);
59 
60  /**
61  * Returns the number of given rows.
62  *
63  * @param parent Parent QObject
64  * @return number of rows
65  */
66  int rowCount(const QModelIndex& parent) const override;
67 
68  /**
69  * Returns the number of given columns (standard = 2).
70  *
71  * @param parent Parent QObject
72  * @return number of columns
73  */
74  int columnCount(const QModelIndex& parent) const override;
75 
76  /**
77  * Returns the value of a given Position in the model.
78  *
79  * @param index Position in Model to be returned
80  * @param role Role that is used to get data
81  * @return Value of given Position
82  */
83  QVariant data(const QModelIndex& index, int role) const override;
84 
85  /**
86  * Returns the header of a given Section by orientation.
87  *
88  * @param section Section in Header to be returned
89  * @param orientation Orientation to find given section
90  * @param role Role that is used to get data
91  * @return Headervalue of given Section
92  */
93  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
94 
95  /**
96  * Returns the Name of the Action of the given Row.
97  *
98  * @param index Position in Model to be returned
99  * @param role Role that is used to get data
100  * @return Name of the action
101  */
102  QVariant actionName(const QModelIndex& index, int role) const;
103 
104  private:
105  QHash<QString, QKeySequence> registeredShortcuts;
106 
107  };
108 
109 }
110 
gui::ShortcutTableModel::columnCount
int columnCount(const QModelIndex &parent) const override
Returns the number of given columns (standard = 2).
Definition: ShortcutTableModel.cpp:48
gui::ShortcutTableModel::data
QVariant data(const QModelIndex &index, int role) const override
Returns the value of a given Position in the model.
Definition: ShortcutTableModel.cpp:53
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:9
index
uint8_t index
Definition: EtherCATFrame.h:59
gui::ShortcutTableModel::ShortcutTableModel
ShortcutTableModel(QObject *parent=0)
A constructor.
Definition: ShortcutTableModel.cpp:26
gui::ShortcutTableModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Returns the header of a given Section by orientation.
Definition: ShortcutTableModel.cpp:80
gui::ShortcutTableModel
Definition: ShortcutTableModel.h:32
gui::ShortcutTableModel::setShortcutHashTable
void setShortcutHashTable(QHash< QString, QKeySequence > Shortcuts)
Sets a predefined Shortcuts-Hash as new Hash of this ShortcutTableModel.
Definition: ShortcutTableModel.cpp:37
gui::ShortcutTableModel::rowCount
int rowCount(const QModelIndex &parent) const override
Returns the number of given rows.
Definition: ShortcutTableModel.cpp:43
gui::ShortcutTableModel::actionName
QVariant actionName(const QModelIndex &index, int role) const
Returns the Name of the Action of the given Row.
Definition: ShortcutTableModel.cpp:105