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 /noncore | |
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 | |||
@@ -25,6 +25,7 @@ | |||
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> |
@@ -78,6 +79,12 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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 |
@@ -519,3 +526,11 @@ void DrawPad::exportPage() | |||
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 | |||
@@ -59,6 +59,7 @@ private slots: | |||
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; |
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 | |||
@@ -11,10 +11,12 @@ HEADERS = drawpad.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 \ |
@@ -28,10 +30,12 @@ SOURCES = drawpad.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 |
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 | |||
@@ -15,6 +15,7 @@ | |||
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> |
@@ -25,7 +26,6 @@ | |||
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> |
@@ -38,7 +38,7 @@ 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); |
@@ -55,7 +55,7 @@ private: | |||
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() |
@@ -67,9 +67,9 @@ 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, |
@@ -147,9 +147,9 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch) | |||
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; |
@@ -181,15 +181,15 @@ void DrawPadCanvas::load(QIODevice* ioDevice) | |||
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(); |
@@ -200,11 +200,11 @@ void DrawPadCanvas::load(QIODevice* ioDevice) | |||
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(); |
@@ -221,7 +221,7 @@ void DrawPadCanvas::save(QIODevice* ioDevice) | |||
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; |
@@ -256,13 +256,13 @@ void DrawPadCanvas::save(QIODevice* ioDevice) | |||
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(); |
@@ -308,12 +308,12 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c | |||
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 | } |
@@ -339,7 +339,7 @@ void DrawPadCanvas::backupPage() | |||
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 | } |
@@ -357,11 +357,11 @@ void DrawPadCanvas::deleteAll() | |||
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(); |
@@ -379,12 +379,12 @@ void DrawPadCanvas::newPage() | |||
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(); |
@@ -425,12 +425,12 @@ void DrawPadCanvas::deletePage() | |||
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(); |
@@ -482,7 +482,7 @@ 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(); |
@@ -495,7 +495,7 @@ 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(); |
@@ -508,7 +508,7 @@ 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(); |
@@ -521,7 +521,7 @@ 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(); |
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 | |||
@@ -20,8 +20,7 @@ | |||
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 | { |
@@ -43,8 +42,8 @@ public: | |||
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 | ||
@@ -76,8 +75,8 @@ protected: | |||
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 | |||
@@ -15,9 +15,9 @@ | |||
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) |
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 | |||
@@ -15,9 +15,9 @@ | |||
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) |
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 | |||
@@ -15,9 +15,9 @@ | |||
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) |
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 | |||
@@ -15,9 +15,9 @@ | |||
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) |
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 | |||
@@ -15,11 +15,11 @@ | |||
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) |
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 | ||