author | leseb <leseb> | 2002-06-06 20:51:27 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-06 20:51:27 (UTC) |
commit | 43bde653ce03f4c5202860f4e23c7612144a38f0 (patch) (unidiff) | |
tree | aa89f01ade2667699e2d9ba69daabb9810e48c35 | |
parent | 38946b6ef966a154d979d7dd254cf463f6dadbe5 (diff) | |
download | opie-43bde653ce03f4c5202860f4e23c7612144a38f0.zip opie-43bde653ce03f4c5202860f4e23c7612144a38f0.tar.gz opie-43bde653ce03f4c5202860f4e23c7612144a38f0.tar.bz2 |
New page class, thumbnail view draft
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 15 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.pro | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 64 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 11 | ||||
-rw-r--r-- | noncore/graphics/drawpad/erasetool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filltool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/page.cpp | 33 | ||||
-rw-r--r-- | noncore/graphics/drawpad/page.h | 29 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pointtool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/shapetool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/texttool.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 121 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.h | 40 |
14 files changed, 285 insertions, 43 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 74787e5..b325323 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -16,24 +16,25 @@ | |||
16 | #include "drawpadcanvas.h" | 16 | #include "drawpadcanvas.h" |
17 | #include "ellipsetool.h" | 17 | #include "ellipsetool.h" |
18 | #include "erasetool.h" | 18 | #include "erasetool.h" |
19 | #include "exportdialog.h" | 19 | #include "exportdialog.h" |
20 | #include "filledellipsetool.h" | 20 | #include "filledellipsetool.h" |
21 | #include "filledrectangletool.h" | 21 | #include "filledrectangletool.h" |
22 | #include "filltool.h" | 22 | #include "filltool.h" |
23 | #include "importdialog.h" | 23 | #include "importdialog.h" |
24 | #include "linetool.h" | 24 | #include "linetool.h" |
25 | #include "pointtool.h" | 25 | #include "pointtool.h" |
26 | #include "rectangletool.h" | 26 | #include "rectangletool.h" |
27 | #include "texttool.h" | 27 | #include "texttool.h" |
28 | #include "thumbnailview.h" | ||
28 | 29 | ||
29 | #include <opie/colordialog.h> | 30 | #include <opie/colordialog.h> |
30 | #include <opie/colorpopupmenu.h> | 31 | #include <opie/colorpopupmenu.h> |
31 | 32 | ||
32 | #include <qpe/applnk.h> | 33 | #include <qpe/applnk.h> |
33 | #include <qpe/global.h> | 34 | #include <qpe/global.h> |
34 | #include <qpe/qpemenubar.h> | 35 | #include <qpe/qpemenubar.h> |
35 | #include <qpe/qpetoolbar.h> | 36 | #include <qpe/qpetoolbar.h> |
36 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
37 | 38 | ||
38 | #include <qaction.h> | 39 | #include <qaction.h> |
39 | #include <qfile.h> | 40 | #include <qfile.h> |
@@ -69,24 +70,30 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
69 | deleteAllAction->addTo(toolsPopupMenu); | 70 | deleteAllAction->addTo(toolsPopupMenu); |
70 | 71 | ||
71 | toolsPopupMenu->insertSeparator(); | 72 | toolsPopupMenu->insertSeparator(); |
72 | 73 | ||
73 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 74 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
74 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 75 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
75 | importPageAction->addTo(toolsPopupMenu); | 76 | importPageAction->addTo(toolsPopupMenu); |
76 | 77 | ||
77 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 78 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
78 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 79 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
79 | exportPageAction->addTo(toolsPopupMenu); | 80 | exportPageAction->addTo(toolsPopupMenu); |
80 | 81 | ||
82 | toolsPopupMenu->insertSeparator(); | ||
83 | |||
84 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); | ||
85 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); | ||
86 | thumbnailViewAction->addTo(toolsPopupMenu); | ||
87 | |||
81 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); | 88 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); |
82 | 89 | ||
83 | // init page toolbar | 90 | // init page toolbar |
84 | 91 | ||
85 | QPEToolBar* pageToolBar = new QPEToolBar(this); | 92 | QPEToolBar* pageToolBar = new QPEToolBar(this); |
86 | 93 | ||
87 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); | 94 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); |
88 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); | 95 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); |
89 | newPageAction->addTo(pageToolBar); | 96 | newPageAction->addTo(pageToolBar); |
90 | 97 | ||
91 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); | 98 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); |
92 | connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); | 99 | connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); |
@@ -510,12 +517,20 @@ void DrawPad::importPage() | |||
510 | 517 | ||
511 | void DrawPad::exportPage() | 518 | void DrawPad::exportPage() |
512 | { | 519 | { |
513 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | 520 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); |
514 | 521 | ||
515 | exportDialog.showMaximized(); | 522 | exportDialog.showMaximized(); |
516 | 523 | ||
517 | if (exportDialog.exec() == QDialog::Accepted) { | 524 | if (exportDialog.exec() == QDialog::Accepted) { |
518 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | 525 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), |
519 | exportDialog.selectedName(), exportDialog.selectedFormat()); | 526 | exportDialog.selectedName(), exportDialog.selectedFormat()); |
520 | } | 527 | } |
521 | } | 528 | } |
529 | |||
530 | void DrawPad::thumbnailView() | ||
531 | { | ||
532 | ThumbnailView thumbnailView(m_pDrawPadCanvas->pages(), this); | ||
533 | |||
534 | thumbnailView.showMaximized(); | ||
535 | thumbnailView.exec(); | ||
536 | } | ||
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index 0dcd5c9..b0b3666 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -50,24 +50,25 @@ private slots: | |||
50 | void setEraseTool(); | 50 | void setEraseTool(); |
51 | 51 | ||
52 | void changePenWidth(int value); | 52 | void changePenWidth(int value); |
53 | void changePenColor(const QColor& color); | 53 | void changePenColor(const QColor& color); |
54 | void changeBrushColor(const QColor& color); | 54 | void changeBrushColor(const QColor& color); |
55 | 55 | ||
56 | void updateUndoRedoToolButtons(); | 56 | void updateUndoRedoToolButtons(); |
57 | void updateNavigationToolButtons(); | 57 | void updateNavigationToolButtons(); |
58 | void updateCaption(); | 58 | void updateCaption(); |
59 | 59 | ||
60 | void importPage(); | 60 | void importPage(); |
61 | void exportPage(); | 61 | void exportPage(); |
62 | void thumbnailView(); | ||
62 | 63 | ||
63 | private: | 64 | private: |
64 | DrawPadCanvas* m_pDrawPadCanvas; | 65 | DrawPadCanvas* m_pDrawPadCanvas; |
65 | 66 | ||
66 | Tool* m_pTool; | 67 | Tool* m_pTool; |
67 | QPen m_pen; | 68 | QPen m_pen; |
68 | QBrush m_brush; | 69 | QBrush m_brush; |
69 | 70 | ||
70 | QAction* m_pUndoAction; | 71 | QAction* m_pUndoAction; |
71 | QAction* m_pRedoAction; | 72 | QAction* m_pRedoAction; |
72 | 73 | ||
73 | QAction* m_pFirstPageAction; | 74 | QAction* m_pFirstPageAction; |
diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro index 9360256..9a640d2 100644 --- a/noncore/graphics/drawpad/drawpad.pro +++ b/noncore/graphics/drawpad/drawpad.pro | |||
@@ -2,45 +2,49 @@ TEMPLATE = app | |||
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = drawpad.h \ | 3 | HEADERS = drawpad.h \ |
4 | drawpadcanvas.h \ | 4 | drawpadcanvas.h \ |
5 | ellipsetool.h \ | 5 | ellipsetool.h \ |
6 | erasetool.h \ | 6 | erasetool.h \ |
7 | exportdialog.h \ | 7 | exportdialog.h \ |
8 | filltool.h \ | 8 | filltool.h \ |
9 | filledellipsetool.h \ | 9 | filledellipsetool.h \ |
10 | filledrectangletool.h \ | 10 | filledrectangletool.h \ |
11 | importdialog.h \ | 11 | importdialog.h \ |
12 | linetool.h \ | 12 | linetool.h \ |
13 | newpagedialog.h \ | 13 | newpagedialog.h \ |
14 | page.h \ | ||
14 | pointtool.h \ | 15 | pointtool.h \ |
15 | rectangletool.h \ | 16 | rectangletool.h \ |
16 | shapetool.h \ | 17 | shapetool.h \ |
17 | texttool.h \ | 18 | texttool.h \ |
19 | thumbnailview.h \ | ||
18 | tool.h | 20 | tool.h |
19 | SOURCES = drawpad.cpp \ | 21 | SOURCES = drawpad.cpp \ |
20 | drawpadcanvas.cpp \ | 22 | drawpadcanvas.cpp \ |
21 | ellipsetool.cpp \ | 23 | ellipsetool.cpp \ |
22 | erasetool.cpp \ | 24 | erasetool.cpp \ |
23 | exportdialog.cpp \ | 25 | exportdialog.cpp \ |
24 | filltool.cpp \ | 26 | filltool.cpp \ |
25 | filledellipsetool.cpp \ | 27 | filledellipsetool.cpp \ |
26 | filledrectangletool.cpp \ | 28 | filledrectangletool.cpp \ |
27 | importdialog.cpp \ | 29 | importdialog.cpp \ |
28 | linetool.cpp \ | 30 | linetool.cpp \ |
29 | main.cpp \ | 31 | main.cpp \ |
30 | newpagedialog.cpp \ | 32 | newpagedialog.cpp \ |
33 | page.cpp \ | ||
31 | pointtool.cpp \ | 34 | pointtool.cpp \ |
32 | rectangletool.cpp \ | 35 | rectangletool.cpp \ |
33 | shapetool.cpp \ | 36 | shapetool.cpp \ |
34 | texttool.cpp \ | 37 | texttool.cpp \ |
38 | thumbnailview.cpp \ | ||
35 | tool.cpp | 39 | tool.cpp |
36 | INCLUDEPATH+= $(OPIEDIR)/include \ | 40 | INCLUDEPATH+= $(OPIEDIR)/include \ |
37 | $(QTDIR)/src/3rdparty/zlib | 41 | $(QTDIR)/src/3rdparty/zlib |
38 | DEPENDPATH+= $(OPIEDIR)/include | 42 | DEPENDPATH+= $(OPIEDIR)/include |
39 | LIBS += -lqpe -lopie | 43 | LIBS += -lqpe -lopie |
40 | DESTDIR = $(OPIEDIR)/bin | 44 | DESTDIR = $(OPIEDIR)/bin |
41 | TARGET = drawpad | 45 | TARGET = drawpad |
42 | 46 | ||
43 | TRANSLATIONS= ../../i18n/de/drawpad.ts | 47 | TRANSLATIONS= ../../i18n/de/drawpad.ts |
44 | TRANSLATIONS+= ../../i18n/en/drawpad.ts | 48 | TRANSLATIONS+= ../../i18n/en/drawpad.ts |
45 | TRANSLATIONS+= ../../i18n/fr/drawpad.ts | 49 | TRANSLATIONS+= ../../i18n/fr/drawpad.ts |
46 | TRANSLATIONS+= ../../i18n/hu/drawpad.ts | 50 | TRANSLATIONS+= ../../i18n/hu/drawpad.ts |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 9f1e50b..79bef35 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -6,79 +6,79 @@ | |||
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 "tool.h" | 19 | #include "tool.h" |
19 | 20 | ||
20 | #include <qpe/applnk.h> | 21 | #include <qpe/applnk.h> |
21 | #include <qpe/filemanager.h> | 22 | #include <qpe/filemanager.h> |
22 | #include <qpe/mimetype.h> | 23 | #include <qpe/mimetype.h> |
23 | 24 | ||
24 | #include <qbuffer.h> | 25 | #include <qbuffer.h> |
25 | #include <qimage.h> | 26 | #include <qimage.h> |
26 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
27 | #include <qpainter.h> | 28 | #include <qpainter.h> |
28 | #include <qpixmap.h> | ||
29 | #include <qtextcodec.h> | 29 | #include <qtextcodec.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qxml.h> | 31 | #include <qxml.h> |
32 | 32 | ||
33 | #include <zlib.h> | 33 | #include <zlib.h> |
34 | 34 | ||
35 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler | 35 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | DrawPadCanvasXmlHandler(); | 38 | DrawPadCanvasXmlHandler(); |
39 | ~DrawPadCanvasXmlHandler(); | 39 | ~DrawPadCanvasXmlHandler(); |
40 | 40 | ||
41 | QList<QPixmap> pixmaps(); | 41 | QList<Page> pages(); |
42 | 42 | ||
43 | bool startElement(const QString& namespaceURI, const QString& localName, | 43 | bool startElement(const QString& namespaceURI, const QString& localName, |
44 | const QString& qName, const QXmlAttributes& atts); | 44 | const QString& qName, const QXmlAttributes& atts); |
45 | bool endElement(const QString& namespaceURI, const QString& localName, | 45 | bool endElement(const QString& namespaceURI, const QString& localName, |
46 | const QString& qName); | 46 | const QString& qName); |
47 | bool characters(const QString& ch); | 47 | bool characters(const QString& ch); |
48 | 48 | ||
49 | private: | 49 | private: |
50 | enum State { | 50 | enum State { |
51 | Unknown, | 51 | Unknown, |
52 | InData | 52 | InData |
53 | }; | 53 | }; |
54 | 54 | ||
55 | State m_state; | 55 | State m_state; |
56 | ulong m_dataLenght; | 56 | ulong m_dataLenght; |
57 | QString m_dataFormat; | 57 | QString m_dataFormat; |
58 | QList<QPixmap> m_pixmaps; | 58 | QList<Page> m_pages; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() | 61 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() |
62 | { | 62 | { |
63 | m_state = Unknown; | 63 | m_state = Unknown; |
64 | } | 64 | } |
65 | 65 | ||
66 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() | 66 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | QList<QPixmap> DrawPadCanvasXmlHandler::pixmaps() | 70 | QList<Page> DrawPadCanvasXmlHandler::pages() |
71 | { | 71 | { |
72 | return m_pixmaps; | 72 | return m_pages; |
73 | } | 73 | } |
74 | 74 | ||
75 | bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, | 75 | bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, |
76 | const QString& qName, const QXmlAttributes& atts) | 76 | const QString& qName, const QXmlAttributes& atts) |
77 | { | 77 | { |
78 | Q_CONST_UNUSED(namespaceURI) | 78 | Q_CONST_UNUSED(namespaceURI) |
79 | Q_CONST_UNUSED(localName) | 79 | Q_CONST_UNUSED(localName) |
80 | 80 | ||
81 | if (qName.compare("data") == 0) { | 81 | if (qName.compare("data") == 0) { |
82 | m_state = InData; | 82 | m_state = InData; |
83 | m_dataLenght = atts.value("length").toULong(); | 83 | m_dataLenght = atts.value("length").toULong(); |
84 | m_dataFormat = atts.value("format"); | 84 | m_dataFormat = atts.value("format"); |
@@ -138,27 +138,27 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch) | |||
138 | if (m_dataLenght < ch.length() * 5) { | 138 | if (m_dataLenght < ch.length() * 5) { |
139 | m_dataLenght = ch.length() * 5; | 139 | m_dataLenght = ch.length() * 5; |
140 | } | 140 | } |
141 | 141 | ||
142 | QByteArray byteArrayUnzipped(m_dataLenght); | 142 | QByteArray byteArrayUnzipped(m_dataLenght); |
143 | ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); | 143 | ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); |
144 | 144 | ||
145 | image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat); | 145 | image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat); |
146 | } else { | 146 | } else { |
147 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); | 147 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); |
148 | } | 148 | } |
149 | 149 | ||
150 | QPixmap* pixmap = new QPixmap(image.width(), image.height()); | 150 | Page* page = new Page(image.width(), image.height()); |
151 | pixmap->convertFromImage(image); | 151 | page->convertFromImage(image); |
152 | m_pixmaps.append(pixmap); | 152 | m_pages.append(page); |
153 | } | 153 | } |
154 | 154 | ||
155 | return true; | 155 | return true; |
156 | } | 156 | } |
157 | 157 | ||
158 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) | 158 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) |
159 | : QScrollView(parent, name) | 159 | : QScrollView(parent, name) |
160 | { | 160 | { |
161 | m_pDrawPad = drawPad; | 161 | m_pDrawPad = drawPad; |
162 | m_pages.setAutoDelete(true); | 162 | m_pages.setAutoDelete(true); |
163 | m_pageBackups.setAutoDelete(true); | 163 | m_pageBackups.setAutoDelete(true); |
164 | 164 | ||
@@ -172,65 +172,65 @@ DrawPadCanvas::~DrawPadCanvas() | |||
172 | void DrawPadCanvas::load(QIODevice* ioDevice) | 172 | void DrawPadCanvas::load(QIODevice* ioDevice) |
173 | { | 173 | { |
174 | QTextStream textStream(ioDevice); | 174 | QTextStream textStream(ioDevice); |
175 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 175 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
176 | 176 | ||
177 | QXmlInputSource xmlInputSource(textStream); | 177 | QXmlInputSource xmlInputSource(textStream); |
178 | QXmlSimpleReader xmlSimpleReader; | 178 | QXmlSimpleReader xmlSimpleReader; |
179 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; | 179 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; |
180 | 180 | ||
181 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); | 181 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); |
182 | xmlSimpleReader.parse(xmlInputSource); | 182 | xmlSimpleReader.parse(xmlInputSource); |
183 | 183 | ||
184 | m_pages = drawPadCanvasXmlHandler.pixmaps(); | 184 | m_pages = drawPadCanvasXmlHandler.pages(); |
185 | 185 | ||
186 | if (m_pages.isEmpty()) { | 186 | if (m_pages.isEmpty()) { |
187 | m_pages.append(new QPixmap(contentsRect().size())); | 187 | m_pages.append(new Page(contentsRect().size())); |
188 | m_pages.current()->fill(Qt::white); | 188 | m_pages.current()->fill(Qt::white); |
189 | } | 189 | } |
190 | 190 | ||
191 | m_pageBackups.clear(); | 191 | m_pageBackups.clear(); |
192 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 192 | m_pageBackups.append(new Page(*(m_pages.current()))); |
193 | 193 | ||
194 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 194 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
195 | viewport()->update(); | 195 | viewport()->update(); |
196 | 196 | ||
197 | emit pagesChanged(); | 197 | emit pagesChanged(); |
198 | emit pageBackupsChanged(); | 198 | emit pageBackupsChanged(); |
199 | } | 199 | } |
200 | 200 | ||
201 | void DrawPadCanvas::initialPage() | 201 | void DrawPadCanvas::initialPage() |
202 | { | 202 | { |
203 | m_pages.append(new QPixmap(236, 232)); | 203 | m_pages.append(new Page(236, 232)); |
204 | m_pages.current()->fill(Qt::white); | 204 | m_pages.current()->fill(Qt::white); |
205 | 205 | ||
206 | m_pageBackups.clear(); | 206 | m_pageBackups.clear(); |
207 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 207 | m_pageBackups.append(new Page(*(m_pages.current()))); |
208 | 208 | ||
209 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 209 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
210 | viewport()->update(); | 210 | viewport()->update(); |
211 | 211 | ||
212 | emit pagesChanged(); | 212 | emit pagesChanged(); |
213 | emit pageBackupsChanged(); | 213 | emit pageBackupsChanged(); |
214 | } | 214 | } |
215 | 215 | ||
216 | void DrawPadCanvas::save(QIODevice* ioDevice) | 216 | void DrawPadCanvas::save(QIODevice* ioDevice) |
217 | { | 217 | { |
218 | QTextStream textStream(ioDevice); | 218 | QTextStream textStream(ioDevice); |
219 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 219 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
220 | 220 | ||
221 | textStream << "<drawpad>" << endl; | 221 | textStream << "<drawpad>" << endl; |
222 | textStream << " <images>" << endl; | 222 | textStream << " <images>" << endl; |
223 | 223 | ||
224 | QListIterator<QPixmap> bufferIterator(m_pages); | 224 | QListIterator<Page> bufferIterator(m_pages); |
225 | 225 | ||
226 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { | 226 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { |
227 | textStream << " <image>" << endl; | 227 | textStream << " <image>" << endl; |
228 | 228 | ||
229 | QImage image = bufferIterator.current()->convertToImage(); | 229 | QImage image = bufferIterator.current()->convertToImage(); |
230 | QByteArray byteArray; | 230 | QByteArray byteArray; |
231 | QBuffer buffer(byteArray); | 231 | QBuffer buffer(byteArray); |
232 | QImageIO imageIO(&buffer, "PNG"); | 232 | QImageIO imageIO(&buffer, "PNG"); |
233 | 233 | ||
234 | buffer.open(IO_WriteOnly); | 234 | buffer.open(IO_WriteOnly); |
235 | imageIO.setImage(image); | 235 | imageIO.setImage(image); |
236 | imageIO.write(); | 236 | imageIO.write(); |
@@ -247,31 +247,31 @@ void DrawPadCanvas::save(QIODevice* ioDevice) | |||
247 | } | 247 | } |
248 | 248 | ||
249 | textStream << "</data>" << endl; | 249 | textStream << "</data>" << endl; |
250 | textStream << " </image>" << endl; | 250 | textStream << " </image>" << endl; |
251 | } | 251 | } |
252 | 252 | ||
253 | textStream << " </images>" << endl; | 253 | textStream << " </images>" << endl; |
254 | textStream << "</drawpad>"; | 254 | textStream << "</drawpad>"; |
255 | } | 255 | } |
256 | 256 | ||
257 | void DrawPadCanvas::importPage(const QString& fileName) | 257 | void DrawPadCanvas::importPage(const QString& fileName) |
258 | { | 258 | { |
259 | QPixmap* importedPixmap = new QPixmap(); | 259 | Page* importedPage = new Page(); |
260 | 260 | ||
261 | importedPixmap->load(fileName); | 261 | importedPage->load(fileName); |
262 | m_pages.insert(m_pages.at() + 1, importedPixmap); | 262 | m_pages.insert(m_pages.at() + 1, importedPage); |
263 | 263 | ||
264 | m_pageBackups.clear(); | 264 | m_pageBackups.clear(); |
265 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 265 | m_pageBackups.append(new Page(*(m_pages.current()))); |
266 | 266 | ||
267 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 267 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
268 | viewport()->update(); | 268 | viewport()->update(); |
269 | 269 | ||
270 | emit pagesChanged(); | 270 | emit pagesChanged(); |
271 | emit pageBackupsChanged(); | 271 | emit pageBackupsChanged(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) | 274 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) |
275 | { | 275 | { |
276 | if (fromPage == toPage) { | 276 | if (fromPage == toPage) { |
277 | DocLnk docLnk; | 277 | DocLnk docLnk; |
@@ -299,30 +299,30 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c | |||
299 | FileManager fileManager; | 299 | FileManager fileManager; |
300 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 300 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
301 | QImageIO imageIO(ioDevice, format); | 301 | QImageIO imageIO(ioDevice, format); |
302 | 302 | ||
303 | QImage image = m_pages.at(i - 1)->convertToImage(); | 303 | QImage image = m_pages.at(i - 1)->convertToImage(); |
304 | imageIO.setImage(image); | 304 | imageIO.setImage(image); |
305 | imageIO.write(); | 305 | imageIO.write(); |
306 | delete ioDevice; | 306 | delete ioDevice; |
307 | } | 307 | } |
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | QPixmap* DrawPadCanvas::currentPage() | 311 | Page* DrawPadCanvas::currentPage() |
312 | { | 312 | { |
313 | return m_pages.current(); | 313 | return m_pages.current(); |
314 | } | 314 | } |
315 | 315 | ||
316 | QList<QPixmap> DrawPadCanvas::pages() | 316 | QList<Page> DrawPadCanvas::pages() |
317 | { | 317 | { |
318 | return m_pages; | 318 | return m_pages; |
319 | } | 319 | } |
320 | 320 | ||
321 | uint DrawPadCanvas::pagePosition() | 321 | uint DrawPadCanvas::pagePosition() |
322 | { | 322 | { |
323 | return (m_pages.at() + 1); | 323 | return (m_pages.at() + 1); |
324 | } | 324 | } |
325 | 325 | ||
326 | uint DrawPadCanvas::pageCount() | 326 | uint DrawPadCanvas::pageCount() |
327 | { | 327 | { |
328 | return m_pages.count(); | 328 | return m_pages.count(); |
@@ -330,70 +330,70 @@ uint DrawPadCanvas::pageCount() | |||
330 | 330 | ||
331 | void DrawPadCanvas::backupPage() | 331 | void DrawPadCanvas::backupPage() |
332 | { | 332 | { |
333 | QPixmap* currentBackup = m_pageBackups.current(); | 333 | QPixmap* currentBackup = m_pageBackups.current(); |
334 | while (m_pageBackups.last() != currentBackup) { | 334 | while (m_pageBackups.last() != currentBackup) { |
335 | m_pageBackups.removeLast(); | 335 | m_pageBackups.removeLast(); |
336 | } | 336 | } |
337 | 337 | ||
338 | while (m_pageBackups.count() >= (5 + 1)) { | 338 | while (m_pageBackups.count() >= (5 + 1)) { |
339 | m_pageBackups.removeFirst(); | 339 | m_pageBackups.removeFirst(); |
340 | } | 340 | } |
341 | 341 | ||
342 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 342 | m_pageBackups.append(new Page(*(m_pages.current()))); |
343 | 343 | ||
344 | emit pageBackupsChanged(); | 344 | emit pageBackupsChanged(); |
345 | } | 345 | } |
346 | 346 | ||
347 | void DrawPadCanvas::deleteAll() | 347 | void DrawPadCanvas::deleteAll() |
348 | { | 348 | { |
349 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 349 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
350 | QMessageBox::Information, QMessageBox::Yes, | 350 | QMessageBox::Information, QMessageBox::Yes, |
351 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 351 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
352 | QMessageBox::NoButton, this); | 352 | QMessageBox::NoButton, this); |
353 | 353 | ||
354 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 354 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
355 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 355 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
356 | 356 | ||
357 | if (messageBox.exec() == QMessageBox::Yes) { | 357 | if (messageBox.exec() == QMessageBox::Yes) { |
358 | m_pages.clear(); | 358 | m_pages.clear(); |
359 | 359 | ||
360 | m_pages.append(new QPixmap(contentsRect().size())); | 360 | m_pages.append(new Page(contentsRect().size())); |
361 | m_pages.current()->fill(Qt::white); | 361 | m_pages.current()->fill(Qt::white); |
362 | 362 | ||
363 | m_pageBackups.clear(); | 363 | m_pageBackups.clear(); |
364 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 364 | m_pageBackups.append(new Page(*(m_pages.current()))); |
365 | 365 | ||
366 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 366 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
367 | viewport()->update(); | 367 | viewport()->update(); |
368 | 368 | ||
369 | emit pagesChanged(); | 369 | emit pagesChanged(); |
370 | emit pageBackupsChanged(); | 370 | emit pageBackupsChanged(); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | void DrawPadCanvas::newPage() | 374 | void DrawPadCanvas::newPage() |
375 | { | 375 | { |
376 | QRect rect = contentsRect(); | 376 | QRect rect = contentsRect(); |
377 | 377 | ||
378 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), | 378 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), |
379 | m_pDrawPad->brush().color(), this); | 379 | m_pDrawPad->brush().color(), this); |
380 | 380 | ||
381 | if (newPageDialog.exec() == QDialog::Accepted) { | 381 | if (newPageDialog.exec() == QDialog::Accepted) { |
382 | m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(), | 382 | m_pages.insert(m_pages.at() + 1, new Page(newPageDialog.selectedWidth(), |
383 | newPageDialog.selectedHeight())); | 383 | newPageDialog.selectedHeight())); |
384 | m_pages.current()->fill(newPageDialog.selectedColor()); | 384 | m_pages.current()->fill(newPageDialog.selectedColor()); |
385 | 385 | ||
386 | m_pageBackups.clear(); | 386 | m_pageBackups.clear(); |
387 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 387 | m_pageBackups.append(new Page(*(m_pages.current()))); |
388 | 388 | ||
389 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 389 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
390 | viewport()->update(); | 390 | viewport()->update(); |
391 | 391 | ||
392 | emit pagesChanged(); | 392 | emit pagesChanged(); |
393 | emit pageBackupsChanged(); | 393 | emit pageBackupsChanged(); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | 396 | ||
397 | void DrawPadCanvas::clearPage() | 397 | void DrawPadCanvas::clearPage() |
398 | { | 398 | { |
399 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), | 399 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), |
@@ -416,30 +416,30 @@ void DrawPadCanvas::deletePage() | |||
416 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), | 416 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), |
417 | QMessageBox::Information, QMessageBox::Yes, | 417 | QMessageBox::Information, QMessageBox::Yes, |
418 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 418 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
419 | QMessageBox::NoButton, this); | 419 | QMessageBox::NoButton, this); |
420 | 420 | ||
421 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 421 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
422 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 422 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
423 | 423 | ||
424 | if (messageBox.exec() == QMessageBox::Yes) { | 424 | if (messageBox.exec() == QMessageBox::Yes) { |
425 | m_pages.remove(m_pages.current()); | 425 | m_pages.remove(m_pages.current()); |
426 | 426 | ||
427 | if (m_pages.isEmpty()) { | 427 | if (m_pages.isEmpty()) { |
428 | m_pages.append(new QPixmap(contentsRect().size())); | 428 | m_pages.append(new Page(contentsRect().size())); |
429 | m_pages.current()->fill(Qt::white); | 429 | m_pages.current()->fill(Qt::white); |
430 | } | 430 | } |
431 | 431 | ||
432 | m_pageBackups.clear(); | 432 | m_pageBackups.clear(); |
433 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 433 | m_pageBackups.append(new Page(*(m_pages.current()))); |
434 | 434 | ||
435 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 435 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
436 | viewport()->update(); | 436 | viewport()->update(); |
437 | 437 | ||
438 | emit pagesChanged(); | 438 | emit pagesChanged(); |
439 | emit pageBackupsChanged(); | 439 | emit pageBackupsChanged(); |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | bool DrawPadCanvas::undoEnabled() | 443 | bool DrawPadCanvas::undoEnabled() |
444 | { | 444 | { |
445 | return (m_pageBackups.current() != m_pageBackups.getFirst()); | 445 | return (m_pageBackups.current() != m_pageBackups.getFirst()); |
@@ -473,64 +473,64 @@ void DrawPadCanvas::redo() | |||
473 | { | 473 | { |
474 | *(m_pages.current()) = *(m_pageBackups.next()); | 474 | *(m_pages.current()) = *(m_pageBackups.next()); |
475 | 475 | ||
476 | viewport()->update(); | 476 | viewport()->update(); |
477 | 477 | ||
478 | emit pageBackupsChanged(); | 478 | emit pageBackupsChanged(); |
479 | } | 479 | } |
480 | 480 | ||
481 | void DrawPadCanvas::goFirstPage() | 481 | void DrawPadCanvas::goFirstPage() |
482 | { | 482 | { |
483 | m_pages.first(); | 483 | m_pages.first(); |
484 | m_pageBackups.clear(); | 484 | m_pageBackups.clear(); |
485 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 485 | m_pageBackups.append(new Page(*(m_pages.current()))); |
486 | 486 | ||
487 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 487 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
488 | viewport()->update(); | 488 | viewport()->update(); |
489 | 489 | ||
490 | emit pagesChanged(); | 490 | emit pagesChanged(); |
491 | emit pageBackupsChanged(); | 491 | emit pageBackupsChanged(); |
492 | } | 492 | } |
493 | 493 | ||
494 | void DrawPadCanvas::goPreviousPage() | 494 | void DrawPadCanvas::goPreviousPage() |
495 | { | 495 | { |
496 | m_pages.prev(); | 496 | m_pages.prev(); |
497 | m_pageBackups.clear(); | 497 | m_pageBackups.clear(); |
498 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 498 | m_pageBackups.append(new Page(*(m_pages.current()))); |
499 | 499 | ||
500 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 500 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
501 | viewport()->update(); | 501 | viewport()->update(); |
502 | 502 | ||
503 | emit pagesChanged(); | 503 | emit pagesChanged(); |
504 | emit pageBackupsChanged(); | 504 | emit pageBackupsChanged(); |
505 | } | 505 | } |
506 | 506 | ||
507 | void DrawPadCanvas::goNextPage() | 507 | void DrawPadCanvas::goNextPage() |
508 | { | 508 | { |
509 | m_pages.next(); | 509 | m_pages.next(); |
510 | m_pageBackups.clear(); | 510 | m_pageBackups.clear(); |
511 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 511 | m_pageBackups.append(new Page(*(m_pages.current()))); |
512 | 512 | ||
513 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 513 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
514 | viewport()->update(); | 514 | viewport()->update(); |
515 | 515 | ||
516 | emit pagesChanged(); | 516 | emit pagesChanged(); |
517 | emit pageBackupsChanged(); | 517 | emit pageBackupsChanged(); |
518 | } | 518 | } |
519 | 519 | ||
520 | void DrawPadCanvas::goLastPage() | 520 | void DrawPadCanvas::goLastPage() |
521 | { | 521 | { |
522 | m_pages.last(); | 522 | m_pages.last(); |
523 | m_pageBackups.clear(); | 523 | m_pageBackups.clear(); |
524 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 524 | m_pageBackups.append(new Page(*(m_pages.current()))); |
525 | 525 | ||
526 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 526 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
527 | viewport()->update(); | 527 | viewport()->update(); |
528 | 528 | ||
529 | emit pagesChanged(); | 529 | emit pagesChanged(); |
530 | emit pageBackupsChanged(); | 530 | emit pageBackupsChanged(); |
531 | } | 531 | } |
532 | 532 | ||
533 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | 533 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) |
534 | { | 534 | { |
535 | m_pDrawPad->tool()->mousePressEvent(e); | 535 | m_pDrawPad->tool()->mousePressEvent(e); |
536 | } | 536 | } |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index e05ce8a..47763f9 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -11,49 +11,48 @@ | |||
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #ifndef DRAWPADCANVAS_H | 14 | #ifndef DRAWPADCANVAS_H |
15 | #define DRAWPADCANVAS_H | 15 | #define DRAWPADCANVAS_H |
16 | 16 | ||
17 | #include <qscrollview.h> | 17 | #include <qscrollview.h> |
18 | 18 | ||
19 | #include <qlist.h> | 19 | #include <qlist.h> |
20 | #include <qpointarray.h> | 20 | #include <qpointarray.h> |
21 | 21 | ||
22 | class DrawPad; | 22 | class DrawPad; |
23 | 23 | class Page; | |
24 | class QPixmap; | ||
25 | 24 | ||
26 | class DrawPadCanvas : public QScrollView | 25 | class DrawPadCanvas : public QScrollView |
27 | { | 26 | { |
28 | Q_OBJECT | 27 | Q_OBJECT |
29 | 28 | ||
30 | public: | 29 | public: |
31 | DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); | 30 | DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); |
32 | ~DrawPadCanvas(); | 31 | ~DrawPadCanvas(); |
33 | 32 | ||
34 | void load(QIODevice* ioDevice); | 33 | void load(QIODevice* ioDevice); |
35 | void initialPage(); | 34 | void initialPage(); |
36 | void save(QIODevice* ioDevice); | 35 | void save(QIODevice* ioDevice); |
37 | 36 | ||
38 | void importPage(const QString& fileName); | 37 | void importPage(const QString& fileName); |
39 | 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); |
40 | 39 | ||
41 | bool undoEnabled(); | 40 | bool undoEnabled(); |
42 | bool redoEnabled(); | 41 | bool redoEnabled(); |
43 | bool goPreviousPageEnabled(); | 42 | bool goPreviousPageEnabled(); |
44 | bool goNextPageEnabled(); | 43 | bool goNextPageEnabled(); |
45 | 44 | ||
46 | QPixmap* currentPage(); | 45 | Page* currentPage(); |
47 | QList<QPixmap> pages(); | 46 | QList<Page> pages(); |
48 | uint pagePosition(); | 47 | uint pagePosition(); |
49 | uint pageCount(); | 48 | uint pageCount(); |
50 | 49 | ||
51 | void backupPage(); | 50 | void backupPage(); |
52 | 51 | ||
53 | public slots: | 52 | public slots: |
54 | void deleteAll(); | 53 | void deleteAll(); |
55 | void newPage(); | 54 | void newPage(); |
56 | void clearPage(); | 55 | void clearPage(); |
57 | void deletePage(); | 56 | void deletePage(); |
58 | 57 | ||
59 | void undo(); | 58 | void undo(); |
@@ -67,17 +66,17 @@ public slots: | |||
67 | signals: | 66 | signals: |
68 | void pagesChanged(); | 67 | void pagesChanged(); |
69 | void pageBackupsChanged(); | 68 | void pageBackupsChanged(); |
70 | 69 | ||
71 | protected: | 70 | protected: |
72 | void contentsMousePressEvent(QMouseEvent* e); | 71 | void contentsMousePressEvent(QMouseEvent* e); |
73 | void contentsMouseReleaseEvent(QMouseEvent* e); | 72 | void contentsMouseReleaseEvent(QMouseEvent* e); |
74 | void contentsMouseMoveEvent(QMouseEvent* e); | 73 | void contentsMouseMoveEvent(QMouseEvent* e); |
75 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); | 74 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); |
76 | 75 | ||
77 | private: | 76 | private: |
78 | DrawPad* m_pDrawPad; | 77 | DrawPad* m_pDrawPad; |
79 | QList<QPixmap> m_pages; | 78 | QList<Page> m_pages; |
80 | QList<QPixmap> m_pageBackups; | 79 | QList<Page> m_pageBackups; |
81 | }; | 80 | }; |
82 | 81 | ||
83 | #endif // DRAWPADCANVAS_H | 82 | #endif // DRAWPADCANVAS_H |
diff --git a/noncore/graphics/drawpad/erasetool.cpp b/noncore/graphics/drawpad/erasetool.cpp index 828994b..f77e038 100644 --- a/noncore/graphics/drawpad/erasetool.cpp +++ b/noncore/graphics/drawpad/erasetool.cpp | |||
@@ -6,27 +6,27 @@ | |||
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 "erasetool.h" | 14 | #include "erasetool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | ||
18 | 19 | ||
19 | #include <qpainter.h> | 20 | #include <qpainter.h> |
20 | #include <qpixmap.h> | ||
21 | 21 | ||
22 | EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | m_mousePressed = false; | 25 | m_mousePressed = false; |
26 | m_polyline.resize(3); | 26 | m_polyline.resize(3); |
27 | } | 27 | } |
28 | 28 | ||
29 | EraseTool::~EraseTool() | 29 | EraseTool::~EraseTool() |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp index 004da02..d323cc2 100644 --- a/noncore/graphics/drawpad/filltool.cpp +++ b/noncore/graphics/drawpad/filltool.cpp | |||
@@ -6,27 +6,27 @@ | |||
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 "filltool.h" | 14 | #include "filltool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | ||
18 | 19 | ||
19 | #include <qimage.h> | 20 | #include <qimage.h> |
20 | #include <qpixmap.h> | ||
21 | 21 | ||
22 | FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | FillTool::~FillTool() | 27 | FillTool::~FillTool() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | void FillTool::mousePressEvent(QMouseEvent* e) | 31 | void FillTool::mousePressEvent(QMouseEvent* e) |
32 | { | 32 | { |
diff --git a/noncore/graphics/drawpad/page.cpp b/noncore/graphics/drawpad/page.cpp new file mode 100644 index 0000000..35ec0e0 --- a/dev/null +++ b/noncore/graphics/drawpad/page.cpp | |||
@@ -0,0 +1,33 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * DrawPad - a drawing program for Opie Environment * | ||
4 | * * | ||
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | ||
6 | * * | ||
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 * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | * * | ||
12 | ***************************************************************************/ | ||
13 | |||
14 | #include "page.h" | ||
15 | |||
16 | Page::Page() | ||
17 | : QPixmap() | ||
18 | { | ||
19 | } | ||
20 | |||
21 | Page::Page(int w, int h) | ||
22 | : QPixmap(w, h) | ||
23 | { | ||
24 | } | ||
25 | |||
26 | Page::Page(const QSize& size) | ||
27 | : QPixmap(size) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | Page::~Page() | ||
32 | { | ||
33 | } | ||
diff --git a/noncore/graphics/drawpad/page.h b/noncore/graphics/drawpad/page.h new file mode 100644 index 0000000..888f552 --- a/dev/null +++ b/noncore/graphics/drawpad/page.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * DrawPad - a drawing program for Opie Environment * | ||
4 | * * | ||
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | ||
6 | * * | ||
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 * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | * * | ||
12 | ***************************************************************************/ | ||
13 | |||
14 | #ifndef PAGE_H | ||
15 | #define PAGE_H | ||
16 | |||
17 | #include <qpixmap.h> | ||
18 | |||
19 | class Page : public QPixmap | ||
20 | { | ||
21 | public: | ||
22 | Page(); | ||
23 | Page(int w, int h); | ||
24 | Page(const QSize& size); | ||
25 | |||
26 | ~Page(); | ||
27 | }; | ||
28 | |||
29 | #endif // PAGE_H | ||
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp index e281284..656044b 100644 --- a/noncore/graphics/drawpad/pointtool.cpp +++ b/noncore/graphics/drawpad/pointtool.cpp | |||
@@ -6,27 +6,27 @@ | |||
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 "pointtool.h" | 14 | #include "pointtool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | ||
18 | 19 | ||
19 | #include <qpainter.h> | 20 | #include <qpainter.h> |
20 | #include <qpixmap.h> | ||
21 | 21 | ||
22 | PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | m_mousePressed = false; | 25 | m_mousePressed = false; |
26 | m_polyline.resize(3); | 26 | m_polyline.resize(3); |
27 | } | 27 | } |
28 | 28 | ||
29 | PointTool::~PointTool() | 29 | PointTool::~PointTool() |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp index bc5d9c0..8870a78 100644 --- a/noncore/graphics/drawpad/shapetool.cpp +++ b/noncore/graphics/drawpad/shapetool.cpp | |||
@@ -6,27 +6,27 @@ | |||
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 "shapetool.h" | 14 | #include "shapetool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | ||
18 | 19 | ||
19 | #include <qpainter.h> | 20 | #include <qpainter.h> |
20 | #include <qpixmap.h> | ||
21 | 21 | ||
22 | ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | m_mousePressed = false; | 25 | m_mousePressed = false; |
26 | m_polyline.resize(3); | 26 | m_polyline.resize(3); |
27 | } | 27 | } |
28 | 28 | ||
29 | ShapeTool::~ShapeTool() | 29 | ShapeTool::~ShapeTool() |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
diff --git a/noncore/graphics/drawpad/texttool.cpp b/noncore/graphics/drawpad/texttool.cpp index 37b4801..34c8a76 100644 --- a/noncore/graphics/drawpad/texttool.cpp +++ b/noncore/graphics/drawpad/texttool.cpp | |||
@@ -6,29 +6,29 @@ | |||
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 "texttool.h" | 14 | #include "texttool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | ||
18 | 19 | ||
19 | #include <qlayout.h> | 20 | #include <qlayout.h> |
20 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
21 | #include <qpainter.h> | 22 | #include <qpainter.h> |
22 | #include <qpixmap.h> | ||
23 | 23 | ||
24 | TextToolDialog::TextToolDialog(QWidget* parent, const char* name) | 24 | TextToolDialog::TextToolDialog(QWidget* parent, const char* name) |
25 | : QDialog(parent, name, true) | 25 | : QDialog(parent, name, true) |
26 | { | 26 | { |
27 | setCaption(tr("Insert Text")); | 27 | setCaption(tr("Insert Text")); |
28 | 28 | ||
29 | m_pLineEdit = new QLineEdit(this); | 29 | m_pLineEdit = new QLineEdit(this); |
30 | 30 | ||
31 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 31 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
32 | 32 | ||
33 | mainLayout->addWidget(m_pLineEdit); | 33 | mainLayout->addWidget(m_pLineEdit); |
34 | } | 34 | } |
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp new file mode 100644 index 0000000..10ade90 --- a/dev/null +++ b/noncore/graphics/drawpad/thumbnailview.cpp | |||
@@ -0,0 +1,121 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * DrawPad - a drawing program for Opie Environment * | ||
4 | * * | ||
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | ||
6 | * * | ||
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 * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | * * | ||
12 | ***************************************************************************/ | ||
13 | |||
14 | #include "thumbnailview.h" | ||
15 | |||
16 | #include "page.h" | ||
17 | |||
18 | #include <qpe/resource.h> | ||
19 | |||
20 | #include <qheader.h> | ||
21 | #include <qimage.h> | ||
22 | #include <qlayout.h> | ||
23 | #include <qlistview.h> | ||
24 | #include <qtoolbutton.h> | ||
25 | |||
26 | ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* name) | ||
27 | : QDialog(parent, name, true) | ||
28 | { | ||
29 | setCaption(tr("Thumbnail")); | ||
30 | |||
31 | QToolButton* newPageButton = new QToolButton(this); | ||
32 | newPageButton->setIconSet(Resource::loadIconSet("new")); | ||
33 | newPageButton->setAutoRaise(true); | ||
34 | |||
35 | QToolButton* clearPageButton = new QToolButton(this); | ||
36 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); | ||
37 | clearPageButton->setAutoRaise(true); | ||
38 | |||
39 | QToolButton* deletePageButton = new QToolButton(this); | ||
40 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); | ||
41 | deletePageButton->setAutoRaise(true); | ||
42 | |||
43 | QToolButton* movePageUpButton = new QToolButton(this); | ||
44 | movePageUpButton->setIconSet(Resource::loadIconSet("up")); | ||
45 | movePageUpButton->setAutoRaise(true); | ||
46 | |||
47 | QToolButton* movePageDownButton = new QToolButton(this); | ||
48 | movePageDownButton->setIconSet(Resource::loadIconSet("down")); | ||
49 | movePageDownButton->setAutoRaise(true); | ||
50 | |||
51 | m_pListView = new QListView(this); | ||
52 | |||
53 | m_pListView->header()->hide(); | ||
54 | m_pListView->setAllColumnsShowFocus(true); | ||
55 | |||
56 | m_pListView->addColumn(tr("Thumbnail")); | ||
57 | m_pListView->addColumn(tr("Information")); | ||
58 | |||
59 | m_pListView->setColumnAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); | ||
60 | m_pListView->setColumnAlignment(1, Qt::AlignTop); | ||
61 | |||
62 | QListIterator<Page> iterator(pages); | ||
63 | |||
64 | for (; iterator.current(); ++iterator) { | ||
65 | QImage image = iterator.current()->convertToImage(); | ||
66 | |||
67 | int previewWidth = 64; | ||
68 | int previewHeight = 64; | ||
69 | |||
70 | float widthScale = 1.0; | ||
71 | float heightScale = 1.0; | ||
72 | |||
73 | if (previewWidth < image.width()) { | ||
74 | widthScale = (float)previewWidth / float(image.width()); | ||
75 | } | ||
76 | |||
77 | if (previewHeight < image.height()) { | ||
78 | heightScale = (float)previewHeight / float(image.height()); | ||
79 | } | ||
80 | |||
81 | float scale = (widthScale < heightScale ? widthScale : heightScale); | ||
82 | QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); | ||
83 | |||
84 | QPixmap previewPixmap; | ||
85 | previewPixmap.convertFromImage(previewImage); | ||
86 | |||
87 | QPixmap pixmap(64, 64); | ||
88 | |||
89 | pixmap.fill(colorGroup().mid()); | ||
90 | bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2, | ||
91 | (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap); | ||
92 | |||
93 | QListViewItem* item = new QListViewItem(m_pListView); | ||
94 | item->setPixmap(0, pixmap); | ||
95 | } | ||
96 | |||
97 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | ||
98 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); | ||
99 | |||
100 | buttonLayout->addWidget(newPageButton); | ||
101 | buttonLayout->addWidget(clearPageButton); | ||
102 | buttonLayout->addWidget(deletePageButton); | ||
103 | buttonLayout->addStretch(); | ||
104 | buttonLayout->addWidget(movePageUpButton); | ||
105 | buttonLayout->addWidget(movePageDownButton); | ||
106 | |||
107 | mainLayout->addLayout(buttonLayout); | ||
108 | mainLayout->addWidget(m_pListView); | ||
109 | } | ||
110 | |||
111 | ThumbnailView::~ThumbnailView() | ||
112 | { | ||
113 | } | ||
114 | |||
115 | void ThumbnailView::resizeEvent(QResizeEvent* e) | ||
116 | { | ||
117 | QDialog::resizeEvent(e); | ||
118 | |||
119 | m_pListView->setColumnWidth(1, m_pListView->contentsRect().width() - m_pListView->columnWidth(0) | ||
120 | - m_pListView->verticalScrollBar()->width()); | ||
121 | } | ||
diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h new file mode 100644 index 0000000..c74730d --- a/dev/null +++ b/noncore/graphics/drawpad/thumbnailview.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * DrawPad - a drawing program for Opie Environment * | ||
4 | * * | ||
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | ||
6 | * * | ||
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 * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | * * | ||
12 | ***************************************************************************/ | ||
13 | |||
14 | #ifndef THUMBNAILVIEW_H | ||
15 | #define THUMBNAILVIEW_H | ||
16 | |||
17 | #include <qdialog.h> | ||
18 | |||
19 | #include <qlist.h> | ||
20 | |||
21 | class QListView; | ||
22 | |||
23 | class Page; | ||
24 | |||
25 | class ThumbnailView : public QDialog | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | |||
29 | public: | ||
30 | ThumbnailView(QList<Page> pages, QWidget* parent = 0, const char* name = 0); | ||
31 | ~ThumbnailView(); | ||
32 | |||
33 | protected: | ||
34 | void resizeEvent(QResizeEvent* e); | ||
35 | |||
36 | private: | ||
37 | QListView* m_pListView; | ||
38 | }; | ||
39 | |||
40 | #endif // THUMBNAILVIEW_H | ||