LibEngsas
espreadsheet.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  MA 02110-1301 USA.
18 */
19 
20 #ifndef ESPREADSHEET_H
21 #define ESPREADSHEET_H
22 
23 #include "eglobal.h"
24 #include "eobject.h"
25 
26 #include "espreadsheetcell.h"
27 
29 
30 #include <QModelIndex>
31 #include <QFont>
32 #include <QBrush>
33 
34 class QAbstractItemModel;
35 
59 {
60  Q_OBJECT
61  public:
62  ESpreadsheet(ESpreadsheetProvider* provider, QObject* parent = NULL);
63 
67  enum Header {
68  HeaderNone = 0x0,
69  HeaderVertical = 0x1,
70  HeaderHorizontal = 0x2,
71  HeaderAll = HeaderVertical | HeaderHorizontal
72  };
73  Q_DECLARE_FLAGS(Headers, Header)
74 
75  QString name() const;
76  virtual void setName(QString name);
77  ESpreadsheetProvider *provider() const;
78  void setProvider(ESpreadsheetProvider *provider);
79 
95  bool setData(QAbstractItemModel* model, ESpreadsheet::Headers header = ESpreadsheet::HeaderNone, QModelIndex root = QModelIndex());
112  virtual bool setData(ESpreadsheetCell cell) = 0;
113 
123  bool setForeground(int row, int column, QBrush foreground);
133  bool setBackground(int row, int column, QBrush background);
143  bool setFont(int row, int column, QFont font);
153  bool setAlignment(int row, int column, Qt::AlignmentFlag alignment);
154 
161  bool data(QAbstractItemModel *model, QModelIndex root = QModelIndex()) const;
167  virtual ESpreadsheetCell data(int row, int column) const = 0;
168 
174  virtual int rowCount() const = 0;
180  virtual int columnCount() const = 0;
181 
182  protected:
188  ESpreadsheet(QObject* parent = NULL);
189 
190  private:
191  QString myName;
192  ESpreadsheetProvider *myProvider;
193 };
194 
195 Q_DECLARE_OPERATORS_FOR_FLAGS(ESpreadsheet::Headers)
196 
197 #endif // ESPREADSHEET_H
Mostly the same as EWidget but for QObject as base class.
Definition: eobject.h:42
A spreadsheet, within a spreadsheet file.A spreadsheet consists of cells of type ESpreadsheetCell, which are ordered in rows and columns. An object of this type can be used to manipulate the hold data (see e. g. setData(ESpreadsheetCell)). To retrieve the cell content use data(int, int).
Definition: espreadsheet.h:58
Header
Used by setData(QAbstractItemModel*, QModelIndex, Header) to determine which header to add...
Definition: espreadsheet.h:67
#define E_CORE_EXPORT
Definition: eglobal.h:107
Represents one cell of a ESpreadsheetIt contains the value (see value()) of a cell and also the forma...
Definition: espreadsheetcell.h:40
Interface to implement spreadsheet providers (e. g. to create excel files or ods, ...
Definition: espreadsheetprovider.h:38