author | leseb <leseb> | 2002-06-07 20:30:30 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-07 20:30:30 (UTC) |
commit | 9dcd598f9b815511cae884d26b18e3c8913b9fcf (patch) (unidiff) | |
tree | 4b18e7fa7c864b2dca4da76bc89c2a975e80a73c /noncore/graphics/drawpad/drawpadcanvas.cpp | |
parent | 640d964cfdc7467f6cacb513087cd3acda2c04f0 (diff) | |
download | opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.zip opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.tar.gz opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.tar.bz2 |
Make progress in thumbnail view
Diffstat (limited to 'noncore/graphics/drawpad/drawpadcanvas.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 79bef35..252f4d5 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -3,49 +3,48 @@ | |||
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #include "drawpadcanvas.h" | 14 | #include "drawpadcanvas.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "newpagedialog.h" | 17 | #include "newpagedialog.h" |
18 | #include "page.h" | 18 | #include "page.h" |
19 | #include "tool.h" | 19 | #include "tool.h" |
20 | 20 | ||
21 | #include <qpe/applnk.h> | 21 | #include <qpe/applnk.h> |
22 | #include <qpe/filemanager.h> | 22 | #include <qpe/filemanager.h> |
23 | #include <qpe/mimetype.h> | 23 | #include <qpe/mimetype.h> |
24 | 24 | ||
25 | #include <qbuffer.h> | 25 | #include <qbuffer.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qmessagebox.h> | ||
28 | #include <qpainter.h> | 27 | #include <qpainter.h> |
29 | #include <qtextcodec.h> | 28 | #include <qtextcodec.h> |
30 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
31 | #include <qxml.h> | 30 | #include <qxml.h> |
32 | 31 | ||
33 | #include <zlib.h> | 32 | #include <zlib.h> |
34 | 33 | ||
35 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler | 34 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler |
36 | { | 35 | { |
37 | public: | 36 | public: |
38 | DrawPadCanvasXmlHandler(); | 37 | DrawPadCanvasXmlHandler(); |
39 | ~DrawPadCanvasXmlHandler(); | 38 | ~DrawPadCanvasXmlHandler(); |
40 | 39 | ||
41 | QList<Page> pages(); | 40 | QList<Page> pages(); |
42 | 41 | ||
43 | bool startElement(const QString& namespaceURI, const QString& localName, | 42 | bool startElement(const QString& namespaceURI, const QString& localName, |
44 | const QString& qName, const QXmlAttributes& atts); | 43 | const QString& qName, const QXmlAttributes& atts); |
45 | bool endElement(const QString& namespaceURI, const QString& localName, | 44 | bool endElement(const QString& namespaceURI, const QString& localName, |
46 | const QString& qName); | 45 | const QString& qName); |
47 | bool characters(const QString& ch); | 46 | bool characters(const QString& ch); |
48 | 47 | ||
49 | private: | 48 | private: |
50 | enum State { | 49 | enum State { |
51 | Unknown, | 50 | Unknown, |
@@ -325,141 +324,111 @@ uint DrawPadCanvas::pagePosition() | |||
325 | 324 | ||
326 | uint DrawPadCanvas::pageCount() | 325 | uint DrawPadCanvas::pageCount() |
327 | { | 326 | { |
328 | return m_pages.count(); | 327 | return m_pages.count(); |
329 | } | 328 | } |
330 | 329 | ||
331 | void DrawPadCanvas::backupPage() | 330 | void DrawPadCanvas::backupPage() |
332 | { | 331 | { |
333 | QPixmap* currentBackup = m_pageBackups.current(); | 332 | QPixmap* currentBackup = m_pageBackups.current(); |
334 | while (m_pageBackups.last() != currentBackup) { | 333 | while (m_pageBackups.last() != currentBackup) { |
335 | m_pageBackups.removeLast(); | 334 | m_pageBackups.removeLast(); |
336 | } | 335 | } |
337 | 336 | ||
338 | while (m_pageBackups.count() >= (5 + 1)) { | 337 | while (m_pageBackups.count() >= (5 + 1)) { |
339 | m_pageBackups.removeFirst(); | 338 | m_pageBackups.removeFirst(); |
340 | } | 339 | } |
341 | 340 | ||
342 | m_pageBackups.append(new Page(*(m_pages.current()))); | 341 | m_pageBackups.append(new Page(*(m_pages.current()))); |
343 | 342 | ||
344 | emit pageBackupsChanged(); | 343 | emit pageBackupsChanged(); |
345 | } | 344 | } |
346 | 345 | ||
347 | void DrawPadCanvas::deleteAll() | 346 | void DrawPadCanvas::deleteAll() |
348 | { | 347 | { |
349 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | ||
350 | QMessageBox::Information, QMessageBox::Yes, | ||
351 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
352 | QMessageBox::NoButton, this); | ||
353 | |||
354 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | ||
355 | messageBox.setButtonText(QMessageBox::No, tr("No")); | ||
356 | |||
357 | if (messageBox.exec() == QMessageBox::Yes) { | ||
358 | m_pages.clear(); | 348 | m_pages.clear(); |
359 | 349 | ||
360 | m_pages.append(new Page(contentsRect().size())); | 350 | m_pages.append(new Page(contentsRect().size())); |
361 | m_pages.current()->fill(Qt::white); | 351 | m_pages.current()->fill(Qt::white); |
362 | 352 | ||
363 | m_pageBackups.clear(); | 353 | m_pageBackups.clear(); |
364 | m_pageBackups.append(new Page(*(m_pages.current()))); | 354 | m_pageBackups.append(new Page(*(m_pages.current()))); |
365 | 355 | ||
366 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 356 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
367 | viewport()->update(); | 357 | viewport()->update(); |
368 | 358 | ||
369 | emit pagesChanged(); | 359 | emit pagesChanged(); |
370 | emit pageBackupsChanged(); | 360 | emit pageBackupsChanged(); |
371 | } | 361 | } |
372 | } | ||
373 | 362 | ||
374 | void DrawPadCanvas::newPage() | 363 | void DrawPadCanvas::newPage() |
375 | { | 364 | { |
376 | QRect rect = contentsRect(); | 365 | QRect rect = contentsRect(); |
377 | 366 | ||
378 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), | 367 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), |
379 | m_pDrawPad->brush().color(), this); | 368 | m_pDrawPad->brush().color(), this); |
380 | 369 | ||
381 | if (newPageDialog.exec() == QDialog::Accepted) { | 370 | if (newPageDialog.exec() == QDialog::Accepted) { |
382 | m_pages.insert(m_pages.at() + 1, new Page(newPageDialog.selectedWidth(), | 371 | m_pages.insert(m_pages.at() + 1, new Page(newPageDialog.selectedWidth(), |
383 | newPageDialog.selectedHeight())); | 372 | newPageDialog.selectedHeight())); |
384 | m_pages.current()->fill(newPageDialog.selectedColor()); | 373 | m_pages.current()->fill(newPageDialog.selectedColor()); |
385 | 374 | ||
386 | m_pageBackups.clear(); | 375 | m_pageBackups.clear(); |
387 | m_pageBackups.append(new Page(*(m_pages.current()))); | 376 | m_pageBackups.append(new Page(*(m_pages.current()))); |
388 | 377 | ||
389 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 378 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
390 | viewport()->update(); | 379 | viewport()->update(); |
391 | 380 | ||
392 | emit pagesChanged(); | 381 | emit pagesChanged(); |
393 | emit pageBackupsChanged(); | 382 | emit pageBackupsChanged(); |
394 | } | 383 | } |
395 | } | 384 | } |
396 | 385 | ||
397 | void DrawPadCanvas::clearPage() | 386 | void DrawPadCanvas::clearPage() |
398 | { | 387 | { |
399 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), | ||
400 | QMessageBox::Information, QMessageBox::Yes, | ||
401 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
402 | QMessageBox::NoButton, this); | ||
403 | |||
404 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | ||
405 | messageBox.setButtonText(QMessageBox::No, tr("No")); | ||
406 | |||
407 | if (messageBox.exec() == QMessageBox::Yes) { | ||
408 | m_pages.current()->fill(Qt::white); | 388 | m_pages.current()->fill(Qt::white); |
409 | 389 | ||
410 | viewport()->update(); | 390 | viewport()->update(); |
411 | } | 391 | } |
412 | } | ||
413 | 392 | ||
414 | void DrawPadCanvas::deletePage() | 393 | void DrawPadCanvas::deletePage() |
415 | { | 394 | { |
416 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), | ||
417 | QMessageBox::Information, QMessageBox::Yes, | ||
418 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
419 | QMessageBox::NoButton, this); | ||
420 | |||
421 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | ||
422 | messageBox.setButtonText(QMessageBox::No, tr("No")); | ||
423 | |||
424 | if (messageBox.exec() == QMessageBox::Yes) { | ||
425 | m_pages.remove(m_pages.current()); | 395 | m_pages.remove(m_pages.current()); |
426 | 396 | ||
427 | if (m_pages.isEmpty()) { | 397 | if (m_pages.isEmpty()) { |
428 | m_pages.append(new Page(contentsRect().size())); | 398 | m_pages.append(new Page(contentsRect().size())); |
429 | m_pages.current()->fill(Qt::white); | 399 | m_pages.current()->fill(Qt::white); |
430 | } | 400 | } |
431 | 401 | ||
432 | m_pageBackups.clear(); | 402 | m_pageBackups.clear(); |
433 | m_pageBackups.append(new Page(*(m_pages.current()))); | 403 | m_pageBackups.append(new Page(*(m_pages.current()))); |
434 | 404 | ||
435 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 405 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
436 | viewport()->update(); | 406 | viewport()->update(); |
437 | 407 | ||
438 | emit pagesChanged(); | 408 | emit pagesChanged(); |
439 | emit pageBackupsChanged(); | 409 | emit pageBackupsChanged(); |
440 | } | 410 | } |
441 | } | ||
442 | 411 | ||
443 | bool DrawPadCanvas::undoEnabled() | 412 | bool DrawPadCanvas::undoEnabled() |
444 | { | 413 | { |
445 | return (m_pageBackups.current() != m_pageBackups.getFirst()); | 414 | return (m_pageBackups.current() != m_pageBackups.getFirst()); |
446 | } | 415 | } |
447 | 416 | ||
448 | bool DrawPadCanvas::redoEnabled() | 417 | bool DrawPadCanvas::redoEnabled() |
449 | { | 418 | { |
450 | return (m_pageBackups.current() != m_pageBackups.getLast()); | 419 | return (m_pageBackups.current() != m_pageBackups.getLast()); |
451 | } | 420 | } |
452 | 421 | ||
453 | bool DrawPadCanvas::goPreviousPageEnabled() | 422 | bool DrawPadCanvas::goPreviousPageEnabled() |
454 | { | 423 | { |
455 | return (m_pages.current() != m_pages.getFirst()); | 424 | return (m_pages.current() != m_pages.getFirst()); |
456 | } | 425 | } |
457 | 426 | ||
458 | bool DrawPadCanvas::goNextPageEnabled() | 427 | bool DrawPadCanvas::goNextPageEnabled() |
459 | { | 428 | { |
460 | return (m_pages.current() != m_pages.getLast()); | 429 | return (m_pages.current() != m_pages.getLast()); |
461 | } | 430 | } |
462 | 431 | ||
463 | void DrawPadCanvas::undo() | 432 | void DrawPadCanvas::undo() |
464 | { | 433 | { |
465 | *(m_pages.current()) = *(m_pageBackups.prev()); | 434 | *(m_pages.current()) = *(m_pageBackups.prev()); |