Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesignerSection.cpp
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | 171 | if (changeSet) { | |||
---|---|---|---|---|---|
172 | slotSceneClicked(); // switches property set to this section | 172 | slotSceneClicked(); // switches property set to this section | ||
173 | } | 173 | } | ||
174 | 174 | | |||
175 | qreal h = d->scene->height() + delta; | 175 | qreal h = d->scene->height() + delta; | ||
176 | 176 | | |||
177 | if (h < 1) h = 1; | 177 | if (h < 1) h = 1; | ||
178 | 178 | | |||
179 | h = d->scene->gridPoint(QPointF(0, h)).y(); | 179 | h = d->scene->gridPoint(QPointF(0, h)).y(); | ||
180 | d->sectionData->m_height->setValue(INCH_TO_POINT(h/d->dpiY)); | 180 | d->sectionData->setHeight(INCH_TO_POINT(h/d->dpiY)); | ||
181 | d->sectionRuler->setRulerLength(h); | 181 | d->sectionRuler->setRulerLength(h); | ||
182 | 182 | | |||
183 | d->scene->setSceneRect(0, 0, d->scene->width(), h); | 183 | d->scene->setSceneRect(0, 0, d->scene->width(), h); | ||
184 | d->sceneView->resizeContents(QSize(d->scene->width(), h)); | 184 | d->sceneView->resizeContents(QSize(d->scene->width(), h)); | ||
185 | 185 | | |||
186 | d->reportDesigner->setModified(true); | 186 | d->reportDesigner->setModified(true); | ||
187 | } | 187 | } | ||
188 | 188 | | |||
189 | void KReportDesignerSection::buildXML(QDomDocument *doc, QDomElement *section) | 189 | void KReportDesignerSection::buildXML(QDomDocument *doc, QDomElement *section) | ||
190 | { | 190 | { | ||
191 | KReportUtils::setAttribute(section, QLatin1String("svg:height"), d->sectionData->m_height->value().toDouble()); | 191 | KReportUtils::setAttribute(section, QLatin1String("svg:height"), d->sectionData->height()); | ||
192 | section->setAttribute(QLatin1String("fo:background-color"), d->sectionData->backgroundColor().name()); | 192 | section->setAttribute(QLatin1String("fo:background-color"), d->sectionData->backgroundColor().name()); | ||
193 | 193 | | |||
194 | // now get a list of all the QGraphicsItems on this scene and output them. | 194 | // now get a list of all the QGraphicsItems on this scene and output them. | ||
195 | QGraphicsItemList list = d->scene->items(); | 195 | QGraphicsItemList list = d->scene->items(); | ||
196 | for (QGraphicsItemList::iterator it = list.begin(); | 196 | for (QGraphicsItemList::iterator it = list.begin(); | ||
197 | it != list.end(); ++it) { | 197 | it != list.end(); ++it) { | ||
198 | KReportDesignerItemBase::buildXML((*it), doc, section); | 198 | KReportDesignerItemBase::buildXML((*it), doc, section); | ||
199 | } | 199 | } | ||
200 | } | 200 | } | ||
201 | 201 | | |||
202 | void KReportDesignerSection::initFromXML(const QDomNode & section) | 202 | void KReportDesignerSection::initFromXML(const QDomNode & section) | ||
203 | { | 203 | { | ||
204 | QDomNodeList nl = section.childNodes(); | 204 | QDomNodeList nl = section.childNodes(); | ||
205 | QDomNode node; | 205 | QDomNode node; | ||
206 | QString n; | 206 | QString n; | ||
207 | 207 | | |||
208 | qreal h = KReportUnit::parseValue(section.toElement().attribute(QLatin1String("svg:height"), QLatin1String("2.0cm"))); | 208 | qreal ptHeight = KReportUtils::readSizeAttributes(section.toElement(), QSizeF(DEFAULT_SECTION_SIZE_PT, DEFAULT_SECTION_SIZE_PT)).height(); | ||
209 | d->sectionData->m_height->setValue(h); | 209 | d->sectionData->setHeight(ptHeight); | ||
210 | 210 | | |||
211 | h = POINT_TO_INCH(h) * d->dpiY; | 211 | qreal h = POINT_TO_INCH(ptHeight) * d->dpiY; | ||
212 | //kreportDebug() << "Section Height: " << h; | 212 | //kreportDebug() << "Section Height: " << h; | ||
213 | d->scene->setSceneRect(0, 0, d->scene->width(), h); | 213 | d->scene->setSceneRect(0, 0, d->scene->width(), h); | ||
214 | slotResizeBarDragged(0); | 214 | slotResizeBarDragged(0); | ||
215 | 215 | | |||
216 | d->sectionData->m_backgroundColor->setValue(QColor(section.toElement().attribute(QLatin1String("fo:background-color"), QLatin1String("#ffffff")))); | 216 | d->sectionData->m_backgroundColor->setValue(QColor(section.toElement().attribute(QLatin1String("fo:background-color"), QLatin1String("#ffffff")))); | ||
217 | 217 | | |||
218 | for (int i = 0; i < nl.count(); ++i) { | 218 | for (int i = 0; i < nl.count(); ++i) { | ||
219 | node = nl.item(i); | 219 | node = nl.item(i); | ||
Show All 35 Lines | 254 | { | |||
255 | return QSize(d->scene->width() + d->sectionRuler->frameSize().width(), d->title->frameSize().height() + d->sceneView->sizeHint().height() + d->resizeBar->frameSize().height()); | 255 | return QSize(d->scene->width() + d->sectionRuler->frameSize().width(), d->title->frameSize().height() + d->sceneView->sizeHint().height() + d->resizeBar->frameSize().height()); | ||
256 | } | 256 | } | ||
257 | 257 | | |||
258 | void KReportDesignerSection::slotPageOptionsChanged(KPropertySet &set) | 258 | void KReportDesignerSection::slotPageOptionsChanged(KPropertySet &set) | ||
259 | { | 259 | { | ||
260 | Q_UNUSED(set) | 260 | Q_UNUSED(set) | ||
261 | 261 | | |||
262 | KReportUnit unit = d->reportDesigner->pageUnit(); | 262 | KReportUnit unit = d->reportDesigner->pageUnit(); | ||
263 | 263 | d->sectionData->setUnit(unit); | |||
264 | d->sectionData->m_height->setOption("unit", unit.symbol()); | | |||
265 | 264 | | |||
266 | //update items position with unit | 265 | //update items position with unit | ||
267 | QList<QGraphicsItem*> itms = d->scene->items(); | 266 | QList<QGraphicsItem*> itms = d->scene->items(); | ||
268 | for (int i = 0; i < itms.size(); ++i) { | 267 | for (int i = 0; i < itms.size(); ++i) { | ||
269 | KReportItemBase *obj = dynamic_cast<KReportItemBase*>(itms[i]); | 268 | KReportItemBase *obj = dynamic_cast<KReportItemBase*>(itms[i]); | ||
270 | if (obj) { | 269 | if (obj) { | ||
271 | obj->setUnit(unit); | 270 | obj->setUnit(unit); | ||
272 | } | 271 | } | ||
Show All 24 Lines | 294 | { | |||
297 | //kreportDebug() << p.name(); | 296 | //kreportDebug() << p.name(); | ||
298 | 297 | | |||
299 | //Handle Background Color | 298 | //Handle Background Color | ||
300 | if (p.name() == "background-color") { | 299 | if (p.name() == "background-color") { | ||
301 | d->scene->setBackgroundBrush(p.value().value<QColor>()); | 300 | d->scene->setBackgroundBrush(p.value().value<QColor>()); | ||
302 | } | 301 | } | ||
303 | 302 | | |||
304 | if (p.name() == "height") { | 303 | if (p.name() == "height") { | ||
305 | d->scene->setSceneRect(0, 0, d->scene->width(), POINT_TO_INCH(p.value().toDouble()) * d->dpiY); | 304 | d->scene->setSceneRect(0, 0, d->scene->width(), | ||
305 | POINT_TO_INCH(d->sectionData->height()) * d->dpiY); | ||||
306 | slotResizeBarDragged(0); | 306 | slotResizeBarDragged(0); | ||
307 | } | 307 | } | ||
308 | 308 | | |||
309 | if (d->reportDesigner) | 309 | if (d->reportDesigner) | ||
310 | d->reportDesigner->setModified(true); | 310 | d->reportDesigner->setModified(true); | ||
311 | 311 | | |||
312 | d->sceneView->resetCachedContent(); | 312 | d->sceneView->resetCachedContent(); | ||
313 | d->scene->update(); | 313 | d->scene->update(); | ||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |