KReport

KReportItemBase.h
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#ifndef KREPORTITEMBASE_H
19#define KREPORTITEMBASE_H
20
21#include "config-kreport.h"
22#include "kreport_export.h"
23#include "KReportUnit.h"
24
25#include <QObject>
26#include <QFont>
27#include <QColor>
28
29class OROPage;
30class OROSection;
33
34#ifdef KREPORT_SCRIPTING
35class KReportScriptHandler;
36#else
37#define KReportScriptHandler void
38#endif
39
40class KProperty;
41class KPropertySet;
42
43class QDomElement;
44
45class KReportTextStyleData
46{
47public:
48 QFont font;
49 Qt::Alignment alignment;
50 QColor backgroundColor;
51 QColor foregroundColor;
52 int backgroundOpacity;
53
54};
55
56/*!
57 * @brief Base class for items that are drawn syncronously.
58 */
59class KREPORT_EXPORT KReportItemBase : public QObject
60{
61 Q_OBJECT
62public:
63
65 ~KReportItemBase() override;
66
67 /**
68 @brief Return the item type as a string. Required by all items
69 @return Item type
70 */
71 virtual QString typeName() const = 0;
72
73 /**
74 @brief Render the item into a primitive which is used by the second stage renderer
75 @return the height required by the object
76 */
77 virtual int renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, const QVariant &data, KReportScriptHandler *script);
78
79 /**
80 @brief Render a complex item that uses a sub query as a data source
81 @return the height required by the object
82 */
83 virtual int renderReportData(OROPage *page, OROSection *section, const QPointF &offset, KReportDataSource *dataSource, KReportScriptHandler *script);
84
85 /**
86 @return The field name or expression for the data source
87 */
88 QString itemDataSource() const;
89
90 void setItemDataSource(const QString &source);
91
92 /**
93 @brief Override if the item uses a sub query and linked fields, such as a chart or sub-report
94 @return True if uses a sub query
95 */
96 virtual bool supportsSubQuery() const;
97
98 KPropertySet* propertySet();
99 const KPropertySet* propertySet() const;
100
101 void setEntityName(const QString& n);
102 QString entityName() const;
103
104 KReportUnit unit() const;
105
106 //! Sets unit to @a a and converts values of position and size property from the old
107 //! unit to new if needed.
108 virtual void setUnit(const KReportUnit &u);
109
110 /**
111 * @brief Return the size in points
112 */
113 QSizeF size() const;
114
115 /**
116 * @brief Return the position in points
117 */
118 QPointF position() const;
119
120 /**
121 * @brief Sets position for the element
122 * @param ptPos Position in points
123 */
124 void setPosition(const QPointF &ptPos);
125
126 /**
127 * @brief Sets size for the element
128 * @param ptSize Size in points
129 */
130 void setSize(const QSizeF &ptSize);
131
132 /**
133 * @brief Return the z-value in points
134 */
135 qreal z() const;
136
137 /**
138 * @brief Sets the z-value for the element
139 * @param z Z-value in points
140 */
141 void setZ(qreal z);
142
143 //! Helper function mapping to screen units (pixels), @a ptPos is in points
144 static QPointF scenePosition(const QPointF &ptPos);
145
146 //! Helper function mapping to screen units (pixels), @a ptSize is in points
147 static QSizeF sceneSize(const QSizeF &ptSize);
148
149 //! Helper function mapping from screen units to points, @a pos is in pixels
150 static QPointF positionFromScene(const QPointF &pos);
151
152 //! Helper function mapping from screen units to points, @a size is in pixels
153 static QSizeF sizeFromScene(const QSizeF &size);
154
155protected:
156 virtual void createProperties() = 0;
157 void createDataSourceProperty();
158 bool parseReportRect(const QDomElement &elem);
159 static bool parseReportTextStyleData(const QDomElement &, KReportTextStyleData*);
160 static bool parseReportLineStyleData(const QDomElement &, KReportLineStyle*);
161
162 KProperty *nameProperty();
163 QString oldName() const;
164 void setOldName(const QString &old);
165 KProperty* dataSourceProperty();
166
167 Q_SLOT virtual void propertyChanged(KPropertySet &s, KProperty &p);
168
169private:
170 Q_DISABLE_COPY(KReportItemBase)
171 class Private;
172 Private * const d;
173 Q_SLOT void aboutToDeleteProperty(KPropertySet& set, KProperty& property);
174
175 friend class KReportDesignerItemRectBase;
176};
177
178#endif
Abstraction of report data source.
Base class for rectangular report items used within the designer GUI.
Base class for items that are drawn syncronously.
virtual QString typeName() const =0
Return the item type as a string.
The KReportLineStyle class represents line style.
Converts between different units.
Definition KReportUnit.h:71
Represents a single page in a document and may contain zero or more OROPrimitive objects all of which...
Represents a single a single row in a document and may contain zero or more OROPrimitives.
typedef Alignment
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:12:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.