summaryrefslogtreecommitdiff
Unidiff
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
@@ -9,48 +9,50 @@
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;
@@ -351,49 +353,49 @@ uint DrawPadCanvas::pageCount()
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}