-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 28 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 144 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/erasetool.cpp | 8 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filltool.cpp | 8 | ||||
-rw-r--r-- | noncore/graphics/drawpad/page.cpp | 60 | ||||
-rw-r--r-- | noncore/graphics/drawpad/page.h | 18 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pageinformationdialog.cpp | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pointtool.cpp | 8 | ||||
-rw-r--r-- | noncore/graphics/drawpad/shapetool.cpp | 12 | ||||
-rw-r--r-- | noncore/graphics/drawpad/texttool.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 6 |
13 files changed, 146 insertions, 164 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 4eb47a5..b0a414e 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -55,9 +55,7 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
55 | 55 | ||
56 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 56 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
57 | 57 | ||
58 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); | 58 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); |
59 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); | ||
60 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); | ||
61 | 59 | ||
62 | setCentralWidget(m_pDrawPadCanvas); | 60 | setCentralWidget(m_pDrawPadCanvas); |
63 | 61 | ||
@@ -542,27 +540,21 @@ void DrawPad::changeBrushColor(const QColor& color) | |||
542 | m_pBrushColorToolButton->popup()->hide(); | 540 | m_pBrushColorToolButton->popup()->hide(); |
543 | } | 541 | } |
544 | 542 | ||
545 | void DrawPad::updateUndoRedoToolButtons() | 543 | void DrawPad::updateView() |
546 | { | ||
547 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); | ||
548 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled()); | ||
549 | } | ||
550 | |||
551 | void DrawPad::updateNavigationToolButtons() | ||
552 | { | ||
553 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | ||
554 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | ||
555 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | ||
556 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | ||
557 | } | ||
558 | |||
559 | void DrawPad::updateCaption() | ||
560 | { | 544 | { |
561 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); | 545 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); |
562 | uint pageCount = m_pDrawPadCanvas->pageCount(); | 546 | uint pageCount = m_pDrawPadCanvas->pageCount(); |
563 | 547 | ||
564 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " | 548 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " |
565 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); | 549 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); |
550 | |||
551 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); | ||
552 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); | ||
553 | |||
554 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | ||
555 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | ||
556 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | ||
557 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | ||
566 | } | 558 | } |
567 | 559 | ||
568 | void DrawPad::deleteAll() | 560 | void DrawPad::deleteAll() |
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index c57606c..7306228 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -60,9 +60,7 @@ private slots: | |||
60 | void changePenColor(const QColor& color); | 60 | void changePenColor(const QColor& color); |
61 | void changeBrushColor(const QColor& color); | 61 | void changeBrushColor(const QColor& color); |
62 | 62 | ||
63 | void updateUndoRedoToolButtons(); | 63 | void updateView(); |
64 | void updateNavigationToolButtons(); | ||
65 | void updateCaption(); | ||
66 | 64 | ||
67 | void deleteAll(); | 65 | void deleteAll(); |
68 | void importPage(); | 66 | void importPage(); |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 05dd408..025bebb 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -28,8 +28,6 @@ | |||
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qxml.h> | 29 | #include <qxml.h> |
30 | 30 | ||
31 | const int PAGE_BACKUPS = 99; | ||
32 | |||
33 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler | 31 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler |
34 | { | 32 | { |
35 | public: | 33 | public: |
@@ -149,7 +147,7 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch) | |||
149 | 147 | ||
150 | Page* page = new Page(m_title, image.width(), image.height()); | 148 | Page* page = new Page(m_title, image.width(), image.height()); |
151 | page->setLastModified(m_date); | 149 | page->setLastModified(m_date); |
152 | page->convertFromImage(image); | 150 | page->pixmap()->convertFromImage(image); |
153 | m_pages.append(page); | 151 | m_pages.append(page); |
154 | } | 152 | } |
155 | 153 | ||
@@ -161,7 +159,6 @@ DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name | |||
161 | { | 159 | { |
162 | m_pDrawPad = drawPad; | 160 | m_pDrawPad = drawPad; |
163 | m_pages.setAutoDelete(true); | 161 | m_pages.setAutoDelete(true); |
164 | m_pageBackups.setAutoDelete(true); | ||
165 | 162 | ||
166 | viewport()->setBackgroundMode(QWidget::NoBackground); | 163 | viewport()->setBackgroundMode(QWidget::NoBackground); |
167 | } | 164 | } |
@@ -186,32 +183,24 @@ void DrawPadCanvas::load(QIODevice* ioDevice) | |||
186 | 183 | ||
187 | if (m_pages.isEmpty()) { | 184 | if (m_pages.isEmpty()) { |
188 | m_pages.append(new Page("", contentsRect().size())); | 185 | m_pages.append(new Page("", contentsRect().size())); |
189 | m_pages.current()->fill(Qt::white); | 186 | m_pages.current()->pixmap()->fill(Qt::white); |
190 | } | 187 | } |
191 | 188 | ||
192 | m_pageBackups.clear(); | 189 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
193 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
194 | |||
195 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
196 | viewport()->update(); | 190 | viewport()->update(); |
197 | 191 | ||
198 | emit pagesChanged(); | 192 | emit pagesChanged(); |
199 | emit pageBackupsChanged(); | ||
200 | } | 193 | } |
201 | 194 | ||
202 | void DrawPadCanvas::initialPage() | 195 | void DrawPadCanvas::initialPage() |
203 | { | 196 | { |
204 | m_pages.append(new Page("", 236, 232)); | 197 | m_pages.append(new Page("", 236, 232)); |
205 | m_pages.current()->fill(Qt::white); | 198 | m_pages.current()->pixmap()->fill(Qt::white); |
206 | 199 | ||
207 | m_pageBackups.clear(); | 200 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
208 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
209 | |||
210 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
211 | viewport()->update(); | 201 | viewport()->update(); |
212 | 202 | ||
213 | emit pagesChanged(); | 203 | emit pagesChanged(); |
214 | emit pageBackupsChanged(); | ||
215 | } | 204 | } |
216 | 205 | ||
217 | void DrawPadCanvas::save(QIODevice* ioDevice) | 206 | void DrawPadCanvas::save(QIODevice* ioDevice) |
@@ -231,7 +220,7 @@ void DrawPadCanvas::save(QIODevice* ioDevice) | |||
231 | int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); | 220 | int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); |
232 | textStream << " <date>" << intDate << "</date>" << endl; | 221 | textStream << " <date>" << intDate << "</date>" << endl; |
233 | 222 | ||
234 | QImage image = bufferIterator.current()->convertToImage(); | 223 | QImage image = bufferIterator.current()->pixmap()->convertToImage(); |
235 | QByteArray byteArray; | 224 | QByteArray byteArray; |
236 | QBuffer buffer(byteArray); | 225 | QBuffer buffer(byteArray); |
237 | QImageIO imageIO(&buffer, "PNG"); | 226 | QImageIO imageIO(&buffer, "PNG"); |
@@ -263,17 +252,13 @@ void DrawPadCanvas::importPage(const QString& fileName) | |||
263 | { | 252 | { |
264 | Page* importedPage = new Page(); | 253 | Page* importedPage = new Page(); |
265 | 254 | ||
266 | importedPage->load(fileName); | 255 | importedPage->pixmap()->load(fileName); |
267 | m_pages.insert(m_pages.at() + 1, importedPage); | 256 | m_pages.insert(m_pages.at() + 1, importedPage); |
268 | 257 | ||
269 | m_pageBackups.clear(); | 258 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
270 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
271 | |||
272 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
273 | viewport()->update(); | 259 | viewport()->update(); |
274 | 260 | ||
275 | emit pagesChanged(); | 261 | emit pagesChanged(); |
276 | emit pageBackupsChanged(); | ||
277 | } | 262 | } |
278 | 263 | ||
279 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) | 264 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) |
@@ -289,7 +274,7 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c | |||
289 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 274 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
290 | QImageIO imageIO(ioDevice, format); | 275 | QImageIO imageIO(ioDevice, format); |
291 | 276 | ||
292 | QImage image = m_pages.current()->convertToImage(); | 277 | QImage image = m_pages.current()->pixmap()->convertToImage(); |
293 | imageIO.setImage(image); | 278 | imageIO.setImage(image); |
294 | imageIO.write(); | 279 | imageIO.write(); |
295 | delete ioDevice; | 280 | delete ioDevice; |
@@ -305,7 +290,7 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c | |||
305 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 290 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
306 | QImageIO imageIO(ioDevice, format); | 291 | QImageIO imageIO(ioDevice, format); |
307 | 292 | ||
308 | QImage image = m_pages.at(i - 1)->convertToImage(); | 293 | QImage image = m_pages.at(i - 1)->pixmap()->convertToImage(); |
309 | imageIO.setImage(image); | 294 | imageIO.setImage(image); |
310 | imageIO.write(); | 295 | imageIO.write(); |
311 | delete ioDevice; | 296 | delete ioDevice; |
@@ -336,45 +321,28 @@ uint DrawPadCanvas::pageCount() | |||
336 | void DrawPadCanvas::selectPage(Page* page) | 321 | void DrawPadCanvas::selectPage(Page* page) |
337 | { | 322 | { |
338 | m_pages.findRef(page); | 323 | m_pages.findRef(page); |
339 | m_pageBackups.clear(); | ||
340 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
341 | 324 | ||
342 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 325 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
343 | viewport()->update(); | 326 | viewport()->update(); |
344 | 327 | ||
345 | emit pagesChanged(); | 328 | emit pagesChanged(); |
346 | emit pageBackupsChanged(); | ||
347 | } | 329 | } |
348 | 330 | ||
349 | void DrawPadCanvas::selectPage(uint pagePosition) | 331 | void DrawPadCanvas::backupPage() |
350 | { | 332 | { |
351 | m_pages.at(pagePosition - 1); | 333 | m_pages.current()->backup(); |
352 | m_pageBackups.clear(); | ||
353 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
354 | |||
355 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
356 | viewport()->update(); | ||
357 | 334 | ||
358 | emit pagesChanged(); | 335 | emit pagesChanged(); |
359 | emit pageBackupsChanged(); | ||
360 | } | 336 | } |
361 | 337 | ||
362 | void DrawPadCanvas::backupPage() | 338 | void DrawPadCanvas::selectPage(uint pagePosition) |
363 | { | 339 | { |
364 | m_pages.current()->setLastModified(QDateTime::currentDateTime()); | 340 | m_pages.at(pagePosition - 1); |
365 | |||
366 | Page* currentBackup = m_pageBackups.current(); | ||
367 | while (m_pageBackups.last() != currentBackup) { | ||
368 | m_pageBackups.removeLast(); | ||
369 | } | ||
370 | |||
371 | while (m_pageBackups.count() >= (PAGE_BACKUPS + 1)) { | ||
372 | m_pageBackups.removeFirst(); | ||
373 | } | ||
374 | 341 | ||
375 | m_pageBackups.append(new Page(*(m_pages.current()))); | 342 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
343 | viewport()->update(); | ||
376 | 344 | ||
377 | emit pageBackupsChanged(); | 345 | emit pagesChanged(); |
378 | } | 346 | } |
379 | 347 | ||
380 | void DrawPadCanvas::deleteAll() | 348 | void DrawPadCanvas::deleteAll() |
@@ -382,44 +350,31 @@ void DrawPadCanvas::deleteAll() | |||
382 | m_pages.clear(); | 350 | m_pages.clear(); |
383 | 351 | ||
384 | m_pages.append(new Page("", contentsRect().size())); | 352 | m_pages.append(new Page("", contentsRect().size())); |
385 | m_pages.current()->fill(Qt::white); | 353 | m_pages.current()->pixmap()->fill(Qt::white); |
386 | 354 | ||
387 | m_pageBackups.clear(); | 355 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
388 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
389 | |||
390 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
391 | viewport()->update(); | 356 | viewport()->update(); |
392 | 357 | ||
393 | emit pagesChanged(); | 358 | emit pagesChanged(); |
394 | emit pageBackupsChanged(); | ||
395 | } | 359 | } |
396 | 360 | ||
397 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) | 361 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) |
398 | { | 362 | { |
399 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); | 363 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); |
400 | m_pages.current()->fill(color); | 364 | m_pages.current()->pixmap()->fill(color); |
401 | |||
402 | m_pageBackups.clear(); | ||
403 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
404 | 365 | ||
405 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 366 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
406 | viewport()->update(); | 367 | viewport()->update(); |
407 | 368 | ||
408 | emit pagesChanged(); | 369 | emit pagesChanged(); |
409 | emit pageBackupsChanged(); | ||
410 | } | 370 | } |
411 | 371 | ||
412 | void DrawPadCanvas::clearPage() | 372 | void DrawPadCanvas::clearPage() |
413 | { | 373 | { |
414 | m_pages.current()->fill(Qt::white); | 374 | m_pages.current()->pixmap()->fill(Qt::white); |
415 | 375 | ||
416 | m_pageBackups.clear(); | 376 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
417 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
418 | |||
419 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
420 | viewport()->update(); | 377 | viewport()->update(); |
421 | |||
422 | emit pageBackupsChanged(); | ||
423 | } | 378 | } |
424 | 379 | ||
425 | void DrawPadCanvas::deletePage() | 380 | void DrawPadCanvas::deletePage() |
@@ -428,17 +383,13 @@ void DrawPadCanvas::deletePage() | |||
428 | 383 | ||
429 | if (m_pages.isEmpty()) { | 384 | if (m_pages.isEmpty()) { |
430 | m_pages.append(new Page("", contentsRect().size())); | 385 | m_pages.append(new Page("", contentsRect().size())); |
431 | m_pages.current()->fill(Qt::white); | 386 | m_pages.current()->pixmap()->fill(Qt::white); |
432 | } | 387 | } |
433 | 388 | ||
434 | m_pageBackups.clear(); | 389 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
435 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
436 | |||
437 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
438 | viewport()->update(); | 390 | viewport()->update(); |
439 | 391 | ||
440 | emit pagesChanged(); | 392 | emit pagesChanged(); |
441 | emit pageBackupsChanged(); | ||
442 | } | 393 | } |
443 | 394 | ||
444 | void DrawPadCanvas::movePageUp() | 395 | void DrawPadCanvas::movePageUp() |
@@ -459,16 +410,6 @@ void DrawPadCanvas::movePageDown() | |||
459 | emit pagesChanged(); | 410 | emit pagesChanged(); |
460 | } | 411 | } |
461 | 412 | ||
462 | bool DrawPadCanvas::undoEnabled() | ||
463 | { | ||
464 | return (m_pageBackups.current() != m_pageBackups.getFirst()); | ||
465 | } | ||
466 | |||
467 | bool DrawPadCanvas::redoEnabled() | ||
468 | { | ||
469 | return (m_pageBackups.current() != m_pageBackups.getLast()); | ||
470 | } | ||
471 | |||
472 | bool DrawPadCanvas::goPreviousPageEnabled() | 413 | bool DrawPadCanvas::goPreviousPageEnabled() |
473 | { | 414 | { |
474 | return (m_pages.current() != m_pages.getFirst()); | 415 | return (m_pages.current() != m_pages.getFirst()); |
@@ -481,72 +422,59 @@ bool DrawPadCanvas::goNextPageEnabled() | |||
481 | 422 | ||
482 | void DrawPadCanvas::undo() | 423 | void DrawPadCanvas::undo() |
483 | { | 424 | { |
484 | *(m_pages.current()) = *(m_pageBackups.prev()); | 425 | m_pages.current()->undo(); |
485 | 426 | ||
486 | viewport()->update(); | 427 | viewport()->update(); |
487 | 428 | ||
488 | emit pageBackupsChanged(); | 429 | emit pagesChanged(); |
489 | } | 430 | } |
490 | 431 | ||
491 | void DrawPadCanvas::redo() | 432 | void DrawPadCanvas::redo() |
492 | { | 433 | { |
493 | *(m_pages.current()) = *(m_pageBackups.next()); | 434 | m_pages.current()->redo(); |
494 | 435 | ||
495 | viewport()->update(); | 436 | viewport()->update(); |
496 | 437 | ||
497 | emit pageBackupsChanged(); | 438 | emit pagesChanged(); |
498 | } | 439 | } |
499 | 440 | ||
500 | void DrawPadCanvas::goFirstPage() | 441 | void DrawPadCanvas::goFirstPage() |
501 | { | 442 | { |
502 | m_pages.first(); | 443 | m_pages.first(); |
503 | m_pageBackups.clear(); | ||
504 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
505 | 444 | ||
506 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 445 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
507 | viewport()->update(); | 446 | viewport()->update(); |
508 | 447 | ||
509 | emit pagesChanged(); | 448 | emit pagesChanged(); |
510 | emit pageBackupsChanged(); | ||
511 | } | 449 | } |
512 | 450 | ||
513 | void DrawPadCanvas::goPreviousPage() | 451 | void DrawPadCanvas::goPreviousPage() |
514 | { | 452 | { |
515 | m_pages.prev(); | 453 | m_pages.prev(); |
516 | m_pageBackups.clear(); | ||
517 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
518 | 454 | ||
519 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 455 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
520 | viewport()->update(); | 456 | viewport()->update(); |
521 | 457 | ||
522 | emit pagesChanged(); | 458 | emit pagesChanged(); |
523 | emit pageBackupsChanged(); | ||
524 | } | 459 | } |
525 | 460 | ||
526 | void DrawPadCanvas::goNextPage() | 461 | void DrawPadCanvas::goNextPage() |
527 | { | 462 | { |
528 | m_pages.next(); | 463 | m_pages.next(); |
529 | m_pageBackups.clear(); | 464 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
530 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
531 | |||
532 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
533 | viewport()->update(); | 465 | viewport()->update(); |
534 | 466 | ||
535 | emit pagesChanged(); | 467 | emit pagesChanged(); |
536 | emit pageBackupsChanged(); | ||
537 | } | 468 | } |
538 | 469 | ||
539 | void DrawPadCanvas::goLastPage() | 470 | void DrawPadCanvas::goLastPage() |
540 | { | 471 | { |
541 | m_pages.last(); | 472 | m_pages.last(); |
542 | m_pageBackups.clear(); | ||
543 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
544 | 473 | ||
545 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 474 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
546 | viewport()->update(); | 475 | viewport()->update(); |
547 | 476 | ||
548 | emit pagesChanged(); | 477 | emit pagesChanged(); |
549 | emit pageBackupsChanged(); | ||
550 | } | 478 | } |
551 | 479 | ||
552 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | 480 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) |
@@ -567,10 +495,10 @@ void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) | |||
567 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 495 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
568 | { | 496 | { |
569 | QRect clipRect(cx, cy, cw, ch); | 497 | QRect clipRect(cx, cy, cw, ch); |
570 | QRect pixmapRect(0, 0, m_pages.current()->width(), m_pages.current()->height()); | 498 | QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
571 | QRect drawRect = pixmapRect.intersect(clipRect); | 499 | QRect drawRect = pixmapRect.intersect(clipRect); |
572 | 500 | ||
573 | p->drawPixmap(drawRect.topLeft(), *(m_pages.current()), drawRect); | 501 | p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect); |
574 | 502 | ||
575 | if (drawRect.right() < clipRect.right()) { | 503 | if (drawRect.right() < clipRect.right()) { |
576 | p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); | 504 | p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index 2283e5e..80a2a7e 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -37,8 +37,6 @@ public: | |||
37 | void importPage(const QString& fileName); | 37 | void importPage(const QString& fileName); |
38 | void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); | 38 | void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); |
39 | 39 | ||
40 | bool undoEnabled(); | ||
41 | bool redoEnabled(); | ||
42 | bool goPreviousPageEnabled(); | 40 | bool goPreviousPageEnabled(); |
43 | bool goNextPageEnabled(); | 41 | bool goNextPageEnabled(); |
44 | 42 | ||
@@ -69,7 +67,6 @@ public slots: | |||
69 | 67 | ||
70 | signals: | 68 | signals: |
71 | void pagesChanged(); | 69 | void pagesChanged(); |
72 | void pageBackupsChanged(); | ||
73 | 70 | ||
74 | protected: | 71 | protected: |
75 | void contentsMousePressEvent(QMouseEvent* e); | 72 | void contentsMousePressEvent(QMouseEvent* e); |
@@ -80,7 +77,6 @@ protected: | |||
80 | private: | 77 | private: |
81 | DrawPad* m_pDrawPad; | 78 | DrawPad* m_pDrawPad; |
82 | QList<Page> m_pages; | 79 | QList<Page> m_pages; |
83 | QList<Page> m_pageBackups; | ||
84 | }; | 80 | }; |
85 | 81 | ||
86 | #endif // DRAWPADCANVAS_H | 82 | #endif // DRAWPADCANVAS_H |
diff --git a/noncore/graphics/drawpad/erasetool.cpp b/noncore/graphics/drawpad/erasetool.cpp index f77e038..2326da5 100644 --- a/noncore/graphics/drawpad/erasetool.cpp +++ b/noncore/graphics/drawpad/erasetool.cpp | |||
@@ -32,6 +32,8 @@ EraseTool::~EraseTool() | |||
32 | 32 | ||
33 | void EraseTool::mousePressEvent(QMouseEvent* e) | 33 | void EraseTool::mousePressEvent(QMouseEvent* e) |
34 | { | 34 | { |
35 | m_pDrawPadCanvas->backupPage(); | ||
36 | |||
35 | m_mousePressed = true; | 37 | m_mousePressed = true; |
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 38 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
37 | } | 39 | } |
@@ -41,8 +43,6 @@ void EraseTool::mouseReleaseEvent(QMouseEvent* e) | |||
41 | Q_UNUSED(e) | 43 | Q_UNUSED(e) |
42 | 44 | ||
43 | m_mousePressed = false; | 45 | m_mousePressed = false; |
44 | |||
45 | m_pDrawPadCanvas->backupPage(); | ||
46 | } | 46 | } |
47 | 47 | ||
48 | void EraseTool::mouseMoveEvent(QMouseEvent* e) | 48 | void EraseTool::mouseMoveEvent(QMouseEvent* e) |
@@ -50,7 +50,7 @@ void EraseTool::mouseMoveEvent(QMouseEvent* e) | |||
50 | if (m_mousePressed) { | 50 | if (m_mousePressed) { |
51 | QPainter painter; | 51 | QPainter painter; |
52 | QPen pen(Qt::white, m_pDrawPad->pen().width()); | 52 | QPen pen(Qt::white, m_pDrawPad->pen().width()); |
53 | painter.begin(m_pDrawPadCanvas->currentPage()); | 53 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
54 | painter.setPen(pen); | 54 | painter.setPen(pen); |
55 | m_polyline[2] = m_polyline[1]; | 55 | m_polyline[2] = m_polyline[1]; |
56 | m_polyline[1] = m_polyline[0]; | 56 | m_polyline[1] = m_polyline[0]; |
@@ -69,7 +69,7 @@ void EraseTool::mouseMoveEvent(QMouseEvent* e) | |||
69 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 69 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
70 | 70 | ||
71 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 71 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
72 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 72 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
73 | 73 | ||
74 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 74 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
75 | } | 75 | } |
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp index 0177e1c..2a39d04 100644 --- a/noncore/graphics/drawpad/filltool.cpp +++ b/noncore/graphics/drawpad/filltool.cpp | |||
@@ -35,11 +35,13 @@ void FillTool::mousePressEvent(QMouseEvent* e) | |||
35 | int x = e->x(); | 35 | int x = e->x(); |
36 | int y = e->y(); | 36 | int y = e->y(); |
37 | 37 | ||
38 | m_image = m_pDrawPadCanvas->currentPage()->convertToImage(); | 38 | m_image = m_pDrawPadCanvas->currentPage()->pixmap()->convertToImage(); |
39 | m_fillRgb = m_pDrawPad->brush().color().rgb(); | 39 | m_fillRgb = m_pDrawPad->brush().color().rgb(); |
40 | m_oldRgb = m_image.pixel(x, y); | 40 | m_oldRgb = m_image.pixel(x, y); |
41 | 41 | ||
42 | if (m_oldRgb != m_fillRgb) { | 42 | if (m_oldRgb != m_fillRgb) { |
43 | m_pDrawPadCanvas->backupPage(); | ||
44 | |||
43 | if (m_pDrawPad->antiAliasing()) { | 45 | if (m_pDrawPad->antiAliasing()) { |
44 | m_mask.create(m_image.width(), m_image.height(), 8, 2); | 46 | m_mask.create(m_image.width(), m_image.height(), 8, 2); |
45 | m_mask.fill(0); | 47 | m_mask.fill(0); |
@@ -58,10 +60,8 @@ void FillTool::mousePressEvent(QMouseEvent* e) | |||
58 | fillLine(x, y); | 60 | fillLine(x, y); |
59 | } | 61 | } |
60 | 62 | ||
61 | m_pDrawPadCanvas->currentPage()->convertFromImage(m_image); | 63 | m_pDrawPadCanvas->currentPage()->pixmap()->convertFromImage(m_image); |
62 | m_pDrawPadCanvas->viewport()->update(); | 64 | m_pDrawPadCanvas->viewport()->update(); |
63 | |||
64 | m_pDrawPadCanvas->backupPage(); | ||
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
diff --git a/noncore/graphics/drawpad/page.cpp b/noncore/graphics/drawpad/page.cpp index 601d1c3..fbf3d01 100644 --- a/noncore/graphics/drawpad/page.cpp +++ b/noncore/graphics/drawpad/page.cpp | |||
@@ -13,28 +13,41 @@ | |||
13 | 13 | ||
14 | #include "page.h" | 14 | #include "page.h" |
15 | 15 | ||
16 | const int PAGE_BACKUPS = 99; | ||
17 | |||
16 | Page::Page() | 18 | Page::Page() |
17 | : QPixmap() | ||
18 | { | 19 | { |
20 | m_title = ""; | ||
19 | m_lastModified = QDateTime::currentDateTime(); | 21 | m_lastModified = QDateTime::currentDateTime(); |
22 | m_pPixmap = new QPixmap(); | ||
23 | |||
24 | m_backHistory.setAutoDelete(true); | ||
25 | m_forwardHistory.setAutoDelete(true); | ||
20 | } | 26 | } |
21 | 27 | ||
22 | Page::Page(QString title, int w, int h) | 28 | Page::Page(QString title, int w, int h) |
23 | : QPixmap(w, h) | ||
24 | { | 29 | { |
25 | m_title = title; | 30 | m_title = title; |
26 | m_lastModified = QDateTime::currentDateTime(); | 31 | m_lastModified = QDateTime::currentDateTime(); |
32 | m_pPixmap = new QPixmap(w, h); | ||
33 | |||
34 | m_backHistory.setAutoDelete(true); | ||
35 | m_forwardHistory.setAutoDelete(true); | ||
27 | } | 36 | } |
28 | 37 | ||
29 | Page::Page(QString title, const QSize& size) | 38 | Page::Page(QString title, const QSize& size) |
30 | : QPixmap(size) | ||
31 | { | 39 | { |
32 | m_title = title; | 40 | m_title = title; |
33 | m_lastModified = QDateTime::currentDateTime(); | 41 | m_lastModified = QDateTime::currentDateTime(); |
42 | m_pPixmap = new QPixmap(size); | ||
43 | |||
44 | m_backHistory.setAutoDelete(true); | ||
45 | m_forwardHistory.setAutoDelete(true); | ||
34 | } | 46 | } |
35 | 47 | ||
36 | Page::~Page() | 48 | Page::~Page() |
37 | { | 49 | { |
50 | delete m_pPixmap; | ||
38 | } | 51 | } |
39 | 52 | ||
40 | QString Page::title() const | 53 | QString Page::title() const |
@@ -47,6 +60,12 @@ QDateTime Page::lastModified() const | |||
47 | return m_lastModified; | 60 | return m_lastModified; |
48 | } | 61 | } |
49 | 62 | ||
63 | QPixmap* Page::pixmap() const | ||
64 | |||
65 | { | ||
66 | return m_pPixmap; | ||
67 | } | ||
68 | |||
50 | void Page::setTitle(QString title) | 69 | void Page::setTitle(QString title) |
51 | { | 70 | { |
52 | m_title = title; | 71 | m_title = title; |
@@ -57,3 +76,38 @@ void Page::setLastModified(QDateTime lastModified) | |||
57 | m_lastModified = lastModified; | 76 | m_lastModified = lastModified; |
58 | } | 77 | } |
59 | 78 | ||
79 | bool Page::undoEnabled() | ||
80 | { | ||
81 | return (!m_backHistory.isEmpty()); | ||
82 | } | ||
83 | |||
84 | bool Page::redoEnabled() | ||
85 | { | ||
86 | return (!m_forwardHistory.isEmpty()); | ||
87 | } | ||
88 | |||
89 | void Page::backup() | ||
90 | { | ||
91 | setLastModified(QDateTime::currentDateTime()); | ||
92 | |||
93 | while (m_backHistory.count() >= (PAGE_BACKUPS + 1)) { | ||
94 | m_backHistory.removeFirst(); | ||
95 | } | ||
96 | |||
97 | m_backHistory.append(new QPixmap(*m_pPixmap)); | ||
98 | m_forwardHistory.clear(); | ||
99 | } | ||
100 | |||
101 | void Page::undo() | ||
102 | { | ||
103 | m_forwardHistory.append(new QPixmap(*m_pPixmap)); | ||
104 | m_pPixmap = new QPixmap(*(m_backHistory.last())); | ||
105 | m_backHistory.removeLast(); | ||
106 | } | ||
107 | |||
108 | void Page::redo() | ||
109 | { | ||
110 | m_backHistory.append(new QPixmap(*m_pPixmap)); | ||
111 | m_pPixmap = new QPixmap(*(m_forwardHistory.last())); | ||
112 | m_forwardHistory.removeLast(); | ||
113 | } | ||
diff --git a/noncore/graphics/drawpad/page.h b/noncore/graphics/drawpad/page.h index 20a37b5..8ce7bc9 100644 --- a/noncore/graphics/drawpad/page.h +++ b/noncore/graphics/drawpad/page.h | |||
@@ -14,11 +14,13 @@ | |||
14 | #ifndef PAGE_H | 14 | #ifndef PAGE_H |
15 | #define PAGE_H | 15 | #define PAGE_H |
16 | 16 | ||
17 | #include <qpixmap.h> | 17 | #include <qobject.h> |
18 | 18 | ||
19 | #include <qdatetime.h> | 19 | #include <qdatetime.h> |
20 | #include <qlist.h> | ||
21 | #include <qpixmap.h> | ||
20 | 22 | ||
21 | class Page : public QPixmap | 23 | class Page : public QObject |
22 | { | 24 | { |
23 | public: | 25 | public: |
24 | Page(); | 26 | Page(); |
@@ -29,13 +31,25 @@ public: | |||
29 | 31 | ||
30 | QString title() const; | 32 | QString title() const; |
31 | QDateTime lastModified() const; | 33 | QDateTime lastModified() const; |
34 | QPixmap* pixmap() const; | ||
32 | 35 | ||
33 | void setTitle(QString title); | 36 | void setTitle(QString title); |
34 | void setLastModified(QDateTime lastModified); | 37 | void setLastModified(QDateTime lastModified); |
35 | 38 | ||
39 | bool undoEnabled(); | ||
40 | bool redoEnabled(); | ||
41 | |||
42 | void backup(); | ||
43 | void undo(); | ||
44 | void redo(); | ||
45 | |||
36 | private: | 46 | private: |
37 | QString m_title; | 47 | QString m_title; |
38 | QDateTime m_lastModified; | 48 | QDateTime m_lastModified; |
49 | QPixmap* m_pPixmap; | ||
50 | |||
51 | QList<QPixmap> m_backHistory; | ||
52 | QList<QPixmap> m_forwardHistory; | ||
39 | }; | 53 | }; |
40 | 54 | ||
41 | #endif // PAGE_H | 55 | #endif // PAGE_H |
diff --git a/noncore/graphics/drawpad/pageinformationdialog.cpp b/noncore/graphics/drawpad/pageinformationdialog.cpp index c0d055e..cb14d73 100644 --- a/noncore/graphics/drawpad/pageinformationdialog.cpp +++ b/noncore/graphics/drawpad/pageinformationdialog.cpp | |||
@@ -43,10 +43,10 @@ PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const | |||
43 | QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this); | 43 | QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this); |
44 | 44 | ||
45 | QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox); | 45 | QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox); |
46 | QLabel* widthValueLabel = new QLabel(QString::number(m_pPage->width()), sizeGroupBox); | 46 | QLabel* widthValueLabel = new QLabel(QString::number(m_pPage->pixmap()->width()), sizeGroupBox); |
47 | 47 | ||
48 | QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox); | 48 | QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox); |
49 | QLabel* heightValueLabel = new QLabel(QString::number(m_pPage->height()), sizeGroupBox); | 49 | QLabel* heightValueLabel = new QLabel(QString::number(m_pPage->pixmap()->height()), sizeGroupBox); |
50 | 50 | ||
51 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 51 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
52 | generalGroupBox->layout()->setSpacing(4); | 52 | generalGroupBox->layout()->setSpacing(4); |
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp index a4f846e..b9b52bc 100644 --- a/noncore/graphics/drawpad/pointtool.cpp +++ b/noncore/graphics/drawpad/pointtool.cpp | |||
@@ -33,6 +33,8 @@ PointTool::~PointTool() | |||
33 | 33 | ||
34 | void PointTool::mousePressEvent(QMouseEvent* e) | 34 | void PointTool::mousePressEvent(QMouseEvent* e) |
35 | { | 35 | { |
36 | m_pDrawPadCanvas->backupPage(); | ||
37 | |||
36 | m_mousePressed = true; | 38 | m_mousePressed = true; |
37 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 39 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
38 | } | 40 | } |
@@ -42,8 +44,6 @@ void PointTool::mouseReleaseEvent(QMouseEvent* e) | |||
42 | Q_UNUSED(e) | 44 | Q_UNUSED(e) |
43 | 45 | ||
44 | m_mousePressed = false; | 46 | m_mousePressed = false; |
45 | |||
46 | m_pDrawPadCanvas->backupPage(); | ||
47 | } | 47 | } |
48 | 48 | ||
49 | void PointTool::mouseMoveEvent(QMouseEvent* e) | 49 | void PointTool::mouseMoveEvent(QMouseEvent* e) |
@@ -61,7 +61,7 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) | |||
61 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 61 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
62 | 62 | ||
63 | QPainter painter; | 63 | QPainter painter; |
64 | painter.begin(m_pDrawPadCanvas->currentPage()); | 64 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
65 | 65 | ||
66 | if (m_pDrawPad->antiAliasing()) { | 66 | if (m_pDrawPad->antiAliasing()) { |
67 | QPixmap areaPixmap(r.width(), r.height()); | 67 | QPixmap areaPixmap(r.width(), r.height()); |
@@ -104,7 +104,7 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) | |||
104 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 104 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
105 | 105 | ||
106 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 106 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
107 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 107 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
108 | 108 | ||
109 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 109 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
110 | } | 110 | } |
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp index 8870a78..22e3dd6 100644 --- a/noncore/graphics/drawpad/shapetool.cpp +++ b/noncore/graphics/drawpad/shapetool.cpp | |||
@@ -32,6 +32,8 @@ ShapeTool::~ShapeTool() | |||
32 | 32 | ||
33 | void ShapeTool::mousePressEvent(QMouseEvent* e) | 33 | void ShapeTool::mousePressEvent(QMouseEvent* e) |
34 | { | 34 | { |
35 | m_pDrawPadCanvas->backupPage(); | ||
36 | |||
35 | m_mousePressed = true; | 37 | m_mousePressed = true; |
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 38 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
37 | } | 39 | } |
@@ -41,7 +43,7 @@ void ShapeTool::mouseReleaseEvent(QMouseEvent* e) | |||
41 | Q_UNUSED(e) | 43 | Q_UNUSED(e) |
42 | 44 | ||
43 | QPainter painter; | 45 | QPainter painter; |
44 | painter.begin(m_pDrawPadCanvas->currentPage()); | 46 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
45 | drawFinalShape(painter); | 47 | drawFinalShape(painter); |
46 | painter.end(); | 48 | painter.end(); |
47 | 49 | ||
@@ -56,13 +58,11 @@ void ShapeTool::mouseReleaseEvent(QMouseEvent* e) | |||
56 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 58 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
57 | 59 | ||
58 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 60 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
59 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 61 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
60 | 62 | ||
61 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 63 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
62 | 64 | ||
63 | m_mousePressed = false; | 65 | m_mousePressed = false; |
64 | |||
65 | m_pDrawPadCanvas->backupPage(); | ||
66 | } | 66 | } |
67 | 67 | ||
68 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) | 68 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) |
@@ -70,7 +70,7 @@ void ShapeTool::mouseMoveEvent(QMouseEvent* e) | |||
70 | if (m_mousePressed) { | 70 | if (m_mousePressed) { |
71 | m_polyline[0] = e->pos(); | 71 | m_polyline[0] = e->pos(); |
72 | QPainter painter; | 72 | QPainter painter; |
73 | painter.begin(m_pDrawPadCanvas->currentPage()); | 73 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
74 | drawTemporaryShape(painter); | 74 | drawTemporaryShape(painter); |
75 | painter.end(); | 75 | painter.end(); |
76 | 76 | ||
@@ -85,7 +85,7 @@ void ShapeTool::mouseMoveEvent(QMouseEvent* e) | |||
85 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 85 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
86 | 86 | ||
87 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 87 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
88 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 88 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
89 | 89 | ||
90 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 90 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
91 | 91 | ||
diff --git a/noncore/graphics/drawpad/texttool.cpp b/noncore/graphics/drawpad/texttool.cpp index 34c8a76..9037abd 100644 --- a/noncore/graphics/drawpad/texttool.cpp +++ b/noncore/graphics/drawpad/texttool.cpp | |||
@@ -56,15 +56,15 @@ void TextTool::mousePressEvent(QMouseEvent* e) | |||
56 | TextToolDialog textToolDialog(m_pDrawPad); | 56 | TextToolDialog textToolDialog(m_pDrawPad); |
57 | 57 | ||
58 | if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) { | 58 | if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) { |
59 | m_pDrawPadCanvas->backupPage(); | ||
60 | |||
59 | QPainter painter; | 61 | QPainter painter; |
60 | painter.begin(m_pDrawPadCanvas->currentPage()); | 62 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
61 | painter.setPen(m_pDrawPad->pen()); | 63 | painter.setPen(m_pDrawPad->pen()); |
62 | painter.drawText(e->x(), e->y(), textToolDialog.text()); | 64 | painter.drawText(e->x(), e->y(), textToolDialog.text()); |
63 | painter.end(); | 65 | painter.end(); |
64 | 66 | ||
65 | m_pDrawPadCanvas->viewport()->update(); | 67 | m_pDrawPadCanvas->viewport()->update(); |
66 | |||
67 | m_pDrawPadCanvas->backupPage(); | ||
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 14092bf..9b08ca2 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp | |||
@@ -35,7 +35,7 @@ PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) | |||
35 | { | 35 | { |
36 | m_pPage = page; | 36 | m_pPage = page; |
37 | 37 | ||
38 | QImage image = m_pPage->convertToImage(); | 38 | QImage image = m_pPage->pixmap()->convertToImage(); |
39 | 39 | ||
40 | int previewWidth = THUMBNAIL_SIZE; | 40 | int previewWidth = THUMBNAIL_SIZE; |
41 | int previewHeight = THUMBNAIL_SIZE; | 41 | int previewHeight = THUMBNAIL_SIZE; |
@@ -57,8 +57,8 @@ PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) | |||
57 | m_thumbnail.convertFromImage(thumbnailImage); | 57 | m_thumbnail.convertFromImage(thumbnailImage); |
58 | 58 | ||
59 | m_titleText = QObject::tr("Title:") + " " + m_pPage->title(); | 59 | m_titleText = QObject::tr("Title:") + " " + m_pPage->title(); |
60 | m_dimensionText = QObject::tr("Dimension:") + " " + QString::number(m_pPage->width()) | 60 | m_dimensionText = QObject::tr("Dimension:") + " " + QString::number(m_pPage->pixmap()->width()) |
61 | + "x" + QString::number(m_pPage->height()); | 61 | + "x" + QString::number(m_pPage->pixmap()->height()); |
62 | m_dateText = QObject::tr("Date:") + " " + dateTimeString(m_pPage->lastModified()); | 62 | m_dateText = QObject::tr("Date:") + " " + dateTimeString(m_pPage->lastModified()); |
63 | 63 | ||
64 | QColor baseColor = parent->colorGroup().base(); | 64 | QColor baseColor = parent->colorGroup().base(); |