summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp15
-rw-r--r--noncore/graphics/drawpad/drawpad.h1
-rw-r--r--noncore/graphics/drawpad/drawpad.pro4
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp64
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h11
-rw-r--r--noncore/graphics/drawpad/erasetool.cpp2
-rw-r--r--noncore/graphics/drawpad/filltool.cpp2
-rw-r--r--noncore/graphics/drawpad/page.cpp33
-rw-r--r--noncore/graphics/drawpad/page.h29
-rw-r--r--noncore/graphics/drawpad/pointtool.cpp2
-rw-r--r--noncore/graphics/drawpad/shapetool.cpp2
-rw-r--r--noncore/graphics/drawpad/texttool.cpp2
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp121
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h40
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
@@ -27,2 +27,3 @@
27#include "texttool.h" 27#include "texttool.h"
28#include "thumbnailview.h"
28 29
@@ -80,2 +81,8 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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);
@@ -521 +528,9 @@ void DrawPad::exportPage()
521} 528}
529
530void 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
@@ -61,2 +61,3 @@ private slots:
61 void exportPage(); 61 void exportPage();
62 void thumbnailView();
62 63
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
@@ -13,2 +13,3 @@ HEADERS = drawpad.h \
13 newpagedialog.h \ 13 newpagedialog.h \
14 page.h \
14 pointtool.h \ 15 pointtool.h \
@@ -17,2 +18,3 @@ HEADERS = drawpad.h \
17 texttool.h \ 18 texttool.h \
19 thumbnailview.h \
18 tool.h 20 tool.h
@@ -30,2 +32,3 @@ SOURCES = drawpad.cpp \
30 newpagedialog.cpp \ 32 newpagedialog.cpp \
33 page.cpp \
31 pointtool.cpp \ 34 pointtool.cpp \
@@ -34,2 +37,3 @@ SOURCES = drawpad.cpp \
34 texttool.cpp \ 37 texttool.cpp \
38 thumbnailview.cpp \
35 tool.cpp 39 tool.cpp
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
@@ -17,2 +17,3 @@
17#include "newpagedialog.h" 17#include "newpagedialog.h"
18#include "page.h"
18#include "tool.h" 19#include "tool.h"
@@ -27,3 +28,2 @@
27#include <qpainter.h> 28#include <qpainter.h>
28#include <qpixmap.h>
29#include <qtextcodec.h> 29#include <qtextcodec.h>
@@ -40,3 +40,3 @@ public:
40 40
41 QList<QPixmap> pixmaps(); 41 QList<Page> pages();
42 42
@@ -57,3 +57,3 @@ private:
57 QString m_dataFormat; 57 QString m_dataFormat;
58 QList<QPixmap> m_pixmaps; 58 QList<Page> m_pages;
59}; 59};
@@ -69,5 +69,5 @@ DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler()
69 69
70QList<QPixmap> DrawPadCanvasXmlHandler::pixmaps() 70QList<Page> DrawPadCanvasXmlHandler::pages()
71{ 71{
72 return m_pixmaps; 72 return m_pages;
73} 73}
@@ -149,5 +149,5 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch)
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 }
@@ -183,6 +183,6 @@ void DrawPadCanvas::load(QIODevice* ioDevice)
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);
@@ -191,3 +191,3 @@ void DrawPadCanvas::load(QIODevice* ioDevice)
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
@@ -202,3 +202,3 @@ 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);
@@ -206,3 +206,3 @@ void DrawPadCanvas::initialPage()
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
@@ -223,3 +223,3 @@ void DrawPadCanvas::save(QIODevice* ioDevice)
223 223
224 QListIterator<QPixmap> bufferIterator(m_pages); 224 QListIterator<Page> bufferIterator(m_pages);
225 225
@@ -258,9 +258,9 @@ 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
@@ -310,3 +310,3 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c
310 310
311QPixmap* DrawPadCanvas::currentPage() 311Page* DrawPadCanvas::currentPage()
312{ 312{
@@ -315,3 +315,3 @@ QPixmap* DrawPadCanvas::currentPage()
315 315
316QList<QPixmap> DrawPadCanvas::pages() 316QList<Page> DrawPadCanvas::pages()
317{ 317{
@@ -341,3 +341,3 @@ void DrawPadCanvas::backupPage()
341 341
342 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 342 m_pageBackups.append(new Page(*(m_pages.current())));
343 343
@@ -359,3 +359,3 @@ void DrawPadCanvas::deleteAll()
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);
@@ -363,3 +363,3 @@ void DrawPadCanvas::deleteAll()
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
@@ -381,4 +381,4 @@ void DrawPadCanvas::newPage()
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());
@@ -386,3 +386,3 @@ void DrawPadCanvas::newPage()
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
@@ -427,3 +427,3 @@ void DrawPadCanvas::deletePage()
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);
@@ -432,3 +432,3 @@ void DrawPadCanvas::deletePage()
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
@@ -484,3 +484,3 @@ void DrawPadCanvas::goFirstPage()
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
@@ -497,3 +497,3 @@ void DrawPadCanvas::goPreviousPage()
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
@@ -510,3 +510,3 @@ void DrawPadCanvas::goNextPage()
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
@@ -523,3 +523,3 @@ void DrawPadCanvas::goLastPage()
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
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
@@ -22,4 +22,3 @@
22class DrawPad; 22class DrawPad;
23 23class Page;
24class QPixmap;
25 24
@@ -45,4 +44,4 @@ public:
45 44
46 QPixmap* currentPage(); 45 Page* currentPage();
47 QList<QPixmap> pages(); 46 QList<Page> pages();
48 uint pagePosition(); 47 uint pagePosition();
@@ -78,4 +77,4 @@ 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};
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
@@ -17,5 +17,5 @@
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
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
@@ -17,5 +17,5 @@
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
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
16Page::Page()
17 : QPixmap()
18{
19}
20
21Page::Page(int w, int h)
22 : QPixmap(w, h)
23{
24}
25
26Page::Page(const QSize& size)
27 : QPixmap(size)
28{
29}
30
31Page::~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
19class Page : public QPixmap
20{
21public:
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
@@ -17,5 +17,5 @@
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
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
@@ -17,5 +17,5 @@
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
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
@@ -17,2 +17,3 @@
17#include "drawpadcanvas.h" 17#include "drawpadcanvas.h"
18#include "page.h"
18 19
@@ -21,3 +22,2 @@
21#include <qpainter.h> 22#include <qpainter.h>
22#include <qpixmap.h>
23 23
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
26ThumbnailView::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
111ThumbnailView::~ThumbnailView()
112{
113}
114
115void 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
21class QListView;
22
23class Page;
24
25class ThumbnailView : public QDialog
26{
27 Q_OBJECT
28
29public:
30 ThumbnailView(QList<Page> pages, QWidget* parent = 0, const char* name = 0);
31 ~ThumbnailView();
32
33protected:
34 void resizeEvent(QResizeEvent* e);
35
36private:
37 QListView* m_pListView;
38};
39
40#endif // THUMBNAILVIEW_H