~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to libs/koreport/common/KoReportData.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Koffice/Kexi report engine
 
2
 * Copyright (C) 2007-2010 by Adam Pigg (adam@piggz.co.uk)
 
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, see <http://www.gnu.org/licenses/>.
 
16
 */
 
17
#ifndef __KOREPORTDATA_H__
 
18
#define __KOREPORTDATA_H__
 
19
 
 
20
#include "koreport_export.h"
 
21
#include <QStringList>
 
22
 
 
23
/**
 
24
 
 
25
*/
 
26
class KOREPORT_EXPORT KoReportData
 
27
{
 
28
 
 
29
public:
 
30
    virtual ~KoReportData() {}
 
31
 
 
32
    //! Describes sorting for single field
 
33
    /*! By default the order is ascending. */
 
34
    class KOREPORT_EXPORT SortedField
 
35
    {
 
36
    public:
 
37
        SortedField() : order(Qt::AscendingOrder) {}
 
38
        QString field;
 
39
        Qt::SortOrder order;
 
40
        //bool group; //probably not required?
 
41
    };
 
42
 
 
43
    //!Open the dataset
 
44
    virtual bool open() = 0;
 
45
 
 
46
    //!Close the dataset
 
47
    virtual bool close() = 0;
 
48
 
 
49
    //!Move to the next record
 
50
    virtual bool moveNext() = 0;
 
51
 
 
52
    //!Move to the previous record
 
53
    virtual bool movePrevious() = 0;
 
54
 
 
55
    //!Move to the first record
 
56
    virtual bool moveFirst() = 0;
 
57
 
 
58
    //!Move to the last record
 
59
    virtual bool moveLast() = 0;
 
60
 
 
61
    //!Return the current position in the dataset
 
62
    virtual qint64 at() const = 0;
 
63
 
 
64
    //!Return the total number of records
 
65
    virtual qint64 recordCount() const = 0;
 
66
 
 
67
    //!Return the index number of the field given by nane field
 
68
    virtual unsigned int fieldNumber(const QString &field) const = 0;
 
69
 
 
70
    //!Return the list of field names
 
71
    virtual QStringList fieldNames() const = 0;
 
72
    
 
73
    //!Return the list of field keys. Returns fieldNames() by default
 
74
    virtual QStringList fieldKeys() const { return fieldNames(); }
 
75
    
 
76
    //!Return the value of the field at the given position for the current record
 
77
    virtual QVariant value(unsigned int) const = 0;
 
78
 
 
79
    //!Return the value of the field fir the given name for the current record
 
80
    virtual QVariant value(const QString &field) const = 0;
 
81
 
 
82
    //!Return the name of this source
 
83
    virtual QString sourceName() const {return QString();}
 
84
 
 
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); }
 
89
 
 
90
    //!Utility Functions
 
91
    //!TODO These are probably eligable to be moved into a new class
 
92
 
 
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();
 
96
    }
 
97
 
 
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();
 
102
    }
 
103
 
 
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(); }
 
109
 
 
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;
 
115
    }
 
116
};
 
117
 
 
118
#endif