KReport

KReportDataSource.cpp
1 /* This file is part of the KDE project
2  * Copyright (C) 2007-2010 by Adam Pigg ([email protected])
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 
23 class KReportDataSource::SortedField::Private
24 {
25 
26 public:
27  Private() {}
28  Private(const Private& other) {
29  KReportDataSortedFieldPrivateArgs((*this)) = KReportDataSortedFieldPrivateArgs(other);
30  }
31  QString field;
33 };
34 
35 class KReportDataSource::Private
36 {
37 public:
38  bool dummy = true;
39 };
40 
41 //==========KReportData::SortedField==========
42 
43 KReportDataSource::SortedField::SortedField()
44  : d(new Private)
45 {
46 }
47 
48 KReportDataSource::SortedField::SortedField(const KReportDataSource::SortedField& other) : d(new Private(*other.d))
49 {
50 }
51 
52 
53 KReportDataSource::SortedField::~SortedField()
54 {
55  delete d;
56 }
57 
58 KReportDataSource::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 
67 bool KReportDataSource::SortedField::operator==(const KReportDataSource::SortedField& other) const
68 {
69  return KReportDataSortedFieldPrivateArgs((*d)) == KReportDataSortedFieldPrivateArgs((*other.d));
70 }
71 
72 bool KReportDataSource::SortedField::operator!=(const KReportDataSource::SortedField& other) const
73 {
74  return KReportDataSortedFieldPrivateArgs((*d)) != KReportDataSortedFieldPrivateArgs((*other.d));
75 }
76 
77 QString KReportDataSource::SortedField::field() const
78 {
79  return d->field;
80 }
81 
82 Qt::SortOrder KReportDataSource::SortedField::order() const
83 {
84  return d->order;
85 }
86 
87 void KReportDataSource::SortedField::setField(const QString& field)
88 {
89  d->field = field;
90 }
91 
92 void KReportDataSource::SortedField::setOrder(Qt::SortOrder order)
93 {
94  d->order = order;
95 }
96 
97 
98 //==========KReportData==========
99 
100 KReportDataSource::KReportDataSource() : d(new Private())
101 {
102 }
103 
104 KReportDataSource::~KReportDataSource()
105 {
106  delete d;
107 }
108 
110 {
111  return fieldNames();
112 }
113 
115 {
116  return QString();
117 }
118 
120 {
121  return QString();
122 }
123 
125 {
126  Q_UNUSED(sorting);
127 }
128 
129 void 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 
137 {
138  return QStringList();
139 }
140 
142 {
143  return dataSourceName;
144 }
145 
147 {
148  Q_UNUSED(source);
149  return nullptr;
150 }
virtual QVariant value(int pos) const =0
Return the value of the field at the given position for the current record.
virtual QString sourceName() const
Return the name of this source.
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.
Describes sorting for single field, By default the order is ascending.
SortOrder
virtual QString dataSourceCaption(const QString &dataSourceName) const
Return data source caption for specified dataSourceName It is possibly translated.
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 QStringList fieldKeys() const
Return the list of field keys. Returns fieldNames() by default.
Abstraction of report data source.
virtual QString sourceClass() const
virtual QStringList fieldNames() const =0
Return the list of field names.
virtual void addCondition(const QString &field, const QVariant &value, const QString &relation=QLatin1String("="))
Adds a condition to the data source.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Jun 28 2022 04:12:21 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.