labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

SpreadsheetView.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : SpreadsheetView.h
3  Project : LabPlot
4  Description : View class for Spreadsheet
5  --------------------------------------------------------------------
6  Copyright : (C) 2010-2020 by Alexander Semke (alexander.semke@web.de)
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  * This program is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU General Public License *
23  * along with this program; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
25  * Boston, MA 02110-1301 USA *
26  * *
27  ***************************************************************************/
28 
29 #ifndef SPREADSHEETVIEW_H
30 #define SPREADSHEETVIEW_H
31 
32 #include <QWidget>
33 
36 
37 class AbstractAspect;
38 class Column;
39 class Spreadsheet;
42 class SpreadsheetModel;
43 
44 class QActionGroup;
45 class QItemSelection;
46 class QMenu;
47 class QPrinter;
48 class QModelIndex;
49 class QTableView;
50 class QToolBar;
51 
52 #ifdef Q_OS_MAC
53  class KDMacTouchBar;
54 #endif
55 
56 class SpreadsheetView : public QWidget {
57  Q_OBJECT
58 
59  friend class SpreadsheetTest;
60 
61 public:
62  explicit SpreadsheetView(Spreadsheet* spreadsheet, bool readOnly = false);
63  ~SpreadsheetView() override;
64 
65  void resizeHeader();
66 
67  void showComments(bool on = true);
68  bool areCommentsShown() const;
69 
70  int selectedColumnCount(bool full = false) const;
72  bool isColumnSelected(int col, bool full = false) const;
73  QVector<Column*> selectedColumns(bool full = false) const;
74  int firstSelectedColumn(bool full = false) const;
75  int lastSelectedColumn(bool full = false) const;
76 
77  bool isRowSelected(int row, bool full = false) const;
78  int firstSelectedRow(bool full = false) const;
79  int lastSelectedRow(bool full = false) const;
80  IntervalAttribute<bool> selectedRows(bool full = false) const;
81 
82  bool isCellSelected(int row, int col) const;
83  void setCellSelected(int row, int col, bool select = true);
84  void setCellsSelected(int first_row, int first_col, int last_row, int last_col, bool select = true);
85  void getCurrentCell(int* row, int* col) const;
86 
87  bool exportView();
88  bool printView();
89  bool printPreview();
90 
91 private:
92  void init();
93  void initActions();
94  void initMenus();
95  void connectActions();
96  bool formulaModeActive() const;
97  void exportToFile(const QString&, const bool, const QString&, QLocale::Language) const;
98  void exportToLaTeX(const QString&, const bool exportHeaders,
99  const bool gridLines, const bool captions, const bool latexHeaders,
100  const bool skipEmptyRows,const bool exportEntire) const;
101  void exportToFits(const QString& path, const int exportTo, const bool commentsAsUnits) const;
102  void exportToSQLite(const QString& path) const;
103  int maxRowToExport() const;
104 
105  void insertColumnsLeft(int);
106  void insertColumnsRight(int);
107 
108  void insertRowsAbove(int);
109  void insertRowsBelow(int);
110 
111  QTableView* m_tableView;
112  bool m_editorEntered{false};
119  bool eventFilter(QObject*, QEvent*) override;
120  void checkSpreadsheetMenu();
121  void checkColumnMenus(bool numeric, bool datetime, bool hasValues);
122 
123  //selection related actions
130 // QAction* action_set_formula;
131 // QAction* action_recalculate;
138 
139  //spreadsheet related actions
147 
148  //column related actions
157  QAction* action_set_as_x;
158  QAction* action_set_as_y;
159  QAction* action_set_as_z;
180 
181  //row related actions
189 
190  //analysis and plot data menu actions
198  QAction* addSmoothAction;
201 
202  //Menus
203  QMenu* m_selectionMenu{nullptr};;
204  QMenu* m_columnMenu{nullptr};;
205  QMenu* m_columnSetAsMenu{nullptr};
206  QMenu* m_columnGenerateDataMenu{nullptr};
208  QMenu* m_columnNormalizeMenu{nullptr};
209  QMenu* m_columnLadderOfPowersMenu{nullptr};
210  QMenu* m_columnSortMenu{nullptr};
211  QMenu* m_rowMenu{nullptr};;
212  QMenu* m_spreadsheetMenu{nullptr};;
213  QMenu* m_plotDataMenu{nullptr};;
214  QMenu* m_analyzePlotMenu{nullptr};;
215 
216 public slots:
217  void createContextMenu(QMenu*);
218  void fillToolBar(QToolBar*);
219 #ifdef Q_OS_MAC
220  void fillTouchBar(KDMacTouchBar*);
221 #endif
222  void print(QPrinter*) const;
223 
224 private slots:
225  void createColumnContextMenu(QMenu*);
226  void goToCell(int row, int col);
227  void toggleComments();
228  void goToNextColumn();
229  void goToPreviousColumn();
230  void goToCell();
231  void sortSpreadsheet();
232  void sortDialog(const QVector<Column*>&);
233 
234  void cutSelection();
235  void copySelection();
236  void clearSelectedCells();
237  void maskSelection();
238  void unmaskSelection();
239  void pasteIntoSelection();
240 // void recalculateSelectedCells();
241 
242  void plotData();
243 
245  void fillWithRowNumbers();
247  void fillWithRandomValues();
249  void fillWithFunctionValues();
251 
252  void insertRowAbove();
253  void insertRowBelow();
254  void insertRowsAbove();
255  void insertRowsBelow();
256  void removeSelectedRows();
257  void clearSelectedRows();
258 
259  void insertColumnLeft();
260  void insertColumnRight();
261  void insertColumnsLeft();
262  void insertColumnsRight();
263  void removeSelectedColumns();
264  void clearSelectedColumns();
265 
266  void modifyValues();
267  void reverseColumns();
268  void dropColumnValues();
269  void maskColumnValues();
270 // void joinColumns();
271  void normalizeSelectedColumns(QAction*);
272  void powerTransformSelectedColumns(QAction*);
273 
274  void sortSelectedColumns();
275  void sortColumnAscending();
276  void sortColumnDescending();
277 
278  void setSelectionAs();
279 
280  void activateFormulaMode(bool on);
281 
282  void showColumnStatistics(bool forAll = false);
284  void showRowStatistics();
285 
286  void handleHorizontalSectionResized(int logicalIndex, int oldSize, int newSize);
287  void handleHorizontalSectionMoved(int index, int from, int to);
288  void handleHorizontalHeaderDoubleClicked(int index);
289  void handleHeaderDataChanged(Qt::Orientation orientation, int first, int last);
290  void currentColumnChanged(const QModelIndex& current, const QModelIndex & previous);
291  void handleAspectAdded(const AbstractAspect*);
293  void updateHeaderGeometry(Qt::Orientation o, int first, int last);
294 
295  void selectColumn(int);
296  void deselectColumn(int);
297  void columnClicked(int);
298  void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
299  void advanceCell();
300 };
301 
302 #endif
Base class of all persistent objects in a Project.
Aspect that manages a column.
Definition: Column.h:42
A class representing an interval-based attribute (bool version)
Item delegate for SpreadsheetView.
Model for the access to a Spreadsheet.
View class for Spreadsheet.
QAction * action_mask_selection
QActionGroup * ladderOfPowersActionGroup
QAction * action_set_as_none
QAction * action_unmask_selection
QAction * action_set_as_xerr_minus
void exportToFits(const QString &path, const int exportTo, const bool commentsAsUnits) const
QAction * action_subtract_value
QAction * action_statistics_all_columns
QAction * action_set_as_xerr_plus
void exportToLaTeX(const QString &, const bool exportHeaders, const bool gridLines, const bool captions, const bool latexHeaders, const bool skipEmptyRows, const bool exportEntire) const
QAction * action_paste_into_selection
SpreadsheetModel * m_model
QMenu * m_columnNormalizeMenu
QMenu * m_columnGenerateDataMenu
QAction * action_mask_values
bool isRowSelected(int row, bool full=false) const
QAction * action_sort_desc_column
QMenu * m_columnManipulateDataMenu
void handleHorizontalHeaderDoubleClicked(int index)
void handleHorizontalSectionMoved(int index, int from, int to)
bool isColumnSelected(int col, bool full=false) const
void handleAspectAdded(const AbstractAspect *)
void fillWithEquidistantValues()
QAction * action_set_as_z
QAction * addInterpolationAction
void getCurrentCell(int *row, int *col) const
SpreadsheetView(Spreadsheet *spreadsheet, bool readOnly=false)
void showComments(bool on=true)
Shows (on=true) or hides (on=false) the column comments in the horizontal header.
QAction * action_copy_selection
void exportToFile(const QString &, const bool, const QString &, QLocale::Language) const
SpreadsheetHeaderView * m_horizontalHeader
void print(QPrinter *) const
QAction * action_statistics_rows
QAction * addDifferentiationAction
QAction * action_insert_row_below
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
QAction * action_clear_rows
QAction * action_insert_columns_left
void exportToSQLite(const QString &path) const
QAction * action_join_columns
void sortDialog(const QVector< Column * > &)
Open the sort dialog for the given columns.
QAction * action_insert_columns_right
bool isCellSelected(int row, int col) const
QVector< Column * > selectedColumns(bool full=false) const
QAction * action_divide_value
~SpreadsheetView() override
void powerTransformSelectedColumns(QAction *)
QAction * action_remove_columns
QAction * addDataOperationAction
QAction * action_set_as_x
void createColumnContextMenu(QMenu *)
QTableView * m_tableView
bool eventFilter(QObject *, QEvent *) override
QAction * action_plot_data_xycurve
QAction * addDataReductionAction
void fillSelectedCellsWithRowNumbers()
QAction * action_insert_rows_above
QAction * action_remove_rows
QAction * action_insert_column_right
void createContextMenu(QMenu *)
QAction * action_statistics_columns
IntervalAttribute< bool > selectedRows(bool full=false) const
Spreadsheet * m_spreadsheet
QAction * action_cut_selection
friend class SpreadsheetTest
QAction * action_set_as_xerr
QAction * action_fill_random
void activateFormulaMode(bool on)
void setCellsSelected(int first_row, int first_col, int last_row, int last_col, bool select=true)
QMenu * m_columnSortMenu
QAction * addSmoothAction
int firstSelectedColumn(bool full=false) const
int selectedColumnCount(bool full=false) const
bool m_suppressSelectionChangedEvent
QMenu * m_columnLadderOfPowersMenu
QAction * action_plot_data_histogram
QAction * action_clear_selection
void handleHorizontalSectionResized(int logicalIndex, int oldSize, int newSize)
QAction * action_drop_values
QActionGroup * normalizeColumnActionGroup
void handleHeaderDataChanged(Qt::Orientation orientation, int first, int last)
void checkColumnMenus(bool numeric, bool datetime, bool hasValues)
QMenu * m_columnSetAsMenu
QAction * action_add_value
QAction * action_sort_spreadsheet
QAction * action_insert_rows_below
QAction * action_multiply_value
void updateHeaderGeometry(Qt::Orientation o, int first, int last)
QAction * action_sort_asc_column
QAction * action_fill_function
void currentColumnChanged(const QModelIndex &current, const QModelIndex &previous)
QAction * action_clear_columns
QAction * action_clear_masks
QAction * action_insert_row_above
bool areCommentsShown() const
QVector< QAction * > addFitAction
QAction * action_toggle_comments
QAction * action_sort_columns
bool formulaModeActive() const
QAction * action_set_as_yerr
QMenu * m_spreadsheetMenu
QAction * addIntegrationAction
int maxRowToExport() const
void handleAspectAboutToBeRemoved(const AbstractAspect *)
QAction * action_clear_spreadsheet
void fillSelectedCellsWithConstValues()
QAction * action_reverse_columns
QAction * action_select_all
QAction * action_go_to_cell
QAction * action_set_as_y
void showColumnStatistics(bool forAll=false)
void setCellSelected(int row, int col, bool select=true)
int lastSelectedColumn(bool full=false) const
int firstSelectedRow(bool full=false) const
QAction * action_set_as_yerr_plus
void fillToolBar(QToolBar *)
SpreadsheetItemDelegate * m_delegate
QAction * action_insert_column_left
QAction * action_fill_random_nonuniform
QAction * action_fill_equidistant
void normalizeSelectedColumns(QAction *)
QAction * action_set_as_yerr_minus
QAction * action_fill_const
QAction * action_add_columns
void fillSelectedCellsWithRandomNumbers()
QAction * addFourierFilterAction
QAction * action_fill_row_numbers
int lastSelectedRow(bool full=false) const
QMenu * m_analyzePlotMenu
Aspect providing a spreadsheet table with column logic.
Definition: Spreadsheet.h:40