itom  4.1.0
itomQWidgets.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet 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 <qtabbar.h>
31 #include <qevent.h>
32 
33 namespace ito
34 {
35 
36 //----------------------------------------------------------------------------------------------------------------------------------
41 class QTabWidgetItom : public QTabWidget
42 {
43  Q_OBJECT
44 
45  public:
46  QTabWidgetItom(QWidget * parent = 0) : QTabWidget(parent) {};
47 
48  inline QTabBar* getTabBar() {return tabBar(); };
49 
50  protected:
51  void contextMenuEvent (QContextMenuEvent * event)
52  {
53  emit tabContextMenuEvent(event);
54  event->accept();
55  };
56 
57  signals:
58  void tabContextMenuEvent (QContextMenuEvent *event);
59 };
60 
61 //----------------------------------------------------------------------------------------------------------------------------------
62 class QTreeViewItom : public QTreeView
63 {
64  Q_OBJECT
65 
66  public:
67  QTreeViewItom(QWidget * parent = 0) : QTreeView(parent) {}
68  ~QTreeViewItom () {}
69 
70  QModelIndexList selectedIndexes() const
71  {
72  QModelIndexList retList;
73  for (int i = 0; i < QTreeView::selectedIndexes().length(); ++i)
74  {
75  if (QTreeView::selectedIndexes().at(i).column() == 0)
76  {
77  retList.append(QTreeView::selectedIndexes().at(i));
78  }
79  }
80  return retList;
81  }
82 
83  protected:
84  virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
85  {
86  QTreeView::selectionChanged(selected, deselected);
87  emit selectedItemsChanged(selected, deselected);
88  }
89 
90  signals:
91  void selectedItemsChanged(const QItemSelection &selected, const QItemSelection &deselected);
92 };
93 
94 //----------------------------------------------------------------------------------------------------------------------------------
95 class QListViewItom : public QListView
96 {
97  Q_OBJECT
98 
99  public:
100  QListViewItom(QWidget * parent = 0) : QListView(parent) {}
101  ~QListViewItom () {}
102 
103  QModelIndexList selectedIndexes() const
104  {
105  QModelIndexList retList;
106  for (int i = 0; i < QListView::selectedIndexes().length(); ++i)
107  {
108  if (QListView::selectedIndexes().at(i).column() == 0)
109  {
110  retList.append(QListView::selectedIndexes().at(i));
111  }
112  }
113  return retList;
114  }
115 
116  protected:
117  virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
118  {
119  QListView::selectionChanged(selected, deselected);
120  emit selectedItemsChanged(selected, deselected);
121  }
122 
123  signals:
124  void selectedItemsChanged(const QItemSelection &selected, const QItemSelection &deselected);
125 };
126 
127 //----------------------------------------------------------------------------------------------------------------------------------
128 class QTableViewItom : public QTableView
129 {
130  Q_OBJECT
131 
132  public:
133  QTableViewItom(QWidget * parent = 0) : QTableView(parent) {}
134  ~QTableViewItom () {}
135 
136  QModelIndexList selectedIndexes() const
137  {
138  QModelIndexList retList;
139  for (int i = 0; i < QTableView::selectedIndexes().length(); ++i)
140  {
141  if (QTableView::selectedIndexes().at(i).column() == 0)
142  {
143  retList.append(QTableView::selectedIndexes().at(i));
144  }
145  }
146  return retList;
147  }
148 
149  protected:
150  virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
151  {
152  QTableView::selectionChanged(selected, deselected);
153  emit selectedItemsChanged(selected, deselected);
154  }
155 
156  signals:
157  void selectedItemsChanged(const QItemSelection &selected, const QItemSelection &deselected);
158 };
159 
160 } //end namespace ito
161 
162 #endif
Definition: itomQWidgets.h:128
Definition: apiFunctionsGraph.cpp:39
Definition: itomQWidgets.h:62
Definition: itomQWidgets.h:95
Definition: itomQWidgets.h:41