MyBooks
datasetinterface.h
Go to the documentation of this file.
1 /***************************************************************************
2  * This file is part of the CuteReport project *
3  * Copyright (C) 2012-2017 by Alexander Mikhalov *
4  * alexander.mikhalov@gmail.com *
5  * *
6  ** GNU General Public License Usage **
7  * *
8  * This library is free software: you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation, either version 3 of the License, or *
11  * (at your option) any later version. *
12  * You should have received a copy of the GNU General Public License *
13  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
14  * *
15  ** GNU Lesser General Public License **
16  * *
17  * This library is free software: you can redistribute it and/or modify *
18  * it under the terms of the GNU Lesser General Public License as *
19  * published by the Free Software Foundation, either version 3 of the *
20  * License, or (at your option) any later version. *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library. *
23  * If not, see <http://www.gnu.org/licenses/>. *
24  * *
25  * This library is distributed in the hope that it will be useful, *
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
28  * GNU General Public License for more details. *
29  ****************************************************************************/
30 #ifndef DATASETINTERFACE_H
31 #define DATASETINTERFACE_H
32 
33 #include "cutereport_globals.h"
34 #include "reportplugininterface.h"
35 
36 #include <QWidget>
37 #include <QAbstractTableModel>
38 #include <QVariant>
39 #include <QSet>
40 
41 class DatasetEditorInterface;
42 
43 namespace CuteDesigner
44 {
45  class Core;
46 }
47 
48 namespace CuteReport
49 {
50 
51 class ReportInterface;
52 class DatasetHelperInterface;
53 //class RendererPublicInterface;
54 class ScriptEngineInterface;
55 
57 {
58  Q_OBJECT
60 
61  Q_PROPERTY(QString parentDataset READ getParentDataset WRITE setParentDataset)
62  Q_PROPERTY(QString filterCondition READ getFilterCondition WRITE setFilterCondition)
63  Q_PROPERTY(int filterColumn READ getFilterColumn WRITE setFilterColumn)
64 
65  Q_PROPERTY(int datasetFlags READ datasetFlags WRITE setDatasetFlags NOTIFY datasetFlagsChanged DESIGNABLE false)
66 
67 public:
68  enum DatasetFlag {
69  BaseReportDataset = 0x0001,
70  };
71  Q_DECLARE_FLAGS(DatasetFlags, DatasetFlag)
72 
73  enum Stage {Unpopulated, Populating, Populated};
74 
75  DatasetInterface(QObject *parent = 0);
76  virtual ~DatasetInterface() {}
77 
78  virtual void init(){}
79  virtual DatasetHelperInterface * createHelper(CuteDesigner::Core * designer) = 0;
80  virtual DatasetInterface * clone() const;
81  Q_INVOKABLE virtual QAbstractItemModel * model();
82 
83  virtual QIcon icon() = 0;
84  Q_INVOKABLE virtual QString getLastError();
85 
86  Q_INVOKABLE virtual bool populate() = 0;
87  Q_INVOKABLE virtual bool isPopulated() = 0;
88  Q_INVOKABLE virtual void reset() = 0;
89  Q_INVOKABLE virtual void resetCursor() = 0;
90  Q_INVOKABLE virtual bool setFirstRow() = 0;
91  Q_INVOKABLE virtual bool setLastRow() = 0;
92  Q_INVOKABLE virtual bool setNextRow() = 0;
93  Q_INVOKABLE virtual bool setPreviousRow() = 0;
94  Q_INVOKABLE virtual void setPopulated(bool b) = 0;
95  Q_INVOKABLE virtual int getCurrentRowNumber() = 0;
96  Q_INVOKABLE virtual bool setCurrentRowNumber(int index) = 0;
97  Q_INVOKABLE virtual int getRowCount() = 0;
98  Q_INVOKABLE virtual int getColumnCount() = 0;
99 
100  Q_INVOKABLE virtual QVariant getValue(int column, int row = -1) = 0;
101  Q_INVOKABLE virtual QVariant getValue(const QString & fieldName, int row = -1) = 0;
102 
103 // Q_INVOKABLE virtual QVariant getValue(const QString & field, const QString &roleName) = 0;
104 // Q_INVOKABLE virtual QVariant getValue(const QString & field, int row, const QString &roleName) = 0;
105 
106  Q_INVOKABLE virtual QVariant getNextRowValue(int index);
107  Q_INVOKABLE virtual QVariant getNextRowValue(const QString & field);
108  Q_INVOKABLE virtual QVariant getPreviousRowValue(int index);
109  Q_INVOKABLE virtual QVariant getPreviousRowValue(const QString & field);
110  Q_INVOKABLE virtual QString getFieldName(int column);
111  Q_INVOKABLE virtual QVariant::Type getFieldType(int column ) = 0;
112  Q_INVOKABLE virtual void setFilter ( const int col, const QString & str, Qt::CaseSensitivity cs = Qt::CaseSensitive );
113 
114  Q_INVOKABLE QString getParentDataset();
115  Q_INVOKABLE void setParentDataset(QString pDataset);
116  Q_INVOKABLE QString getFilterCondition();
117  Q_INVOKABLE void setFilterCondition(QString str);
118  Q_INVOKABLE int getFilterColumn();
119  Q_INVOKABLE void setFilterColumn(int col);
120 
121  virtual QList<CuteReport::InternalStringData> renderingStrings() = 0;
122 
124  virtual void renderInit(CuteReport::ScriptEngineInterface *scriptEngine) = 0;
125 
127  virtual void renderReset() = 0;
128 
129  virtual int datasetFlags() const;
130  virtual void setDatasetFlags(int flags);
131  virtual void setDatasetFlag(int flag, bool value = true);
132  virtual bool isDatasetFlagSet(int flag);
133 
134 signals:
135  void beforeNext();
136  void afterNext();
137  void beforePrevious();
138  void afterPrevious();
139  void beforeFirst();
140  void afterFirst();
141  void beforeLast();
142  void afterLast();
143  void beforeSeek(int index);
144  void afterSeek(int index);
145  void beforePopulate();
146  void afterPopulate();
147  void beforeSetFilter(int col, QString str);
148  void afterSetFilter(int col, QString str);
149  void renderingStringsChanged();
150  void datasetFlagsChanged(int flags);
151 
152 protected:
153  virtual DatasetInterface * createInstance(QObject* parent = 0) const = 0;
154  virtual DatasetInterface * objectClone() const = 0;
155 private:
160 
161  friend class ReportCore;
162 };
163 
164 class DatasetHelperInterface: public QWidget
165 {
166 public:
167  DatasetHelperInterface (CuteDesigner::Core * designer): m_designer(designer) {}
168  virtual void save() {}
169  virtual void load() {}
170 
171 protected:
172  CuteDesigner::Core * m_designer;
173 };
174 
175 Q_DECLARE_OPERATORS_FOR_FLAGS(DatasetInterface::DatasetFlags)
176 
177 }
178 Q_DECLARE_METATYPE(CuteReport::DatasetInterface*)
179 Q_DECLARE_INTERFACE(CuteReport::DatasetInterface, "CuteReport.DatasetInterface/1.0")
180 
181 #endif
virtual void save()
Definition: datasetinterface.h:168
DatasetHelperInterface(CuteDesigner::Core *designer)
Definition: datasetinterface.h:167
QString m_filterCondition
Definition: datasetinterface.h:157
Definition: abstractpainterdelegate.h:42
Definition: datasetinterface.h:43
virtual void load()
Definition: datasetinterface.h:169
Definition: datasetinterface.h:56
virtual void init()
Definition: datasetinterface.h:78
virtual ~DatasetInterface()
Definition: datasetinterface.h:76
Definition: reportplugininterface.h:53
int m_filterColumn
Definition: datasetinterface.h:158
CuteDesigner::Core * m_designer
Definition: datasetinterface.h:172
QString m_parentDataset
Definition: datasetinterface.h:156
Definition: datasetinterface.h:73
Definition: datasetinterface.h:164
Stage
Definition: datasetinterface.h:73
#define CUTEREPORT_EXPORTS
Definition: cutereport_globals.h:47
DatasetFlag
Definition: datasetinterface.h:68
qint32 m_datasetFlags
Definition: datasetinterface.h:159
Definition: reportcore.h:83