summaryrefslogtreecommitdiff
authorzecke <zecke>2004-04-08 00:42:01 (UTC)
committer zecke <zecke>2004-04-08 00:42:01 (UTC)
commit5afca2540a2d6bf733c89ea97748496a679bc576 (patch) (unidiff)
tree3e4e419ccc0e1b1cb71cc2cf7e75d36f9301de81
parent8c54ad421c7bee65b2a1442ce85c09f2eff3efc6 (diff)
downloadopie-5afca2540a2d6bf733c89ea97748496a679bc576.zip
opie-5afca2540a2d6bf733c89ea97748496a679bc576.tar.gz
opie-5afca2540a2d6bf733c89ea97748496a679bc576.tar.bz2
Import a QPixmap via QCOP
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp19
-rw-r--r--noncore/graphics/drawpad/drawpad.h2
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp20
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h5
4 files changed, 40 insertions, 6 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 3331193..d9d0ce0 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -1,665 +1,684 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "drawpad.h" 14#include "drawpad.h"
15 15
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 "newpagedialog.h" 25#include "newpagedialog.h"
26#include "page.h" 26#include "page.h"
27#include "pageinformationdialog.h" 27#include "pageinformationdialog.h"
28#include "pointtool.h" 28#include "pointtool.h"
29#include "rectangletool.h" 29#include "rectangletool.h"
30#include "texttool.h" 30#include "texttool.h"
31#include "thumbnailview.h" 31#include "thumbnailview.h"
32 32
33#include <opie2/qcolordialog.h> 33#include <opie2/qcolordialog.h>
34#include <opie2/ocolorpopupmenu.h> 34#include <opie2/ocolorpopupmenu.h>
35 35
36#include <qpe/applnk.h> 36#include <qpe/applnk.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qtoolbar.h> 38#include <qtoolbar.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
41 41
42#include <qmenubar.h> 42#include <qmenubar.h>
43#include <qaction.h> 43#include <qaction.h>
44#include <qfile.h> 44#include <qfile.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qspinbox.h> 46#include <qspinbox.h>
47#include <qtoolbutton.h> 47#include <qtoolbutton.h>
48#include <qtooltip.h> 48#include <qtooltip.h>
49#include <qwhatsthis.h> 49#include <qwhatsthis.h>
50 50
51using namespace Opie::Ui; 51using namespace Opie::Ui;
52using namespace Opie::Ui; 52using namespace Opie::Ui;
53DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) 53DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ )
54 : QMainWindow(parent, name, WStyle_ContextHelp) 54 : QMainWindow(parent, name, WStyle_ContextHelp)
55{ 55{
56 // init members 56 // init members
57 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
58 this, SLOT(slotAppMessage(const QCString&, const QByteArray&)) );
57 59
58 m_pDrawPadCanvas = new DrawPadCanvas(this, this); 60 m_pDrawPadCanvas = new DrawPadCanvas(this, this);
59 61
60 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); 62 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView()));
61 63
62 setCentralWidget(m_pDrawPadCanvas); 64 setCentralWidget(m_pDrawPadCanvas);
63 65
64 // init menu 66 // init menu
65 67
66 setToolBarsMovable(false); 68 setToolBarsMovable(false);
67 69
68 QToolBar* menuToolBar = new QToolBar(this); 70 QToolBar* menuToolBar = new QToolBar(this);
69 QMenuBar* menuBar = new QMenuBar(menuToolBar); 71 QMenuBar* menuBar = new QMenuBar(menuToolBar);
70 72
71 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); 73 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar);
72 74
73 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); 75 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
74 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); 76 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll()));
75 deleteAllAction->addTo(toolsPopupMenu); 77 deleteAllAction->addTo(toolsPopupMenu);
76 78
77 toolsPopupMenu->insertSeparator(); 79 toolsPopupMenu->insertSeparator();
78 80
79 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); 81 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
80 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); 82 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
81 importPageAction->addTo(toolsPopupMenu); 83 importPageAction->addTo(toolsPopupMenu);
82 84
83 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); 85 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this);
84 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); 86 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage()));
85 exportPageAction->addTo(toolsPopupMenu); 87 exportPageAction->addTo(toolsPopupMenu);
86 88
87 toolsPopupMenu->insertSeparator(); 89 toolsPopupMenu->insertSeparator();
88 90
89 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); 91 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this);
90 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); 92 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView()));
91 thumbnailViewAction->addTo(toolsPopupMenu); 93 thumbnailViewAction->addTo(toolsPopupMenu);
92 94
93 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); 95 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this);
94 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); 96 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation()));
95 pageInformationAction->addTo(toolsPopupMenu); 97 pageInformationAction->addTo(toolsPopupMenu);
96 98
97 toolsPopupMenu->insertSeparator(); 99 toolsPopupMenu->insertSeparator();
98 100
99 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); 101 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this);
100 m_pAntiAliasingAction->setToggleAction(true); 102 m_pAntiAliasingAction->setToggleAction(true);
101 m_pAntiAliasingAction->addTo(toolsPopupMenu); 103 m_pAntiAliasingAction->addTo(toolsPopupMenu);
102 104
103 menuBar->insertItem(tr("Tools"), toolsPopupMenu); 105 menuBar->insertItem(tr("Tools"), toolsPopupMenu);
104 106
105 // init page toolbar 107 // init page toolbar
106 108
107 QToolBar* pageToolBar = new QToolBar(this); 109 QToolBar* pageToolBar = new QToolBar(this);
108 110
109 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); 111 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this);
110 connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); 112 connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage()));
111 newPageAction->addTo(pageToolBar); 113 newPageAction->addTo(pageToolBar);
112 newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); 114 newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) );
113 115
114 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); 116 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this);
115 connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); 117 connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage()));
116 clearPageAction->addTo(pageToolBar); 118 clearPageAction->addTo(pageToolBar);
117 clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); 119 clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) );
118 120
119 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); 121 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this);
120 connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); 122 connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage()));
121 deletePageAction->addTo(pageToolBar); 123 deletePageAction->addTo(pageToolBar);
122 deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); 124 deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) );
123 125
124 QToolBar* emptyToolBar = new QToolBar(this); 126 QToolBar* emptyToolBar = new QToolBar(this);
125 emptyToolBar->setHorizontalStretchable(true); 127 emptyToolBar->setHorizontalStretchable(true);
126 128
127 // init navigation toolbar 129 // init navigation toolbar
128 130
129 QToolBar* navigationToolBar = new QToolBar(this); 131 QToolBar* navigationToolBar = new QToolBar(this);
130 132
131 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); 133 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this);
132 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); 134 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo()));
133 m_pUndoAction->addTo(navigationToolBar); 135 m_pUndoAction->addTo(navigationToolBar);
134 m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); 136 m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) );
135 137
136 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); 138 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this);
137 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); 139 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo()));
138 m_pRedoAction->addTo(navigationToolBar); 140 m_pRedoAction->addTo(navigationToolBar);
139 m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); 141 m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) );
140 142
141 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); 143 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this);
142 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); 144 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage()));
143 m_pFirstPageAction->addTo(navigationToolBar); 145 m_pFirstPageAction->addTo(navigationToolBar);
144 m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); 146 m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) );
145 147
146 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); 148 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this);
147 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); 149 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage()));
148 m_pPreviousPageAction->addTo(navigationToolBar); 150 m_pPreviousPageAction->addTo(navigationToolBar);
149 m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); 151 m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) );
150 152
151 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); 153 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this);
152 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); 154 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage()));
153 m_pNextPageAction->addTo(navigationToolBar); 155 m_pNextPageAction->addTo(navigationToolBar);
154 m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); 156 m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) );
155 157
156 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); 158 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this);
157 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); 159 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage()));
158 m_pLastPageAction->addTo(navigationToolBar); 160 m_pLastPageAction->addTo(navigationToolBar);
159 m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); 161 m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) );
160 162
161 // init draw mode toolbar 163 // init draw mode toolbar
162 164
163 QToolBar* drawModeToolBar = new QToolBar(this); 165 QToolBar* drawModeToolBar = new QToolBar(this);
164 166
165 m_pLineToolButton = new QToolButton(drawModeToolBar); 167 m_pLineToolButton = new QToolButton(drawModeToolBar);
166 m_pLineToolButton->setToggleButton(true); 168 m_pLineToolButton->setToggleButton(true);
167 QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); 169 QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) );
168 170
169 171
170 QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); 172 QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton);
171 173
172 m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); 174 m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this);
173 connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); 175 connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool()));
174 m_pPointToolAction->addTo(linePopupMenu); 176 m_pPointToolAction->addTo(linePopupMenu);
175 177
176 m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); 178 m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this);
177 connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); 179 connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool()));
178 m_pLineToolAction->addTo(linePopupMenu); 180 m_pLineToolAction->addTo(linePopupMenu);
179 181
180 m_pLineToolButton->setPopup(linePopupMenu); 182 m_pLineToolButton->setPopup(linePopupMenu);
181 m_pLineToolButton->setPopupDelay(0); 183 m_pLineToolButton->setPopupDelay(0);
182 184
183 m_pRectangleToolButton = new QToolButton(drawModeToolBar); 185 m_pRectangleToolButton = new QToolButton(drawModeToolBar);
184 m_pRectangleToolButton->setToggleButton(true); 186 m_pRectangleToolButton->setToggleButton(true);
185 QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); 187 QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) );
186 188
187 QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); 189 QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton);
188 190
189 m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); 191 m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this);
190 connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); 192 connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool()));
191 m_pRectangleToolAction->addTo(rectanglePopupMenu); 193 m_pRectangleToolAction->addTo(rectanglePopupMenu);
192 194
193 m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); 195 m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this);
194 connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); 196 connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool()));
195 m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); 197 m_pFilledRectangleToolAction->addTo(rectanglePopupMenu);
196 198
197 m_pRectangleToolButton->setPopup(rectanglePopupMenu); 199 m_pRectangleToolButton->setPopup(rectanglePopupMenu);
198 m_pRectangleToolButton->setPopupDelay(0); 200 m_pRectangleToolButton->setPopupDelay(0);
199 201
200 m_pEllipseToolButton = new QToolButton(drawModeToolBar); 202 m_pEllipseToolButton = new QToolButton(drawModeToolBar);
201 m_pEllipseToolButton->setToggleButton(true); 203 m_pEllipseToolButton->setToggleButton(true);
202 QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); 204 QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) );
203 205
204 QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); 206 QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton);
205 207
206 m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); 208 m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this);
207 connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); 209 connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool()));
208 m_pEllipseToolAction->addTo(ellipsePopupMenu); 210 m_pEllipseToolAction->addTo(ellipsePopupMenu);
209 211
210 m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); 212 m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this);
211 connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); 213 connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool()));
212 m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); 214 m_pFilledEllipseToolAction->addTo(ellipsePopupMenu);
213 215
214 m_pEllipseToolButton->setPopup(ellipsePopupMenu); 216 m_pEllipseToolButton->setPopup(ellipsePopupMenu);
215 m_pEllipseToolButton->setPopupDelay(0); 217 m_pEllipseToolButton->setPopupDelay(0);
216 218
217 m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); 219 m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this);
218 m_pTextToolAction->setToggleAction(true); 220 m_pTextToolAction->setToggleAction(true);
219 connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); 221 connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool()));
220 m_pTextToolAction->addTo(drawModeToolBar); 222 m_pTextToolAction->addTo(drawModeToolBar);
221 m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); 223 m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) );
222 224
223 m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); 225 m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this);
224 m_pFillToolAction->setToggleAction(true); 226 m_pFillToolAction->setToggleAction(true);
225 connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); 227 connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool()));
226 m_pFillToolAction->addTo(drawModeToolBar); 228 m_pFillToolAction->addTo(drawModeToolBar);
227 m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); 229 m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) );
228 230
229 m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); 231 m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this);
230 m_pEraseToolAction->setToggleAction(true); 232 m_pEraseToolAction->setToggleAction(true);
231 connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); 233 connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool()));
232 m_pEraseToolAction->addTo(drawModeToolBar); 234 m_pEraseToolAction->addTo(drawModeToolBar);
233 m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); 235 m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) );
234 236
235 m_pTool = 0; 237 m_pTool = 0;
236 setRectangleTool(); 238 setRectangleTool();
237 setEllipseTool(); 239 setEllipseTool();
238 setPointTool(); 240 setPointTool();
239 241
240 emptyToolBar = new QToolBar(this); 242 emptyToolBar = new QToolBar(this);
241 emptyToolBar->setHorizontalStretchable(true); 243 emptyToolBar->setHorizontalStretchable(true);
242 emptyToolBar->addSeparator(); 244 emptyToolBar->addSeparator();
243 245
244 // init draw parameters toolbar 246 // init draw parameters toolbar
245 247
246 QToolBar* drawParametersToolBar = new QToolBar(this); 248 QToolBar* drawParametersToolBar = new QToolBar(this);
247 249
248 m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); 250 m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
249 connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); 251 connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
250 252
251 QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); 253 QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width"));
252 m_pPenWidthSpinBox->setValue(1); 254 m_pPenWidthSpinBox->setValue(1);
253 m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); 255 m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
254 QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); 256 QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) );
255 257
256 m_pPenColorToolButton = new QToolButton(drawParametersToolBar); 258 m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
257 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); 259 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor"));
258 QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); 260 QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) );
259 261
260 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, m_pPenColorToolButton); 262 Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, m_pPenColorToolButton);
261 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); 263 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
262 264
263 QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); 265 QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
264 m_pPenColorToolButton->setPopup(penColorPopupMenu); 266 m_pPenColorToolButton->setPopup(penColorPopupMenu);
265 m_pPenColorToolButton->setPopupDelay(0); 267 m_pPenColorToolButton->setPopupDelay(0);
266 268
267 changePenColor(Qt::black); 269 changePenColor(Qt::black);
268 270
269 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); 271 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
270 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); 272 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor"));
271 QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); 273 QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) );
272 274
273 Opie::OColorPopupMenu* brushColorPopupMenu = new Opie::OColorPopupMenu(Qt::white, m_pBrushColorToolButton); 275 Opie::OColorPopupMenu* brushColorPopupMenu = new Opie::OColorPopupMenu(Qt::white, m_pBrushColorToolButton);
274 connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); 276 connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
275 277
276 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); 278 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
277 m_pBrushColorToolButton->setPopup(brushColorPopupMenu); 279 m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
278 m_pBrushColorToolButton->setPopupDelay(0); 280 m_pBrushColorToolButton->setPopupDelay(0);
279 281
280 changeBrushColor(Qt::white); 282 changeBrushColor(Qt::white);
281 283
282 finishStartup(); 284 finishStartup();
283} 285}
284 286
285 287
286void DrawPad::finishStartup() 288void DrawPad::finishStartup()
287{ 289{
288 // init pages 290 // init pages
289 291
290 QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); 292 QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
291 293
292 if (file.open(IO_ReadOnly)) { 294 if (file.open(IO_ReadOnly)) {
293 m_pDrawPadCanvas->load(&file); 295 m_pDrawPadCanvas->load(&file);
294 file.close(); 296 file.close();
295 } else { 297 } else {
296 m_pDrawPadCanvas->initialPage(); 298 m_pDrawPadCanvas->initialPage();
297 } 299 }
298 300
299 loadConfig(); 301 loadConfig();
300 302
301} 303}
302 304
303DrawPad::~DrawPad() 305DrawPad::~DrawPad()
304{ 306{
305 saveConfig(); 307 saveConfig();
306 308
307 QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); 309 QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
308 310
309 if (file.open(IO_WriteOnly)) { 311 if (file.open(IO_WriteOnly)) {
310 m_pDrawPadCanvas->save(&file); 312 m_pDrawPadCanvas->save(&file);
311 file.close(); 313 file.close();
312 } 314 }
313} 315}
314 316
315bool DrawPad::antiAliasing() 317bool DrawPad::antiAliasing()
316{ 318{
317 return (m_pAntiAliasingAction->isOn()); 319 return (m_pAntiAliasingAction->isOn());
318} 320}
319 321
320void DrawPad::newPage() 322void DrawPad::newPage()
321{ 323{
322 QRect rect = m_pDrawPadCanvas->contentsRect(); 324 QRect rect = m_pDrawPadCanvas->contentsRect();
323 325
324 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); 326 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this);
325 327
326 if (newPageDialog.exec() == QDialog::Accepted) { 328 if (newPageDialog.exec() == QDialog::Accepted) {
327 m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), 329 m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(),
328 newPageDialog.selectedHeight(), newPageDialog.selectedColor()); 330 newPageDialog.selectedHeight(), newPageDialog.selectedColor());
329 } 331 }
330} 332}
331 333
332void DrawPad::clearPage() 334void DrawPad::clearPage()
333{ 335{
334 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), 336 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
335 QMessageBox::Information, QMessageBox::Yes, 337 QMessageBox::Information, QMessageBox::Yes,
336 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 338 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
337 QMessageBox::NoButton, this); 339 QMessageBox::NoButton, this);
338 340
339 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 341 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
340 messageBox.setButtonText(QMessageBox::No, tr("No")); 342 messageBox.setButtonText(QMessageBox::No, tr("No"));
341 343
342 if (messageBox.exec() == QMessageBox::Yes) { 344 if (messageBox.exec() == QMessageBox::Yes) {
343 m_pDrawPadCanvas->clearPage(); 345 m_pDrawPadCanvas->clearPage();
344 } 346 }
345} 347}
346 348
347void DrawPad::deletePage() 349void DrawPad::deletePage()
348{ 350{
349 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), 351 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"),
350 QMessageBox::Information, QMessageBox::Yes, 352 QMessageBox::Information, QMessageBox::Yes,
351 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 353 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
352 QMessageBox::NoButton, this); 354 QMessageBox::NoButton, this);
353 355
354 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 356 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
355 messageBox.setButtonText(QMessageBox::No, tr("No")); 357 messageBox.setButtonText(QMessageBox::No, tr("No"));
356 358
357 if (messageBox.exec() == QMessageBox::Yes) { 359 if (messageBox.exec() == QMessageBox::Yes) {
358 m_pDrawPadCanvas->deletePage(); 360 m_pDrawPadCanvas->deletePage();
359 } 361 }
360} 362}
361 363
362void DrawPad::setPointTool() 364void DrawPad::setPointTool()
363{ 365{
364 if (m_pTool) { 366 if (m_pTool) {
365 delete m_pTool; 367 delete m_pTool;
366 } 368 }
367 369
368 m_pTool = new PointTool(this, m_pDrawPadCanvas); 370 m_pTool = new PointTool(this, m_pDrawPadCanvas);
369 371
370 m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); 372 m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet());
371 QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); 373 QToolTip::add(m_pLineToolButton, m_pPointToolAction->text());
372 374
373 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); 375 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0);
374 connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); 376 connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated()));
375 377
376 m_pLineToolButton->setOn(true); 378 m_pLineToolButton->setOn(true);
377 m_pRectangleToolButton->setOn(false); 379 m_pRectangleToolButton->setOn(false);
378 m_pEllipseToolButton->setOn(false); 380 m_pEllipseToolButton->setOn(false);
379 m_pTextToolAction->setOn(false); 381 m_pTextToolAction->setOn(false);
380 m_pFillToolAction->setOn(false); 382 m_pFillToolAction->setOn(false);
381 m_pEraseToolAction->setOn(false); 383 m_pEraseToolAction->setOn(false);
382} 384}
383 385
384void DrawPad::setLineTool() 386void DrawPad::setLineTool()
385{ 387{
386 if (m_pTool) { 388 if (m_pTool) {
387 delete m_pTool; 389 delete m_pTool;
388 } 390 }
389 391
390 m_pTool = new LineTool(this, m_pDrawPadCanvas); 392 m_pTool = new LineTool(this, m_pDrawPadCanvas);
391 393
392 m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); 394 m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet());
393 QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); 395 QToolTip::add(m_pLineToolButton, m_pLineToolAction->text());
394 396
395 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); 397 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0);
396 connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); 398 connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated()));
397 399
398 m_pLineToolButton->setOn(true); 400 m_pLineToolButton->setOn(true);
399 m_pRectangleToolButton->setOn(false); 401 m_pRectangleToolButton->setOn(false);
400 m_pEllipseToolButton->setOn(false); 402 m_pEllipseToolButton->setOn(false);
401 m_pTextToolAction->setOn(false); 403 m_pTextToolAction->setOn(false);
402 m_pFillToolAction->setOn(false); 404 m_pFillToolAction->setOn(false);
403 m_pEraseToolAction->setOn(false); 405 m_pEraseToolAction->setOn(false);
404} 406}
405 407
406void DrawPad::setRectangleTool() 408void DrawPad::setRectangleTool()
407{ 409{
408 if (m_pTool) { 410 if (m_pTool) {
409 delete m_pTool; 411 delete m_pTool;
410 } 412 }
411 413
412 m_pTool = new RectangleTool(this, m_pDrawPadCanvas); 414 m_pTool = new RectangleTool(this, m_pDrawPadCanvas);
413 415
414 m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); 416 m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet());
415 QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); 417 QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text());
416 418
417 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); 419 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
418 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); 420 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated()));
419 421
420 m_pLineToolButton->setOn(false); 422 m_pLineToolButton->setOn(false);
421 m_pRectangleToolButton->setOn(true); 423 m_pRectangleToolButton->setOn(true);
422 m_pEllipseToolButton->setOn(false); 424 m_pEllipseToolButton->setOn(false);
423 m_pTextToolAction->setOn(false); 425 m_pTextToolAction->setOn(false);
424 m_pFillToolAction->setOn(false); 426 m_pFillToolAction->setOn(false);
425 m_pEraseToolAction->setOn(false); 427 m_pEraseToolAction->setOn(false);
426} 428}
427 429
428void DrawPad::setFilledRectangleTool() 430void DrawPad::setFilledRectangleTool()
429{ 431{
430 if (m_pTool) { 432 if (m_pTool) {
431 delete m_pTool; 433 delete m_pTool;
432 } 434 }
433 435
434 m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); 436 m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas);
435 437
436 m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); 438 m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet());
437 QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); 439 QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text());
438 440
439 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); 441 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
440 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); 442 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated()));
441 443
442 m_pLineToolButton->setOn(false); 444 m_pLineToolButton->setOn(false);
443 m_pRectangleToolButton->setOn(true); 445 m_pRectangleToolButton->setOn(true);
444 m_pEllipseToolButton->setOn(false); 446 m_pEllipseToolButton->setOn(false);
445 m_pTextToolAction->setOn(false); 447 m_pTextToolAction->setOn(false);
446 m_pFillToolAction->setOn(false); 448 m_pFillToolAction->setOn(false);
447 m_pEraseToolAction->setOn(false); 449 m_pEraseToolAction->setOn(false);
448} 450}
449 451
450void DrawPad::setEllipseTool() 452void DrawPad::setEllipseTool()
451{ 453{
452 if (m_pTool) { 454 if (m_pTool) {
453 delete m_pTool; 455 delete m_pTool;
454 } 456 }
455 457
456 m_pTool = new EllipseTool(this, m_pDrawPadCanvas); 458 m_pTool = new EllipseTool(this, m_pDrawPadCanvas);
457 459
458 m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); 460 m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet());
459 QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); 461 QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text());
460 462
461 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); 463 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
462 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); 464 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated()));
463 465
464 m_pLineToolButton->setOn(false); 466 m_pLineToolButton->setOn(false);
465 m_pRectangleToolButton->setOn(false); 467 m_pRectangleToolButton->setOn(false);
466 m_pEllipseToolButton->setOn(true); 468 m_pEllipseToolButton->setOn(true);
467 m_pTextToolAction->setOn(false); 469 m_pTextToolAction->setOn(false);
468 m_pFillToolAction->setOn(false); 470 m_pFillToolAction->setOn(false);
469 m_pEraseToolAction->setOn(false); 471 m_pEraseToolAction->setOn(false);
470} 472}
471 473
472void DrawPad::setFilledEllipseTool() 474void DrawPad::setFilledEllipseTool()
473{ 475{
474 if (m_pTool) { 476 if (m_pTool) {
475 delete m_pTool; 477 delete m_pTool;
476 } 478 }
477 479
478 m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); 480 m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas);
479 481
480 m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); 482 m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet());
481 QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); 483 QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text());
482 484
483 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); 485 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
484 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); 486 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated()));
485 487
486 m_pLineToolButton->setOn(false); 488 m_pLineToolButton->setOn(false);
487 m_pRectangleToolButton->setOn(false); 489 m_pRectangleToolButton->setOn(false);
488 m_pEllipseToolButton->setOn(true); 490 m_pEllipseToolButton->setOn(true);
489 m_pTextToolAction->setOn(false); 491 m_pTextToolAction->setOn(false);
490 m_pFillToolAction->setOn(false); 492 m_pFillToolAction->setOn(false);
491 m_pEraseToolAction->setOn(false); 493 m_pEraseToolAction->setOn(false);
492} 494}
493 495
494void DrawPad::setTextTool() 496void DrawPad::setTextTool()
495{ 497{
496 if (m_pTool) { 498 if (m_pTool) {
497 delete m_pTool; 499 delete m_pTool;
498 } 500 }
499 501
500 m_pTool = new TextTool(this, m_pDrawPadCanvas); 502 m_pTool = new TextTool(this, m_pDrawPadCanvas);
501 503
502 m_pLineToolButton->setOn(false); 504 m_pLineToolButton->setOn(false);
503 m_pRectangleToolButton->setOn(false); 505 m_pRectangleToolButton->setOn(false);
504 m_pEllipseToolButton->setOn(false); 506 m_pEllipseToolButton->setOn(false);
505 m_pTextToolAction->setOn(true); 507 m_pTextToolAction->setOn(true);
506 m_pFillToolAction->setOn(false); 508 m_pFillToolAction->setOn(false);
507 m_pEraseToolAction->setOn(false); 509 m_pEraseToolAction->setOn(false);
508} 510}
509 511
510void DrawPad::setFillTool() 512void DrawPad::setFillTool()
511{ 513{
512 if (m_pTool) { 514 if (m_pTool) {
513 delete m_pTool; 515 delete m_pTool;
514 } 516 }
515 517
516 m_pTool = new FillTool(this, m_pDrawPadCanvas); 518 m_pTool = new FillTool(this, m_pDrawPadCanvas);
517 519
518 m_pLineToolButton->setOn(false); 520 m_pLineToolButton->setOn(false);
519 m_pRectangleToolButton->setOn(false); 521 m_pRectangleToolButton->setOn(false);
520 m_pEllipseToolButton->setOn(false); 522 m_pEllipseToolButton->setOn(false);
521 m_pTextToolAction->setOn(false); 523 m_pTextToolAction->setOn(false);
522 m_pFillToolAction->setOn(true); 524 m_pFillToolAction->setOn(true);
523 m_pEraseToolAction->setOn(false); 525 m_pEraseToolAction->setOn(false);
524} 526}
525 527
526void DrawPad::setEraseTool() 528void DrawPad::setEraseTool()
527{ 529{
528 if (m_pTool) { 530 if (m_pTool) {
529 delete m_pTool; 531 delete m_pTool;
530 } 532 }
531 533
532 m_pTool = new EraseTool(this, m_pDrawPadCanvas); 534 m_pTool = new EraseTool(this, m_pDrawPadCanvas);
533 535
534 m_pLineToolButton->setOn(false); 536 m_pLineToolButton->setOn(false);
535 m_pRectangleToolButton->setOn(false); 537 m_pRectangleToolButton->setOn(false);
536 m_pEllipseToolButton->setOn(false); 538 m_pEllipseToolButton->setOn(false);
537 m_pTextToolAction->setOn(false); 539 m_pTextToolAction->setOn(false);
538 m_pFillToolAction->setOn(false); 540 m_pFillToolAction->setOn(false);
539 m_pEraseToolAction->setOn(true); 541 m_pEraseToolAction->setOn(true);
540} 542}
541 543
542void DrawPad::changePenWidth(int value) 544void DrawPad::changePenWidth(int value)
543{ 545{
544 m_pen.setWidth(value); 546 m_pen.setWidth(value);
545} 547}
546 548
547void DrawPad::changePenColor(const QColor& color) 549void DrawPad::changePenColor(const QColor& color)
548{ 550{
549 m_pen.setColor(color); 551 m_pen.setColor(color);
550 552
551 QPainter painter; 553 QPainter painter;
552 painter.begin(m_pPenColorToolButton->pixmap()); 554 painter.begin(m_pPenColorToolButton->pixmap());
553 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); 555 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color());
554 painter.end(); 556 painter.end();
555 557
556 m_pPenColorToolButton->popup()->hide(); 558 m_pPenColorToolButton->popup()->hide();
557} 559}
558 560
559void DrawPad::changeBrushColor(const QColor& color) 561void DrawPad::changeBrushColor(const QColor& color)
560{ 562{
561 m_brush = QBrush(color); 563 m_brush = QBrush(color);
562 564
563 QPainter painter; 565 QPainter painter;
564 painter.begin(m_pBrushColorToolButton->pixmap()); 566 painter.begin(m_pBrushColorToolButton->pixmap());
565 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); 567 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color());
566 painter.end(); 568 painter.end();
567 569
568 m_pBrushColorToolButton->popup()->hide(); 570 m_pBrushColorToolButton->popup()->hide();
569} 571}
570 572
571void DrawPad::updateView() 573void DrawPad::updateView()
572{ 574{
573 uint pagePosition = m_pDrawPadCanvas->pagePosition(); 575 uint pagePosition = m_pDrawPadCanvas->pagePosition();
574 uint pageCount = m_pDrawPadCanvas->pageCount(); 576 uint pageCount = m_pDrawPadCanvas->pageCount();
575 577
576 setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); 578 setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) );
577 579
578 m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); 580 m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled());
579 m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); 581 m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled());
580 582
581 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 583 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
582 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 584 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
583 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 585 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
584 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 586 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
585} 587}
586 588
587void DrawPad::deleteAll() 589void DrawPad::deleteAll()
588{ 590{
589 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), 591 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"),
590 QMessageBox::Information, QMessageBox::Yes, 592 QMessageBox::Information, QMessageBox::Yes,
591 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 593 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
592 QMessageBox::NoButton, this); 594 QMessageBox::NoButton, this);
593 595
594 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 596 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
595 messageBox.setButtonText(QMessageBox::No, tr("No")); 597 messageBox.setButtonText(QMessageBox::No, tr("No"));
596 598
597 if (messageBox.exec() == QMessageBox::Yes) { 599 if (messageBox.exec() == QMessageBox::Yes) {
598 m_pDrawPadCanvas->deleteAll(); 600 m_pDrawPadCanvas->deleteAll();
599 } 601 }
600} 602}
601 603
602void DrawPad::importPage() 604void DrawPad::importPage()
603{ 605{
604 ImportDialog importDialog(this); 606 ImportDialog importDialog(this);
605 607
606 if ( QPEApplication::execDialog( &importDialog ) == QDialog::Accepted ) { 608 if ( QPEApplication::execDialog( &importDialog ) == QDialog::Accepted ) {
607 const DocLnk* docLnk = importDialog.selected(); 609 const DocLnk* docLnk = importDialog.selected();
608 610
609 if (docLnk) { 611 if (docLnk) {
610 m_pDrawPadCanvas->importPage(docLnk->file()); 612 m_pDrawPadCanvas->importPage(docLnk->file());
611 delete docLnk; 613 delete docLnk;
612 } 614 }
613 } 615 }
614} 616}
615 617
616void DrawPad::exportPage() 618void DrawPad::exportPage()
617{ 619{
618 ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); 620 ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this);
619 621
620 if ( QPEApplication::execDialog( &exportDialog ) == QDialog::Accepted ) { 622 if ( QPEApplication::execDialog( &exportDialog ) == QDialog::Accepted ) {
621 m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), 623 m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(),
622 exportDialog.selectedName(), exportDialog.selectedFormat()); 624 exportDialog.selectedName(), exportDialog.selectedFormat());
623 } 625 }
624} 626}
625 627
626void DrawPad::thumbnailView() 628void DrawPad::thumbnailView()
627{ 629{
628 ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); 630 ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this);
629 631
630 QPEApplication::showWidget( &thumbnailView ); 632 QPEApplication::showWidget( &thumbnailView );
631 thumbnailView.exec(); 633 thumbnailView.exec();
632} 634}
633 635
634void DrawPad::pageInformation() 636void DrawPad::pageInformation()
635{ 637{
636 PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); 638 PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage());
637 639
638 if (pageInformationDialog.exec() == QDialog::Accepted) { 640 if (pageInformationDialog.exec() == QDialog::Accepted) {
639 m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); 641 m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle());
640 } 642 }
641} 643}
642 644
643void DrawPad::loadConfig() 645void DrawPad::loadConfig()
644{ 646{
645 Config config("drawpad"); 647 Config config("drawpad");
646 config.setGroup("General"); 648 config.setGroup("General");
647 649
648 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); 650 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false));
649 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); 651 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1));
650 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); 652 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name())));
651 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); 653 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name())));
652 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); 654 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1));
653} 655}
654 656
655void DrawPad::saveConfig() 657void DrawPad::saveConfig()
656{ 658{
657 Config config("drawpad"); 659 Config config("drawpad");
658 config.setGroup("General"); 660 config.setGroup("General");
659 661
660 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); 662 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition());
661 config.writeEntry("AntiAliasing", antiAliasing()); 663 config.writeEntry("AntiAliasing", antiAliasing());
662 config.writeEntry("PenWidth", (int)m_pen.width()); 664 config.writeEntry("PenWidth", (int)m_pen.width());
663 config.writeEntry("PenColor", m_pen.color().name()); 665 config.writeEntry("PenColor", m_pen.color().name());
664 config.writeEntry("BrushColor", m_brush.color().name()); 666 config.writeEntry("BrushColor", m_brush.color().name());
665} 667}
668
669
670/*
671 * Import a Thumbnail from SCAP or similiar
672 */
673void DrawPad::slotAppMessage( const QCString& str, const QByteArray& ar ) {
674 QDataStream stream(ar, IO_ReadOnly );
675 /*
676 * import the pixmap
677 */
678 if ( str == "importPixmap(QPixmap)" ) {
679 QPixmap pix;
680 stream >> pix;;
681 m_pDrawPadCanvas->importPixmap( pix );
682 QPEApplication::setKeepRunning();
683 }
684}
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index 8ba6e58..ba9e47d 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -1,112 +1,114 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef DRAWPAD_H 14#ifndef DRAWPAD_H
15#define DRAWPAD_H 15#define DRAWPAD_H
16 16
17#include <qmainwindow.h> 17#include <qmainwindow.h>
18#include <qpen.h> 18#include <qpen.h>
19 19
20class DrawPadCanvas; 20class DrawPadCanvas;
21class Tool; 21class Tool;
22 22
23class QAction; 23class QAction;
24class QColor; 24class QColor;
25class QSpinBox; 25class QSpinBox;
26class QToolButton; 26class QToolButton;
27class QWidgetStack; 27class QWidgetStack;
28 28
29class DrawPad : public QMainWindow 29class DrawPad : public QMainWindow
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 DrawPad(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 34 DrawPad(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
35 ~DrawPad(); 35 ~DrawPad();
36 36
37 static QString appName() { return QString::fromLatin1("drawpad"); } 37 static QString appName() { return QString::fromLatin1("drawpad"); }
38 38
39 Tool* tool() { return m_pTool; } 39 Tool* tool() { return m_pTool; }
40 QPen pen() { return m_pen; } 40 QPen pen() { return m_pen; }
41 QBrush brush() { return m_brush; } 41 QBrush brush() { return m_brush; }
42 42
43 bool antiAliasing(); 43 bool antiAliasing();
44 void finishStartup(); 44 void finishStartup();
45 45
46private slots: 46private slots:
47 void newPage(); 47 void newPage();
48 void clearPage(); 48 void clearPage();
49 void deletePage(); 49 void deletePage();
50 50
51 void slotAppMessage( const QCString&, const QByteArray& );
52
51 void setPointTool(); 53 void setPointTool();
52 void setLineTool(); 54 void setLineTool();
53 void setRectangleTool(); 55 void setRectangleTool();
54 void setFilledRectangleTool(); 56 void setFilledRectangleTool();
55 void setEllipseTool(); 57 void setEllipseTool();
56 void setFilledEllipseTool(); 58 void setFilledEllipseTool();
57 void setTextTool(); 59 void setTextTool();
58 void setFillTool(); 60 void setFillTool();
59 void setEraseTool(); 61 void setEraseTool();
60 62
61 void changePenWidth(int value); 63 void changePenWidth(int value);
62 void changePenColor(const QColor& color); 64 void changePenColor(const QColor& color);
63 void changeBrushColor(const QColor& color); 65 void changeBrushColor(const QColor& color);
64 66
65 void updateView(); 67 void updateView();
66 68
67 void deleteAll(); 69 void deleteAll();
68 void importPage(); 70 void importPage();
69 void exportPage(); 71 void exportPage();
70 void thumbnailView(); 72 void thumbnailView();
71 void pageInformation(); 73 void pageInformation();
72 74
73private: 75private:
74 void loadConfig(); 76 void loadConfig();
75 void saveConfig(); 77 void saveConfig();
76 78
77 DrawPadCanvas* m_pDrawPadCanvas; 79 DrawPadCanvas* m_pDrawPadCanvas;
78 80
79 Tool* m_pTool; 81 Tool* m_pTool;
80 QPen m_pen; 82 QPen m_pen;
81 QBrush m_brush; 83 QBrush m_brush;
82 84
83 QAction* m_pAntiAliasingAction; 85 QAction* m_pAntiAliasingAction;
84 86
85 QAction* m_pUndoAction; 87 QAction* m_pUndoAction;
86 QAction* m_pRedoAction; 88 QAction* m_pRedoAction;
87 89
88 QAction* m_pFirstPageAction; 90 QAction* m_pFirstPageAction;
89 QAction* m_pPreviousPageAction; 91 QAction* m_pPreviousPageAction;
90 QAction* m_pNextPageAction; 92 QAction* m_pNextPageAction;
91 QAction* m_pLastPageAction; 93 QAction* m_pLastPageAction;
92 94
93 QAction* m_pPointToolAction; 95 QAction* m_pPointToolAction;
94 QAction* m_pLineToolAction; 96 QAction* m_pLineToolAction;
95 QAction* m_pRectangleToolAction; 97 QAction* m_pRectangleToolAction;
96 QAction* m_pFilledRectangleToolAction; 98 QAction* m_pFilledRectangleToolAction;
97 QAction* m_pEllipseToolAction; 99 QAction* m_pEllipseToolAction;
98 QAction* m_pFilledEllipseToolAction; 100 QAction* m_pFilledEllipseToolAction;
99 QAction* m_pTextToolAction; 101 QAction* m_pTextToolAction;
100 QAction* m_pFillToolAction; 102 QAction* m_pFillToolAction;
101 QAction* m_pEraseToolAction; 103 QAction* m_pEraseToolAction;
102 104
103 QToolButton* m_pLineToolButton; 105 QToolButton* m_pLineToolButton;
104 QToolButton* m_pRectangleToolButton; 106 QToolButton* m_pRectangleToolButton;
105 QToolButton* m_pEllipseToolButton; 107 QToolButton* m_pEllipseToolButton;
106 QToolButton* m_pPenColorToolButton; 108 QToolButton* m_pPenColorToolButton;
107 QToolButton* m_pBrushColorToolButton; 109 QToolButton* m_pBrushColorToolButton;
108 110
109 QSpinBox* m_pPenWidthSpinBox; 111 QSpinBox* m_pPenWidthSpinBox;
110}; 112};
111 113
112#endif // DRAWPAD_H 114#endif // DRAWPAD_H
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 446096c..423ef26 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -1,520 +1,532 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "drawpadcanvas.h" 14#include "drawpadcanvas.h"
15 15
16#include "drawpad.h" 16#include "drawpad.h"
17#include "page.h" 17#include "page.h"
18#include "tool.h" 18#include "tool.h"
19 19
20#include <qpe/applnk.h> 20#include <qpe/applnk.h>
21#include <qpe/filemanager.h> 21#include <qpe/filemanager.h>
22#include <qpe/mimetype.h> 22#include <qpe/mimetype.h>
23 23
24#include <qbuffer.h> 24#include <qbuffer.h>
25#include <qimage.h> 25#include <qimage.h>
26#include <qtextcodec.h> 26#include <qtextcodec.h>
27#include <qxml.h> 27#include <qxml.h>
28 28
29class DrawPadCanvasXmlHandler: public QXmlDefaultHandler 29class DrawPadCanvasXmlHandler: public QXmlDefaultHandler
30{ 30{
31public: 31public:
32 DrawPadCanvasXmlHandler(); 32 DrawPadCanvasXmlHandler();
33 ~DrawPadCanvasXmlHandler(); 33 ~DrawPadCanvasXmlHandler();
34 34
35 QList<Page> pages(); 35 QList<Page> pages();
36 36
37 bool startElement(const QString& namespaceURI, const QString& localName, 37 bool startElement(const QString& namespaceURI, const QString& localName,
38 const QString& qName, const QXmlAttributes& atts); 38 const QString& qName, const QXmlAttributes& atts);
39 bool endElement(const QString& namespaceURI, const QString& localName, 39 bool endElement(const QString& namespaceURI, const QString& localName,
40 const QString& qName); 40 const QString& qName);
41 bool characters(const QString& ch); 41 bool characters(const QString& ch);
42 42
43private: 43private:
44 enum State { 44 enum State {
45 Unknown, 45 Unknown,
46 InTitle, 46 InTitle,
47 InDate, 47 InDate,
48 InData 48 InData
49 }; 49 };
50 50
51 State m_state; 51 State m_state;
52 QString m_title; 52 QString m_title;
53 QDateTime m_date; 53 QDateTime m_date;
54 ulong m_dataLenght; 54 ulong m_dataLenght;
55 QString m_dataFormat; 55 QString m_dataFormat;
56 QList<Page> m_pages; 56 QList<Page> m_pages;
57}; 57};
58 58
59DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() 59DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler()
60{ 60{
61 m_state = Unknown; 61 m_state = Unknown;
62} 62}
63 63
64DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() 64DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler()
65{ 65{
66} 66}
67 67
68QList<Page> DrawPadCanvasXmlHandler::pages() 68QList<Page> DrawPadCanvasXmlHandler::pages()
69{ 69{
70 return m_pages; 70 return m_pages;
71} 71}
72 72
73bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, 73bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName,
74 const QString& qName, const QXmlAttributes& atts) 74 const QString& qName, const QXmlAttributes& atts)
75{ 75{
76 Q_CONST_UNUSED(namespaceURI) 76 Q_CONST_UNUSED(namespaceURI)
77 Q_CONST_UNUSED(localName) 77 Q_CONST_UNUSED(localName)
78 78
79 if (qName == "image") { 79 if (qName == "image") {
80 m_title = QString(); 80 m_title = QString();
81 m_date = QDateTime::currentDateTime(); 81 m_date = QDateTime::currentDateTime();
82 } else if (qName == "title") { 82 } else if (qName == "title") {
83 m_state = InTitle; 83 m_state = InTitle;
84 } else if (qName == "date") { 84 } else if (qName == "date") {
85 m_state = InDate; 85 m_state = InDate;
86 } else if (qName == "data") { 86 } else if (qName == "data") {
87 m_state = InData; 87 m_state = InData;
88 m_dataLenght = atts.value("length").toULong(); 88 m_dataLenght = atts.value("length").toULong();
89 m_dataFormat = atts.value("format"); 89 m_dataFormat = atts.value("format");
90 } 90 }
91 91
92 return true; 92 return true;
93} 93}
94 94
95bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, 95bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName,
96 const QString& qName) 96 const QString& qName)
97{ 97{
98 Q_CONST_UNUSED(namespaceURI) 98 Q_CONST_UNUSED(namespaceURI)
99 Q_CONST_UNUSED(localName) 99 Q_CONST_UNUSED(localName)
100 100
101 if (qName == "title") { 101 if (qName == "title") {
102 m_state = Unknown; 102 m_state = Unknown;
103 } else if (qName == "date") { 103 } else if (qName == "date") {
104 m_state = Unknown; 104 m_state = Unknown;
105 } else if (qName == "data") { 105 } else if (qName == "data") {
106 m_state = Unknown; 106 m_state = Unknown;
107 } 107 }
108 108
109 return true; 109 return true;
110} 110}
111 111
112bool DrawPadCanvasXmlHandler::characters(const QString& ch) 112bool DrawPadCanvasXmlHandler::characters(const QString& ch)
113{ 113{
114 if (m_state == InTitle) { 114 if (m_state == InTitle) {
115 m_title = ch; 115 m_title = ch;
116 } else if (m_state == InDate) { 116 } else if (m_state == InDate) {
117 m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt()); 117 m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt());
118 } else if (m_state == InData) { 118 } else if (m_state == InData) {
119 QByteArray byteArray(ch.length() / 2); 119 QByteArray byteArray(ch.length() / 2);
120 120
121 for (int i = 0; i < (int)ch.length() / 2; i++) { 121 for (int i = 0; i < (int)ch.length() / 2; i++) {
122 char h = ch[2 * i].latin1(); 122 char h = ch[2 * i].latin1();
123 char l = ch[2 * i + 1].latin1(); 123 char l = ch[2 * i + 1].latin1();
124 uchar r = 0; 124 uchar r = 0;
125 125
126 if (h <= '9') { 126 if (h <= '9') {
127 r += h - '0'; 127 r += h - '0';
128 } else { 128 } else {
129 r += h - 'a' + 10; 129 r += h - 'a' + 10;
130 } 130 }
131 131
132 r = r << 4; 132 r = r << 4;
133 133
134 if (l <= '9') { 134 if (l <= '9') {
135 r += l - '0'; 135 r += l - '0';
136 } else { 136 } else {
137 r += l - 'a' + 10; 137 r += l - 'a' + 10;
138 } 138 }
139 139
140 byteArray[i] = r; 140 byteArray[i] = r;
141 } 141 }
142 142
143 QImage image; 143 QImage image;
144 image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); 144 image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat);
145 145
146 Page* page = new Page(m_title, image.width(), image.height()); 146 Page* page = new Page(m_title, image.width(), image.height());
147 page->setLastModified(m_date); 147 page->setLastModified(m_date);
148 page->pixmap()->convertFromImage(image); 148 page->pixmap()->convertFromImage(image);
149 m_pages.append(page); 149 m_pages.append(page);
150 } 150 }
151 151
152 return true; 152 return true;
153} 153}
154 154
155DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) 155DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name)
156 : QScrollView(parent, name) 156 : QScrollView(parent, name)
157{ 157{
158 m_pDrawPad = drawPad; 158 m_pDrawPad = drawPad;
159 m_pages.setAutoDelete(true); 159 m_pages.setAutoDelete(true);
160 160
161 viewport()->setBackgroundMode(QWidget::NoBackground); 161 viewport()->setBackgroundMode(QWidget::NoBackground);
162} 162}
163 163
164DrawPadCanvas::~DrawPadCanvas() 164DrawPadCanvas::~DrawPadCanvas()
165{ 165{
166} 166}
167 167
168void DrawPadCanvas::load(QIODevice* ioDevice) 168void DrawPadCanvas::load(QIODevice* ioDevice)
169{ 169{
170 QTextStream textStream(ioDevice); 170 QTextStream textStream(ioDevice);
171 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 171 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
172 172
173 QXmlInputSource xmlInputSource(textStream); 173 QXmlInputSource xmlInputSource(textStream);
174 QXmlSimpleReader xmlSimpleReader; 174 QXmlSimpleReader xmlSimpleReader;
175 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; 175 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler;
176 176
177 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); 177 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
178 xmlSimpleReader.parse(xmlInputSource); 178 xmlSimpleReader.parse(xmlInputSource);
179 179
180 m_pages = drawPadCanvasXmlHandler.pages(); 180 m_pages = drawPadCanvasXmlHandler.pages();
181 181
182 if (m_pages.isEmpty()) { 182 if (m_pages.isEmpty()) {
183 m_pages.append(new Page("", 183 m_pages.append(new Page("",
184 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 184 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
185 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 185 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
186 m_pages.current()->pixmap()->fill(Qt::white); 186 m_pages.current()->pixmap()->fill(Qt::white);
187 } 187 }
188 188
189 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 189 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
190 viewport()->update(); 190 viewport()->update();
191 191
192 emit pagesChanged(); 192 emit pagesChanged();
193} 193}
194 194
195void DrawPadCanvas::initialPage() 195void DrawPadCanvas::initialPage()
196{ 196{
197 m_pages.append(new Page("", 197 m_pages.append(new Page("",
198 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 198 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
199 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 199 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
200 //236, 232)); no more fixed sizes 200 //236, 232)); no more fixed sizes
201 201
202 m_pages.current()->pixmap()->fill(Qt::white); 202 m_pages.current()->pixmap()->fill(Qt::white);
203 203
204 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 204 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
205 viewport()->update(); 205 viewport()->update();
206 206
207 emit pagesChanged(); 207 emit pagesChanged();
208} 208}
209 209
210void DrawPadCanvas::save(QIODevice* ioDevice) 210void DrawPadCanvas::save(QIODevice* ioDevice)
211{ 211{
212 QTextStream textStream(ioDevice); 212 QTextStream textStream(ioDevice);
213 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 213 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
214 214
215 textStream << "<drawpad>" << endl; 215 textStream << "<drawpad>" << endl;
216 textStream << " <images>" << endl; 216 textStream << " <images>" << endl;
217 217
218 QListIterator<Page> bufferIterator(m_pages); 218 QListIterator<Page> bufferIterator(m_pages);
219 219
220 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { 220 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
221 textStream << " <image>" << endl; 221 textStream << " <image>" << endl;
222 textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; 222 textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl;
223 223
224 int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); 224 int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified());
225 textStream << " <date>" << intDate << "</date>" << endl; 225 textStream << " <date>" << intDate << "</date>" << endl;
226 226
227 QImage image = bufferIterator.current()->pixmap()->convertToImage(); 227 QImage image = bufferIterator.current()->pixmap()->convertToImage();
228 QByteArray byteArray; 228 QByteArray byteArray;
229 QBuffer buffer(byteArray); 229 QBuffer buffer(byteArray);
230 QImageIO imageIO(&buffer, "PNG"); 230 QImageIO imageIO(&buffer, "PNG");
231 231
232 buffer.open(IO_WriteOnly); 232 buffer.open(IO_WriteOnly);
233 imageIO.setImage(image); 233 imageIO.setImage(image);
234 imageIO.write(); 234 imageIO.write();
235 buffer.close(); 235 buffer.close();
236 236
237 textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">"; 237 textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">";
238 238
239 static const char hexchars[] = "0123456789abcdef"; 239 static const char hexchars[] = "0123456789abcdef";
240 240
241 for (int i = 0; i < (int)byteArray.size(); i++ ) { 241 for (int i = 0; i < (int)byteArray.size(); i++ ) {
242 uchar s = (uchar)byteArray[i]; 242 uchar s = (uchar)byteArray[i];
243 textStream << hexchars[s >> 4]; 243 textStream << hexchars[s >> 4];
244 textStream << hexchars[s & 0x0f]; 244 textStream << hexchars[s & 0x0f];
245 } 245 }
246 246
247 textStream << "</data>" << endl; 247 textStream << "</data>" << endl;
248 textStream << " </image>" << endl; 248 textStream << " </image>" << endl;
249 } 249 }
250 250
251 textStream << " </images>" << endl; 251 textStream << " </images>" << endl;
252 textStream << "</drawpad>"; 252 textStream << "</drawpad>";
253} 253}
254 254
255void DrawPadCanvas::importPage(const QString& fileName) 255void DrawPadCanvas::importPage(const QString& fileName)
256{ 256{
257 Page* importedPage = new Page(); 257 Page* importedPage = new Page();
258 258
259 importedPage->pixmap()->load(fileName); 259 importedPage->pixmap()->load(fileName);
260 m_pages.insert(m_pages.at() + 1, importedPage); 260 m_pages.insert(m_pages.at() + 1, importedPage);
261 261
262 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 262 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
263 viewport()->update(); 263 viewport()->update();
264 264
265 emit pagesChanged(); 265 emit pagesChanged();
266} 266}
267 267
268void DrawPadCanvas::importPixmap( const QPixmap& pix ) {
269 Page* importedPage = new Page();
270
271 (*importedPage->pixmap()) = pix;
272 m_pages.insert(m_pages.at()+1, importedPage );
273 resizeContents(m_pages.current()->pixmap()->width(),
274 m_pages.current()->pixmap()->height() );
275 viewport()->update();
276
277 emit pagesChanged();
278}
279
268void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) 280void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format)
269{ 281{
270 if (fromPage == toPage) { 282 if (fromPage == toPage) {
271 DocLnk docLnk; 283 DocLnk docLnk;
272 MimeType mimeType(format); 284 MimeType mimeType(format);
273 285
274 docLnk.setName(name); 286 docLnk.setName(name);
275 docLnk.setType(mimeType.id()); 287 docLnk.setType(mimeType.id());
276 288
277 FileManager fileManager; 289 FileManager fileManager;
278 QIODevice* ioDevice = fileManager.saveFile(docLnk); 290 QIODevice* ioDevice = fileManager.saveFile(docLnk);
279 QImageIO imageIO(ioDevice, format); 291 QImageIO imageIO(ioDevice, format);
280 292
281 QImage image = m_pages.current()->pixmap()->convertToImage(); 293 QImage image = m_pages.current()->pixmap()->convertToImage();
282 imageIO.setImage(image); 294 imageIO.setImage(image);
283 imageIO.write(); 295 imageIO.write();
284 delete ioDevice; 296 delete ioDevice;
285 } else { 297 } else {
286 for (uint i = fromPage; i <= toPage; i++) { 298 for (uint i = fromPage; i <= toPage; i++) {
287 DocLnk docLnk; 299 DocLnk docLnk;
288 MimeType mimeType(format); 300 MimeType mimeType(format);
289 301
290 docLnk.setName(name + QString::number(i)); 302 docLnk.setName(name + QString::number(i));
291 docLnk.setType(mimeType.id()); 303 docLnk.setType(mimeType.id());
292 304
293 FileManager fileManager; 305 FileManager fileManager;
294 QIODevice* ioDevice = fileManager.saveFile(docLnk); 306 QIODevice* ioDevice = fileManager.saveFile(docLnk);
295 QImageIO imageIO(ioDevice, format); 307 QImageIO imageIO(ioDevice, format);
296 308
297 QImage image = m_pages.at(i - 1)->pixmap()->convertToImage(); 309 QImage image = m_pages.at(i - 1)->pixmap()->convertToImage();
298 imageIO.setImage(image); 310 imageIO.setImage(image);
299 imageIO.write(); 311 imageIO.write();
300 delete ioDevice; 312 delete ioDevice;
301 } 313 }
302 } 314 }
303} 315}
304 316
305Page* DrawPadCanvas::currentPage() 317Page* DrawPadCanvas::currentPage()
306{ 318{
307 return m_pages.current(); 319 return m_pages.current();
308} 320}
309 321
310QList<Page> DrawPadCanvas::pages() 322QList<Page> DrawPadCanvas::pages()
311{ 323{
312 return m_pages; 324 return m_pages;
313} 325}
314 326
315uint DrawPadCanvas::pagePosition() 327uint DrawPadCanvas::pagePosition()
316{ 328{
317 return (m_pages.at() + 1); 329 return (m_pages.at() + 1);
318} 330}
319 331
320uint DrawPadCanvas::pageCount() 332uint DrawPadCanvas::pageCount()
321{ 333{
322 return m_pages.count(); 334 return m_pages.count();
323} 335}
324 336
325void DrawPadCanvas::selectPage(Page* page) 337void DrawPadCanvas::selectPage(Page* page)
326{ 338{
327 m_pages.findRef(page); 339 m_pages.findRef(page);
328 340
329 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 341 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
330 viewport()->update(); 342 viewport()->update();
331 343
332 emit pagesChanged(); 344 emit pagesChanged();
333} 345}
334 346
335void DrawPadCanvas::backupPage() 347void DrawPadCanvas::backupPage()
336{ 348{
337 m_pages.current()->backup(); 349 m_pages.current()->backup();
338 350
339 emit pagesChanged(); 351 emit pagesChanged();
340} 352}
341 353
342void DrawPadCanvas::selectPage(uint pagePosition) 354void DrawPadCanvas::selectPage(uint pagePosition)
343{ 355{
344 m_pages.at(pagePosition - 1); 356 m_pages.at(pagePosition - 1);
345 357
346 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 358 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
347 viewport()->update(); 359 viewport()->update();
348 360
349 emit pagesChanged(); 361 emit pagesChanged();
350} 362}
351 363
352void DrawPadCanvas::deleteAll() 364void DrawPadCanvas::deleteAll()
353{ 365{
354 m_pages.clear(); 366 m_pages.clear();
355 367
356 m_pages.append(new Page("", 368 m_pages.append(new Page("",
357 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 369 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
358 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 370 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
359 371
360 m_pages.current()->pixmap()->fill(Qt::white); 372 m_pages.current()->pixmap()->fill(Qt::white);
361 373
362 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 374 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
363 viewport()->update(); 375 viewport()->update();
364 376
365 emit pagesChanged(); 377 emit pagesChanged();
366} 378}
367 379
368void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) 380void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color)
369{ 381{
370 m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); 382 m_pages.insert(m_pages.at() + 1, new Page(title, width, height));
371 m_pages.current()->pixmap()->fill(color); 383 m_pages.current()->pixmap()->fill(color);
372 384
373 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 385 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
374 viewport()->update(); 386 viewport()->update();
375 387
376 emit pagesChanged(); 388 emit pagesChanged();
377} 389}
378 390
379void DrawPadCanvas::clearPage() 391void DrawPadCanvas::clearPage()
380{ 392{
381 m_pages.current()->pixmap()->fill(Qt::white); 393 m_pages.current()->pixmap()->fill(Qt::white);
382 394
383 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 395 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
384 viewport()->update(); 396 viewport()->update();
385} 397}
386 398
387void DrawPadCanvas::deletePage() 399void DrawPadCanvas::deletePage()
388{ 400{
389 m_pages.remove(m_pages.current()); 401 m_pages.remove(m_pages.current());
390 402
391 if (m_pages.isEmpty()) { 403 if (m_pages.isEmpty()) {
392 m_pages.append(new Page("", 404 m_pages.append(new Page("",
393 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 405 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
394 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 406 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
395 407
396 m_pages.current()->pixmap()->fill(Qt::white); 408 m_pages.current()->pixmap()->fill(Qt::white);
397 } 409 }
398 410
399 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 411 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
400 viewport()->update(); 412 viewport()->update();
401 413
402 emit pagesChanged(); 414 emit pagesChanged();
403} 415}
404 416
405void DrawPadCanvas::movePageUp() 417void DrawPadCanvas::movePageUp()
406{ 418{
407 int index = m_pages.at(); 419 int index = m_pages.at();
408 Page* page = m_pages.take(); 420 Page* page = m_pages.take();
409 m_pages.insert(index - 1, page); 421 m_pages.insert(index - 1, page);
410 422
411 emit pagesChanged(); 423 emit pagesChanged();
412} 424}
413 425
414void DrawPadCanvas::movePageDown() 426void DrawPadCanvas::movePageDown()
415{ 427{
416 int index = m_pages.at(); 428 int index = m_pages.at();
417 Page* page = m_pages.take(); 429 Page* page = m_pages.take();
418 m_pages.insert(index + 1, page); 430 m_pages.insert(index + 1, page);
419 431
420 emit pagesChanged(); 432 emit pagesChanged();
421} 433}
422 434
423bool DrawPadCanvas::goPreviousPageEnabled() 435bool DrawPadCanvas::goPreviousPageEnabled()
424{ 436{
425 return (m_pages.current() != m_pages.getFirst()); 437 return (m_pages.current() != m_pages.getFirst());
426} 438}
427 439
428bool DrawPadCanvas::goNextPageEnabled() 440bool DrawPadCanvas::goNextPageEnabled()
429{ 441{
430 return (m_pages.current() != m_pages.getLast()); 442 return (m_pages.current() != m_pages.getLast());
431} 443}
432 444
433void DrawPadCanvas::undo() 445void DrawPadCanvas::undo()
434{ 446{
435 m_pages.current()->undo(); 447 m_pages.current()->undo();
436 448
437 viewport()->update(); 449 viewport()->update();
438 450
439 emit pagesChanged(); 451 emit pagesChanged();
440} 452}
441 453
442void DrawPadCanvas::redo() 454void DrawPadCanvas::redo()
443{ 455{
444 m_pages.current()->redo(); 456 m_pages.current()->redo();
445 457
446 viewport()->update(); 458 viewport()->update();
447 459
448 emit pagesChanged(); 460 emit pagesChanged();
449} 461}
450 462
451void DrawPadCanvas::goFirstPage() 463void DrawPadCanvas::goFirstPage()
452{ 464{
453 m_pages.first(); 465 m_pages.first();
454 466
455 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 467 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
456 viewport()->update(); 468 viewport()->update();
457 469
458 emit pagesChanged(); 470 emit pagesChanged();
459} 471}
460 472
461void DrawPadCanvas::goPreviousPage() 473void DrawPadCanvas::goPreviousPage()
462{ 474{
463 m_pages.prev(); 475 m_pages.prev();
464 476
465 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 477 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
466 viewport()->update(); 478 viewport()->update();
467 479
468 emit pagesChanged(); 480 emit pagesChanged();
469} 481}
470 482
471void DrawPadCanvas::goNextPage() 483void DrawPadCanvas::goNextPage()
472{ 484{
473 m_pages.next(); 485 m_pages.next();
474 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 486 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
475 viewport()->update(); 487 viewport()->update();
476 488
477 emit pagesChanged(); 489 emit pagesChanged();
478} 490}
479 491
480void DrawPadCanvas::goLastPage() 492void DrawPadCanvas::goLastPage()
481{ 493{
482 m_pages.last(); 494 m_pages.last();
483 495
484 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 496 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
485 viewport()->update(); 497 viewport()->update();
486 498
487 emit pagesChanged(); 499 emit pagesChanged();
488} 500}
489 501
490void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) 502void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e)
491{ 503{
492 m_pDrawPad->tool()->mousePressEvent(e); 504 m_pDrawPad->tool()->mousePressEvent(e);
493} 505}
494 506
495void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) 507void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e)
496{ 508{
497 m_pDrawPad->tool()->mouseReleaseEvent(e); 509 m_pDrawPad->tool()->mouseReleaseEvent(e);
498} 510}
499 511
500void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) 512void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e)
501{ 513{
502 m_pDrawPad->tool()->mouseMoveEvent(e); 514 m_pDrawPad->tool()->mouseMoveEvent(e);
503} 515}
504 516
505void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 517void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
506{ 518{
507 QRect clipRect(cx, cy, cw, ch); 519 QRect clipRect(cx, cy, cw, ch);
508 QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 520 QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
509 QRect drawRect = pixmapRect.intersect(clipRect); 521 QRect drawRect = pixmapRect.intersect(clipRect);
510 522
511 p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect); 523 p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect);
512 524
513 if (drawRect.right() < clipRect.right()) { 525 if (drawRect.right() < clipRect.right()) {
514 p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); 526 p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark());
515 } 527 }
516 528
517 if (drawRect.bottom() < clipRect.bottom()) { 529 if (drawRect.bottom() < clipRect.bottom()) {
518 p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark()); 530 p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark());
519 } 531 }
520} 532}
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h
index 80a2a7e..2b3d4a5 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.h
+++ b/noncore/graphics/drawpad/drawpadcanvas.h
@@ -1,82 +1,83 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#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
22class DrawPad; 22class DrawPad;
23class Page; 23class Page;
24 24
25class DrawPadCanvas : public QScrollView 25class DrawPadCanvas : public QScrollView
26{ 26{
27 Q_OBJECT 27 Q_OBJECT
28 28
29public: 29public:
30 DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); 30 DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0);
31 ~DrawPadCanvas(); 31 ~DrawPadCanvas();
32 32
33 void load(QIODevice* ioDevice); 33 void load(QIODevice* ioDevice);
34 void initialPage(); 34 void initialPage();
35 void save(QIODevice* ioDevice); 35 void save(QIODevice* ioDevice);
36 36
37 void importPage(const QString& fileName); 37 void importPage(const QString& fileName);
38 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);
39 void importPixmap( const QPixmap& );
39 40
40 bool goPreviousPageEnabled(); 41 bool goPreviousPageEnabled();
41 bool goNextPageEnabled(); 42 bool goNextPageEnabled();
42 43
43 Page* currentPage(); 44 Page* currentPage();
44 QList<Page> pages(); 45 QList<Page> pages();
45 uint pagePosition(); 46 uint pagePosition();
46 uint pageCount(); 47 uint pageCount();
47 48
48 void selectPage(Page* page); 49 void selectPage(Page* page);
49 void selectPage(uint pagePosition); 50 void selectPage(uint pagePosition);
50 void backupPage(); 51 void backupPage();
51 52
52public slots: 53public slots:
53 void deleteAll(); 54 void deleteAll();
54 void newPage(QString title, uint width, uint height, const QColor& color); 55 void newPage(QString title, uint width, uint height, const QColor& color);
55 void clearPage(); 56 void clearPage();
56 void deletePage(); 57 void deletePage();
57 void movePageUp(); 58 void movePageUp();
58 void movePageDown(); 59 void movePageDown();
59 60
60 void undo(); 61 void undo();
61 void redo(); 62 void redo();
62 63
63 void goFirstPage(); 64 void goFirstPage();
64 void goPreviousPage(); 65 void goPreviousPage();
65 void goNextPage(); 66 void goNextPage();
66 void goLastPage(); 67 void goLastPage();
67 68
68signals: 69signals:
69 void pagesChanged(); 70 void pagesChanged();
70 71
71protected: 72protected:
72 void contentsMousePressEvent(QMouseEvent* e); 73 void contentsMousePressEvent(QMouseEvent* e);
73 void contentsMouseReleaseEvent(QMouseEvent* e); 74 void contentsMouseReleaseEvent(QMouseEvent* e);
74 void contentsMouseMoveEvent(QMouseEvent* e); 75 void contentsMouseMoveEvent(QMouseEvent* e);
75 void drawContents(QPainter* p, int cx, int cy, int cw, int ch); 76 void drawContents(QPainter* p, int cx, int cy, int cw, int ch);
76 77
77private: 78private:
78 DrawPad* m_pDrawPad; 79 DrawPad* m_pDrawPad;
79 QList<Page> m_pages; 80 QList<Page> m_pages;
80}; 81};
81 82
82#endif // DRAWPADCANVAS_H 83#endif // DRAWPADCANVAS_H