-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 5 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 58192d3..db6288f 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -268,96 +268,101 @@ void DrawPadCanvas::importPage(const QString& fileName) | |||
268 | viewport()->update(); | 268 | viewport()->update(); |
269 | 269 | ||
270 | emit pagesChanged(); | 270 | emit pagesChanged(); |
271 | emit pageBackupsChanged(); | 271 | emit pageBackupsChanged(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) | 274 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) |
275 | { | 275 | { |
276 | if (fromPage == toPage) { | 276 | if (fromPage == toPage) { |
277 | DocLnk docLnk; | 277 | DocLnk docLnk; |
278 | MimeType mimeType(format); | 278 | MimeType mimeType(format); |
279 | 279 | ||
280 | docLnk.setName(name); | 280 | docLnk.setName(name); |
281 | docLnk.setType(mimeType.id()); | 281 | docLnk.setType(mimeType.id()); |
282 | 282 | ||
283 | FileManager fileManager; | 283 | FileManager fileManager; |
284 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 284 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
285 | QImageIO imageIO(ioDevice, format); | 285 | QImageIO imageIO(ioDevice, format); |
286 | 286 | ||
287 | QImage image = m_pages.current()->convertToImage(); | 287 | QImage image = m_pages.current()->convertToImage(); |
288 | imageIO.setImage(image); | 288 | imageIO.setImage(image); |
289 | imageIO.write(); | 289 | imageIO.write(); |
290 | delete ioDevice; | 290 | delete ioDevice; |
291 | } else { | 291 | } else { |
292 | for (uint i = fromPage; i <= toPage; i++) { | 292 | for (uint i = fromPage; i <= toPage; i++) { |
293 | DocLnk docLnk; | 293 | DocLnk docLnk; |
294 | MimeType mimeType(format); | 294 | MimeType mimeType(format); |
295 | 295 | ||
296 | docLnk.setName(name + QString::number(i)); | 296 | docLnk.setName(name + QString::number(i)); |
297 | docLnk.setType(mimeType.id()); | 297 | docLnk.setType(mimeType.id()); |
298 | 298 | ||
299 | FileManager fileManager; | 299 | FileManager fileManager; |
300 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 300 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
301 | QImageIO imageIO(ioDevice, format); | 301 | QImageIO imageIO(ioDevice, format); |
302 | 302 | ||
303 | QImage image = m_pages.at(i - 1)->convertToImage(); | 303 | QImage image = m_pages.at(i - 1)->convertToImage(); |
304 | imageIO.setImage(image); | 304 | imageIO.setImage(image); |
305 | imageIO.write(); | 305 | imageIO.write(); |
306 | delete ioDevice; | 306 | delete ioDevice; |
307 | } | 307 | } |
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | QPixmap* DrawPadCanvas::currentPage() | 311 | QPixmap* DrawPadCanvas::currentPage() |
312 | { | 312 | { |
313 | return m_pages.current(); | 313 | return m_pages.current(); |
314 | } | 314 | } |
315 | 315 | ||
316 | QList<QPixmap> DrawPadCanvas::pages() | ||
317 | { | ||
318 | return m_pages; | ||
319 | } | ||
320 | |||
316 | uint DrawPadCanvas::pagePosition() | 321 | uint DrawPadCanvas::pagePosition() |
317 | { | 322 | { |
318 | return (m_pages.at() + 1); | 323 | return (m_pages.at() + 1); |
319 | } | 324 | } |
320 | 325 | ||
321 | uint DrawPadCanvas::pageCount() | 326 | uint DrawPadCanvas::pageCount() |
322 | { | 327 | { |
323 | return m_pages.count(); | 328 | return m_pages.count(); |
324 | } | 329 | } |
325 | 330 | ||
326 | void DrawPadCanvas::deleteAll() | 331 | void DrawPadCanvas::deleteAll() |
327 | { | 332 | { |
328 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 333 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
329 | QMessageBox::Information, QMessageBox::Yes, | 334 | QMessageBox::Information, QMessageBox::Yes, |
330 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 335 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
331 | QMessageBox::NoButton, this); | 336 | QMessageBox::NoButton, this); |
332 | 337 | ||
333 | if (messageBox.exec() == QMessageBox::Yes) { | 338 | if (messageBox.exec() == QMessageBox::Yes) { |
334 | m_pages.clear(); | 339 | m_pages.clear(); |
335 | 340 | ||
336 | m_pages.append(new QPixmap(contentsRect().size())); | 341 | m_pages.append(new QPixmap(contentsRect().size())); |
337 | m_pages.current()->fill(Qt::white); | 342 | m_pages.current()->fill(Qt::white); |
338 | 343 | ||
339 | m_pageBackups.clear(); | 344 | m_pageBackups.clear(); |
340 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 345 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
341 | 346 | ||
342 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 347 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
343 | viewport()->update(); | 348 | viewport()->update(); |
344 | 349 | ||
345 | emit pagesChanged(); | 350 | emit pagesChanged(); |
346 | emit pageBackupsChanged(); | 351 | emit pageBackupsChanged(); |
347 | } | 352 | } |
348 | } | 353 | } |
349 | 354 | ||
350 | void DrawPadCanvas::newPage() | 355 | void DrawPadCanvas::newPage() |
351 | { | 356 | { |
352 | QRect rect = contentsRect(); | 357 | QRect rect = contentsRect(); |
353 | 358 | ||
354 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), | 359 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), |
355 | m_pDrawPad->brush().color(), this); | 360 | m_pDrawPad->brush().color(), this); |
356 | 361 | ||
357 | if (newPageDialog.exec() == QDialog::Accepted) { | 362 | if (newPageDialog.exec() == QDialog::Accepted) { |
358 | m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(), | 363 | m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(), |
359 | newPageDialog.selectedHeight())); | 364 | newPageDialog.selectedHeight())); |
360 | m_pages.current()->fill(newPageDialog.selectedColor()); | 365 | m_pages.current()->fill(newPageDialog.selectedColor()); |
361 | 366 | ||
362 | m_pageBackups.clear(); | 367 | m_pageBackups.clear(); |
363 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 368 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index 90dd951..a1a9466 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -1,80 +1,81 @@ | |||
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 | 23 | ||
24 | class QPixmap; | 24 | class QPixmap; |
25 | 25 | ||
26 | class DrawPadCanvas : public QScrollView | 26 | class DrawPadCanvas : public QScrollView |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | public: | 30 | public: |
31 | DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); | 31 | DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); |
32 | ~DrawPadCanvas(); | 32 | ~DrawPadCanvas(); |
33 | 33 | ||
34 | void load(QIODevice* ioDevice); | 34 | void load(QIODevice* ioDevice); |
35 | void initialPage(); | 35 | void initialPage(); |
36 | void save(QIODevice* ioDevice); | 36 | void save(QIODevice* ioDevice); |
37 | 37 | ||
38 | void importPage(const QString& fileName); | 38 | void importPage(const QString& fileName); |
39 | void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); | 39 | void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); |
40 | 40 | ||
41 | bool undoEnabled(); | 41 | bool undoEnabled(); |
42 | bool redoEnabled(); | 42 | bool redoEnabled(); |
43 | bool goPreviousPageEnabled(); | 43 | bool goPreviousPageEnabled(); |
44 | bool goNextPageEnabled(); | 44 | bool goNextPageEnabled(); |
45 | 45 | ||
46 | QPixmap* currentPage(); | 46 | QPixmap* currentPage(); |
47 | QList<QPixmap> pages(); | ||
47 | uint pagePosition(); | 48 | uint pagePosition(); |
48 | uint pageCount(); | 49 | uint pageCount(); |
49 | 50 | ||
50 | public slots: | 51 | public slots: |
51 | void deleteAll(); | 52 | void deleteAll(); |
52 | void newPage(); | 53 | void newPage(); |
53 | void clearPage(); | 54 | void clearPage(); |
54 | void deletePage(); | 55 | void deletePage(); |
55 | 56 | ||
56 | void undo(); | 57 | void undo(); |
57 | void redo(); | 58 | void redo(); |
58 | 59 | ||
59 | void goFirstPage(); | 60 | void goFirstPage(); |
60 | void goPreviousPage(); | 61 | void goPreviousPage(); |
61 | void goNextPage(); | 62 | void goNextPage(); |
62 | void goLastPage(); | 63 | void goLastPage(); |
63 | 64 | ||
64 | signals: | 65 | signals: |
65 | void pagesChanged(); | 66 | void pagesChanged(); |
66 | void pageBackupsChanged(); | 67 | void pageBackupsChanged(); |
67 | 68 | ||
68 | protected: | 69 | protected: |
69 | void contentsMousePressEvent(QMouseEvent* e); | 70 | void contentsMousePressEvent(QMouseEvent* e); |
70 | void contentsMouseReleaseEvent(QMouseEvent* e); | 71 | void contentsMouseReleaseEvent(QMouseEvent* e); |
71 | void contentsMouseMoveEvent(QMouseEvent* e); | 72 | void contentsMouseMoveEvent(QMouseEvent* e); |
72 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); | 73 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); |
73 | 74 | ||
74 | private: | 75 | private: |
75 | DrawPad* m_pDrawPad; | 76 | DrawPad* m_pDrawPad; |
76 | QList<QPixmap> m_pages; | 77 | QList<QPixmap> m_pages; |
77 | QList<QPixmap> m_pageBackups; | 78 | QList<QPixmap> m_pageBackups; |
78 | }; | 79 | }; |
79 | 80 | ||
80 | #endif // DRAWPADCANVAS_H | 81 | #endif // DRAWPADCANVAS_H |