summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-19 06:08:54 (UTC)
committer leseb <leseb>2002-06-19 06:08:54 (UTC)
commitb83e9d1f794fdd6089beda10697243bb087e3d0a (patch) (unidiff)
treebdd278f80903fcc9463c3623645967fef8e787fa
parent3e7ae42a203c31d44e0c24a29a9a63772ef56046 (diff)
downloadopie-b83e9d1f794fdd6089beda10697243bb087e3d0a.zip
opie-b83e9d1f794fdd6089beda10697243bb087e3d0a.tar.gz
opie-b83e9d1f794fdd6089beda10697243bb087e3d0a.tar.bz2
99 undo actions
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 4547b41..ae1b554 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -1,80 +1,82 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
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 "page.h" 17#include "page.h"
18#include "tool.h" 18#include "tool.h"
19 19
20#include <qpe/applnk.h> 20#include <qpe/applnk.h>
21#include <qpe/filemanager.h> 21#include <qpe/filemanager.h>
22#include <qpe/mimetype.h> 22#include <qpe/mimetype.h>
23 23
24#include <qbuffer.h> 24#include <qbuffer.h>
25#include <qimage.h> 25#include <qimage.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qtextcodec.h> 27#include <qtextcodec.h>
28#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qxml.h> 29#include <qxml.h>
30 30
31#include <zlib.h> 31#include <zlib.h>
32 32
33const int PAGE_BACKUPS = 99;
34
33class DrawPadCanvasXmlHandler: public QXmlDefaultHandler 35class DrawPadCanvasXmlHandler: public QXmlDefaultHandler
34{ 36{
35public: 37public:
36 DrawPadCanvasXmlHandler(); 38 DrawPadCanvasXmlHandler();
37 ~DrawPadCanvasXmlHandler(); 39 ~DrawPadCanvasXmlHandler();
38 40
39 QList<Page> pages(); 41 QList<Page> pages();
40 42
41 bool startElement(const QString& namespaceURI, const QString& localName, 43 bool startElement(const QString& namespaceURI, const QString& localName,
42 const QString& qName, const QXmlAttributes& atts); 44 const QString& qName, const QXmlAttributes& atts);
43 bool endElement(const QString& namespaceURI, const QString& localName, 45 bool endElement(const QString& namespaceURI, const QString& localName,
44 const QString& qName); 46 const QString& qName);
45 bool characters(const QString& ch); 47 bool characters(const QString& ch);
46 48
47private: 49private:
48 enum State { 50 enum State {
49 Unknown, 51 Unknown,
50 InTitle, 52 InTitle,
51 InDate, 53 InDate,
52 InData 54 InData
53 }; 55 };
54 56
55 State m_state; 57 State m_state;
56 QString m_title; 58 QString m_title;
57 QDateTime m_date; 59 QDateTime m_date;
58 ulong m_dataLenght; 60 ulong m_dataLenght;
59 QString m_dataFormat; 61 QString m_dataFormat;
60 QList<Page> m_pages; 62 QList<Page> m_pages;
61}; 63};
62 64
63DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() 65DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler()
64{ 66{
65 m_state = Unknown; 67 m_state = Unknown;
66} 68}
67 69
68DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() 70DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler()
69{ 71{
70} 72}
71 73
72QList<Page> DrawPadCanvasXmlHandler::pages() 74QList<Page> DrawPadCanvasXmlHandler::pages()
73{ 75{
74 return m_pages; 76 return m_pages;
75} 77}
76 78
77bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, 79bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName,
78 const QString& qName, const QXmlAttributes& atts) 80 const QString& qName, const QXmlAttributes& atts)
79{ 81{
80 Q_CONST_UNUSED(namespaceURI) 82 Q_CONST_UNUSED(namespaceURI)
@@ -327,97 +329,97 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c
327 imageIO.write(); 329 imageIO.write();
328 delete ioDevice; 330 delete ioDevice;
329 } 331 }
330 } 332 }
331} 333}
332 334
333Page* DrawPadCanvas::currentPage() 335Page* DrawPadCanvas::currentPage()
334{ 336{
335 return m_pages.current(); 337 return m_pages.current();
336} 338}
337 339
338QList<Page> DrawPadCanvas::pages() 340QList<Page> DrawPadCanvas::pages()
339{ 341{
340 return m_pages; 342 return m_pages;
341} 343}
342 344
343uint DrawPadCanvas::pagePosition() 345uint DrawPadCanvas::pagePosition()
344{ 346{
345 return (m_pages.at() + 1); 347 return (m_pages.at() + 1);
346} 348}
347 349
348uint DrawPadCanvas::pageCount() 350uint DrawPadCanvas::pageCount()
349{ 351{
350 return m_pages.count(); 352 return m_pages.count();
351} 353}
352 354
353void DrawPadCanvas::selectPage(Page* page) 355void DrawPadCanvas::selectPage(Page* page)
354{ 356{
355 m_pages.findRef(page); 357 m_pages.findRef(page);
356 m_pageBackups.clear(); 358 m_pageBackups.clear();
357 m_pageBackups.append(new Page(*(m_pages.current()))); 359 m_pageBackups.append(new Page(*(m_pages.current())));
358 360
359 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 361 resizeContents(m_pages.current()->width(), m_pages.current()->height());
360 viewport()->update(); 362 viewport()->update();
361 363
362 emit pagesChanged(); 364 emit pagesChanged();
363 emit pageBackupsChanged(); 365 emit pageBackupsChanged();
364} 366}
365 367
366void DrawPadCanvas::backupPage() 368void DrawPadCanvas::backupPage()
367{ 369{
368 m_pages.current()->setLastModified(QDateTime::currentDateTime()); 370 m_pages.current()->setLastModified(QDateTime::currentDateTime());
369 371
370 Page* currentBackup = m_pageBackups.current(); 372 Page* currentBackup = m_pageBackups.current();
371 while (m_pageBackups.last() != currentBackup) { 373 while (m_pageBackups.last() != currentBackup) {
372 m_pageBackups.removeLast(); 374 m_pageBackups.removeLast();
373 } 375 }
374 376
375 while (m_pageBackups.count() >= (5 + 1)) { 377 while (m_pageBackups.count() >= (PAGE_BACKUPS + 1)) {
376 m_pageBackups.removeFirst(); 378 m_pageBackups.removeFirst();
377 } 379 }
378 380
379 m_pageBackups.append(new Page(*(m_pages.current()))); 381 m_pageBackups.append(new Page(*(m_pages.current())));
380 382
381 emit pageBackupsChanged(); 383 emit pageBackupsChanged();
382} 384}
383 385
384void DrawPadCanvas::deleteAll() 386void DrawPadCanvas::deleteAll()
385{ 387{
386 m_pages.clear(); 388 m_pages.clear();
387 389
388 m_pages.append(new Page("", contentsRect().size())); 390 m_pages.append(new Page("", contentsRect().size()));
389 m_pages.current()->fill(Qt::white); 391 m_pages.current()->fill(Qt::white);
390 392
391 m_pageBackups.clear(); 393 m_pageBackups.clear();
392 m_pageBackups.append(new Page(*(m_pages.current()))); 394 m_pageBackups.append(new Page(*(m_pages.current())));
393 395
394 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 396 resizeContents(m_pages.current()->width(), m_pages.current()->height());
395 viewport()->update(); 397 viewport()->update();
396 398
397 emit pagesChanged(); 399 emit pagesChanged();
398 emit pageBackupsChanged(); 400 emit pageBackupsChanged();
399} 401}
400 402
401void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) 403void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color)
402{ 404{
403 m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); 405 m_pages.insert(m_pages.at() + 1, new Page(title, width, height));
404 m_pages.current()->fill(color); 406 m_pages.current()->fill(color);
405 407
406 m_pageBackups.clear(); 408 m_pageBackups.clear();
407 m_pageBackups.append(new Page(*(m_pages.current()))); 409 m_pageBackups.append(new Page(*(m_pages.current())));
408 410
409 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 411 resizeContents(m_pages.current()->width(), m_pages.current()->height());
410 viewport()->update(); 412 viewport()->update();
411 413
412 emit pagesChanged(); 414 emit pagesChanged();
413 emit pageBackupsChanged(); 415 emit pageBackupsChanged();
414} 416}
415 417
416void DrawPadCanvas::clearPage() 418void DrawPadCanvas::clearPage()
417{ 419{
418 m_pages.current()->fill(Qt::white); 420 m_pages.current()->fill(Qt::white);
419 421
420 m_pageBackups.clear(); 422 m_pageBackups.clear();
421 m_pageBackups.append(new Page(*(m_pages.current()))); 423 m_pageBackups.append(new Page(*(m_pages.current())));
422 424
423 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 425 resizeContents(m_pages.current()->width(), m_pages.current()->height());