KReport

KReportDataSource.cpp
1/* This file is part of the KDE project
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
18#include "KReportDataSource.h"
19#include <QVariant>
20
21#define KReportDataSortedFieldPrivateArgs(o) std::tie(o.field, o.order)
22
23class KReportDataSource::SortedField::Private
24{
25
26public:
27 Private() {}
28 Private(const Private& other) {
29 KReportDataSortedFieldPrivateArgs((*this)) = KReportDataSortedFieldPrivateArgs(other);
30 }
31 QString field;
33};
34
35class KReportDataSource::Private
36{
37public:
38 bool dummy = true;
39};
40
41//==========KReportData::SortedField==========
42
43KReportDataSource::SortedField::SortedField()
44 : d(new Private)
45{
46}
47
48KReportDataSource::SortedField::SortedField(const KReportDataSource::SortedField& other) : d(new Private(*other.d))
49{
50}
51
52
53KReportDataSource::SortedField::~SortedField()
54{
55 delete d;
56}
57
58KReportDataSource::SortedField & KReportDataSource::SortedField::operator=(const KReportDataSource::SortedField& other)
59{
60 if (this != &other) {
61 setField(other.field());
62 setOrder(other.order());
63 }
64 return *this;
65}
66
67bool KReportDataSource::SortedField::operator==(const KReportDataSource::SortedField& other) const
68{
69 return KReportDataSortedFieldPrivateArgs((*d)) == KReportDataSortedFieldPrivateArgs((*other.d));
70}
71
72bool KReportDataSource::SortedField::operator!=(const KReportDataSource::SortedField& other) const
73{
74 return KReportDataSortedFieldPrivateArgs((*d)) != KReportDataSortedFieldPrivateArgs((*other.d));
75}
76
77QString KReportDataSource::SortedField::field() const
78{
79 return d->field;
80}
81
82Qt::SortOrder KReportDataSource::SortedField::order() const
83{
84 return d->order;
85}
86
87void KReportDataSource::SortedField::setField(const QString& field)
88{
89 d->field = field;
90}
91
92void KReportDataSource::SortedField::setOrder(Qt::SortOrder order)
93{
94 d->order = order;
95}
96
97
98//==========KReportData==========
99
100KReportDataSource::KReportDataSource() : d(new Private())
101{
102}
103
104KReportDataSource::~KReportDataSource()
105{
106 delete d;
107}
108
113
115{
116 return QString();
117}
118
120{
121 return QString();
122}
123
125{
126 Q_UNUSED(sorting);
127}
128
129void KReportDataSource::addCondition(const QString &field, const QVariant &value, const QString& relation)
130{
131 Q_UNUSED(field);
132 Q_UNUSED(value);
133 Q_UNUSED(relation);
134}
135
140
142{
143 return dataSourceName;
144}
145
147{
148 Q_UNUSED(source);
149 return nullptr;
150}
Describes sorting for single field, By default the order is ascending.
Abstraction of report data source.
virtual QString sourceClass() const
virtual QStringList fieldKeys() const
Return the list of field keys. Returns fieldNames() by default.
virtual void addCondition(const QString &field, const QVariant &value, const QString &relation=QLatin1String("="))
Adds a condition to the data source.
virtual void setSorting(const QList< SortedField > &sorting)
Sets the sorting for the data Should be called before open() so that the data source can be edited ac...
virtual KReportDataSource * create(const QString &source) const
Creates a new instance with data source.
virtual QStringList dataSourceNames() const =0
Return a list of data source names available for this data source Works after the source is opened.
virtual QString dataSourceCaption(const QString &dataSourceName) const
Return data source caption for specified dataSourceName It is possibly translated.
virtual QStringList fieldNames() const =0
Return the list of field names.
virtual QString sourceName() const
Return the name of this source.
virtual QVariant value(int pos) const =0
Return the value of the field at the given position for the current record.
SortOrder
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.