Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesignerSection.cpp
Show First 20 Lines • Show All 130 Lines • ▼ Show 20 Line(s) | 104 | { | |||
---|---|---|---|---|---|
131 | 131 | | |||
132 | d->sceneView = new KReportDesignerSectionView(rptdes, d->scene, this); | 132 | d->sceneView = new KReportDesignerSectionView(rptdes, d->scene, this); | ||
133 | d->sceneView->setObjectName(QLatin1String("scene view")); | 133 | d->sceneView->setObjectName(QLatin1String("scene view")); | ||
134 | d->sceneView->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | 134 | d->sceneView->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | ||
135 | 135 | | |||
136 | d->resizeBar = new ReportResizeBar(this); | 136 | d->resizeBar = new ReportResizeBar(this); | ||
137 | 137 | | |||
138 | connect(d->resizeBar, SIGNAL(barDragged(int)), this, SLOT(slotResizeBarDragged(int))); | 138 | connect(d->resizeBar, SIGNAL(barDragged(int)), this, SLOT(slotResizeBarDragged(int))); | ||
139 | connect(d->reportDesigner, SIGNAL(pagePropertyChanged(KPropertySet&)), | 139 | connect(d->reportDesigner, &KReportDesigner::pagePropertyChanged, | ||
140 | this, SLOT(slotPageOptionsChanged(KPropertySet&))); | 140 | this, &KReportDesignerSection::slotPageOptionsChanged); | ||
141 | connect(d->scene, SIGNAL(clicked()), this, (SLOT(slotSceneClicked()))); | 141 | connect(d->scene, &KReportDesignerSectionScene::clicked, this, &KReportDesignerSection::slotSceneClicked); | ||
142 | connect(d->scene, SIGNAL(lostFocus()), d->title, SLOT(update())); | 142 | connect(d->scene, SIGNAL(lostFocus()), d->title, SLOT(update())); | ||
143 | connect(d->title, SIGNAL(clicked()), this, (SLOT(slotSceneClicked()))); | 143 | connect(d->title, &KReportDesignerSectionTitle::clicked, this, &KReportDesignerSection::slotSceneClicked); | ||
144 | 144 | | |||
145 | glayout->addWidget(d->title, 0, 0, 1, 2); | 145 | glayout->addWidget(d->title, 0, 0, 1, 2); | ||
146 | glayout->addWidget(d->sectionRuler, 1, 0); | 146 | glayout->addWidget(d->sectionRuler, 1, 0); | ||
147 | glayout->addWidget(d->sceneView , 1, 1); | 147 | glayout->addWidget(d->sceneView , 1, 1); | ||
148 | glayout->addWidget(d->resizeBar, 2, 0, 1, 2); | 148 | glayout->addWidget(d->resizeBar, 2, 0, 1, 2); | ||
149 | d->sectionRuler->setFixedWidth(d->sectionRuler->sizeHint().width()); | 149 | d->sectionRuler->setFixedWidth(d->sectionRuler->sizeHint().width()); | ||
150 | 150 | | |||
151 | setLayout(glayout); | 151 | setLayout(glayout); | ||
Show All 20 Lines | 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 | } | ||
273 | } | 272 | } | ||
274 | 273 | | |||
275 | d->scene->setSceneRect(0, 0, d->reportDesigner->pageWidthPx(), d->scene->height()); | 274 | d->scene->setSceneRect(0, 0, d->reportDesigner->pageWidthPx(), d->scene->height()); | ||
276 | d->title->setMinimumWidth(d->reportDesigner->pageWidthPx() + d->sectionRuler->frameSize().width()); | 275 | d->title->setMinimumWidth(d->reportDesigner->pageWidthPx() + d->sectionRuler->frameSize().width()); | ||
277 | d->sectionRuler->setUnit(d->reportDesigner->pageUnit()); | 276 | d->sectionRuler->setUnit(d->reportDesigner->pageUnit()); | ||
278 | 277 | | |||
279 | //Trigger a redraw of the background | 278 | //Trigger a redraw of the background | ||
279 | d->sceneView->resizeContents(QSize(d->scene->width(), d->scene->height())); | ||||
280 | | ||||
280 | d->sceneView->resetCachedContent(); | 281 | d->sceneView->resetCachedContent(); | ||
282 | d->sceneView->update(); | ||||
281 | 283 | | |||
282 | d->reportDesigner->adjustSize(); | 284 | d->reportDesigner->adjustSize(); | ||
283 | d->reportDesigner->repaint(); | 285 | d->reportDesigner->repaint(); | ||
284 | | ||||
285 | slotResizeBarDragged(0, false); | | |||
286 | } | 286 | } | ||
287 | 287 | | |||
288 | void KReportDesignerSection::slotSceneClicked() | 288 | void KReportDesignerSection::slotSceneClicked() | ||
289 | { | 289 | { | ||
290 | d->reportDesigner->setActiveScene(d->scene); | 290 | d->reportDesigner->setActiveScene(d->scene); | ||
291 | d->reportDesigner->changeSet(d->sectionData->propertySet()); | 291 | d->reportDesigner->changeSet(d->sectionData->propertySet()); | ||
292 | } | 292 | } | ||
293 | 293 | | |||
294 | void KReportDesignerSection::slotPropertyChanged(KPropertySet &s, KProperty &p) | 294 | void KReportDesignerSection::slotPropertyChanged(KPropertySet &s, KProperty &p) | ||
295 | { | 295 | { | ||
296 | Q_UNUSED(s) | 296 | Q_UNUSED(s) | ||
297 | //kreportDebug() << p.name(); | 297 | //kreportDebug() << p.name(); | ||
298 | 298 | | |||
299 | //Handle Background Color | 299 | //Handle Background Color | ||
300 | if (p.name() == "background-color") { | 300 | if (p.name() == "background-color") { | ||
301 | d->scene->setBackgroundBrush(p.value().value<QColor>()); | 301 | d->scene->setBackgroundBrush(p.value().value<QColor>()); | ||
302 | } | 302 | } | ||
303 | 303 | | |||
304 | if (p.name() == "height") { | 304 | if (p.name() == "height") { | ||
305 | d->scene->setSceneRect(0, 0, d->scene->width(), POINT_TO_INCH(p.value().toDouble()) * d->dpiY); | 305 | d->scene->setSceneRect(0, 0, d->scene->width(), | ||
306 | slotResizeBarDragged(0); | 306 | POINT_TO_INCH(d->sectionData->height()) * d->dpiY); | ||
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(); | ||
314 | } | 314 | } | ||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |