Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportDataSource.h
- This file was moved from src/common/KReportData.h.
Show All 19 Lines | |||||
20 | #include <QStringList> | 20 | #include <QStringList> | ||
21 | #include <QVariant> | 21 | #include <QVariant> | ||
22 | 22 | | |||
23 | #include "kreport_export.h" | 23 | #include "kreport_export.h" | ||
24 | #include "config-kreport.h" | 24 | #include "config-kreport.h" | ||
25 | 25 | | |||
26 | /** @brief Abstraction of report data source | 26 | /** @brief Abstraction of report data source | ||
27 | */ | 27 | */ | ||
28 | class KREPORT_EXPORT KReportData | 28 | class KREPORT_EXPORT KReportDataSource | ||
29 | { | 29 | { | ||
30 | 30 | | |||
31 | public: | 31 | public: | ||
32 | KReportData(); | 32 | KReportDataSource(); | ||
33 | virtual ~KReportData(); | 33 | virtual ~KReportDataSource(); | ||
34 | 34 | | |||
35 | //! Describes sorting for single field | 35 | //! Describes sorting for single field | ||
36 | /*! By default the order is ascending. */ | 36 | /*! By default the order is ascending. */ | ||
37 | class KREPORT_EXPORT SortedField | 37 | class KREPORT_EXPORT SortedField | ||
38 | { | 38 | { | ||
39 | public: | 39 | public: | ||
40 | SortedField(); | 40 | SortedField(); | ||
41 | SortedField(const SortedField& other); | 41 | SortedField(const SortedField& other); | ||
Show All 40 Lines | |||||
82 | 82 | | |||
83 | //! Return the list of field names | 83 | //! Return the list of field names | ||
84 | virtual QStringList fieldNames() const = 0; | 84 | virtual QStringList fieldNames() const = 0; | ||
85 | 85 | | |||
86 | //! Return the list of field keys. Returns fieldNames() by default | 86 | //! Return the list of field keys. Returns fieldNames() by default | ||
87 | virtual QStringList fieldKeys() const; | 87 | virtual QStringList fieldKeys() const; | ||
88 | 88 | | |||
89 | //! Return the value of the field at the given position for the current record | 89 | //! Return the value of the field at the given position for the current record | ||
90 | virtual QVariant value(unsigned int) const = 0; | 90 | virtual QVariant value(int pos) const = 0; | ||
staniek: `int` -> `int pos` | |||||
91 | 91 | | |||
92 | //! Return the value of the field fir the given name for the current record | 92 | //! Return the value of the field fir the given name for the current record | ||
93 | virtual QVariant value(const QString &field) const = 0; | 93 | virtual QVariant value(const QString &field) const = 0; | ||
94 | 94 | | |||
95 | //! Return the name of this source | 95 | //! Return the name of this source | ||
96 | virtual QString sourceName() const; | 96 | virtual QString sourceName() const; | ||
97 | 97 | | |||
98 | //! @return the class name of this source | 98 | //! @return the class name of this source | ||
99 | virtual QString sourceClass() const; | 99 | virtual QString sourceClass() const; | ||
100 | 100 | | |||
101 | //! Sets the sorting for the data | 101 | //! Sets the sorting for the data | ||
102 | //! Should be called before open() so that the data source can be edited accordingly | 102 | //! Should be called before open() so that the data source can be edited accordingly | ||
103 | //! Default impl does nothing | 103 | //! Default impl does nothing | ||
104 | virtual void setSorting(const QList<SortedField> &sorting); | 104 | virtual void setSorting(const QList<SortedField> &sorting); | ||
105 | 105 | | |||
106 | //! Adds an expression to the data source | 106 | //! Adds a condition to the data source | ||
an expression -> a condition Previous condition, if there is any, is joined using "AND" operator staniek: an expression -> a condition
Previous condition, if there is any, is joined using "AND"… | |||||
107 | virtual void addExpression(const QString &field, const QVariant &value, char relation = '='); | 107 | virtual void addCondition(const QString &field, const QVariant &value, const QString& relation = QLatin1String("=")); | ||
Perhaps relation would be better const QString& because how can be ">=" supplied otherwise? staniek: Perhaps `relation` would be better `const QString&` because how can be ">=" supplied otherwise? | |||||
108 | 108 | | |||
109 | //! Utility Functions | 109 | //! Utility Functions | ||
110 | //! @todo These are probably eligable to be moved into a new class | 110 | //! @todo These are probably eligable to be moved into a new class | ||
111 | 111 | | |||
112 | #ifdef KREPORT_SCRIPTING | 112 | #ifdef KREPORT_SCRIPTING | ||
113 | //! Allow the reportdata implementation to return a list of possible scripts | 113 | //! Allow the reportdata implementation to return a list of possible scripts | ||
114 | virtual QStringList scriptList() const; | 114 | virtual QStringList scriptList() const; | ||
115 | 115 | | |||
116 | //! Allow the reportdata implementation to return some script code based on a specific script name | 116 | //! Allow the reportdata implementation to return some script code based on a specific script name | ||
117 | //! as set in the report | 117 | //! as set in the report | ||
118 | virtual QString scriptCode(const QString& script) const; | 118 | virtual QString scriptCode(const QString& script) const; | ||
119 | #endif | 119 | #endif | ||
120 | 120 | | |||
121 | //! Return a list of data sources possible for advanced controls | 121 | //! Return a list of data source names available for this data source | ||
122 | virtual QStringList dataSources() const; | 122 | //! Works after the source is opened | ||
123 | 123 | virtual QStringList dataSourceNames() const = 0; | |||
124 | //! Return a list of data source names possible for advanced controls. | 124 | | ||
125 | //! Returns dataSources() by default | 125 | //! Return data source caption for specified @a dataSourceName | ||
126 | virtual QStringList dataSourceNames() const; | 126 | //! It is possibly translated. As such it is suitable for use in GUIs. | ||
127 | //! Default implementation just returns @a dataSourceName. | ||||
128 | virtual QString dataSourceCaption(const QString &dataSourceName) const; | ||||
127 | 129 | | |||
128 | //! Creates a new instance with data source. Default implementation returns @c nullptr. | 130 | //! Creates a new instance with data source. Default implementation returns @c nullptr. | ||
129 | //! @a source is implementation-specific identifier. | 131 | //! @a source is implementation-specific identifier. | ||
130 | //! Owner of the returned pointer is the caller. | 132 | //! Owner of the returned pointer is the caller. | ||
131 | virtual KReportData* create(const QString &source) const Q_REQUIRED_RESULT; | 133 | virtual KReportDataSource* create(const QString &source) const Q_REQUIRED_RESULT; | ||
Why is it needed? Constructor would be enough. The create() does not supply a proper plugin behavior I am afraid... staniek: Why is it needed? Constructor would be enough. The create() does not supply a proper plugin… | |||||
It is used in the KexiDBReportData implementation. It allows to create an instance of a subclass, without knowing about the implementation. Again, like the dataSourceNames/Captions, it is used in advanced controls like the the chart plugin, to create another datasource given its name. Would you like it implemented differently? piggz: It is used in the KexiDBReportData implementation. It allows to create an instance of a… | |||||
staniek: It's OK for now! Thanks for the info. | |||||
132 | 134 | | |||
133 | private: | 135 | private: | ||
134 | Q_DISABLE_COPY(KReportData) | 136 | Q_DISABLE_COPY(KReportDataSource) | ||
135 | class Private; | 137 | class Private; | ||
136 | Private * const d; | 138 | Private * const d; | ||
137 | }; | 139 | }; | ||
138 | 140 | | |||
139 | #endif | 141 | #endif |
int -> int pos