-rw-r--r-- | noncore/graphics/drawpad/drawpad.pro | 3 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 21 |
2 files changed, 2 insertions, 22 deletions
diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro index 6bea193..8f70cc6 100644 --- a/noncore/graphics/drawpad/drawpad.pro +++ b/noncore/graphics/drawpad/drawpad.pro @@ -1,62 +1,61 @@ TEMPLATE = app CONFIG = qt warn_on release HEADERS = drawpad.h \ drawpadcanvas.h \ ellipsetool.h \ erasetool.h \ exportdialog.h \ filltool.h \ filledellipsetool.h \ filledrectangletool.h \ importdialog.h \ linetool.h \ newpagedialog.h \ page.h \ pageinformationdialog.h \ pointtool.h \ rectangletool.h \ shapetool.h \ texttool.h \ thumbnailview.h \ tool.h SOURCES = drawpad.cpp \ drawpadcanvas.cpp \ ellipsetool.cpp \ erasetool.cpp \ exportdialog.cpp \ filltool.cpp \ filledellipsetool.cpp \ filledrectangletool.cpp \ importdialog.cpp \ linetool.cpp \ main.cpp \ newpagedialog.cpp \ page.cpp \ pageinformationdialog.cpp \ pointtool.cpp \ rectangletool.cpp \ shapetool.cpp \ texttool.cpp \ thumbnailview.cpp \ tool.cpp -INCLUDEPATH += $(OPIEDIR)/include \ - $(QTDIR)/src/3rdparty/zlib +INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie DESTDIR = $(OPIEDIR)/bin TARGET = drawpad TRANSLATIONS = ../../i18n/de/drawpad.ts TRANSLATIONS += ../../i18n/en/drawpad.ts TRANSLATIONS += ../../i18n/es/drawpad.ts TRANSLATIONS += ../../i18n/fr/drawpad.ts TRANSLATIONS += ../../i18n/hu/drawpad.ts TRANSLATIONS += ../../i18n/ja/drawpad.ts TRANSLATIONS += ../../i18n/ko/drawpad.ts TRANSLATIONS += ../../i18n/no/drawpad.ts TRANSLATIONS += ../../i18n/pl/drawpad.ts TRANSLATIONS += ../../i18n/pt/drawpad.ts TRANSLATIONS += ../../i18n/pt_BR/drawpad.ts TRANSLATIONS += ../../i18n/sl/drawpad.ts TRANSLATIONS += ../../i18n/zh_CN/drawpad.ts TRANSLATIONS += ../../i18n/zh_TW/drawpad.ts diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index ae1b554..5437068 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp @@ -1,215 +1,196 @@ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "drawpadcanvas.h" #include "drawpad.h" #include "page.h" #include "tool.h" #include <qpe/applnk.h> #include <qpe/filemanager.h> #include <qpe/mimetype.h> #include <qbuffer.h> #include <qimage.h> #include <qpainter.h> #include <qtextcodec.h> #include <qtextstream.h> #include <qxml.h> -#include <zlib.h> - const int PAGE_BACKUPS = 99; class DrawPadCanvasXmlHandler: public QXmlDefaultHandler { public: DrawPadCanvasXmlHandler(); ~DrawPadCanvasXmlHandler(); QList<Page> pages(); bool startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts); bool endElement(const QString& namespaceURI, const QString& localName, const QString& qName); bool characters(const QString& ch); private: enum State { Unknown, InTitle, InDate, InData }; State m_state; QString m_title; QDateTime m_date; ulong m_dataLenght; QString m_dataFormat; QList<Page> m_pages; }; DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() { m_state = Unknown; } DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() { } QList<Page> DrawPadCanvasXmlHandler::pages() { return m_pages; } bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts) { Q_CONST_UNUSED(namespaceURI) Q_CONST_UNUSED(localName) if (qName == "image") { m_title = QString(); m_date = QDateTime::currentDateTime(); } else if (qName == "title") { m_state = InTitle; } else if (qName == "date") { m_state = InDate; } else if (qName == "data") { m_state = InData; m_dataLenght = atts.value("length").toULong(); m_dataFormat = atts.value("format"); - - if (m_dataFormat.isEmpty()) { - m_dataFormat = "XPM"; - } } return true; } bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, const QString& qName) { Q_CONST_UNUSED(namespaceURI) Q_CONST_UNUSED(localName) if (qName == "title") { m_state = Unknown; } else if (qName == "date") { m_state = Unknown; } else if (qName == "data") { m_state = Unknown; } return true; } bool DrawPadCanvasXmlHandler::characters(const QString& ch) { if (m_state == InTitle) { m_title = ch; } else if (m_state == InDate) { m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt()); } else if (m_state == InData) { QByteArray byteArray(ch.length() / 2); for (int i = 0; i < (int)ch.length() / 2; i++) { char h = ch[2 * i].latin1(); char l = ch[2 * i + 1].latin1(); uchar r = 0; if (h <= '9') { r += h - '0'; } else { r += h - 'a' + 10; } r = r << 4; if (l <= '9') { r += l - '0'; } else { r += l - 'a' + 10; } byteArray[i] = r; } - QImage image; - - if (m_dataFormat == "XPM") { - if (m_dataLenght < ch.length() * 5) { - m_dataLenght = ch.length() * 5; - } - - QByteArray byteArrayUnzipped(m_dataLenght); - ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); - - image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat); - } else { - image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); - } + image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); Page* page = new Page(m_title, image.width(), image.height()); page->setLastModified(m_date); page->convertFromImage(image); m_pages.append(page); } return true; } DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) : QScrollView(parent, name) { m_pDrawPad = drawPad; m_pages.setAutoDelete(true); m_pageBackups.setAutoDelete(true); viewport()->setBackgroundMode(QWidget::NoBackground); } DrawPadCanvas::~DrawPadCanvas() { } void DrawPadCanvas::load(QIODevice* ioDevice) { QTextStream textStream(ioDevice); textStream.setCodec(QTextCodec::codecForName("UTF-8")); QXmlInputSource xmlInputSource(textStream); QXmlSimpleReader xmlSimpleReader; DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); xmlSimpleReader.parse(xmlInputSource); m_pages = drawPadCanvasXmlHandler.pages(); if (m_pages.isEmpty()) { m_pages.append(new Page("", contentsRect().size())); m_pages.current()->fill(Qt::white); } m_pageBackups.clear(); m_pageBackups.append(new Page(*(m_pages.current()))); resizeContents(m_pages.current()->width(), m_pages.current()->height()); viewport()->update(); |