SciDAVis  1.D4
TableModel.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : TableModel.h
3  Project : SciDAVis
4  Description : Model for the access to a 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 TABLEMODEL_H
31 #define TABLEMODEL_H
32 
33 #include <QAbstractItemModel>
34 #include <QList>
35 #include <QStringList>
36 #include "core/AbstractFilter.h"
37 #include <QColor>
38 
39 class Column;
40 namespace future{ class Table; }
41 
43 
52 class TableModel : public QAbstractItemModel
53 {
54  Q_OBJECT
55 
56  public:
58  explicit TableModel(future::Table * table);
60  ~TableModel();
61 
64  MaskingRole = Qt::UserRole,
65  FormulaRole = Qt::UserRole+1,
66  CommentRole = Qt::UserRole+2,
67  };
68 
70 
71  Qt::ItemFlags flags( const QModelIndex & index ) const;
72  QVariant data(const QModelIndex &index, int role) const;
73  QVariant headerData(int section,
74  Qt::Orientation orientation,int role) const;
75  int rowCount(const QModelIndex &parent = QModelIndex()) const;
76  int columnCount(const QModelIndex & parent = QModelIndex()) const;
77  bool setData(const QModelIndex & index, const QVariant & value, int role);
78  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
79  QModelIndex parent(const QModelIndex & child) const;
81 
82 #ifdef LEGACY_CODE_0_2_x
83  bool isReadOnly() const { return d_read_only; }
84  void setReadOnly(bool read_only) { d_read_only = read_only; }
85 #endif
86 
87  Column * column(int index); // this is needed for the comment header view
88 
89  void activateFormulaMode(bool on) { d_formula_mode = on; }
90  bool formulaModeActive() const { return d_formula_mode; }
91 
92  private slots:
94 
95  void handleColumnsAboutToBeInserted(int, QList<Column*>);
96  void handleColumnsInserted(int first, int count);
97  void handleColumnsAboutToBeRemoved(int first, int count);
98  void handleColumnsRemoved(int first, int count);
99  void handleRowsAboutToBeInserted(int before, int count);
100  void handleRowsInserted(int first, int count);
101  void handleRowsAboutToBeRemoved(int first, int count);
102  void handleRowsRemoved(int first, int count);
103  void handleDataChanged(int top, int left, int bottom, int right);
105 
106  private:
108 
109 #ifdef LEGACY_CODE_0_2_x
110  bool d_read_only;
111 #endif
112 
114 };
115 
116 #endif