itom 2.2.1
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom. 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 itom is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00017 General Public Licence for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with itom. If not, see <http://www.gnu.org/licenses/>. 00021 *********************************************************************** */ 00022 00023 #ifndef ITOMQTWIDGETS_H 00024 #define ITOMQTWIDGETS_H 00025 00026 #include <qtabwidget.h> 00027 #include <qtreeview.h> 00028 #include <qlistview.h> 00029 #include <qtableview.h> 00030 #include <qtabbar.h> 00031 #include <qevent.h> 00032 00033 namespace ito 00034 { 00035 00036 //---------------------------------------------------------------------------------------------------------------------------------- 00041 class QTabWidgetItom : public QTabWidget 00042 { 00043 Q_OBJECT 00044 00045 public: 00046 QTabWidgetItom(QWidget * parent = 0) : QTabWidget(parent) {}; 00047 00048 inline QTabBar* getTabBar() {return tabBar(); }; 00049 00050 protected: 00051 void contextMenuEvent (QContextMenuEvent * event) 00052 { 00053 emit tabContextMenuEvent(event); 00054 event->accept(); 00055 }; 00056 00057 signals: 00058 void tabContextMenuEvent (QContextMenuEvent *event); 00059 }; 00060 00061 //---------------------------------------------------------------------------------------------------------------------------------- 00062 class QTreeViewItom : public QTreeView 00063 { 00064 Q_OBJECT 00065 00066 public: 00067 QTreeViewItom(QWidget * parent = 0) : QTreeView(parent) {} 00068 ~QTreeViewItom () {} 00069 00070 QModelIndexList selectedIndexes() const 00071 { 00072 QModelIndexList retList; 00073 for (int i = 0; i < QTreeView::selectedIndexes().length(); ++i) 00074 { 00075 if (QTreeView::selectedIndexes().at(i).column() == 0) 00076 { 00077 retList.append(QTreeView::selectedIndexes().at(i)); 00078 } 00079 } 00080 return retList; 00081 } 00082 00083 protected: 00084 virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) 00085 { 00086 QTreeView::selectionChanged(selected, deselected); 00087 emit selectedItemsChanged(selected, deselected); 00088 } 00089 00090 signals: 00091 void selectedItemsChanged(const QItemSelection &selected, const QItemSelection &deselected); 00092 }; 00093 00094 //---------------------------------------------------------------------------------------------------------------------------------- 00095 class QListViewItom : public QListView 00096 { 00097 Q_OBJECT 00098 00099 public: 00100 QListViewItom(QWidget * parent = 0) : QListView(parent) {} 00101 ~QListViewItom () {} 00102 00103 QModelIndexList selectedIndexes() const 00104 { 00105 QModelIndexList retList; 00106 for (int i = 0; i < QListView::selectedIndexes().length(); ++i) 00107 { 00108 if (QListView::selectedIndexes().at(i).column() == 0) 00109 { 00110 retList.append(QListView::selectedIndexes().at(i)); 00111 } 00112 } 00113 return retList; 00114 } 00115 00116 protected: 00117 virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) 00118 { 00119 QListView::selectionChanged(selected, deselected); 00120 emit selectedItemsChanged(selected, deselected); 00121 } 00122 00123 signals: 00124 void selectedItemsChanged(const QItemSelection &selected, const QItemSelection &deselected); 00125 }; 00126 00127 //---------------------------------------------------------------------------------------------------------------------------------- 00128 class QTableViewItom : public QTableView 00129 { 00130 Q_OBJECT 00131 00132 public: 00133 QTableViewItom(QWidget * parent = 0) : QTableView(parent) {} 00134 ~QTableViewItom () {} 00135 00136 QModelIndexList selectedIndexes() const 00137 { 00138 QModelIndexList retList; 00139 for (int i = 0; i < QTableView::selectedIndexes().length(); ++i) 00140 { 00141 if (QTableView::selectedIndexes().at(i).column() == 0) 00142 { 00143 retList.append(QTableView::selectedIndexes().at(i)); 00144 } 00145 } 00146 return retList; 00147 } 00148 00149 protected: 00150 virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) 00151 { 00152 QTableView::selectionChanged(selected, deselected); 00153 emit selectedItemsChanged(selected, deselected); 00154 } 00155 00156 signals: 00157 void selectedItemsChanged(const QItemSelection &selected, const QItemSelection &deselected); 00158 }; 00159 00160 } //end namespace ito 00161 00162 #endif