Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportSectionData.cpp
Show All 36 Lines | |||||
37 | 37 | | |||
38 | KReportSectionData::KReportSectionData(const QDomElement & elemSource, KReportDocument* report) | 38 | KReportSectionData::KReportSectionData(const QDomElement & elemSource, KReportDocument* report) | ||
39 | : QObject(report) | 39 | : QObject(report) | ||
40 | { | 40 | { | ||
41 | setObjectName(elemSource.tagName()); | 41 | setObjectName(elemSource.tagName()); | ||
42 | 42 | | |||
43 | m_type = sectionTypeFromString(elemSource.attribute(QLatin1String("report:section-type"))); | 43 | m_type = sectionTypeFromString(elemSource.attribute(QLatin1String("report:section-type"))); | ||
44 | createProperties(elemSource); | 44 | createProperties(elemSource); | ||
45 | if (objectName() != QLatin1String("report:section") || m_type == KReportSectionData::None) { | 45 | if (objectName() != QLatin1String("report:section") || m_type == KReportSectionData::Type::None) { | ||
46 | m_valid = false; | 46 | m_valid = false; | ||
47 | return; | 47 | return; | ||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | m_backgroundColor->setValue(QColor(elemSource.attribute(QLatin1String("fo:background-color")))); | 50 | m_backgroundColor->setValue(QColor(elemSource.attribute(QLatin1String("fo:background-color")))); | ||
51 | 51 | | |||
52 | KReportPluginManager* manager = KReportPluginManager::self(); | 52 | KReportPluginManager* manager = KReportPluginManager::self(); | ||
53 | 53 | | |||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 100 | { | |||
112 | m_set->addProperty(m_backgroundColor); | 112 | m_set->addProperty(m_backgroundColor); | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | QString KReportSectionData::name() const | 115 | QString KReportSectionData::name() const | ||
116 | { | 116 | { | ||
117 | return (objectName() + QLatin1Char('-') + sectionTypeString(m_type)); | 117 | return (objectName() + QLatin1Char('-') + sectionTypeString(m_type)); | ||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | QString KReportSectionData::sectionTypeString(KReportSectionData::Section s) | 120 | QString KReportSectionData::sectionTypeString(KReportSectionData::Type type) | ||
121 | { | 121 | { | ||
122 | //! @todo use QMap | 122 | //! @todo use QMap | ||
123 | QString sectiontype; | 123 | QString sectiontype; | ||
124 | switch (s) { | 124 | switch (type) { | ||
125 | case KReportSectionData::PageHeaderAny: | 125 | case KReportSectionData::Type::PageHeaderAny: | ||
126 | sectiontype = QLatin1String("header-page-any"); | 126 | sectiontype = QLatin1String("header-page-any"); | ||
127 | break; | 127 | break; | ||
128 | case KReportSectionData::PageHeaderEven: | 128 | case KReportSectionData::Type::PageHeaderEven: | ||
129 | sectiontype = QLatin1String("header-page-even"); | 129 | sectiontype = QLatin1String("header-page-even"); | ||
130 | break; | 130 | break; | ||
131 | case KReportSectionData::PageHeaderOdd: | 131 | case KReportSectionData::Type::PageHeaderOdd: | ||
132 | sectiontype = QLatin1String("header-page-odd"); | 132 | sectiontype = QLatin1String("header-page-odd"); | ||
133 | break; | 133 | break; | ||
134 | case KReportSectionData::PageHeaderFirst: | 134 | case KReportSectionData::Type::PageHeaderFirst: | ||
135 | sectiontype = QLatin1String("header-page-first"); | 135 | sectiontype = QLatin1String("header-page-first"); | ||
136 | break; | 136 | break; | ||
137 | case KReportSectionData::PageHeaderLast: | 137 | case KReportSectionData::Type::PageHeaderLast: | ||
138 | sectiontype = QLatin1String("header-page-last"); | 138 | sectiontype = QLatin1String("header-page-last"); | ||
139 | break; | 139 | break; | ||
140 | case KReportSectionData::PageFooterAny: | 140 | case KReportSectionData::Type::PageFooterAny: | ||
141 | sectiontype = QLatin1String("footer-page-any"); | 141 | sectiontype = QLatin1String("footer-page-any"); | ||
142 | break; | 142 | break; | ||
143 | case KReportSectionData::PageFooterEven: | 143 | case KReportSectionData::Type::PageFooterEven: | ||
144 | sectiontype = QLatin1String("footer-page-even"); | 144 | sectiontype = QLatin1String("footer-page-even"); | ||
145 | break; | 145 | break; | ||
146 | case KReportSectionData::PageFooterOdd: | 146 | case KReportSectionData::Type::PageFooterOdd: | ||
147 | sectiontype = QLatin1String("footer-page-odd"); | 147 | sectiontype = QLatin1String("footer-page-odd"); | ||
148 | break; | 148 | break; | ||
149 | case KReportSectionData::PageFooterFirst: | 149 | case KReportSectionData::Type::PageFooterFirst: | ||
150 | sectiontype = QLatin1String("footer-page-first"); | 150 | sectiontype = QLatin1String("footer-page-first"); | ||
151 | break; | 151 | break; | ||
152 | case KReportSectionData::PageFooterLast: | 152 | case KReportSectionData::Type::PageFooterLast: | ||
153 | sectiontype = QLatin1String("footer-page-last"); | 153 | sectiontype = QLatin1String("footer-page-last"); | ||
154 | break; | 154 | break; | ||
155 | case KReportSectionData::ReportHeader: | 155 | case KReportSectionData::Type::ReportHeader: | ||
156 | sectiontype = QLatin1String("header-report"); | 156 | sectiontype = QLatin1String("header-report"); | ||
157 | break; | 157 | break; | ||
158 | case KReportSectionData::ReportFooter: | 158 | case KReportSectionData::Type::ReportFooter: | ||
159 | sectiontype = QLatin1String("footer-report"); | 159 | sectiontype = QLatin1String("footer-report"); | ||
160 | break; | 160 | break; | ||
161 | case KReportSectionData::GroupHeader: | 161 | case KReportSectionData::Type::GroupHeader: | ||
162 | sectiontype = QLatin1String("group-header"); | 162 | sectiontype = QLatin1String("group-header"); | ||
163 | break; | 163 | break; | ||
164 | case KReportSectionData::GroupFooter: | 164 | case KReportSectionData::Type::GroupFooter: | ||
165 | sectiontype = QLatin1String("group-footer"); | 165 | sectiontype = QLatin1String("group-footer"); | ||
166 | break; | 166 | break; | ||
167 | case KReportSectionData::Detail: | 167 | case KReportSectionData::Type::Detail: | ||
168 | sectiontype = QLatin1String("detail"); | 168 | sectiontype = QLatin1String("detail"); | ||
169 | break; | 169 | break; | ||
170 | default: | 170 | default: | ||
171 | ; | 171 | break; | ||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | return sectiontype; | 174 | return sectiontype; | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | KReportSectionData::Section KReportSectionData::sectionTypeFromString(const QString& s) | 177 | KReportSectionData::Type KReportSectionData::sectionTypeFromString(const QString& s) | ||
178 | { | 178 | { | ||
179 | //! @todo use QMap | 179 | //! @todo use QMap | ||
180 | KReportSectionData::Section sec; | 180 | KReportSectionData::Type type; | ||
181 | //kreportDebug() << "Determining section type for " << s; | 181 | //kreportDebug() << "Determining section type for " << s; | ||
182 | if (s == QLatin1String("header-page-any")) | 182 | if (s == QLatin1String("header-page-any")) | ||
183 | sec = KReportSectionData::PageHeaderAny; | 183 | type = KReportSectionData::Type::PageHeaderAny; | ||
184 | else if (s == QLatin1String("header-page-even")) | 184 | else if (s == QLatin1String("header-page-even")) | ||
185 | sec = KReportSectionData::PageHeaderEven; | 185 | type = KReportSectionData::Type::PageHeaderEven; | ||
186 | else if (s == QLatin1String("header-page-odd")) | 186 | else if (s == QLatin1String("header-page-odd")) | ||
187 | sec = KReportSectionData::PageHeaderOdd; | 187 | type = KReportSectionData::Type::PageHeaderOdd; | ||
188 | else if (s == QLatin1String("header-page-first")) | 188 | else if (s == QLatin1String("header-page-first")) | ||
189 | sec = KReportSectionData::PageHeaderFirst; | 189 | type = KReportSectionData::Type::PageHeaderFirst; | ||
190 | else if (s == QLatin1String("header-page-last")) | 190 | else if (s == QLatin1String("header-page-last")) | ||
191 | sec = KReportSectionData::PageHeaderLast; | 191 | type = KReportSectionData::Type::PageHeaderLast; | ||
192 | else if (s == QLatin1String("header-report")) | 192 | else if (s == QLatin1String("header-report")) | ||
193 | sec = KReportSectionData::ReportHeader; | 193 | type = KReportSectionData::Type::ReportHeader; | ||
194 | else if (s == QLatin1String("footer-page-any")) | 194 | else if (s == QLatin1String("footer-page-any")) | ||
195 | sec = KReportSectionData::PageFooterAny; | 195 | type = KReportSectionData::Type::PageFooterAny; | ||
196 | else if (s == QLatin1String("footer-page-even")) | 196 | else if (s == QLatin1String("footer-page-even")) | ||
197 | sec = KReportSectionData::PageFooterEven; | 197 | type = KReportSectionData::Type::PageFooterEven; | ||
198 | else if (s == QLatin1String("footer-page-odd")) | 198 | else if (s == QLatin1String("footer-page-odd")) | ||
199 | sec = KReportSectionData::PageFooterOdd; | 199 | type = KReportSectionData::Type::PageFooterOdd; | ||
200 | else if (s == QLatin1String("footer-page-first")) | 200 | else if (s == QLatin1String("footer-page-first")) | ||
201 | sec = KReportSectionData::PageFooterFirst; | 201 | type = KReportSectionData::Type::PageFooterFirst; | ||
202 | else if (s == QLatin1String("footer-page-last")) | 202 | else if (s == QLatin1String("footer-page-last")) | ||
203 | sec = KReportSectionData::PageFooterLast; | 203 | type = KReportSectionData::Type::PageFooterLast; | ||
204 | else if (s == QLatin1String("footer-report")) | 204 | else if (s == QLatin1String("footer-report")) | ||
205 | sec = KReportSectionData::ReportFooter; | 205 | type = KReportSectionData::Type::ReportFooter; | ||
206 | else if (s == QLatin1String("group-header")) | 206 | else if (s == QLatin1String("group-header")) | ||
207 | sec = KReportSectionData::GroupHeader; | 207 | type = KReportSectionData::Type::GroupHeader; | ||
208 | else if (s == QLatin1String("group-footer")) | 208 | else if (s == QLatin1String("group-footer")) | ||
209 | sec = KReportSectionData::GroupFooter; | 209 | type = KReportSectionData::Type::GroupFooter; | ||
210 | else if (s == QLatin1String("detail")) | 210 | else if (s == QLatin1String("detail")) | ||
211 | sec = KReportSectionData::Detail; | 211 | type = KReportSectionData::Type::Detail; | ||
212 | else | 212 | else | ||
213 | sec = KReportSectionData::None; | 213 | type = KReportSectionData::Type::None; | ||
214 | 214 | | |||
215 | return sec; | 215 | return type; | ||
216 | } | 216 | } |