author | leseb <leseb> | 2002-04-15 09:02:41 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-04-15 09:02:41 (UTC) |
commit | 6fe76c38a8c38e491bc292475bb2b27c4e63218c (patch) (side-by-side diff) | |
tree | 83fd51845ebfa698a13f126d9e733d9a50e98cc1 | |
parent | d126d607fe18c9253330692f9da53bb932941af5 (diff) | |
download | opie-6fe76c38a8c38e491bc292475bb2b27c4e63218c.zip opie-6fe76c38a8c38e491bc292475bb2b27c4e63218c.tar.gz opie-6fe76c38a8c38e491bc292475bb2b27c4e63218c.tar.bz2 |
Add pages get method
-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 @@ -252,128 +252,133 @@ void DrawPadCanvas::save(QIODevice* ioDevice) textStream << " </images>" << endl; textStream << "</drawpad>"; } void DrawPadCanvas::importPage(const QString& fileName) { QPixmap* importedPixmap = new QPixmap(); importedPixmap->load(fileName); m_pages.insert(m_pages.at() + 1, importedPixmap); m_pageBackups.clear(); m_pageBackups.append(new QPixmap(*(m_pages.current()))); resizeContents(m_pages.current()->width(), m_pages.current()->height()); viewport()->update(); emit pagesChanged(); emit pageBackupsChanged(); } void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) { if (fromPage == toPage) { DocLnk docLnk; MimeType mimeType(format); docLnk.setName(name); docLnk.setType(mimeType.id()); FileManager fileManager; QIODevice* ioDevice = fileManager.saveFile(docLnk); QImageIO imageIO(ioDevice, format); QImage image = m_pages.current()->convertToImage(); imageIO.setImage(image); imageIO.write(); delete ioDevice; } else { for (uint i = fromPage; i <= toPage; i++) { DocLnk docLnk; MimeType mimeType(format); docLnk.setName(name + QString::number(i)); docLnk.setType(mimeType.id()); FileManager fileManager; QIODevice* ioDevice = fileManager.saveFile(docLnk); QImageIO imageIO(ioDevice, format); QImage image = m_pages.at(i - 1)->convertToImage(); imageIO.setImage(image); imageIO.write(); delete ioDevice; } } } QPixmap* DrawPadCanvas::currentPage() { return m_pages.current(); } +QList<QPixmap> DrawPadCanvas::pages() +{ + return m_pages; +} + uint DrawPadCanvas::pagePosition() { return (m_pages.at() + 1); } uint DrawPadCanvas::pageCount() { return m_pages.count(); } void DrawPadCanvas::deleteAll() { QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), QMessageBox::Information, QMessageBox::Yes, QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, QMessageBox::NoButton, this); if (messageBox.exec() == QMessageBox::Yes) { m_pages.clear(); m_pages.append(new QPixmap(contentsRect().size())); m_pages.current()->fill(Qt::white); m_pageBackups.clear(); m_pageBackups.append(new QPixmap(*(m_pages.current()))); resizeContents(m_pages.current()->width(), m_pages.current()->height()); viewport()->update(); emit pagesChanged(); emit pageBackupsChanged(); } } void DrawPadCanvas::newPage() { QRect rect = contentsRect(); NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), m_pDrawPad->brush().color(), this); if (newPageDialog.exec() == QDialog::Accepted) { m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(), newPageDialog.selectedHeight())); m_pages.current()->fill(newPageDialog.selectedColor()); m_pageBackups.clear(); m_pageBackups.append(new QPixmap(*(m_pages.current()))); resizeContents(m_pages.current()->width(), m_pages.current()->height()); viewport()->update(); emit pagesChanged(); emit pageBackupsChanged(); } } void DrawPadCanvas::clearPage() { QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), QMessageBox::Information, QMessageBox::Yes, QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, QMessageBox::NoButton, this); 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 @@ /*************************************************************************** * * * DrawPad - a drawing program for Opie Environment * * * * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef DRAWPADCANVAS_H #define DRAWPADCANVAS_H #include <qscrollview.h> #include <qlist.h> #include <qpointarray.h> class DrawPad; class QPixmap; class DrawPadCanvas : public QScrollView { Q_OBJECT public: DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); ~DrawPadCanvas(); void load(QIODevice* ioDevice); void initialPage(); void save(QIODevice* ioDevice); void importPage(const QString& fileName); void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); bool undoEnabled(); bool redoEnabled(); bool goPreviousPageEnabled(); bool goNextPageEnabled(); QPixmap* currentPage(); + QList<QPixmap> pages(); uint pagePosition(); uint pageCount(); public slots: void deleteAll(); void newPage(); void clearPage(); void deletePage(); void undo(); void redo(); void goFirstPage(); void goPreviousPage(); void goNextPage(); void goLastPage(); signals: void pagesChanged(); void pageBackupsChanged(); protected: void contentsMousePressEvent(QMouseEvent* e); void contentsMouseReleaseEvent(QMouseEvent* e); void contentsMouseMoveEvent(QMouseEvent* e); void drawContents(QPainter* p, int cx, int cy, int cw, int ch); private: DrawPad* m_pDrawPad; QList<QPixmap> m_pages; QList<QPixmap> m_pageBackups; }; #endif // DRAWPADCANVAS_H |