Diffstat (limited to 'noncore/graphics/drawpad/drawpadcanvas.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 025bebb..dec498b 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -161,61 +161,67 @@ DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name | |||
161 | m_pages.setAutoDelete(true); | 161 | m_pages.setAutoDelete(true); |
162 | 162 | ||
163 | viewport()->setBackgroundMode(QWidget::NoBackground); | 163 | viewport()->setBackgroundMode(QWidget::NoBackground); |
164 | } | 164 | } |
165 | 165 | ||
166 | DrawPadCanvas::~DrawPadCanvas() | 166 | DrawPadCanvas::~DrawPadCanvas() |
167 | { | 167 | { |
168 | } | 168 | } |
169 | 169 | ||
170 | void DrawPadCanvas::load(QIODevice* ioDevice) | 170 | void DrawPadCanvas::load(QIODevice* ioDevice) |
171 | { | 171 | { |
172 | QTextStream textStream(ioDevice); | 172 | QTextStream textStream(ioDevice); |
173 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 173 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
174 | 174 | ||
175 | QXmlInputSource xmlInputSource(textStream); | 175 | QXmlInputSource xmlInputSource(textStream); |
176 | QXmlSimpleReader xmlSimpleReader; | 176 | QXmlSimpleReader xmlSimpleReader; |
177 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; | 177 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; |
178 | 178 | ||
179 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); | 179 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); |
180 | xmlSimpleReader.parse(xmlInputSource); | 180 | xmlSimpleReader.parse(xmlInputSource); |
181 | 181 | ||
182 | m_pages = drawPadCanvasXmlHandler.pages(); | 182 | m_pages = drawPadCanvasXmlHandler.pages(); |
183 | 183 | ||
184 | if (m_pages.isEmpty()) { | 184 | if (m_pages.isEmpty()) { |
185 | m_pages.append(new Page("", contentsRect().size())); | 185 | m_pages.append(new Page("", |
186 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), | ||
187 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); | ||
186 | m_pages.current()->pixmap()->fill(Qt::white); | 188 | m_pages.current()->pixmap()->fill(Qt::white); |
187 | } | 189 | } |
188 | 190 | ||
189 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 191 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
190 | viewport()->update(); | 192 | viewport()->update(); |
191 | 193 | ||
192 | emit pagesChanged(); | 194 | emit pagesChanged(); |
193 | } | 195 | } |
194 | 196 | ||
195 | void DrawPadCanvas::initialPage() | 197 | void DrawPadCanvas::initialPage() |
196 | { | 198 | { |
197 | m_pages.append(new Page("", 236, 232)); | 199 | m_pages.append(new Page("", |
200 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), | ||
201 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); | ||
202 | //236, 232)); no more fixed sizes | ||
203 | |||
198 | m_pages.current()->pixmap()->fill(Qt::white); | 204 | m_pages.current()->pixmap()->fill(Qt::white); |
199 | 205 | ||
200 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 206 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
201 | viewport()->update(); | 207 | viewport()->update(); |
202 | 208 | ||
203 | emit pagesChanged(); | 209 | emit pagesChanged(); |
204 | } | 210 | } |
205 | 211 | ||
206 | void DrawPadCanvas::save(QIODevice* ioDevice) | 212 | void DrawPadCanvas::save(QIODevice* ioDevice) |
207 | { | 213 | { |
208 | QTextStream textStream(ioDevice); | 214 | QTextStream textStream(ioDevice); |
209 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 215 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
210 | 216 | ||
211 | textStream << "<drawpad>" << endl; | 217 | textStream << "<drawpad>" << endl; |
212 | textStream << " <images>" << endl; | 218 | textStream << " <images>" << endl; |
213 | 219 | ||
214 | QListIterator<Page> bufferIterator(m_pages); | 220 | QListIterator<Page> bufferIterator(m_pages); |
215 | 221 | ||
216 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { | 222 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { |
217 | textStream << " <image>" << endl; | 223 | textStream << " <image>" << endl; |
218 | textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; | 224 | textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; |
219 | 225 | ||
220 | int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); | 226 | int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); |
221 | textStream << " <date>" << intDate << "</date>" << endl; | 227 | textStream << " <date>" << intDate << "</date>" << endl; |
@@ -328,82 +334,88 @@ void DrawPadCanvas::selectPage(Page* page) | |||
328 | emit pagesChanged(); | 334 | emit pagesChanged(); |
329 | } | 335 | } |
330 | 336 | ||
331 | void DrawPadCanvas::backupPage() | 337 | void DrawPadCanvas::backupPage() |
332 | { | 338 | { |
333 | m_pages.current()->backup(); | 339 | m_pages.current()->backup(); |
334 | 340 | ||
335 | emit pagesChanged(); | 341 | emit pagesChanged(); |
336 | } | 342 | } |
337 | 343 | ||
338 | void DrawPadCanvas::selectPage(uint pagePosition) | 344 | void DrawPadCanvas::selectPage(uint pagePosition) |
339 | { | 345 | { |
340 | m_pages.at(pagePosition - 1); | 346 | m_pages.at(pagePosition - 1); |
341 | 347 | ||
342 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 348 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
343 | viewport()->update(); | 349 | viewport()->update(); |
344 | 350 | ||
345 | emit pagesChanged(); | 351 | emit pagesChanged(); |
346 | } | 352 | } |
347 | 353 | ||
348 | void DrawPadCanvas::deleteAll() | 354 | void DrawPadCanvas::deleteAll() |
349 | { | 355 | { |
350 | m_pages.clear(); | 356 | m_pages.clear(); |
351 | 357 | ||
352 | m_pages.append(new Page("", contentsRect().size())); | 358 | m_pages.append(new Page("", |
359 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), | ||
360 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); | ||
361 | |||
353 | m_pages.current()->pixmap()->fill(Qt::white); | 362 | m_pages.current()->pixmap()->fill(Qt::white); |
354 | 363 | ||
355 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 364 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
356 | viewport()->update(); | 365 | viewport()->update(); |
357 | 366 | ||
358 | emit pagesChanged(); | 367 | emit pagesChanged(); |
359 | } | 368 | } |
360 | 369 | ||
361 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) | 370 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) |
362 | { | 371 | { |
363 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); | 372 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); |
364 | m_pages.current()->pixmap()->fill(color); | 373 | m_pages.current()->pixmap()->fill(color); |
365 | 374 | ||
366 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 375 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
367 | viewport()->update(); | 376 | viewport()->update(); |
368 | 377 | ||
369 | emit pagesChanged(); | 378 | emit pagesChanged(); |
370 | } | 379 | } |
371 | 380 | ||
372 | void DrawPadCanvas::clearPage() | 381 | void DrawPadCanvas::clearPage() |
373 | { | 382 | { |
374 | m_pages.current()->pixmap()->fill(Qt::white); | 383 | m_pages.current()->pixmap()->fill(Qt::white); |
375 | 384 | ||
376 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 385 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
377 | viewport()->update(); | 386 | viewport()->update(); |
378 | } | 387 | } |
379 | 388 | ||
380 | void DrawPadCanvas::deletePage() | 389 | void DrawPadCanvas::deletePage() |
381 | { | 390 | { |
382 | m_pages.remove(m_pages.current()); | 391 | m_pages.remove(m_pages.current()); |
383 | 392 | ||
384 | if (m_pages.isEmpty()) { | 393 | if (m_pages.isEmpty()) { |
385 | m_pages.append(new Page("", contentsRect().size())); | 394 | m_pages.append(new Page("", |
395 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), | ||
396 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); | ||
397 | |||
386 | m_pages.current()->pixmap()->fill(Qt::white); | 398 | m_pages.current()->pixmap()->fill(Qt::white); |
387 | } | 399 | } |
388 | 400 | ||
389 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 401 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
390 | viewport()->update(); | 402 | viewport()->update(); |
391 | 403 | ||
392 | emit pagesChanged(); | 404 | emit pagesChanged(); |
393 | } | 405 | } |
394 | 406 | ||
395 | void DrawPadCanvas::movePageUp() | 407 | void DrawPadCanvas::movePageUp() |
396 | { | 408 | { |
397 | int index = m_pages.at(); | 409 | int index = m_pages.at(); |
398 | Page* page = m_pages.take(); | 410 | Page* page = m_pages.take(); |
399 | m_pages.insert(index - 1, page); | 411 | m_pages.insert(index - 1, page); |
400 | 412 | ||
401 | emit pagesChanged(); | 413 | emit pagesChanged(); |
402 | } | 414 | } |
403 | 415 | ||
404 | void DrawPadCanvas::movePageDown() | 416 | void DrawPadCanvas::movePageDown() |
405 | { | 417 | { |
406 | int index = m_pages.at(); | 418 | int index = m_pages.at(); |
407 | Page* page = m_pages.take(); | 419 | Page* page = m_pages.take(); |
408 | m_pages.insert(index + 1, page); | 420 | m_pages.insert(index + 1, page); |
409 | 421 | ||