Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportSectionData.h
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com) | 2 | * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com) | ||
3 | * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk) | 3 | * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk) | ||
4 | * Copyright (C) 2010 Jarosław Staniek <staniek@kde.org> | 4 | * Copyright (C) 2010-2018 Jarosław Staniek <staniek@kde.org> | ||
5 | * | 5 | * | ||
6 | * This library is free software; you can redistribute it and/or | 6 | * This library is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | 7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | 8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | 10 | * | ||
11 | * This library is distributed in the hope that it will be useful, | 11 | * This library is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 18 Lines | |||||
31 | class KReportDocument; | 31 | class KReportDocument; | ||
32 | class QDomElement; | 32 | class QDomElement; | ||
33 | 33 | | |||
34 | namespace Scripting | 34 | namespace Scripting | ||
35 | { | 35 | { | ||
36 | class Section; | 36 | class Section; | ||
37 | } | 37 | } | ||
38 | 38 | | |||
39 | // | 39 | /** | ||
40 | // KReportSectionData is used to store the information about a specific | 40 | * KReportSectionData is used to store the information about a specific report section | ||
41 | // section. | 41 | * | ||
42 | // A section has a name and optionally extra data. `name' | 42 | * A section has a name, type, unit and optionally extra data. | ||
43 | // reportheader, reportfooter, pageheader, pagefooter, groupheader, groupfooter or detail. | 43 | */ | ||
44 | // In the case of pghead and pgfoot extra would contain the page | 44 | class KREPORT_EXPORT KReportSectionData : public QObject | ||
45 | // designation (firstpage, odd, even or lastpage). | | |||
46 | class KReportSectionData : public QObject | | |||
47 | { | 45 | { | ||
48 | Q_OBJECT | 46 | Q_OBJECT | ||
49 | public: | 47 | public: | ||
50 | enum class Type { | 48 | enum class Type { | ||
51 | None, | 49 | None, | ||
52 | PageHeaderFirst, | 50 | PageHeaderFirst, | ||
53 | PageHeaderOdd, | 51 | PageHeaderOdd, | ||
54 | PageHeaderEven, | 52 | PageHeaderEven, | ||
Show All 16 Lines | |||||
71 | explicit KReportSectionData(const QDomElement &elemSource, QObject *parent = nullptr); | 69 | explicit KReportSectionData(const QDomElement &elemSource, QObject *parent = nullptr); | ||
72 | 70 | | |||
73 | ~KReportSectionData() override; | 71 | ~KReportSectionData() override; | ||
74 | 72 | | |||
75 | KReportUnit unit() const; | 73 | KReportUnit unit() const; | ||
76 | 74 | | |||
77 | void setUnit(const KReportUnit &u); | 75 | void setUnit(const KReportUnit &u); | ||
78 | 76 | | |||
79 | KPropertySet* propertySet() const { | 77 | /** | ||
80 | return m_set; | 78 | * Returns property set for this section | ||
81 | } | 79 | * | ||
80 | * @since 3.1 | ||||
81 | */ | ||||
82 | KPropertySet* propertySet(); | ||||
82 | 83 | | |||
83 | bool isValid() const { | 84 | /** | ||
84 | return m_valid; | 85 | * @overload | ||
85 | } | 86 | */ | ||
87 | const KPropertySet* propertySet() const; | ||||
88 | | ||||
89 | bool isValid() const; | ||||
86 | 90 | | |||
87 | qreal height() const; | 91 | qreal height() const; | ||
88 | 92 | | |||
89 | void setHeight(qreal ptHeight); | 93 | void setHeight(qreal ptHeight); | ||
90 | 94 | | |||
91 | QList<KReportItemBase*> objects() const { | 95 | QList<KReportItemBase*> objects() const; | ||
92 | return m_objects; | | |||
93 | } | | |||
94 | 96 | | |||
95 | QString name() const; | 97 | QString name() const; | ||
96 | 98 | | |||
97 | QColor backgroundColor() const { | 99 | QColor backgroundColor() const; | ||
98 | return m_backgroundColor->value().value<QColor>(); | | |||
99 | } | | |||
100 | 100 | | |||
101 | Type type() const { | 101 | Type type() const; | ||
102 | return m_type; | | |||
103 | } | | |||
104 | 102 | | |||
105 | static KReportSectionData::Type sectionTypeFromString(const QString& s); | 103 | static KReportSectionData::Type sectionTypeFromString(const QString& s); | ||
106 | static QString sectionTypeString(KReportSectionData::Type type); | 104 | static QString sectionTypeString(KReportSectionData::Type type); | ||
107 | protected: | | |||
108 | KPropertySet *m_set; | | |||
109 | KProperty *m_backgroundColor; | | |||
110 | 105 | | |||
111 | private: | 106 | private: | ||
112 | void createProperties(const QDomElement & elemSource); | 107 | void setBackgroundColor(const QColor &color); | ||
113 | void loadXml(const QDomElement &elemSource); | | |||
114 | void setHeight(qreal ptHeight, KProperty::ValueOptions options); | 108 | void setHeight(qreal ptHeight, KProperty::ValueOptions options); | ||
109 | KReportItemBase* object(int index); | ||||
115 | 110 | | |||
116 | KProperty *m_height; | 111 | Q_DISABLE_COPY(KReportSectionData) | ||
117 | QList<KReportItemBase*> m_objects; | 112 | class Private; | ||
118 | KReportUnit m_unit; | 113 | Private * const d; | ||
119 | | ||||
120 | Type m_type; | | |||
121 | | ||||
122 | static bool zLessThan(KReportItemBase* s1, KReportItemBase* s2); | | |||
123 | static bool xLessThan(KReportItemBase* s1, KReportItemBase* s2); | | |||
124 | | ||||
125 | bool m_valid; | | |||
126 | 114 | | |||
127 | friend class Scripting::Section; | 115 | friend class Scripting::Section; | ||
128 | friend class KReportDesignerSection; | 116 | friend class KReportDesignerSection; | ||
129 | }; | 117 | }; | ||
130 | 118 | | |||
131 | #endif | 119 | #endif |