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