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