1
/***************************************************************************
4
Description : View class for Table
5
--------------------------------------------------------------------
6
Copyright : (C) 2007 Tilman Benkert (thzs*gmx.net)
7
(replace * with @ in the email addresses)
9
***************************************************************************/
11
/***************************************************************************
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. *
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. *
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 *
28
***************************************************************************/
35
#include <QMessageBox>
36
#include <QHeaderView>
39
#include <QPushButton>
40
#include <QToolButton>
41
#include <QHBoxLayout>
42
#include <QVBoxLayout>
46
#include <QPushButton>
49
#include <QScrollArea>
50
#include "ui_controltabs.h"
54
#include "lib/IntervalAttribute.h"
57
namespace future{ class Table; }
59
class TableItemDelegate;
60
class TableDoubleHeaderView;
63
//! Helper class for TableView
64
class TableViewWidget : public QTableView
70
TableViewWidget(QWidget * parent = 0) : QTableView(parent) {};
73
//! Overloaded function (cf. Qt documentation)
74
virtual void keyPressEvent(QKeyEvent * event);
80
//! Cause a repaint of the header
81
void updateHeaderGeometry(Qt::Orientation o, int first, int last);
86
//! View class for Table
87
class TableView : public MyWidget
93
#ifndef LEGACY_CODE_0_2_x
94
TableView(future::Table * table);
96
TableView(const QString & label, QWidget * parent=0, const char * name=0, Qt::WFlags f=0);
97
void setTable(future::Table * table);
100
virtual ~TableView();
101
bool isControlTabBarVisible() { return d_control_tabs->isVisible(); }
102
//! Show or hide (if on = false) the column comments
103
void showComments(bool on = true);
104
//! Return whether comments are show currently
105
bool areCommentsShown() const;
107
//! \name selection related functions
109
//! Return how many columns are selected
111
* If full is true, this function only returns the number of fully
114
int selectedColumnCount(bool full = false);
115
//! Return how many columns with the given plot designation are (at least partly) selected
116
int selectedColumnCount(SciDAVis::PlotDesignation pd);
117
//! Returns true if column 'col' is selected; otherwise false
119
* If full is true, this function only returns true if the whole
120
* column is selected.
122
bool isColumnSelected(int col, bool full = false);
123
//! Return all selected columns
125
* If full is true, this function only returns a column if the whole
126
* column is selected.
128
QList<Column *> selectedColumns(bool full = false);
129
//! Return how many rows are (at least partly) selected
131
* If full is true, this function only returns the number of fully
134
int selectedRowCount(bool full = false);
135
//! Returns true if row 'row' is selected; otherwise false
137
* If full is true, this function only returns true if the whole
140
bool isRowSelected(int row, bool full = false);
141
//! Return the index of the first selected column
143
* If full is true, this function only looks for fully
146
int firstSelectedColumn(bool full = false);
147
//! Return the index of the last selected column
149
* If full is true, this function only looks for fully
152
int lastSelectedColumn(bool full = false);
153
//! Return the index of the first selected row
155
* If full is true, this function only looks for fully
158
int firstSelectedRow(bool full = false);
159
//! Return the index of the last selected row
161
* If full is true, this function only looks for fully
164
int lastSelectedRow(bool full = false);
165
//! Get the complete set of selected rows.
166
IntervalAttribute<bool> selectedRows(bool full = false);
167
//! Return whether a cell is selected
168
bool isCellSelected(int row, int col);
169
//! Select/Deselect a cell
170
void setCellSelected(int row, int col, bool select = true);
171
//! Select/Deselect a range of cells
172
void setCellsSelected(int first_row, int first_col, int last_row, int last_col, bool select = true);
173
//! Determine the current cell (-1 if no cell is designated as the current)
174
void getCurrentCell(int * row, int * col);
177
void setColumnWidth(int col, int width);
178
int columnWidth(int col) const;
179
bool formulaModeActive() const;
182
void activateFormulaMode(bool on);
183
void goToCell(int row, int col);
184
void rereadSectionSizes();
187
void toggleControlTabBar();
188
void toggleComments();
189
void showControlDescriptionTab();
190
void showControlTypeTab();
191
void showControlFormulaTab();
192
void handleHorizontalSectionResized(int logicalIndex, int oldSize, int newSize);
193
void goToNextColumn();
194
void goToPreviousColumn();
197
//! Advance current cell after [Return] or [Enter] was pressed
199
void handleHorizontalSectionMoved(int index, int from, int to);
200
void handleHorizontalHeaderDoubleClicked(int index);
201
void handleAspectDescriptionChanged(const AbstractAspect * aspect);
202
void handleAspectAdded(const AbstractAspect *aspect);
203
void handleAspectAboutToBeRemoved(const AbstractAspect *aspect, int index);
204
void updateTypeInfo();
205
void updateFormatBox();
206
void handleHeaderDataChanged(Qt::Orientation orientation, int first, int last);
207
void currentColumnChanged(const QModelIndex & current, const QModelIndex & previous);
208
void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
209
void applyDescription();
213
//! Pointer to the item delegate
214
TableItemDelegate * d_delegate;
215
//! Pointer to the current underlying model
216
TableModel * d_model;
218
virtual void changeEvent(QEvent * event);
219
void retranslateStrings();
220
void setColumnForControlTabs(int col);
222
bool eventFilter( QObject * watched, QEvent * event);
224
//! UI with options tabs (description, format, formula etc.)
226
//! The table view (first part of the UI)
227
TableViewWidget * d_view_widget;
228
//! Widget that contains the control tabs UI from #ui
229
QWidget * d_control_tabs;
230
//! Button to toogle the visibility of #d_tool_box
231
QToolButton * d_hide_button;
232
QHBoxLayout * d_main_layout;
233
TableDoubleHeaderView * d_horizontal_header;
234
future::Table * d_table;