SciDAVis  1.D4
MatrixView.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : MatrixView.h
3  Project : SciDAVis
4  Description : View class for Matrix
5  --------------------------------------------------------------------
6  Copyright : (C) 2008-2009 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 MATRIXVIEW_H
31 #define MATRIXVIEW_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 "globals.h"
51 #include "ui_matrixcontroltabs.h"
52 #include "MyWidget.h"
53 
54 namespace future{
55 class Matrix;
56 }
57 
58 class MatrixModel;
59 
61 class MatrixViewWidget : public QTableView
62 {
63  Q_OBJECT
64 
65  public:
67  MatrixViewWidget(QWidget * parent = 0) : QTableView(parent) {};
68 
69  protected:
71  virtual void keyPressEvent(QKeyEvent * event);
72 
73  signals:
74  void advanceCell();
75 
76  public slots:
77  void selectAll();
78 };
79 
81 class MatrixView : public MyWidget
82 {
83  Q_OBJECT
84 
85  public:
87 #ifndef LEGACY_CODE_0_2_x
88  MatrixView(future::Matrix * matrix);
89 #else
90  MatrixView(const QString & label, QWidget * parent=0, const QString name=0, Qt::WFlags f=0);
91  void setMatrix(future::Matrix * matrix);
92 #endif
93 
94  virtual ~MatrixView();
95  bool isControlTabBarVisible() { return d_control_tabs->isVisible(); }
96 
98 
99 
100 
104  int selectedColumnCount(bool full = false);
106 
110  bool isColumnSelected(int col, bool full = false);
112 
116  int selectedRowCount(bool full = false);
118 
122  bool isRowSelected(int row, bool full = false);
124 
128  int firstSelectedColumn(bool full = false);
130 
134  int lastSelectedColumn(bool full = false);
136 
140  int firstSelectedRow(bool full = false);
142 
146  int lastSelectedRow(bool full = false);
148  bool isCellSelected(int row, int col);
150  void setCellSelected(int row, int col);
152  void setCellsSelected(int first_row, int first_col, int last_row, int last_col);
154  void getCurrentCell(int * row, int * col);
156 
157  void setRowHeight(int row, int height);
158  void setColumnWidth(int col, int width);
159  int rowHeight(int row) const;
160  int columnWidth(int col) const;
161 
162 
163  public slots:
164  void rereadSectionSizes();
165  void goToCell(int row, int col);
166  void selectAll();
167  void toggleControlTabBar();
169  void showControlFormatTab();
170  void showControlFormulaTab();
171  void applyCoordinates();
172  void updateCoordinatesTab();
173  void updateFormulaTab();
174 #ifndef LEGACY_CODE_0_2_x
175  void applyFormula();
176 #endif
177  void updateFormatTab();
178  void applyFormat();
179  void handleHorizontalSectionResized(int logicalIndex, int oldSize, int newSize);
180  void handleVerticalSectionResized(int logicalIndex, int oldSize, int newSize);
181 
182  signals:
183  void controlTabBarStatusChanged(bool visible);
184 
185  protected slots:
187  void advanceCell();
188  void updateTypeInfo();
189 
190  protected:
193 
194  virtual void changeEvent(QEvent * event);
195  void retranslateStrings();
196 
197  bool eventFilter( QObject * watched, QEvent * event);
198 
199  protected:
200  Ui::MatrixControlTabs ui;
204  QWidget * d_control_tabs;
206  QToolButton * d_hide_button;
207  QHBoxLayout * d_main_layout;
209 
211  void init();
212 };
213 
214 
215 #endif