author | leseb <leseb> | 2002-06-23 17:47:21 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-23 17:47:21 (UTC) |
commit | 3251c55f854ecbd4ece8bf169177ffac28081aaa (patch) (unidiff) | |
tree | beaf75deb513c8ef4a3ea222135308241fe09f6f | |
parent | 7c22b9cbf92650c432a84537f4b9c3d810e7dc75 (diff) | |
download | opie-3251c55f854ecbd4ece8bf169177ffac28081aaa.zip opie-3251c55f854ecbd4ece8bf169177ffac28081aaa.tar.gz opie-3251c55f854ecbd4ece8bf169177ffac28081aaa.tar.bz2 |
Remove old format reading (XPM gzipped)
-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 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = drawpad.h \ | 3 | HEADERS = drawpad.h \ |
4 | drawpadcanvas.h \ | 4 | drawpadcanvas.h \ |
5 | ellipsetool.h \ | 5 | ellipsetool.h \ |
6 | erasetool.h \ | 6 | erasetool.h \ |
7 | exportdialog.h \ | 7 | exportdialog.h \ |
8 | filltool.h \ | 8 | filltool.h \ |
9 | filledellipsetool.h \ | 9 | filledellipsetool.h \ |
10 | filledrectangletool.h \ | 10 | filledrectangletool.h \ |
11 | importdialog.h \ | 11 | importdialog.h \ |
12 | linetool.h \ | 12 | linetool.h \ |
13 | newpagedialog.h \ | 13 | newpagedialog.h \ |
14 | page.h \ | 14 | page.h \ |
15 | pageinformationdialog.h \ | 15 | pageinformationdialog.h \ |
16 | pointtool.h \ | 16 | pointtool.h \ |
17 | rectangletool.h \ | 17 | rectangletool.h \ |
18 | shapetool.h \ | 18 | shapetool.h \ |
19 | texttool.h \ | 19 | texttool.h \ |
20 | thumbnailview.h \ | 20 | thumbnailview.h \ |
21 | tool.h | 21 | tool.h |
22 | SOURCES = drawpad.cpp \ | 22 | SOURCES = drawpad.cpp \ |
23 | drawpadcanvas.cpp \ | 23 | drawpadcanvas.cpp \ |
24 | ellipsetool.cpp \ | 24 | ellipsetool.cpp \ |
25 | erasetool.cpp \ | 25 | erasetool.cpp \ |
26 | exportdialog.cpp \ | 26 | exportdialog.cpp \ |
27 | filltool.cpp \ | 27 | filltool.cpp \ |
28 | filledellipsetool.cpp \ | 28 | filledellipsetool.cpp \ |
29 | filledrectangletool.cpp \ | 29 | filledrectangletool.cpp \ |
30 | importdialog.cpp \ | 30 | importdialog.cpp \ |
31 | linetool.cpp \ | 31 | linetool.cpp \ |
32 | main.cpp \ | 32 | main.cpp \ |
33 | newpagedialog.cpp \ | 33 | newpagedialog.cpp \ |
34 | page.cpp \ | 34 | page.cpp \ |
35 | pageinformationdialog.cpp \ | 35 | pageinformationdialog.cpp \ |
36 | pointtool.cpp \ | 36 | pointtool.cpp \ |
37 | rectangletool.cpp \ | 37 | rectangletool.cpp \ |
38 | shapetool.cpp \ | 38 | shapetool.cpp \ |
39 | texttool.cpp \ | 39 | texttool.cpp \ |
40 | thumbnailview.cpp \ | 40 | thumbnailview.cpp \ |
41 | tool.cpp | 41 | tool.cpp |
42 | INCLUDEPATH+= $(OPIEDIR)/include \ | 42 | INCLUDEPATH+= $(OPIEDIR)/include |
43 | $(QTDIR)/src/3rdparty/zlib | ||
44 | DEPENDPATH+= $(OPIEDIR)/include | 43 | DEPENDPATH+= $(OPIEDIR)/include |
45 | LIBS += -lqpe -lopie | 44 | LIBS += -lqpe -lopie |
46 | DESTDIR = $(OPIEDIR)/bin | 45 | DESTDIR = $(OPIEDIR)/bin |
47 | TARGET = drawpad | 46 | TARGET = drawpad |
48 | 47 | ||
49 | TRANSLATIONS= ../../i18n/de/drawpad.ts | 48 | TRANSLATIONS= ../../i18n/de/drawpad.ts |
50 | TRANSLATIONS+= ../../i18n/en/drawpad.ts | 49 | TRANSLATIONS+= ../../i18n/en/drawpad.ts |
51 | TRANSLATIONS+= ../../i18n/es/drawpad.ts | 50 | TRANSLATIONS+= ../../i18n/es/drawpad.ts |
52 | TRANSLATIONS+= ../../i18n/fr/drawpad.ts | 51 | TRANSLATIONS+= ../../i18n/fr/drawpad.ts |
53 | TRANSLATIONS+= ../../i18n/hu/drawpad.ts | 52 | TRANSLATIONS+= ../../i18n/hu/drawpad.ts |
54 | TRANSLATIONS+= ../../i18n/ja/drawpad.ts | 53 | TRANSLATIONS+= ../../i18n/ja/drawpad.ts |
55 | TRANSLATIONS+= ../../i18n/ko/drawpad.ts | 54 | TRANSLATIONS+= ../../i18n/ko/drawpad.ts |
56 | TRANSLATIONS+= ../../i18n/no/drawpad.ts | 55 | TRANSLATIONS+= ../../i18n/no/drawpad.ts |
57 | TRANSLATIONS+= ../../i18n/pl/drawpad.ts | 56 | TRANSLATIONS+= ../../i18n/pl/drawpad.ts |
58 | TRANSLATIONS+= ../../i18n/pt/drawpad.ts | 57 | TRANSLATIONS+= ../../i18n/pt/drawpad.ts |
59 | TRANSLATIONS+= ../../i18n/pt_BR/drawpad.ts | 58 | TRANSLATIONS+= ../../i18n/pt_BR/drawpad.ts |
60 | TRANSLATIONS+= ../../i18n/sl/drawpad.ts | 59 | TRANSLATIONS+= ../../i18n/sl/drawpad.ts |
61 | TRANSLATIONS+= ../../i18n/zh_CN/drawpad.ts | 60 | TRANSLATIONS+= ../../i18n/zh_CN/drawpad.ts |
62 | TRANSLATIONS+= ../../i18n/zh_TW/drawpad.ts | 61 | 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 @@ | |||
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> | ||
32 | |||
33 | const int PAGE_BACKUPS = 99; | 31 | const int PAGE_BACKUPS = 99; |
34 | 32 | ||
35 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler | 33 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler |
36 | { | 34 | { |
37 | public: | 35 | public: |
38 | DrawPadCanvasXmlHandler(); | 36 | DrawPadCanvasXmlHandler(); |
39 | ~DrawPadCanvasXmlHandler(); | 37 | ~DrawPadCanvasXmlHandler(); |
40 | 38 | ||
41 | QList<Page> pages(); | 39 | QList<Page> pages(); |
42 | 40 | ||
43 | bool startElement(const QString& namespaceURI, const QString& localName, | 41 | bool startElement(const QString& namespaceURI, const QString& localName, |
44 | const QString& qName, const QXmlAttributes& atts); | 42 | const QString& qName, const QXmlAttributes& atts); |
45 | bool endElement(const QString& namespaceURI, const QString& localName, | 43 | bool endElement(const QString& namespaceURI, const QString& localName, |
46 | const QString& qName); | 44 | const QString& qName); |
47 | bool characters(const QString& ch); | 45 | bool characters(const QString& ch); |
48 | 46 | ||
49 | private: | 47 | private: |
50 | enum State { | 48 | enum State { |
51 | Unknown, | 49 | Unknown, |
52 | InTitle, | 50 | InTitle, |
53 | InDate, | 51 | InDate, |
54 | InData | 52 | InData |
55 | }; | 53 | }; |
56 | 54 | ||
57 | State m_state; | 55 | State m_state; |
58 | QString m_title; | 56 | QString m_title; |
59 | QDateTime m_date; | 57 | QDateTime m_date; |
60 | ulong m_dataLenght; | 58 | ulong m_dataLenght; |
61 | QString m_dataFormat; | 59 | QString m_dataFormat; |
62 | QList<Page> m_pages; | 60 | QList<Page> m_pages; |
63 | }; | 61 | }; |
64 | 62 | ||
65 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() | 63 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() |
66 | { | 64 | { |
67 | m_state = Unknown; | 65 | m_state = Unknown; |
68 | } | 66 | } |
69 | 67 | ||
70 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() | 68 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() |
71 | { | 69 | { |
72 | } | 70 | } |
73 | 71 | ||
74 | QList<Page> DrawPadCanvasXmlHandler::pages() | 72 | QList<Page> DrawPadCanvasXmlHandler::pages() |
75 | { | 73 | { |
76 | return m_pages; | 74 | return m_pages; |
77 | } | 75 | } |
78 | 76 | ||
79 | bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, | 77 | bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, |
80 | const QString& qName, const QXmlAttributes& atts) | 78 | const QString& qName, const QXmlAttributes& atts) |
81 | { | 79 | { |
82 | Q_CONST_UNUSED(namespaceURI) | 80 | Q_CONST_UNUSED(namespaceURI) |
83 | Q_CONST_UNUSED(localName) | 81 | Q_CONST_UNUSED(localName) |
84 | 82 | ||
85 | if (qName == "image") { | 83 | if (qName == "image") { |
86 | m_title = QString(); | 84 | m_title = QString(); |
87 | m_date = QDateTime::currentDateTime(); | 85 | m_date = QDateTime::currentDateTime(); |
88 | } else if (qName == "title") { | 86 | } else if (qName == "title") { |
89 | m_state = InTitle; | 87 | m_state = InTitle; |
90 | } else if (qName == "date") { | 88 | } else if (qName == "date") { |
91 | m_state = InDate; | 89 | m_state = InDate; |
92 | } else if (qName == "data") { | 90 | } else if (qName == "data") { |
93 | m_state = InData; | 91 | m_state = InData; |
94 | m_dataLenght = atts.value("length").toULong(); | 92 | m_dataLenght = atts.value("length").toULong(); |
95 | m_dataFormat = atts.value("format"); | 93 | m_dataFormat = atts.value("format"); |
96 | |||
97 | if (m_dataFormat.isEmpty()) { | ||
98 | m_dataFormat = "XPM"; | ||
99 | } | ||
100 | } | 94 | } |
101 | 95 | ||
102 | return true; | 96 | return true; |
103 | } | 97 | } |
104 | 98 | ||
105 | bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, | 99 | bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, |
106 | const QString& qName) | 100 | const QString& qName) |
107 | { | 101 | { |
108 | Q_CONST_UNUSED(namespaceURI) | 102 | Q_CONST_UNUSED(namespaceURI) |
109 | Q_CONST_UNUSED(localName) | 103 | Q_CONST_UNUSED(localName) |
110 | 104 | ||
111 | if (qName == "title") { | 105 | if (qName == "title") { |
112 | m_state = Unknown; | 106 | m_state = Unknown; |
113 | } else if (qName == "date") { | 107 | } else if (qName == "date") { |
114 | m_state = Unknown; | 108 | m_state = Unknown; |
115 | } else if (qName == "data") { | 109 | } else if (qName == "data") { |
116 | m_state = Unknown; | 110 | m_state = Unknown; |
117 | } | 111 | } |
118 | 112 | ||
119 | return true; | 113 | return true; |
120 | } | 114 | } |
121 | 115 | ||
122 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) | 116 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) |
123 | { | 117 | { |
124 | if (m_state == InTitle) { | 118 | if (m_state == InTitle) { |
125 | m_title = ch; | 119 | m_title = ch; |
126 | } else if (m_state == InDate) { | 120 | } else if (m_state == InDate) { |
127 | m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt()); | 121 | m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt()); |
128 | } else if (m_state == InData) { | 122 | } else if (m_state == InData) { |
129 | QByteArray byteArray(ch.length() / 2); | 123 | QByteArray byteArray(ch.length() / 2); |
130 | 124 | ||
131 | for (int i = 0; i < (int)ch.length() / 2; i++) { | 125 | for (int i = 0; i < (int)ch.length() / 2; i++) { |
132 | char h = ch[2 * i].latin1(); | 126 | char h = ch[2 * i].latin1(); |
133 | char l = ch[2 * i + 1].latin1(); | 127 | char l = ch[2 * i + 1].latin1(); |
134 | uchar r = 0; | 128 | uchar r = 0; |
135 | 129 | ||
136 | if (h <= '9') { | 130 | if (h <= '9') { |
137 | r += h - '0'; | 131 | r += h - '0'; |
138 | } else { | 132 | } else { |
139 | r += h - 'a' + 10; | 133 | r += h - 'a' + 10; |
140 | } | 134 | } |
141 | 135 | ||
142 | r = r << 4; | 136 | r = r << 4; |
143 | 137 | ||
144 | if (l <= '9') { | 138 | if (l <= '9') { |
145 | r += l - '0'; | 139 | r += l - '0'; |
146 | } else { | 140 | } else { |
147 | r += l - 'a' + 10; | 141 | r += l - 'a' + 10; |
148 | } | 142 | } |
149 | 143 | ||
150 | byteArray[i] = r; | 144 | byteArray[i] = r; |
151 | } | 145 | } |
152 | 146 | ||
153 | |||
154 | QImage image; | 147 | QImage image; |
155 | 148 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); | |
156 | if (m_dataFormat == "XPM") { | ||
157 | if (m_dataLenght < ch.length() * 5) { | ||
158 | m_dataLenght = ch.length() * 5; | ||
159 | } | ||
160 | |||
161 | QByteArray byteArrayUnzipped(m_dataLenght); | ||
162 | ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); | ||
163 | |||
164 | image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat); | ||
165 | } else { | ||
166 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); | ||
167 | } | ||
168 | 149 | ||
169 | Page* page = new Page(m_title, image.width(), image.height()); | 150 | Page* page = new Page(m_title, image.width(), image.height()); |
170 | page->setLastModified(m_date); | 151 | page->setLastModified(m_date); |
171 | page->convertFromImage(image); | 152 | page->convertFromImage(image); |
172 | m_pages.append(page); | 153 | m_pages.append(page); |
173 | } | 154 | } |
174 | 155 | ||
175 | return true; | 156 | return true; |
176 | } | 157 | } |
177 | 158 | ||
178 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) | 159 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) |
179 | : QScrollView(parent, name) | 160 | : QScrollView(parent, name) |
180 | { | 161 | { |
181 | m_pDrawPad = drawPad; | 162 | m_pDrawPad = drawPad; |
182 | m_pages.setAutoDelete(true); | 163 | m_pages.setAutoDelete(true); |
183 | m_pageBackups.setAutoDelete(true); | 164 | m_pageBackups.setAutoDelete(true); |
184 | 165 | ||
185 | viewport()->setBackgroundMode(QWidget::NoBackground); | 166 | viewport()->setBackgroundMode(QWidget::NoBackground); |
186 | } | 167 | } |
187 | 168 | ||
188 | DrawPadCanvas::~DrawPadCanvas() | 169 | DrawPadCanvas::~DrawPadCanvas() |
189 | { | 170 | { |
190 | } | 171 | } |
191 | 172 | ||
192 | void DrawPadCanvas::load(QIODevice* ioDevice) | 173 | void DrawPadCanvas::load(QIODevice* ioDevice) |
193 | { | 174 | { |
194 | QTextStream textStream(ioDevice); | 175 | QTextStream textStream(ioDevice); |
195 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 176 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
196 | 177 | ||
197 | QXmlInputSource xmlInputSource(textStream); | 178 | QXmlInputSource xmlInputSource(textStream); |
198 | QXmlSimpleReader xmlSimpleReader; | 179 | QXmlSimpleReader xmlSimpleReader; |
199 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; | 180 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; |
200 | 181 | ||
201 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); | 182 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); |
202 | xmlSimpleReader.parse(xmlInputSource); | 183 | xmlSimpleReader.parse(xmlInputSource); |
203 | 184 | ||
204 | m_pages = drawPadCanvasXmlHandler.pages(); | 185 | m_pages = drawPadCanvasXmlHandler.pages(); |
205 | 186 | ||
206 | if (m_pages.isEmpty()) { | 187 | if (m_pages.isEmpty()) { |
207 | m_pages.append(new Page("", contentsRect().size())); | 188 | m_pages.append(new Page("", contentsRect().size())); |
208 | m_pages.current()->fill(Qt::white); | 189 | m_pages.current()->fill(Qt::white); |
209 | } | 190 | } |
210 | 191 | ||
211 | m_pageBackups.clear(); | 192 | m_pageBackups.clear(); |
212 | m_pageBackups.append(new Page(*(m_pages.current()))); | 193 | m_pageBackups.append(new Page(*(m_pages.current()))); |
213 | 194 | ||
214 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 195 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
215 | viewport()->update(); | 196 | viewport()->update(); |