SciDAVis  1.D4
TableView.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : TableView.h
3  Project : SciDAVis
4  Description : View class for Table
5  --------------------------------------------------------------------
6  Copyright : (C) 2007 Tilman Benkert (thzs*gmx.net)
7  (replace * with @ in the email addresses)
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 
30 #ifndef TABLEVIEW_H
31 #define TABLEVIEW_H
32 
33 #include <QWidget>
34 #include <QTableView>
35 #include <QMessageBox>
36 #include <QHeaderView>
37 #include <QSize>
38 #include <QTabWidget>
39 #include <QPushButton>
40 #include <QToolButton>
41 #include <QHBoxLayout>
42 #include <QVBoxLayout>
43 #include <QLabel>
44 #include <QLineEdit>
45 #include <QTextEdit>
46 #include <QPushButton>
47 #include <QComboBox>
48 #include <QSpinBox>
49 #include <QScrollArea>
50 #include "ui_controltabs.h"
51 #include <QtDebug>
52 #include "globals.h"
53 #include "MyWidget.h"
54 #include "lib/IntervalAttribute.h"
55 
56 class Column;
57 namespace future{ class Table; }
58 class TableModel;
59 class TableItemDelegate;
61 class AbstractAspect;
62 
64 class TableViewWidget : public QTableView
65 {
66  Q_OBJECT
67 
68  public:
70  TableViewWidget(QWidget * parent = 0) : QTableView(parent) {};
71 
72  protected:
74  virtual void keyPressEvent(QKeyEvent * event);
75 
76  signals:
77  void advanceCell();
78 
79  protected slots:
81  void updateHeaderGeometry(Qt::Orientation o, int first, int last);
82  public slots:
83  void selectAll();
84 };
85 
87 class TableView : public MyWidget
88 {
89  Q_OBJECT
90 
91  public:
93 #ifndef LEGACY_CODE_0_2_x
94  TableView(future::Table * table);
95 #else
96  TableView(const QString & label, QWidget * parent=0, const QString name=0, Qt::WFlags f=0);
97  void setTable(future::Table * table);
98 #endif
99 
100  virtual ~TableView();
101  bool isControlTabBarVisible() { return d_control_tabs->isVisible(); }
103  void showComments(bool on = true);
105  bool areCommentsShown() const;
106 
108 
109 
110 
114  int selectedColumnCount(bool full = false);
118 
122  bool isColumnSelected(int col, bool full = false);
124 
128  QList<Column *> selectedColumns(bool full = false);
130 
134  int selectedRowCount(bool full = false);
136 
140  bool isRowSelected(int row, bool full = false);
142 
146  int firstSelectedColumn(bool full = false);
148 
152  int lastSelectedColumn(bool full = false);
154 
158  int firstSelectedRow(bool full = false);
160 
164  int lastSelectedRow(bool full = false);
166  IntervalAttribute<bool> selectedRows(bool full = false);
168  bool isCellSelected(int row, int col);
170  void setCellSelected(int row, int col, bool select = true);
172  void setCellsSelected(int first_row, int first_col, int last_row, int last_col, bool select = true);
174  void getCurrentCell(int * row, int * col);
176 
177  void setColumnWidth(int col, int width);
178  int columnWidth(int col) const;
179  bool formulaModeActive() const;
180 
181  public slots:
182  void activateFormulaMode(bool on);
183  void goToCell(int row, int col);
184  void rereadSectionSizes();
185  void selectAll();
186  void deselectAll();
187  void toggleControlTabBar();
188  void toggleComments();
190  void showControlTypeTab();
191  void showControlFormulaTab();
192  void handleHorizontalSectionResized(int logicalIndex, int oldSize, int newSize);
193  void goToNextColumn();
194  void goToPreviousColumn();
195 
196  protected slots:
198  void advanceCell();
199  void handleHorizontalSectionMoved(int index, int from, int to);
200  void handleHorizontalHeaderDoubleClicked(int index);
204  void handleAspectAboutToBeRemoved(const AbstractAspect *aspect, int index);
205  void updateTypeInfo();
206  void updateFormatBox();
207  void handleHeaderDataChanged(Qt::Orientation orientation, int first, int last);
208  void currentColumnChanged(const QModelIndex & current, const QModelIndex & previous);
209  void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
210  void applyDescription();
211  void applyType();
212 
213  protected:
218 
219  virtual void changeEvent(QEvent * event);
220  void retranslateStrings();
221  void setColumnForControlTabs(int col);
222 
223  bool eventFilter( QObject * watched, QEvent * event);
224 
226  Ui::ControlTabs ui;
230  QWidget * d_control_tabs;
232  QToolButton * d_hide_button;
233  QHBoxLayout * d_main_layout;
236 
238  void init();
239 };
240 
241 
242 #endif