1
/* Koffice/Kexi report engine
2
* Copyright (C) 2007-2010 by Adam Pigg (adam@piggz.co.uk)
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.
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.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
17
#ifndef __KOREPORTDATA_H__
18
#define __KOREPORTDATA_H__
20
#include "koreport_export.h"
21
#include <QStringList>
26
class KOREPORT_EXPORT KoReportData
30
virtual ~KoReportData() {}
32
//! Describes sorting for single field
33
/*! By default the order is ascending. */
34
class KOREPORT_EXPORT SortedField
37
SortedField() : order(Qt::AscendingOrder) {}
40
//bool group; //probably not required?
44
virtual bool open() = 0;
47
virtual bool close() = 0;
49
//!Move to the next record
50
virtual bool moveNext() = 0;
52
//!Move to the previous record
53
virtual bool movePrevious() = 0;
55
//!Move to the first record
56
virtual bool moveFirst() = 0;
58
//!Move to the last record
59
virtual bool moveLast() = 0;
61
//!Return the current position in the dataset
62
virtual qint64 at() const = 0;
64
//!Return the total number of records
65
virtual qint64 recordCount() const = 0;
67
//!Return the index number of the field given by nane field
68
virtual unsigned int fieldNumber(const QString &field) const = 0;
70
//!Return the list of field names
71
virtual QStringList fieldNames() const = 0;
73
//!Return the list of field keys. Returns fieldNames() by default
74
virtual QStringList fieldKeys() const { return fieldNames(); }
76
//!Return the value of the field at the given position for the current record
77
virtual QVariant value(unsigned int) const = 0;
79
//!Return the value of the field fir the given name for the current record
80
virtual QVariant value(const QString &field) const = 0;
82
//!Return the name of this source
83
virtual QString sourceName() const {return QString();}
85
//!Sets the sorting for the data
86
//!Should be called before open() so that the data source can be edited accordingly
87
//!Default impl does nothing
88
virtual void setSorting(const QList<SortedField>& sorting) { Q_UNUSED(sorting); }
91
//!TODO These are probably eligable to be moved into a new class
93
//!Allow the reportdata implementation to return a list of possible scripts for a given language
94
virtual QStringList scriptList(const QString& language) const {
95
Q_UNUSED(language); return QStringList();
98
//!Allow the reportdata implementation to return some script code based on a specific script name
99
//!and a language, as set in the report
100
virtual QString scriptCode(const QString& script, const QString& language) const {
101
Q_UNUSED(script); Q_UNUSED(language); return QString();
104
//!Return a list of data sources possible for advanced controls
105
virtual QStringList dataSources() const { return QStringList(); }
106
//!Return a list of data source names possible for advanced controls.
107
//!Returns dataSources() by default
108
virtual QStringList dataSourceNames() const { return dataSources(); }
110
//!Allow a driver to create a new instance with a new data source
111
//!source is a driver specific identifier
112
//!Owner of the returned pointer is the caller
113
virtual KoReportData* data(const QString &source) {
114
Q_UNUSED(source); return 0;