summaryrefslogtreecommitdiff
authorleseb <leseb>2002-03-21 19:43:29 (UTC)
committer leseb <leseb>2002-03-21 19:43:29 (UTC)
commitfb34e5636c9bd56019f7f365ee75ab3da495e1f4 (patch) (unidiff)
tree4ff5c177d79beedc7de481f1a0a6d9090a15c3a0
parent17b43caf4ffafff3a91bd144722d408d1c0dfacd (diff)
downloadopie-fb34e5636c9bd56019f7f365ee75ab3da495e1f4.zip
opie-fb34e5636c9bd56019f7f365ee75ab3da495e1f4.tar.gz
opie-fb34e5636c9bd56019f7f365ee75ab3da495e1f4.tar.bz2
Fix initial page size
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 49a8cf0..40c27b5 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -120,129 +120,129 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch)
120 byteArray[i] = r; 120 byteArray[i] = r;
121 } 121 }
122 122
123 if (m_dataLenght < ch.length() * 5) { 123 if (m_dataLenght < ch.length() * 5) {
124 m_dataLenght = ch.length() * 5; 124 m_dataLenght = ch.length() * 5;
125 } 125 }
126 126
127 QByteArray byteArrayUnzipped(m_dataLenght); 127 QByteArray byteArrayUnzipped(m_dataLenght);
128 ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); 128 ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size());
129 129
130 QImage image; 130 QImage image;
131 image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, "XPM"); 131 image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, "XPM");
132 132
133 QPixmap* pixmap = new QPixmap(image.width(), image.height()); 133 QPixmap* pixmap = new QPixmap(image.width(), image.height());
134 pixmap->convertFromImage(image); 134 pixmap->convertFromImage(image);
135 m_pixmaps.append(pixmap); 135 m_pixmaps.append(pixmap);
136 } 136 }
137 137
138 return true; 138 return true;
139} 139}
140 140
141DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) 141DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name)
142 : QScrollView(parent, name) 142 : QScrollView(parent, name)
143{ 143{
144 m_pDrawPad = drawPad; 144 m_pDrawPad = drawPad;
145 m_pages.setAutoDelete(true); 145 m_pages.setAutoDelete(true);
146 m_pageBackups.setAutoDelete(true); 146 m_pageBackups.setAutoDelete(true);
147} 147}
148 148
149DrawPadCanvas::~DrawPadCanvas() 149DrawPadCanvas::~DrawPadCanvas()
150{ 150{
151} 151}
152 152
153void DrawPadCanvas::load(QIODevice* ioDevice) 153void DrawPadCanvas::load(QIODevice* ioDevice)
154{ 154{
155 QTextStream textStream(ioDevice); 155 QTextStream textStream(ioDevice);
156 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 156 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
157 157
158 QXmlInputSource xmlInputSource(textStream); 158 QXmlInputSource xmlInputSource(textStream);
159 QXmlSimpleReader xmlSimpleReader; 159 QXmlSimpleReader xmlSimpleReader;
160 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; 160 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler;
161 161
162 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); 162 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
163 xmlSimpleReader.parse(xmlInputSource); 163 xmlSimpleReader.parse(xmlInputSource);
164 164
165 m_pages = drawPadCanvasXmlHandler.pixmaps(); 165 m_pages = drawPadCanvasXmlHandler.pixmaps();
166 166
167 if (m_pages.isEmpty()) { 167 if (m_pages.isEmpty()) {
168 m_pages.append(new QPixmap(contentsRect().size())); 168 m_pages.append(new QPixmap(contentsRect().size()));
169 m_pages.current()->fill(Qt::white); 169 m_pages.current()->fill(Qt::white);
170 } 170 }
171 171
172 m_pageBackups.clear(); 172 m_pageBackups.clear();
173 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 173 m_pageBackups.append(new QPixmap(*(m_pages.current())));
174 174
175 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 175 resizeContents(m_pages.current()->width(), m_pages.current()->height());
176 viewport()->update(); 176 viewport()->update();
177 177
178 emit pagesChanged(); 178 emit pagesChanged();
179 emit pageBackupsChanged(); 179 emit pageBackupsChanged();
180} 180}
181 181
182void DrawPadCanvas::initialPage() 182void DrawPadCanvas::initialPage()
183{ 183{
184 m_pages.append(new QPixmap(234, 252)); 184 m_pages.append(new QPixmap(234, 233));
185 m_pages.current()->fill(Qt::white); 185 m_pages.current()->fill(Qt::white);
186 186
187 m_pageBackups.clear(); 187 m_pageBackups.clear();
188 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 188 m_pageBackups.append(new QPixmap(*(m_pages.current())));
189 189
190 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 190 resizeContents(m_pages.current()->width(), m_pages.current()->height());
191 viewport()->update(); 191 viewport()->update();
192 192
193 emit pagesChanged(); 193 emit pagesChanged();
194 emit pageBackupsChanged(); 194 emit pageBackupsChanged();
195} 195}
196 196
197void DrawPadCanvas::save(QIODevice* ioDevice) 197void DrawPadCanvas::save(QIODevice* ioDevice)
198{ 198{
199 QTextStream textStream(ioDevice); 199 QTextStream textStream(ioDevice);
200 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 200 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
201 201
202 textStream << "<drawpad>" << endl; 202 textStream << "<drawpad>" << endl;
203 textStream << " <images>" << endl; 203 textStream << " <images>" << endl;
204 204
205 QListIterator<QPixmap> bufferIterator(m_pages); 205 QListIterator<QPixmap> bufferIterator(m_pages);
206 206
207 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { 207 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
208 textStream << " <image>" << endl; 208 textStream << " <image>" << endl;
209 209
210 QImage image = bufferIterator.current()->convertToImage(); 210 QImage image = bufferIterator.current()->convertToImage();
211 QByteArray byteArray; 211 QByteArray byteArray;
212 QBuffer buffer(byteArray); 212 QBuffer buffer(byteArray);
213 QImageIO imageIO(&buffer, "XPM"); 213 QImageIO imageIO(&buffer, "XPM");
214 214
215 buffer.open(IO_WriteOnly); 215 buffer.open(IO_WriteOnly);
216 imageIO.setImage(image); 216 imageIO.setImage(image);
217 imageIO.write(); 217 imageIO.write();
218 buffer.close(); 218 buffer.close();
219 219
220 ulong size = byteArray.size() * 2; 220 ulong size = byteArray.size() * 2;
221 QByteArray byteArrayZipped(size); 221 QByteArray byteArrayZipped(size);
222 ::compress((uchar*)byteArrayZipped.data(), &size, (uchar*)byteArray.data(), byteArray.size()); 222 ::compress((uchar*)byteArrayZipped.data(), &size, (uchar*)byteArray.data(), byteArray.size());
223 223
224 textStream << " <data length=\"" << byteArray.size() << "\">"; 224 textStream << " <data length=\"" << byteArray.size() << "\">";
225 225
226 static const char hexchars[] = "0123456789abcdef"; 226 static const char hexchars[] = "0123456789abcdef";
227 227
228 for (int i = 0; i < (int)size; i++ ) { 228 for (int i = 0; i < (int)size; i++ ) {
229 uchar s = (uchar)byteArrayZipped[i]; 229 uchar s = (uchar)byteArrayZipped[i];
230 textStream << hexchars[s >> 4]; 230 textStream << hexchars[s >> 4];
231 textStream << hexchars[s & 0x0f]; 231 textStream << hexchars[s & 0x0f];
232 } 232 }
233 233
234 textStream << "</data>" << endl; 234 textStream << "</data>" << endl;
235 textStream << " </image>" << endl; 235 textStream << " </image>" << endl;
236 } 236 }
237 237
238 textStream << " </images>" << endl; 238 textStream << " </images>" << endl;
239 textStream << "</drawpad>"; 239 textStream << "</drawpad>";
240} 240}
241 241
242QPixmap* DrawPadCanvas::currentPage() 242QPixmap* DrawPadCanvas::currentPage()
243{ 243{
244 return m_pages.current(); 244 return m_pages.current();
245} 245}
246 246
247uint DrawPadCanvas::pagePosition() 247uint DrawPadCanvas::pagePosition()
248{ 248{