-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 28 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 146 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/erasetool.cpp | 8 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filltool.cpp | 46 | ||||
-rw-r--r-- | noncore/graphics/drawpad/page.cpp | 60 | ||||
-rw-r--r-- | noncore/graphics/drawpad/page.h | 20 | ||||
-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, 169 insertions, 187 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 | |||
@@ -57,5 +57,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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 | ||
@@ -544,17 +542,3 @@ void DrawPad::changeBrushColor(const QColor& color) | |||
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 | { |
@@ -565,2 +549,10 @@ void DrawPad::updateCaption() | |||
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 | } |
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 | |||
@@ -61,6 +61,4 @@ private slots: | |||
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 | ||
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 | |||
@@ -30,4 +30,2 @@ | |||
30 | 30 | ||
31 | const int PAGE_BACKUPS = 99; | ||
32 | |||
33 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler | 31 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler |
@@ -151,3 +149,3 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch) | |||
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); |
@@ -163,3 +161,2 @@ DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name | |||
163 | m_pages.setAutoDelete(true); | 161 | m_pages.setAutoDelete(true); |
164 | m_pageBackups.setAutoDelete(true); | ||
165 | 162 | ||
@@ -188,9 +185,6 @@ void DrawPadCanvas::load(QIODevice* ioDevice) | |||
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(); |
@@ -198,3 +192,2 @@ void DrawPadCanvas::load(QIODevice* ioDevice) | |||
198 | emit pagesChanged(); | 192 | emit pagesChanged(); |
199 | emit pageBackupsChanged(); | ||
200 | } | 193 | } |
@@ -204,8 +197,5 @@ void DrawPadCanvas::initialPage() | |||
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 | |||
207 | m_pageBackups.clear(); | ||
208 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
209 | 199 | ||
210 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 200 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
211 | viewport()->update(); | 201 | viewport()->update(); |
@@ -213,3 +203,2 @@ void DrawPadCanvas::initialPage() | |||
213 | emit pagesChanged(); | 203 | emit pagesChanged(); |
214 | emit pageBackupsChanged(); | ||
215 | } | 204 | } |
@@ -229,3 +218,3 @@ void DrawPadCanvas::save(QIODevice* ioDevice) | |||
229 | textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; | 218 | textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; |
230 | 219 | ||
231 | int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); | 220 | int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); |
@@ -233,3 +222,3 @@ void DrawPadCanvas::save(QIODevice* ioDevice) | |||
233 | 222 | ||
234 | QImage image = bufferIterator.current()->convertToImage(); | 223 | QImage image = bufferIterator.current()->pixmap()->convertToImage(); |
235 | QByteArray byteArray; | 224 | QByteArray byteArray; |
@@ -265,9 +254,6 @@ void DrawPadCanvas::importPage(const QString& fileName) | |||
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(); |
@@ -275,3 +261,2 @@ void DrawPadCanvas::importPage(const QString& fileName) | |||
275 | emit pagesChanged(); | 261 | emit pagesChanged(); |
276 | emit pageBackupsChanged(); | ||
277 | } | 262 | } |
@@ -291,3 +276,3 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c | |||
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); |
@@ -307,3 +292,3 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c | |||
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); |
@@ -338,6 +323,4 @@ void DrawPadCanvas::selectPage(Page* page) | |||
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(); |
@@ -345,34 +328,19 @@ void DrawPadCanvas::selectPage(Page* page) | |||
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 | } |
@@ -384,8 +352,5 @@ void DrawPadCanvas::deleteAll() | |||
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(); |
@@ -393,3 +358,2 @@ void DrawPadCanvas::deleteAll() | |||
393 | emit pagesChanged(); | 358 | emit pagesChanged(); |
394 | emit pageBackupsChanged(); | ||
395 | } | 359 | } |
@@ -399,8 +363,5 @@ void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor | |||
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(); |
@@ -408,3 +369,2 @@ void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor | |||
408 | emit pagesChanged(); | 369 | emit pagesChanged(); |
409 | emit pageBackupsChanged(); | ||
410 | } | 370 | } |
@@ -413,11 +373,6 @@ 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 | } |
@@ -430,9 +385,6 @@ void DrawPadCanvas::deletePage() | |||
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(); |
@@ -440,3 +392,2 @@ void DrawPadCanvas::deletePage() | |||
440 | emit pagesChanged(); | 392 | emit pagesChanged(); |
441 | emit pageBackupsChanged(); | ||
442 | } | 393 | } |
@@ -461,12 +412,2 @@ void DrawPadCanvas::movePageDown() | |||
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() |
@@ -483,3 +424,3 @@ void DrawPadCanvas::undo() | |||
483 | { | 424 | { |
484 | *(m_pages.current()) = *(m_pageBackups.prev()); | 425 | m_pages.current()->undo(); |
485 | 426 | ||
@@ -487,3 +428,3 @@ void DrawPadCanvas::undo() | |||
487 | 428 | ||
488 | emit pageBackupsChanged(); | 429 | emit pagesChanged(); |
489 | } | 430 | } |
@@ -492,3 +433,3 @@ void DrawPadCanvas::redo() | |||
492 | { | 433 | { |
493 | *(m_pages.current()) = *(m_pageBackups.next()); | 434 | m_pages.current()->redo(); |
494 | 435 | ||
@@ -496,3 +437,3 @@ void DrawPadCanvas::redo() | |||
496 | 437 | ||
497 | emit pageBackupsChanged(); | 438 | emit pagesChanged(); |
498 | } | 439 | } |
@@ -502,6 +443,4 @@ void DrawPadCanvas::goFirstPage() | |||
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(); |
@@ -509,3 +448,2 @@ void DrawPadCanvas::goFirstPage() | |||
509 | emit pagesChanged(); | 448 | emit pagesChanged(); |
510 | emit pageBackupsChanged(); | ||
511 | } | 449 | } |
@@ -515,6 +453,4 @@ void DrawPadCanvas::goPreviousPage() | |||
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(); |
@@ -522,3 +458,2 @@ void DrawPadCanvas::goPreviousPage() | |||
522 | emit pagesChanged(); | 458 | emit pagesChanged(); |
523 | emit pageBackupsChanged(); | ||
524 | } | 459 | } |
@@ -528,6 +463,3 @@ void DrawPadCanvas::goNextPage() | |||
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(); |
@@ -535,3 +467,2 @@ void DrawPadCanvas::goNextPage() | |||
535 | emit pagesChanged(); | 467 | emit pagesChanged(); |
536 | emit pageBackupsChanged(); | ||
537 | } | 468 | } |
@@ -541,6 +472,4 @@ void DrawPadCanvas::goLastPage() | |||
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(); |
@@ -548,3 +477,2 @@ void DrawPadCanvas::goLastPage() | |||
548 | emit pagesChanged(); | 477 | emit pagesChanged(); |
549 | emit pageBackupsChanged(); | ||
550 | } | 478 | } |
@@ -569,6 +497,6 @@ void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | |||
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 | ||
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 | |||
@@ -39,4 +39,2 @@ public: | |||
39 | 39 | ||
40 | bool undoEnabled(); | ||
41 | bool redoEnabled(); | ||
42 | bool goPreviousPageEnabled(); | 40 | bool goPreviousPageEnabled(); |
@@ -60,3 +58,3 @@ public slots: | |||
60 | void movePageDown(); | 58 | void movePageDown(); |
61 | 59 | ||
62 | void undo(); | 60 | void undo(); |
@@ -71,3 +69,2 @@ signals: | |||
71 | void pagesChanged(); | 69 | void pagesChanged(); |
72 | void pageBackupsChanged(); | ||
73 | 70 | ||
@@ -82,3 +79,2 @@ private: | |||
82 | QList<Page> m_pages; | 79 | QList<Page> m_pages; |
83 | QList<Page> m_pageBackups; | ||
84 | }; | 80 | }; |
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 | |||
@@ -34,2 +34,4 @@ void EraseTool::mousePressEvent(QMouseEvent* e) | |||
34 | { | 34 | { |
35 | m_pDrawPadCanvas->backupPage(); | ||
36 | |||
35 | m_mousePressed = true; | 37 | m_mousePressed = true; |
@@ -43,4 +45,2 @@ void EraseTool::mouseReleaseEvent(QMouseEvent* e) | |||
43 | m_mousePressed = false; | 45 | m_mousePressed = false; |
44 | |||
45 | m_pDrawPadCanvas->backupPage(); | ||
46 | } | 46 | } |
@@ -52,3 +52,3 @@ void EraseTool::mouseMoveEvent(QMouseEvent* e) | |||
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); |
@@ -71,3 +71,3 @@ void EraseTool::mouseMoveEvent(QMouseEvent* e) | |||
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 | ||
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 | |||
@@ -37,3 +37,3 @@ void FillTool::mousePressEvent(QMouseEvent* e) | |||
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(); |
@@ -42,2 +42,4 @@ void FillTool::mousePressEvent(QMouseEvent* e) | |||
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()) { |
@@ -60,6 +62,4 @@ void FillTool::mousePressEvent(QMouseEvent* e) | |||
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 | } |
@@ -113,27 +113,27 @@ void FillTool::fillMaskLine(int x, int y) | |||
113 | if (m_mask.pixelIndex(x, y) == 0) { | 113 | if (m_mask.pixelIndex(x, y) == 0) { |
114 | if (rgbDistance(m_image.pixel(x, y), m_oldRgb) < FILL_THRESHOLD) { | 114 | if (rgbDistance(m_image.pixel(x, y), m_oldRgb) < FILL_THRESHOLD) { |
115 | int x1, x2; | 115 | int x1, x2; |
116 | 116 | ||
117 | x1 = x - 1; | 117 | x1 = x - 1; |
118 | x2 = x + 1; | 118 | x2 = x + 1; |
119 | 119 | ||
120 | while ((x1 >= 0) && (rgbDistance(m_image.pixel(x1, y), m_oldRgb) < FILL_THRESHOLD)) { | 120 | while ((x1 >= 0) && (rgbDistance(m_image.pixel(x1, y), m_oldRgb) < FILL_THRESHOLD)) { |
121 | x1--; | 121 | x1--; |
122 | } | 122 | } |
123 | 123 | ||
124 | while ((x2 < m_image.width()) && (rgbDistance(m_image.pixel(x2, y), m_oldRgb) < FILL_THRESHOLD)) { | 124 | while ((x2 < m_image.width()) && (rgbDistance(m_image.pixel(x2, y), m_oldRgb) < FILL_THRESHOLD)) { |
125 | x2++; | 125 | x2++; |
126 | } | 126 | } |
127 | 127 | ||
128 | for (int i = x1 + 1; i < x2; i++) { | 128 | for (int i = x1 + 1; i < x2; i++) { |
129 | m_mask.setPixel(i, y, 1); | 129 | m_mask.setPixel(i, y, 1); |
130 | } | 130 | } |
131 | 131 | ||
132 | for (int i = x1 + 1; i < x2; i++) { | 132 | for (int i = x1 + 1; i < x2; i++) { |
133 | fillMaskLine(i, y - 1); | 133 | fillMaskLine(i, y - 1); |
134 | } | 134 | } |
135 | 135 | ||
136 | for (int i = x1 + 1; i < x2; i++) { | 136 | for (int i = x1 + 1; i < x2; i++) { |
137 | fillMaskLine(i, y + 1); | 137 | fillMaskLine(i, y + 1); |
138 | } | 138 | } |
139 | } | 139 | } |
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 | |||
@@ -15,6 +15,12 @@ | |||
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 | } |
@@ -22,3 +28,2 @@ Page::Page() | |||
22 | Page::Page(QString title, int w, int h) | 28 | Page::Page(QString title, int w, int h) |
23 | : QPixmap(w, h) | ||
24 | { | 29 | { |
@@ -26,2 +31,6 @@ Page::Page(QString title, int w, int h) | |||
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 | } |
@@ -29,3 +38,2 @@ Page::Page(QString title, int w, int h) | |||
29 | Page::Page(QString title, const QSize& size) | 38 | Page::Page(QString title, const QSize& size) |
30 | : QPixmap(size) | ||
31 | { | 39 | { |
@@ -33,2 +41,6 @@ Page::Page(QString title, const QSize& size) | |||
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 | } |
@@ -37,2 +49,3 @@ Page::~Page() | |||
37 | { | 49 | { |
50 | delete m_pPixmap; | ||
38 | } | 51 | } |
@@ -49,2 +62,8 @@ QDateTime Page::lastModified() const | |||
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) |
@@ -59 +78,36 @@ void Page::setLastModified(QDateTime lastModified) | |||
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 | |||
@@ -16,7 +16,9 @@ | |||
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 | { |
@@ -28,5 +30,6 @@ public: | |||
28 | ~Page(); | 30 | ~Page(); |
29 | 31 | ||
30 | QString title() const; | 32 | QString title() const; |
31 | QDateTime lastModified() const; | 33 | QDateTime lastModified() const; |
34 | QPixmap* pixmap() const; | ||
32 | 35 | ||
@@ -35,2 +38,9 @@ public: | |||
35 | 38 | ||
39 | bool undoEnabled(); | ||
40 | bool redoEnabled(); | ||
41 | |||
42 | void backup(); | ||
43 | void undo(); | ||
44 | void redo(); | ||
45 | |||
36 | private: | 46 | private: |
@@ -38,2 +48,6 @@ private: | |||
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 | }; |
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 | |||
@@ -45,6 +45,6 @@ PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const | |||
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 | ||
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 | |||
@@ -35,2 +35,4 @@ void PointTool::mousePressEvent(QMouseEvent* e) | |||
35 | { | 35 | { |
36 | m_pDrawPadCanvas->backupPage(); | ||
37 | |||
36 | m_mousePressed = true; | 38 | m_mousePressed = true; |
@@ -44,4 +46,2 @@ void PointTool::mouseReleaseEvent(QMouseEvent* e) | |||
44 | m_mousePressed = false; | 46 | m_mousePressed = false; |
45 | |||
46 | m_pDrawPadCanvas->backupPage(); | ||
47 | } | 47 | } |
@@ -63,3 +63,3 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) | |||
63 | QPainter painter; | 63 | QPainter painter; |
64 | painter.begin(m_pDrawPadCanvas->currentPage()); | 64 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
65 | 65 | ||
@@ -106,3 +106,3 @@ void PointTool::mouseMoveEvent(QMouseEvent* e) | |||
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 | ||
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 | |||
@@ -34,2 +34,4 @@ void ShapeTool::mousePressEvent(QMouseEvent* e) | |||
34 | { | 34 | { |
35 | m_pDrawPadCanvas->backupPage(); | ||
36 | |||
35 | m_mousePressed = true; | 37 | m_mousePressed = true; |
@@ -43,3 +45,3 @@ void ShapeTool::mouseReleaseEvent(QMouseEvent* e) | |||
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); |
@@ -58,3 +60,3 @@ void ShapeTool::mouseReleaseEvent(QMouseEvent* e) | |||
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 | ||
@@ -63,4 +65,2 @@ void ShapeTool::mouseReleaseEvent(QMouseEvent* e) | |||
63 | m_mousePressed = false; | 65 | m_mousePressed = false; |
64 | |||
65 | m_pDrawPadCanvas->backupPage(); | ||
66 | } | 66 | } |
@@ -72,3 +72,3 @@ void ShapeTool::mouseMoveEvent(QMouseEvent* e) | |||
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); |
@@ -87,3 +87,3 @@ void ShapeTool::mouseMoveEvent(QMouseEvent* e) | |||
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 | ||
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 | |||
@@ -58,4 +58,6 @@ void TextTool::mousePressEvent(QMouseEvent* e) | |||
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()); |
@@ -65,4 +67,2 @@ void TextTool::mousePressEvent(QMouseEvent* e) | |||
65 | m_pDrawPadCanvas->viewport()->update(); | 67 | m_pDrawPadCanvas->viewport()->update(); |
66 | |||
67 | m_pDrawPadCanvas->backupPage(); | ||
68 | } | 68 | } |
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 | |||
@@ -37,3 +37,3 @@ PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) | |||
37 | 37 | ||
38 | QImage image = m_pPage->convertToImage(); | 38 | QImage image = m_pPage->pixmap()->convertToImage(); |
39 | 39 | ||
@@ -59,4 +59,4 @@ PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) | |||
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()); |