itom
Loading...
Searching...
No Matches
itomQWidgets.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2023, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23#ifndef ITOMQTWIDGETS_H
24#define ITOMQTWIDGETS_H
25
26#include <qtabwidget.h>
27#include <qtreeview.h>
28#include <qlistview.h>
29#include <qtableview.h>
30#include <qtreewidget.h>
31#include <qtabbar.h>
32#include <qevent.h>
33
34namespace ito
35{
36
37//----------------------------------------------------------------------------------------------------------------------------------
42class QTabWidgetItom : public QTabWidget
43{
44 Q_OBJECT
45
46 public:
47 QTabWidgetItom(QWidget * parent = 0) : QTabWidget(parent) {};
48
49 inline QTabBar* getTabBar() {return tabBar(); };
50
51 protected:
52 void contextMenuEvent (QContextMenuEvent * event)
53 {
54 emit tabContextMenuEvent(event);
55 event->accept();
56 };
57
58 signals:
59 void tabContextMenuEvent (QContextMenuEvent *event);
60};
61
62//----------------------------------------------------------------------------------------------------------------------------------
63class QTreeWidgetItom : public QTreeWidget
64{
65 Q_OBJECT
66
67public:
68 QTreeWidgetItom(QWidget * parent = 0) : QTreeWidget(parent) {}
70
71
72 QTreeWidgetItem* itemFromIndex2(const QModelIndex &index) const
73 {
74 return itemFromIndex(index);
75 }
76
77};
78
79//----------------------------------------------------------------------------------------------------------------------------------
80class QTreeViewItom : public QTreeView
81{
82 Q_OBJECT
83
84 public:
85 QTreeViewItom(QWidget * parent = 0) : QTreeView(parent) {}
86 ~QTreeViewItom () {}
87
88 QModelIndexList selectedIndexes() const
89 {
90 QModelIndexList retList;
91 for (int i = 0; i < QTreeView::selectedIndexes().length(); ++i)
92 {
93 if (QTreeView::selectedIndexes().at(i).column() == 0)
94 {
95 retList.append(QTreeView::selectedIndexes().at(i));
96 }
97 }
98 return retList;
99 }
100
101 protected:
102 virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
103 {
104 QTreeView::selectionChanged(selected, deselected);
105 emit selectedItemsChanged(selected, deselected);
106 }
107
108 signals:
109 void selectedItemsChanged(const QItemSelection &selected, const QItemSelection &deselected);
110};
111
112//----------------------------------------------------------------------------------------------------------------------------------
113class QListViewItom : public QListView
114{
115 Q_OBJECT
116
117 public:
118 QListViewItom(QWidget * parent = 0) : QListView(parent) {}
119 ~QListViewItom () {}
120
121 QModelIndexList selectedIndexes() const
122 {
123 QModelIndexList retList;
124 for (int i = 0; i < QListView::selectedIndexes().length(); ++i)
125 {
126 if (QListView::selectedIndexes().at(i).column() == 0)
127 {
128 retList.append(QListView::selectedIndexes().at(i));
129 }
130 }
131 return retList;
132 }
133
134 protected:
135 virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
136 {
137 QListView::selectionChanged(selected, deselected);
138 emit selectedItemsChanged(selected, deselected);
139 }
140
141 signals:
142 void selectedItemsChanged(const QItemSelection &selected, const QItemSelection &deselected);
143};
144
145//----------------------------------------------------------------------------------------------------------------------------------
146class QTableViewItom : public QTableView
147{
148 Q_OBJECT
149
150 public:
151 QTableViewItom(QWidget * parent = 0) : QTableView(parent) {}
152 ~QTableViewItom () {}
153
154 QModelIndexList selectedIndexes() const
155 {
156 QModelIndexList retList;
157 for (int i = 0; i < QTableView::selectedIndexes().length(); ++i)
158 {
159 if (QTableView::selectedIndexes().at(i).column() == 0)
160 {
161 retList.append(QTableView::selectedIndexes().at(i));
162 }
163 }
164 return retList;
165 }
166
167 protected:
168 virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
169 {
170 QTableView::selectionChanged(selected, deselected);
171 emit selectedItemsChanged(selected, deselected);
172 }
173
174 signals:
175 void selectedItemsChanged(const QItemSelection &selected, const QItemSelection &deselected);
176};
177
178} //end namespace ito
179
180#endif
Definition itomQWidgets.h:114
Definition itomQWidgets.h:43
Definition itomQWidgets.h:147
Definition itomQWidgets.h:81
Definition itomQWidgets.h:64
Definition apiFunctionsGraph.cpp:40