author | leseb <leseb> | 2002-06-09 16:06:21 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-09 16:06:21 (UTC) |
commit | b59a64c90deba66180e3a778d411296e984f64ea (patch) (unidiff) | |
tree | 88ef0767602dd174f5911719ffb346a4fcf7420f | |
parent | 29c0d188836a59bff1fbcd1d338fcd3334c0f1f5 (diff) | |
download | opie-b59a64c90deba66180e3a778d411296e984f64ea.zip opie-b59a64c90deba66180e3a778d411296e984f64ea.tar.gz opie-b59a64c90deba66180e3a778d411296e984f64ea.tar.bz2 |
Changing page order now works in thumbnail view
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 18 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 43 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.h | 11 |
4 files changed, 65 insertions, 9 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index c23ee34..bcb6877 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -1,542 +1,560 @@ | |||
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 <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qtextcodec.h> | 27 | #include <qtextcodec.h> |
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qxml.h> | 29 | #include <qxml.h> |
30 | 30 | ||
31 | #include <zlib.h> | 31 | #include <zlib.h> |
32 | 32 | ||
33 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler | 33 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | DrawPadCanvasXmlHandler(); | 36 | DrawPadCanvasXmlHandler(); |
37 | ~DrawPadCanvasXmlHandler(); | 37 | ~DrawPadCanvasXmlHandler(); |
38 | 38 | ||
39 | QList<Page> pages(); | 39 | QList<Page> pages(); |
40 | 40 | ||
41 | bool startElement(const QString& namespaceURI, const QString& localName, | 41 | bool startElement(const QString& namespaceURI, const QString& localName, |
42 | const QString& qName, const QXmlAttributes& atts); | 42 | const QString& qName, const QXmlAttributes& atts); |
43 | bool endElement(const QString& namespaceURI, const QString& localName, | 43 | bool endElement(const QString& namespaceURI, const QString& localName, |
44 | const QString& qName); | 44 | const QString& qName); |
45 | bool characters(const QString& ch); | 45 | bool characters(const QString& ch); |
46 | 46 | ||
47 | private: | 47 | private: |
48 | enum State { | 48 | enum State { |
49 | Unknown, | 49 | Unknown, |
50 | InData | 50 | InData |
51 | }; | 51 | }; |
52 | 52 | ||
53 | State m_state; | 53 | State m_state; |
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 | ||
59 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() | 59 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() |
60 | { | 60 | { |
61 | m_state = Unknown; | 61 | m_state = Unknown; |
62 | } | 62 | } |
63 | 63 | ||
64 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() | 64 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() |
65 | { | 65 | { |
66 | } | 66 | } |
67 | 67 | ||
68 | QList<Page> DrawPadCanvasXmlHandler::pages() | 68 | QList<Page> DrawPadCanvasXmlHandler::pages() |
69 | { | 69 | { |
70 | return m_pages; | 70 | return m_pages; |
71 | } | 71 | } |
72 | 72 | ||
73 | bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, | 73 | bool 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.compare("data") == 0) { | 79 | if (qName.compare("data") == 0) { |
80 | m_state = InData; | 80 | m_state = InData; |
81 | m_dataLenght = atts.value("length").toULong(); | 81 | m_dataLenght = atts.value("length").toULong(); |
82 | m_dataFormat = atts.value("format"); | 82 | m_dataFormat = atts.value("format"); |
83 | 83 | ||
84 | if (m_dataFormat.isEmpty()) { | 84 | if (m_dataFormat.isEmpty()) { |
85 | m_dataFormat = "XPM"; | 85 | m_dataFormat = "XPM"; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | return true; | 89 | return true; |
90 | } | 90 | } |
91 | 91 | ||
92 | bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, | 92 | bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, |
93 | const QString& qName) | 93 | const QString& qName) |
94 | { | 94 | { |
95 | Q_CONST_UNUSED(namespaceURI) | 95 | Q_CONST_UNUSED(namespaceURI) |
96 | Q_CONST_UNUSED(localName) | 96 | Q_CONST_UNUSED(localName) |
97 | 97 | ||
98 | if (qName.compare("data") == 0) { | 98 | if (qName.compare("data") == 0) { |
99 | m_state = Unknown; | 99 | m_state = Unknown; |
100 | } | 100 | } |
101 | 101 | ||
102 | return true; | 102 | return true; |
103 | } | 103 | } |
104 | 104 | ||
105 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) | 105 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) |
106 | { | 106 | { |
107 | if (m_state == InData) { | 107 | if (m_state == InData) { |
108 | QByteArray byteArray(ch.length() / 2); | 108 | QByteArray byteArray(ch.length() / 2); |
109 | 109 | ||
110 | for (int i = 0; i < (int)ch.length() / 2; i++) { | 110 | for (int i = 0; i < (int)ch.length() / 2; i++) { |
111 | char h = ch[2 * i].latin1(); | 111 | char h = ch[2 * i].latin1(); |
112 | char l = ch[2 * i + 1].latin1(); | 112 | char l = ch[2 * i + 1].latin1(); |
113 | uchar r = 0; | 113 | uchar r = 0; |
114 | 114 | ||
115 | if (h <= '9') { | 115 | if (h <= '9') { |
116 | r += h - '0'; | 116 | r += h - '0'; |
117 | } else { | 117 | } else { |
118 | r += h - 'a' + 10; | 118 | r += h - 'a' + 10; |
119 | } | 119 | } |
120 | 120 | ||
121 | r = r << 4; | 121 | r = r << 4; |
122 | 122 | ||
123 | if (l <= '9') { | 123 | if (l <= '9') { |
124 | r += l - '0'; | 124 | r += l - '0'; |
125 | } else { | 125 | } else { |
126 | r += l - 'a' + 10; | 126 | r += l - 'a' + 10; |
127 | } | 127 | } |
128 | 128 | ||
129 | byteArray[i] = r; | 129 | byteArray[i] = r; |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | QImage image; | 133 | QImage image; |
134 | 134 | ||
135 | if (m_dataFormat == "XPM") { | 135 | if (m_dataFormat == "XPM") { |
136 | if (m_dataLenght < ch.length() * 5) { | 136 | if (m_dataLenght < ch.length() * 5) { |
137 | m_dataLenght = ch.length() * 5; | 137 | m_dataLenght = ch.length() * 5; |
138 | } | 138 | } |
139 | 139 | ||
140 | QByteArray byteArrayUnzipped(m_dataLenght); | 140 | QByteArray byteArrayUnzipped(m_dataLenght); |
141 | ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); | 141 | ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); |
142 | 142 | ||
143 | image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat); | 143 | image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat); |
144 | } else { | 144 | } else { |
145 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); | 145 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); |
146 | } | 146 | } |
147 | 147 | ||
148 | Page* page = new Page(image.width(), image.height()); | 148 | Page* page = new Page(image.width(), image.height()); |
149 | page->convertFromImage(image); | 149 | page->convertFromImage(image); |
150 | m_pages.append(page); | 150 | m_pages.append(page); |
151 | } | 151 | } |
152 | 152 | ||
153 | return true; | 153 | return true; |
154 | } | 154 | } |
155 | 155 | ||
156 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) | 156 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) |
157 | : QScrollView(parent, name) | 157 | : QScrollView(parent, name) |
158 | { | 158 | { |
159 | m_pDrawPad = drawPad; | 159 | m_pDrawPad = drawPad; |
160 | m_pages.setAutoDelete(true); | 160 | m_pages.setAutoDelete(true); |
161 | m_pageBackups.setAutoDelete(true); | 161 | m_pageBackups.setAutoDelete(true); |
162 | 162 | ||
163 | viewport()->setBackgroundMode(QWidget::NoBackground); | 163 | viewport()->setBackgroundMode(QWidget::NoBackground); |
164 | } | 164 | } |
165 | 165 | ||
166 | DrawPadCanvas::~DrawPadCanvas() | 166 | DrawPadCanvas::~DrawPadCanvas() |
167 | { | 167 | { |
168 | } | 168 | } |
169 | 169 | ||
170 | void DrawPadCanvas::load(QIODevice* ioDevice) | 170 | void DrawPadCanvas::load(QIODevice* ioDevice) |
171 | { | 171 | { |
172 | QTextStream textStream(ioDevice); | 172 | QTextStream textStream(ioDevice); |
173 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 173 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
174 | 174 | ||
175 | QXmlInputSource xmlInputSource(textStream); | 175 | QXmlInputSource xmlInputSource(textStream); |
176 | QXmlSimpleReader xmlSimpleReader; | 176 | QXmlSimpleReader xmlSimpleReader; |
177 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; | 177 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; |
178 | 178 | ||
179 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); | 179 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); |
180 | xmlSimpleReader.parse(xmlInputSource); | 180 | xmlSimpleReader.parse(xmlInputSource); |
181 | 181 | ||
182 | m_pages = drawPadCanvasXmlHandler.pages(); | 182 | m_pages = drawPadCanvasXmlHandler.pages(); |
183 | 183 | ||
184 | if (m_pages.isEmpty()) { | 184 | if (m_pages.isEmpty()) { |
185 | m_pages.append(new Page(contentsRect().size())); | 185 | m_pages.append(new Page(contentsRect().size())); |
186 | m_pages.current()->fill(Qt::white); | 186 | m_pages.current()->fill(Qt::white); |
187 | } | 187 | } |
188 | 188 | ||
189 | m_pageBackups.clear(); | 189 | m_pageBackups.clear(); |
190 | m_pageBackups.append(new Page(*(m_pages.current()))); | 190 | m_pageBackups.append(new Page(*(m_pages.current()))); |
191 | 191 | ||
192 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 192 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
193 | viewport()->update(); | 193 | viewport()->update(); |
194 | 194 | ||
195 | emit pagesChanged(); | 195 | emit pagesChanged(); |
196 | emit pageBackupsChanged(); | 196 | emit pageBackupsChanged(); |
197 | } | 197 | } |
198 | 198 | ||
199 | void DrawPadCanvas::initialPage() | 199 | void DrawPadCanvas::initialPage() |
200 | { | 200 | { |
201 | m_pages.append(new Page(236, 232)); | 201 | m_pages.append(new Page(236, 232)); |
202 | m_pages.current()->fill(Qt::white); | 202 | m_pages.current()->fill(Qt::white); |
203 | 203 | ||
204 | m_pageBackups.clear(); | 204 | m_pageBackups.clear(); |
205 | m_pageBackups.append(new Page(*(m_pages.current()))); | 205 | m_pageBackups.append(new Page(*(m_pages.current()))); |
206 | 206 | ||
207 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 207 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
208 | viewport()->update(); | 208 | viewport()->update(); |
209 | 209 | ||
210 | emit pagesChanged(); | 210 | emit pagesChanged(); |
211 | emit pageBackupsChanged(); | 211 | emit pageBackupsChanged(); |
212 | } | 212 | } |
213 | 213 | ||
214 | void DrawPadCanvas::save(QIODevice* ioDevice) | 214 | void DrawPadCanvas::save(QIODevice* ioDevice) |
215 | { | 215 | { |
216 | QTextStream textStream(ioDevice); | 216 | QTextStream textStream(ioDevice); |
217 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 217 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
218 | 218 | ||
219 | textStream << "<drawpad>" << endl; | 219 | textStream << "<drawpad>" << endl; |
220 | textStream << " <images>" << endl; | 220 | textStream << " <images>" << endl; |
221 | 221 | ||
222 | QListIterator<Page> bufferIterator(m_pages); | 222 | QListIterator<Page> bufferIterator(m_pages); |
223 | 223 | ||
224 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { | 224 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { |
225 | textStream << " <image>" << endl; | 225 | textStream << " <image>" << endl; |
226 | 226 | ||
227 | QImage image = bufferIterator.current()->convertToImage(); | 227 | QImage image = bufferIterator.current()->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 | ||
255 | void DrawPadCanvas::importPage(const QString& fileName) | 255 | void DrawPadCanvas::importPage(const QString& fileName) |
256 | { | 256 | { |
257 | Page* importedPage = new Page(); | 257 | Page* importedPage = new Page(); |
258 | 258 | ||
259 | importedPage->load(fileName); | 259 | importedPage->load(fileName); |
260 | m_pages.insert(m_pages.at() + 1, importedPage); | 260 | m_pages.insert(m_pages.at() + 1, importedPage); |
261 | 261 | ||
262 | m_pageBackups.clear(); | 262 | m_pageBackups.clear(); |
263 | m_pageBackups.append(new Page(*(m_pages.current()))); | 263 | m_pageBackups.append(new Page(*(m_pages.current()))); |
264 | 264 | ||
265 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 265 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
266 | viewport()->update(); | 266 | viewport()->update(); |
267 | 267 | ||
268 | emit pagesChanged(); | 268 | emit pagesChanged(); |
269 | emit pageBackupsChanged(); | 269 | emit pageBackupsChanged(); |
270 | } | 270 | } |
271 | 271 | ||
272 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) | 272 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) |
273 | { | 273 | { |
274 | if (fromPage == toPage) { | 274 | if (fromPage == toPage) { |
275 | DocLnk docLnk; | 275 | DocLnk docLnk; |
276 | MimeType mimeType(format); | 276 | MimeType mimeType(format); |
277 | 277 | ||
278 | docLnk.setName(name); | 278 | docLnk.setName(name); |
279 | docLnk.setType(mimeType.id()); | 279 | docLnk.setType(mimeType.id()); |
280 | 280 | ||
281 | FileManager fileManager; | 281 | FileManager fileManager; |
282 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 282 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
283 | QImageIO imageIO(ioDevice, format); | 283 | QImageIO imageIO(ioDevice, format); |
284 | 284 | ||
285 | QImage image = m_pages.current()->convertToImage(); | 285 | QImage image = m_pages.current()->convertToImage(); |
286 | imageIO.setImage(image); | 286 | imageIO.setImage(image); |
287 | imageIO.write(); | 287 | imageIO.write(); |
288 | delete ioDevice; | 288 | delete ioDevice; |
289 | } else { | 289 | } else { |
290 | for (uint i = fromPage; i <= toPage; i++) { | 290 | for (uint i = fromPage; i <= toPage; i++) { |
291 | DocLnk docLnk; | 291 | DocLnk docLnk; |
292 | MimeType mimeType(format); | 292 | MimeType mimeType(format); |
293 | 293 | ||
294 | docLnk.setName(name + QString::number(i)); | 294 | docLnk.setName(name + QString::number(i)); |
295 | docLnk.setType(mimeType.id()); | 295 | docLnk.setType(mimeType.id()); |
296 | 296 | ||
297 | FileManager fileManager; | 297 | FileManager fileManager; |
298 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 298 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
299 | QImageIO imageIO(ioDevice, format); | 299 | QImageIO imageIO(ioDevice, format); |
300 | 300 | ||
301 | QImage image = m_pages.at(i - 1)->convertToImage(); | 301 | QImage image = m_pages.at(i - 1)->convertToImage(); |
302 | imageIO.setImage(image); | 302 | imageIO.setImage(image); |
303 | imageIO.write(); | 303 | imageIO.write(); |
304 | delete ioDevice; | 304 | delete ioDevice; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | 308 | ||
309 | Page* DrawPadCanvas::currentPage() | 309 | Page* DrawPadCanvas::currentPage() |
310 | { | 310 | { |
311 | return m_pages.current(); | 311 | return m_pages.current(); |
312 | } | 312 | } |
313 | 313 | ||
314 | QList<Page> DrawPadCanvas::pages() | 314 | QList<Page> DrawPadCanvas::pages() |
315 | { | 315 | { |
316 | return m_pages; | 316 | return m_pages; |
317 | } | 317 | } |
318 | 318 | ||
319 | uint DrawPadCanvas::pagePosition() | 319 | uint DrawPadCanvas::pagePosition() |
320 | { | 320 | { |
321 | return (m_pages.at() + 1); | 321 | return (m_pages.at() + 1); |
322 | } | 322 | } |
323 | 323 | ||
324 | uint DrawPadCanvas::pageCount() | 324 | uint DrawPadCanvas::pageCount() |
325 | { | 325 | { |
326 | return m_pages.count(); | 326 | return m_pages.count(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void DrawPadCanvas::selectPage(Page* page) | 329 | void DrawPadCanvas::selectPage(Page* page) |
330 | { | 330 | { |
331 | m_pages.findRef(page); | 331 | m_pages.findRef(page); |
332 | m_pageBackups.clear(); | 332 | m_pageBackups.clear(); |
333 | m_pageBackups.append(new Page(*(m_pages.current()))); | 333 | m_pageBackups.append(new Page(*(m_pages.current()))); |
334 | 334 | ||
335 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 335 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
336 | viewport()->update(); | 336 | viewport()->update(); |
337 | 337 | ||
338 | emit pagesChanged(); | 338 | emit pagesChanged(); |
339 | emit pageBackupsChanged(); | 339 | emit pageBackupsChanged(); |
340 | } | 340 | } |
341 | 341 | ||
342 | void DrawPadCanvas::backupPage() | 342 | void DrawPadCanvas::backupPage() |
343 | { | 343 | { |
344 | QPixmap* currentBackup = m_pageBackups.current(); | 344 | QPixmap* currentBackup = m_pageBackups.current(); |
345 | while (m_pageBackups.last() != currentBackup) { | 345 | while (m_pageBackups.last() != currentBackup) { |
346 | m_pageBackups.removeLast(); | 346 | m_pageBackups.removeLast(); |
347 | } | 347 | } |
348 | 348 | ||
349 | while (m_pageBackups.count() >= (5 + 1)) { | 349 | while (m_pageBackups.count() >= (5 + 1)) { |
350 | m_pageBackups.removeFirst(); | 350 | m_pageBackups.removeFirst(); |
351 | } | 351 | } |
352 | 352 | ||
353 | m_pageBackups.append(new Page(*(m_pages.current()))); | 353 | m_pageBackups.append(new Page(*(m_pages.current()))); |
354 | 354 | ||
355 | emit pageBackupsChanged(); | 355 | emit pageBackupsChanged(); |
356 | } | 356 | } |
357 | 357 | ||
358 | void DrawPadCanvas::deleteAll() | 358 | void DrawPadCanvas::deleteAll() |
359 | { | 359 | { |
360 | m_pages.clear(); | 360 | m_pages.clear(); |
361 | 361 | ||
362 | m_pages.append(new Page(contentsRect().size())); | 362 | m_pages.append(new Page(contentsRect().size())); |
363 | m_pages.current()->fill(Qt::white); | 363 | m_pages.current()->fill(Qt::white); |
364 | 364 | ||
365 | m_pageBackups.clear(); | 365 | m_pageBackups.clear(); |
366 | m_pageBackups.append(new Page(*(m_pages.current()))); | 366 | m_pageBackups.append(new Page(*(m_pages.current()))); |
367 | 367 | ||
368 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 368 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
369 | viewport()->update(); | 369 | viewport()->update(); |
370 | 370 | ||
371 | emit pagesChanged(); | 371 | emit pagesChanged(); |
372 | emit pageBackupsChanged(); | 372 | emit pageBackupsChanged(); |
373 | } | 373 | } |
374 | 374 | ||
375 | void DrawPadCanvas::newPage(uint width, uint height, const QColor& color) | 375 | void DrawPadCanvas::newPage(uint width, uint height, const QColor& color) |
376 | { | 376 | { |
377 | m_pages.insert(m_pages.at() + 1, new Page(width, height)); | 377 | m_pages.insert(m_pages.at() + 1, new Page(width, height)); |
378 | m_pages.current()->fill(color); | 378 | m_pages.current()->fill(color); |
379 | 379 | ||
380 | m_pageBackups.clear(); | 380 | m_pageBackups.clear(); |
381 | m_pageBackups.append(new Page(*(m_pages.current()))); | 381 | m_pageBackups.append(new Page(*(m_pages.current()))); |
382 | 382 | ||
383 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 383 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
384 | viewport()->update(); | 384 | viewport()->update(); |
385 | 385 | ||
386 | emit pagesChanged(); | 386 | emit pagesChanged(); |
387 | emit pageBackupsChanged(); | 387 | emit pageBackupsChanged(); |
388 | } | 388 | } |
389 | 389 | ||
390 | void DrawPadCanvas::clearPage() | 390 | void DrawPadCanvas::clearPage() |
391 | { | 391 | { |
392 | m_pages.current()->fill(Qt::white); | 392 | m_pages.current()->fill(Qt::white); |
393 | 393 | ||
394 | m_pageBackups.clear(); | 394 | m_pageBackups.clear(); |
395 | m_pageBackups.append(new Page(*(m_pages.current()))); | 395 | m_pageBackups.append(new Page(*(m_pages.current()))); |
396 | 396 | ||
397 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 397 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
398 | viewport()->update(); | 398 | viewport()->update(); |
399 | 399 | ||
400 | emit pageBackupsChanged(); | 400 | emit pageBackupsChanged(); |
401 | } | 401 | } |
402 | 402 | ||
403 | void DrawPadCanvas::deletePage() | 403 | void DrawPadCanvas::deletePage() |
404 | { | 404 | { |
405 | m_pages.remove(m_pages.current()); | 405 | m_pages.remove(m_pages.current()); |
406 | 406 | ||
407 | if (m_pages.isEmpty()) { | 407 | if (m_pages.isEmpty()) { |
408 | m_pages.append(new Page(contentsRect().size())); | 408 | m_pages.append(new Page(contentsRect().size())); |
409 | m_pages.current()->fill(Qt::white); | 409 | m_pages.current()->fill(Qt::white); |
410 | } | 410 | } |
411 | 411 | ||
412 | m_pageBackups.clear(); | 412 | m_pageBackups.clear(); |
413 | m_pageBackups.append(new Page(*(m_pages.current()))); | 413 | m_pageBackups.append(new Page(*(m_pages.current()))); |
414 | 414 | ||
415 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 415 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
416 | viewport()->update(); | 416 | viewport()->update(); |
417 | 417 | ||
418 | emit pagesChanged(); | 418 | emit pagesChanged(); |
419 | emit pageBackupsChanged(); | 419 | emit pageBackupsChanged(); |
420 | } | 420 | } |
421 | 421 | ||
422 | void DrawPadCanvas::movePageUp() | ||
423 | { | ||
424 | int index = m_pages.at(); | ||
425 | Page* page = m_pages.take(); | ||
426 | m_pages.insert(index - 1, page); | ||
427 | |||
428 | emit pagesChanged(); | ||
429 | } | ||
430 | |||
431 | void DrawPadCanvas::movePageDown() | ||
432 | { | ||
433 | int index = m_pages.at(); | ||
434 | Page* page = m_pages.take(); | ||
435 | m_pages.insert(index + 1, page); | ||
436 | |||
437 | emit pagesChanged(); | ||
438 | } | ||
439 | |||
422 | bool DrawPadCanvas::undoEnabled() | 440 | bool DrawPadCanvas::undoEnabled() |
423 | { | 441 | { |
424 | return (m_pageBackups.current() != m_pageBackups.getFirst()); | 442 | return (m_pageBackups.current() != m_pageBackups.getFirst()); |
425 | } | 443 | } |
426 | 444 | ||
427 | bool DrawPadCanvas::redoEnabled() | 445 | bool DrawPadCanvas::redoEnabled() |
428 | { | 446 | { |
429 | return (m_pageBackups.current() != m_pageBackups.getLast()); | 447 | return (m_pageBackups.current() != m_pageBackups.getLast()); |
430 | } | 448 | } |
431 | 449 | ||
432 | bool DrawPadCanvas::goPreviousPageEnabled() | 450 | bool DrawPadCanvas::goPreviousPageEnabled() |
433 | { | 451 | { |
434 | return (m_pages.current() != m_pages.getFirst()); | 452 | return (m_pages.current() != m_pages.getFirst()); |
435 | } | 453 | } |
436 | 454 | ||
437 | bool DrawPadCanvas::goNextPageEnabled() | 455 | bool DrawPadCanvas::goNextPageEnabled() |
438 | { | 456 | { |
439 | return (m_pages.current() != m_pages.getLast()); | 457 | return (m_pages.current() != m_pages.getLast()); |
440 | } | 458 | } |
441 | 459 | ||
442 | void DrawPadCanvas::undo() | 460 | void DrawPadCanvas::undo() |
443 | { | 461 | { |
444 | *(m_pages.current()) = *(m_pageBackups.prev()); | 462 | *(m_pages.current()) = *(m_pageBackups.prev()); |
445 | 463 | ||
446 | viewport()->update(); | 464 | viewport()->update(); |
447 | 465 | ||
448 | emit pageBackupsChanged(); | 466 | emit pageBackupsChanged(); |
449 | } | 467 | } |
450 | 468 | ||
451 | void DrawPadCanvas::redo() | 469 | void DrawPadCanvas::redo() |
452 | { | 470 | { |
453 | *(m_pages.current()) = *(m_pageBackups.next()); | 471 | *(m_pages.current()) = *(m_pageBackups.next()); |
454 | 472 | ||
455 | viewport()->update(); | 473 | viewport()->update(); |
456 | 474 | ||
457 | emit pageBackupsChanged(); | 475 | emit pageBackupsChanged(); |
458 | } | 476 | } |
459 | 477 | ||
460 | void DrawPadCanvas::goFirstPage() | 478 | void DrawPadCanvas::goFirstPage() |
461 | { | 479 | { |
462 | m_pages.first(); | 480 | m_pages.first(); |
463 | m_pageBackups.clear(); | 481 | m_pageBackups.clear(); |
464 | m_pageBackups.append(new Page(*(m_pages.current()))); | 482 | m_pageBackups.append(new Page(*(m_pages.current()))); |
465 | 483 | ||
466 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 484 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
467 | viewport()->update(); | 485 | viewport()->update(); |
468 | 486 | ||
469 | emit pagesChanged(); | 487 | emit pagesChanged(); |
470 | emit pageBackupsChanged(); | 488 | emit pageBackupsChanged(); |
471 | } | 489 | } |
472 | 490 | ||
473 | void DrawPadCanvas::goPreviousPage() | 491 | void DrawPadCanvas::goPreviousPage() |
474 | { | 492 | { |
475 | m_pages.prev(); | 493 | m_pages.prev(); |
476 | m_pageBackups.clear(); | 494 | m_pageBackups.clear(); |
477 | m_pageBackups.append(new Page(*(m_pages.current()))); | 495 | m_pageBackups.append(new Page(*(m_pages.current()))); |
478 | 496 | ||
479 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 497 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
480 | viewport()->update(); | 498 | viewport()->update(); |
481 | 499 | ||
482 | emit pagesChanged(); | 500 | emit pagesChanged(); |
483 | emit pageBackupsChanged(); | 501 | emit pageBackupsChanged(); |
484 | } | 502 | } |
485 | 503 | ||
486 | void DrawPadCanvas::goNextPage() | 504 | void DrawPadCanvas::goNextPage() |
487 | { | 505 | { |
488 | m_pages.next(); | 506 | m_pages.next(); |
489 | m_pageBackups.clear(); | 507 | m_pageBackups.clear(); |
490 | m_pageBackups.append(new Page(*(m_pages.current()))); | 508 | m_pageBackups.append(new Page(*(m_pages.current()))); |
491 | 509 | ||
492 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 510 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
493 | viewport()->update(); | 511 | viewport()->update(); |
494 | 512 | ||
495 | emit pagesChanged(); | 513 | emit pagesChanged(); |
496 | emit pageBackupsChanged(); | 514 | emit pageBackupsChanged(); |
497 | } | 515 | } |
498 | 516 | ||
499 | void DrawPadCanvas::goLastPage() | 517 | void DrawPadCanvas::goLastPage() |
500 | { | 518 | { |
501 | m_pages.last(); | 519 | m_pages.last(); |
502 | m_pageBackups.clear(); | 520 | m_pageBackups.clear(); |
503 | m_pageBackups.append(new Page(*(m_pages.current()))); | 521 | m_pageBackups.append(new Page(*(m_pages.current()))); |
504 | 522 | ||
505 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 523 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
506 | viewport()->update(); | 524 | viewport()->update(); |
507 | 525 | ||
508 | emit pagesChanged(); | 526 | emit pagesChanged(); |
509 | emit pageBackupsChanged(); | 527 | emit pageBackupsChanged(); |
510 | } | 528 | } |
511 | 529 | ||
512 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | 530 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) |
513 | { | 531 | { |
514 | m_pDrawPad->tool()->mousePressEvent(e); | 532 | m_pDrawPad->tool()->mousePressEvent(e); |
515 | } | 533 | } |
516 | 534 | ||
517 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) | 535 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) |
518 | { | 536 | { |
519 | m_pDrawPad->tool()->mouseReleaseEvent(e); | 537 | m_pDrawPad->tool()->mouseReleaseEvent(e); |
520 | } | 538 | } |
521 | 539 | ||
522 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) | 540 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) |
523 | { | 541 | { |
524 | m_pDrawPad->tool()->mouseMoveEvent(e); | 542 | m_pDrawPad->tool()->mouseMoveEvent(e); |
525 | } | 543 | } |
526 | 544 | ||
527 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 545 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
528 | { | 546 | { |
529 | QRect clipRect(cx, cy, cw, ch); | 547 | QRect clipRect(cx, cy, cw, ch); |
530 | QRect pixmapRect(0, 0, m_pages.current()->width(), m_pages.current()->height()); | 548 | QRect pixmapRect(0, 0, m_pages.current()->width(), m_pages.current()->height()); |
531 | QRect drawRect = pixmapRect.intersect(clipRect); | 549 | QRect drawRect = pixmapRect.intersect(clipRect); |
532 | 550 | ||
533 | p->drawPixmap(drawRect.topLeft(), *(m_pages.current()), drawRect); | 551 | p->drawPixmap(drawRect.topLeft(), *(m_pages.current()), drawRect); |
534 | 552 | ||
535 | if (drawRect.right() < clipRect.right()) { | 553 | if (drawRect.right() < clipRect.right()) { |
536 | p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); | 554 | p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); |
537 | } | 555 | } |
538 | 556 | ||
539 | if (drawRect.bottom() < clipRect.bottom()) { | 557 | if (drawRect.bottom() < clipRect.bottom()) { |
540 | p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark()); | 558 | p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark()); |
541 | } | 559 | } |
542 | } | 560 | } |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index d74d425..39cf752 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -1,83 +1,85 @@ | |||
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 | ||
22 | class DrawPad; | 22 | class DrawPad; |
23 | class Page; | 23 | class Page; |
24 | 24 | ||
25 | class DrawPadCanvas : public QScrollView | 25 | class DrawPadCanvas : public QScrollView |
26 | { | 26 | { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | 28 | ||
29 | public: | 29 | public: |
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 | 39 | ||
40 | bool undoEnabled(); | 40 | bool undoEnabled(); |
41 | bool redoEnabled(); | 41 | bool redoEnabled(); |
42 | bool goPreviousPageEnabled(); | 42 | bool goPreviousPageEnabled(); |
43 | bool goNextPageEnabled(); | 43 | bool goNextPageEnabled(); |
44 | 44 | ||
45 | Page* currentPage(); | 45 | Page* currentPage(); |
46 | QList<Page> pages(); | 46 | QList<Page> pages(); |
47 | uint pagePosition(); | 47 | uint pagePosition(); |
48 | uint pageCount(); | 48 | uint pageCount(); |
49 | 49 | ||
50 | void selectPage(Page* page); | 50 | void selectPage(Page* page); |
51 | void backupPage(); | 51 | void backupPage(); |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void deleteAll(); | 54 | void deleteAll(); |
55 | void newPage(uint width, uint height, const QColor& color); | 55 | void newPage(uint width, uint height, const QColor& color); |
56 | void clearPage(); | 56 | void clearPage(); |
57 | void deletePage(); | 57 | void deletePage(); |
58 | void movePageUp(); | ||
59 | void movePageDown(); | ||
58 | 60 | ||
59 | void undo(); | 61 | void undo(); |
60 | void redo(); | 62 | void redo(); |
61 | 63 | ||
62 | void goFirstPage(); | 64 | void goFirstPage(); |
63 | void goPreviousPage(); | 65 | void goPreviousPage(); |
64 | void goNextPage(); | 66 | void goNextPage(); |
65 | void goLastPage(); | 67 | void goLastPage(); |
66 | 68 | ||
67 | signals: | 69 | signals: |
68 | void pagesChanged(); | 70 | void pagesChanged(); |
69 | void pageBackupsChanged(); | 71 | void pageBackupsChanged(); |
70 | 72 | ||
71 | protected: | 73 | protected: |
72 | void contentsMousePressEvent(QMouseEvent* e); | 74 | void contentsMousePressEvent(QMouseEvent* e); |
73 | void contentsMouseReleaseEvent(QMouseEvent* e); | 75 | void contentsMouseReleaseEvent(QMouseEvent* e); |
74 | void contentsMouseMoveEvent(QMouseEvent* e); | 76 | void contentsMouseMoveEvent(QMouseEvent* e); |
75 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); | 77 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); |
76 | 78 | ||
77 | private: | 79 | private: |
78 | DrawPad* m_pDrawPad; | 80 | DrawPad* m_pDrawPad; |
79 | QList<Page> m_pages; | 81 | QList<Page> m_pages; |
80 | QList<Page> m_pageBackups; | 82 | QList<Page> m_pageBackups; |
81 | }; | 83 | }; |
82 | 84 | ||
83 | #endif // DRAWPADCANVAS_H | 85 | #endif // DRAWPADCANVAS_H |
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 0c7934e..428e008 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp | |||
@@ -1,272 +1,299 @@ | |||
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 "thumbnailview.h" | 14 | #include "thumbnailview.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "newpagedialog.h" | 18 | #include "newpagedialog.h" |
19 | #include "page.h" | 19 | #include "page.h" |
20 | 20 | ||
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | 22 | ||
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qimage.h> | 25 | #include <qimage.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | 29 | ||
30 | PageListViewItem::PageListViewItem(Page* page, QListView* parent) | 30 | PageListViewItem::PageListViewItem(Page* page, QListView* parent) |
31 | : QListViewItem(parent) | 31 | : QListViewItem(parent) |
32 | { | 32 | { |
33 | m_pPage = page; | 33 | m_pPage = page; |
34 | 34 | ||
35 | QImage image = m_pPage->convertToImage(); | 35 | QImage image = m_pPage->convertToImage(); |
36 | 36 | ||
37 | int previewWidth = 64; | 37 | int previewWidth = 64; |
38 | int previewHeight = 64; | 38 | int previewHeight = 64; |
39 | 39 | ||
40 | float widthScale = 1.0; | 40 | float widthScale = 1.0; |
41 | float heightScale = 1.0; | 41 | float heightScale = 1.0; |
42 | 42 | ||
43 | if (previewWidth < image.width()) { | 43 | if (previewWidth < image.width()) { |
44 | widthScale = (float)previewWidth / float(image.width()); | 44 | widthScale = (float)previewWidth / float(image.width()); |
45 | } | 45 | } |
46 | 46 | ||
47 | if (previewHeight < image.height()) { | 47 | if (previewHeight < image.height()) { |
48 | heightScale = (float)previewHeight / float(image.height()); | 48 | heightScale = (float)previewHeight / float(image.height()); |
49 | } | 49 | } |
50 | 50 | ||
51 | float scale = (widthScale < heightScale ? widthScale : heightScale); | 51 | float scale = (widthScale < heightScale ? widthScale : heightScale); |
52 | QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); | 52 | QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); |
53 | 53 | ||
54 | QPixmap previewPixmap; | 54 | QPixmap previewPixmap; |
55 | previewPixmap.convertFromImage(previewImage); | 55 | previewPixmap.convertFromImage(previewImage); |
56 | 56 | ||
57 | QPixmap pixmap(64, 64); | 57 | QPixmap pixmap(64, 64); |
58 | 58 | ||
59 | pixmap.fill(listView()->colorGroup().mid()); | 59 | pixmap.fill(listView()->colorGroup().mid()); |
60 | bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2, | 60 | bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2, |
61 | (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap); | 61 | (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap); |
62 | 62 | ||
63 | setPixmap(0, pixmap); | 63 | setPixmap(0, pixmap); |
64 | } | 64 | } |
65 | 65 | ||
66 | PageListViewItem::~PageListViewItem() | 66 | PageListViewItem::~PageListViewItem() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | Page* PageListViewItem::page() const | 70 | Page* PageListViewItem::page() const |
71 | { | 71 | { |
72 | return m_pPage; | 72 | return m_pPage; |
73 | } | 73 | } |
74 | 74 | ||
75 | PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 75 | PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
76 | : QListView(parent, name) | 76 | : QListView(parent, name) |
77 | { | 77 | { |
78 | m_pDrawPadCanvas = drawPadCanvas; | 78 | m_pDrawPadCanvas = drawPadCanvas; |
79 | 79 | ||
80 | header()->hide(); | 80 | header()->hide(); |
81 | setVScrollBarMode(QScrollView::AlwaysOn); | 81 | setVScrollBarMode(QScrollView::AlwaysOn); |
82 | setAllColumnsShowFocus(true); | 82 | setAllColumnsShowFocus(true); |
83 | 83 | ||
84 | addColumn(tr("Thumbnail")); | 84 | addColumn(tr("Thumbnail")); |
85 | addColumn(tr("Information")); | 85 | addColumn(tr("Information")); |
86 | 86 | ||
87 | updateView(); | 87 | updateView(); |
88 | } | 88 | } |
89 | 89 | ||
90 | PageListView::~PageListView() | 90 | PageListView::~PageListView() |
91 | { | 91 | { |
92 | } | 92 | } |
93 | 93 | ||
94 | void PageListView::updateView() | 94 | void PageListView::updateView() |
95 | { | 95 | { |
96 | clear(); | 96 | clear(); |
97 | 97 | ||
98 | if (m_pDrawPadCanvas) { | 98 | if (m_pDrawPadCanvas) { |
99 | QList<Page> pageList = m_pDrawPadCanvas->pages(); | 99 | QList<Page> pageList = m_pDrawPadCanvas->pages(); |
100 | QListIterator<Page> it(pageList); | 100 | QListIterator<Page> it(pageList); |
101 | 101 | ||
102 | for (; it.current(); ++it) { | 102 | for (; it.current(); ++it) { |
103 | new PageListViewItem(it.current(), this); | 103 | new PageListViewItem(it.current(), this); |
104 | } | 104 | } |
105 | 105 | ||
106 | setSorting(0, false); | 106 | setSorting(0, false); |
107 | select(m_pDrawPadCanvas->currentPage()); | 107 | select(m_pDrawPadCanvas->currentPage()); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | void PageListView::resizeEvent(QResizeEvent* e) | 111 | void PageListView::resizeEvent(QResizeEvent* e) |
112 | { | 112 | { |
113 | Q_UNUSED(e); | 113 | Q_UNUSED(e); |
114 | 114 | ||
115 | setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width()); | 115 | setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width()); |
116 | } | 116 | } |
117 | 117 | ||
118 | void PageListView::select(Page* page) | 118 | void PageListView::select(Page* page) |
119 | { | 119 | { |
120 | PageListViewItem* item = (PageListViewItem*)firstChild(); | 120 | PageListViewItem* item = (PageListViewItem*)firstChild(); |
121 | 121 | ||
122 | while (item) { | 122 | while (item) { |
123 | if (item->page() == page) { | 123 | if (item->page() == page) { |
124 | setSelected(item, true); | 124 | setSelected(item, true); |
125 | ensureItemVisible(item); | 125 | ensureItemVisible(item); |
126 | break; | 126 | break; |
127 | } | 127 | } |
128 | 128 | ||
129 | item = (PageListViewItem*)(item->nextSibling()); | 129 | item = (PageListViewItem*)(item->nextSibling()); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | Page* PageListView::selected() const | 133 | Page* PageListView::selected() const |
134 | { | 134 | { |
135 | Page* page; | 135 | Page* page; |
136 | 136 | ||
137 | PageListViewItem* item = (PageListViewItem*)selectedItem(); | 137 | PageListViewItem* item = (PageListViewItem*)selectedItem(); |
138 | 138 | ||
139 | if (item) { | 139 | if (item) { |
140 | page = item->page(); | 140 | page = item->page(); |
141 | } else { | 141 | } else { |
142 | page = NULL; | 142 | page = NULL; |
143 | } | 143 | } |
144 | 144 | ||
145 | return page; | 145 | return page; |
146 | } | 146 | } |
147 | 147 | ||
148 | ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 148 | ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
149 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) | 149 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) |
150 | { | 150 | { |
151 | inLoop = false; | 151 | inLoop = false; |
152 | 152 | ||
153 | m_pDrawPad = drawPad; | 153 | m_pDrawPad = drawPad; |
154 | m_pDrawPadCanvas = drawPadCanvas; | 154 | m_pDrawPadCanvas = drawPadCanvas; |
155 | 155 | ||
156 | setCaption(tr("DrawPad - Thumbnail View")); | 156 | setCaption(tr("DrawPad - Thumbnail View")); |
157 | 157 | ||
158 | QToolButton* newPageButton = new QToolButton(this); | 158 | QToolButton* newPageButton = new QToolButton(this); |
159 | newPageButton->setIconSet(Resource::loadIconSet("new")); | 159 | newPageButton->setIconSet(Resource::loadIconSet("new")); |
160 | newPageButton->setAutoRaise(true); | 160 | newPageButton->setAutoRaise(true); |
161 | connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); | 161 | connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); |
162 | 162 | ||
163 | QToolButton* clearPageButton = new QToolButton(this); | 163 | QToolButton* clearPageButton = new QToolButton(this); |
164 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); | 164 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); |
165 | clearPageButton->setAutoRaise(true); | 165 | clearPageButton->setAutoRaise(true); |
166 | connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); | 166 | connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); |
167 | 167 | ||
168 | QToolButton* deletePageButton = new QToolButton(this); | 168 | QToolButton* deletePageButton = new QToolButton(this); |
169 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); | 169 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); |
170 | deletePageButton->setAutoRaise(true); | 170 | deletePageButton->setAutoRaise(true); |
171 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); | 171 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); |
172 | 172 | ||
173 | QToolButton* movePageUpButton = new QToolButton(this); | 173 | m_pMovePageUpButton = new QToolButton(this); |
174 | movePageUpButton->setIconSet(Resource::loadIconSet("up")); | 174 | m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up")); |
175 | movePageUpButton->setAutoRaise(true); | 175 | m_pMovePageUpButton->setAutoRaise(true); |
176 | connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); | ||
176 | 177 | ||
177 | QToolButton* movePageDownButton = new QToolButton(this); | 178 | m_pMovePageDownButton = new QToolButton(this); |
178 | movePageDownButton->setIconSet(Resource::loadIconSet("down")); | 179 | m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down")); |
179 | movePageDownButton->setAutoRaise(true); | 180 | m_pMovePageDownButton->setAutoRaise(true); |
181 | connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); | ||
180 | 182 | ||
181 | m_pPageListView = new PageListView(m_pDrawPadCanvas, this); | 183 | m_pPageListView = new PageListView(m_pDrawPadCanvas, this); |
182 | connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage())); | 184 | connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage())); |
183 | 185 | ||
184 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 186 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
185 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); | 187 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); |
186 | 188 | ||
187 | buttonLayout->addWidget(newPageButton); | 189 | buttonLayout->addWidget(newPageButton); |
188 | buttonLayout->addWidget(clearPageButton); | 190 | buttonLayout->addWidget(clearPageButton); |
189 | buttonLayout->addWidget(deletePageButton); | 191 | buttonLayout->addWidget(deletePageButton); |
190 | buttonLayout->addStretch(); | 192 | buttonLayout->addStretch(); |
191 | buttonLayout->addWidget(movePageUpButton); | 193 | buttonLayout->addWidget(m_pMovePageUpButton); |
192 | buttonLayout->addWidget(movePageDownButton); | 194 | buttonLayout->addWidget(m_pMovePageDownButton); |
193 | 195 | ||
194 | mainLayout->addLayout(buttonLayout); | 196 | mainLayout->addLayout(buttonLayout); |
195 | mainLayout->addWidget(m_pPageListView); | 197 | mainLayout->addWidget(m_pPageListView); |
198 | |||
199 | updateView(); | ||
196 | } | 200 | } |
197 | 201 | ||
198 | ThumbnailView::~ThumbnailView() | 202 | ThumbnailView::~ThumbnailView() |
199 | { | 203 | { |
200 | hide(); | 204 | hide(); |
201 | } | 205 | } |
202 | 206 | ||
207 | void ThumbnailView::updateView() | ||
208 | { | ||
209 | m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | ||
210 | m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | ||
211 | } | ||
212 | |||
203 | void ThumbnailView::hide() | 213 | void ThumbnailView::hide() |
204 | { | 214 | { |
205 | QWidget::hide(); | 215 | QWidget::hide(); |
206 | 216 | ||
207 | if (inLoop) { | 217 | if (inLoop) { |
208 | inLoop = false; | 218 | inLoop = false; |
209 | qApp->exit_loop(); | 219 | qApp->exit_loop(); |
210 | } | 220 | } |
211 | } | 221 | } |
212 | 222 | ||
213 | void ThumbnailView::exec() | 223 | void ThumbnailView::exec() |
214 | { | 224 | { |
215 | show(); | 225 | show(); |
216 | 226 | ||
217 | if (!inLoop) { | 227 | if (!inLoop) { |
218 | inLoop = true; | 228 | inLoop = true; |
219 | qApp->enter_loop(); | 229 | qApp->enter_loop(); |
220 | } | 230 | } |
221 | } | 231 | } |
222 | 232 | ||
223 | void ThumbnailView::newPage() | 233 | void ThumbnailView::newPage() |
224 | { | 234 | { |
225 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 235 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
226 | 236 | ||
227 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), | 237 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), |
228 | m_pDrawPad->brush().color(), this); | 238 | m_pDrawPad->brush().color(), this); |
229 | 239 | ||
230 | if (newPageDialog.exec() == QDialog::Accepted) { | 240 | if (newPageDialog.exec() == QDialog::Accepted) { |
231 | m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(), | 241 | m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(), |
232 | newPageDialog.selectedColor()); | 242 | newPageDialog.selectedColor()); |
233 | m_pPageListView->updateView(); | 243 | m_pPageListView->updateView(); |
244 | updateView(); | ||
234 | } | 245 | } |
235 | } | 246 | } |
236 | 247 | ||
237 | void ThumbnailView::clearPage() | 248 | void ThumbnailView::clearPage() |
238 | { | 249 | { |
239 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), | 250 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), |
240 | QMessageBox::Information, QMessageBox::Yes, | 251 | QMessageBox::Information, QMessageBox::Yes, |
241 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 252 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
242 | QMessageBox::NoButton, this); | 253 | QMessageBox::NoButton, this); |
243 | 254 | ||
244 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 255 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
245 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 256 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
246 | 257 | ||
247 | if (messageBox.exec() == QMessageBox::Yes) { | 258 | if (messageBox.exec() == QMessageBox::Yes) { |
248 | m_pDrawPadCanvas->clearPage(); | 259 | m_pDrawPadCanvas->clearPage(); |
249 | m_pPageListView->updateView(); | 260 | m_pPageListView->updateView(); |
250 | } | 261 | } |
251 | } | 262 | } |
252 | 263 | ||
253 | void ThumbnailView::deletePage() | 264 | void ThumbnailView::deletePage() |
254 | { | 265 | { |
255 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), | 266 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), |
256 | QMessageBox::Information, QMessageBox::Yes, | 267 | QMessageBox::Information, QMessageBox::Yes, |
257 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 268 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
258 | QMessageBox::NoButton, this); | 269 | QMessageBox::NoButton, this); |
259 | 270 | ||
260 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 271 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
261 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 272 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
262 | 273 | ||
263 | if (messageBox.exec() == QMessageBox::Yes) { | 274 | if (messageBox.exec() == QMessageBox::Yes) { |
264 | m_pDrawPadCanvas->deletePage(); | 275 | m_pDrawPadCanvas->deletePage(); |
265 | m_pPageListView->updateView(); | 276 | m_pPageListView->updateView(); |
277 | updateView(); | ||
266 | } | 278 | } |
267 | } | 279 | } |
268 | 280 | ||
281 | void ThumbnailView::movePageUp() | ||
282 | { | ||
283 | m_pDrawPadCanvas->movePageUp(); | ||
284 | m_pPageListView->updateView(); | ||
285 | updateView(); | ||
286 | } | ||
287 | |||
288 | void ThumbnailView::movePageDown() | ||
289 | { | ||
290 | m_pDrawPadCanvas->movePageDown(); | ||
291 | m_pPageListView->updateView(); | ||
292 | updateView(); | ||
293 | } | ||
294 | |||
269 | void ThumbnailView::changePage() | 295 | void ThumbnailView::changePage() |
270 | { | 296 | { |
271 | m_pDrawPadCanvas->selectPage(m_pPageListView->selected()); | 297 | m_pDrawPadCanvas->selectPage(m_pPageListView->selected()); |
298 | updateView(); | ||
272 | } | 299 | } |
diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h index 1fdb168..eb748fa 100644 --- a/noncore/graphics/drawpad/thumbnailview.h +++ b/noncore/graphics/drawpad/thumbnailview.h | |||
@@ -1,80 +1,89 @@ | |||
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 THUMBNAILVIEW_H | 14 | #ifndef THUMBNAILVIEW_H |
15 | #define THUMBNAILVIEW_H | 15 | #define THUMBNAILVIEW_H |
16 | 16 | ||
17 | #include <qwidget.h> | 17 | #include <qwidget.h> |
18 | #include <qlistview.h> | 18 | #include <qlistview.h> |
19 | 19 | ||
20 | class DrawPad; | 20 | class DrawPad; |
21 | class DrawPadCanvas; | 21 | class DrawPadCanvas; |
22 | class Page; | 22 | class Page; |
23 | 23 | ||
24 | class QToolButton; | ||
25 | |||
24 | class PageListViewItem : public QListViewItem | 26 | class PageListViewItem : public QListViewItem |
25 | { | 27 | { |
26 | public: | 28 | public: |
27 | PageListViewItem(Page* page, QListView* parent); | 29 | PageListViewItem(Page* page, QListView* parent); |
28 | ~PageListViewItem(); | 30 | ~PageListViewItem(); |
29 | 31 | ||
30 | Page* page() const; | 32 | Page* page() const; |
31 | 33 | ||
32 | private: | 34 | private: |
33 | Page* m_pPage; | 35 | Page* m_pPage; |
34 | }; | 36 | }; |
35 | 37 | ||
36 | class PageListView : public QListView | 38 | class PageListView : public QListView |
37 | { | 39 | { |
38 | public: | 40 | public: |
39 | PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); | 41 | PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); |
40 | ~PageListView(); | 42 | ~PageListView(); |
41 | 43 | ||
42 | void updateView(); | 44 | void updateView(); |
43 | 45 | ||
44 | void select(Page* page); | 46 | void select(Page* page); |
45 | Page* selected() const; | 47 | Page* selected() const; |
46 | 48 | ||
47 | protected: | 49 | protected: |
48 | void resizeEvent(QResizeEvent* e); | 50 | void resizeEvent(QResizeEvent* e); |
49 | 51 | ||
50 | private: | 52 | private: |
51 | DrawPadCanvas* m_pDrawPadCanvas; | 53 | DrawPadCanvas* m_pDrawPadCanvas; |
52 | }; | 54 | }; |
53 | 55 | ||
54 | class ThumbnailView : public QWidget | 56 | class ThumbnailView : public QWidget |
55 | { | 57 | { |
56 | Q_OBJECT | 58 | Q_OBJECT |
57 | 59 | ||
58 | public: | 60 | public: |
59 | ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); | 61 | ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); |
60 | ~ThumbnailView(); | 62 | ~ThumbnailView(); |
61 | 63 | ||
64 | void updateView(); | ||
65 | |||
62 | void hide(); | 66 | void hide(); |
63 | void exec(); | 67 | void exec(); |
64 | 68 | ||
65 | public slots: | 69 | public slots: |
66 | void newPage(); | 70 | void newPage(); |
67 | void clearPage(); | 71 | void clearPage(); |
68 | void deletePage(); | 72 | void deletePage(); |
73 | void movePageUp(); | ||
74 | void movePageDown(); | ||
69 | void changePage(); | 75 | void changePage(); |
70 | 76 | ||
71 | private: | 77 | private: |
72 | bool inLoop; | 78 | bool inLoop; |
73 | 79 | ||
74 | DrawPad* m_pDrawPad; | 80 | DrawPad* m_pDrawPad; |
75 | DrawPadCanvas* m_pDrawPadCanvas; | 81 | DrawPadCanvas* m_pDrawPadCanvas; |
76 | 82 | ||
83 | QToolButton* m_pMovePageUpButton; | ||
84 | QToolButton* m_pMovePageDownButton; | ||
85 | |||
77 | PageListView* m_pPageListView; | 86 | PageListView* m_pPageListView; |
78 | }; | 87 | }; |
79 | 88 | ||
80 | #endif // THUMBNAILVIEW_H | 89 | #endif // THUMBNAILVIEW_H |