summaryrefslogtreecommitdiff
authorzecke <zecke>2004-07-14 11:22:14 (UTC)
committer zecke <zecke>2004-07-14 11:22:14 (UTC)
commitca486a4558dc7aa23e3e5c677f6eedd26ed02746 (patch) (side-by-side diff)
tree56afc5086ffcd07a5f205017f1940b86e9747628
parentb09d76574ca6d2ebafca0640ea36c3b785e7f3a3 (diff)
downloadopie-ca486a4558dc7aa23e3e5c677f6eedd26ed02746.zip
opie-ca486a4558dc7aa23e3e5c677f6eedd26ed02746.tar.gz
opie-ca486a4558dc7aa23e3e5c677f6eedd26ed02746.tar.bz2
Problem: Opie-Drawpad loads its document delayed. This means a setDocument
like from the Screenshot Applet could be executed prior to the final initialisation of drawpad and the just added page vanishes. Solve: Take the fact into account and 1st) don't create an empty page if there is already a page which is the case with the setDocument call 2nd) if we load but already have pages we need to add the new pages
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 5d0c6e4..5b1aa7e 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -168,41 +168,64 @@ 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);
+ /*
+ * we could have loaded something from setDocument already
+ * due the delayed loading we need to make sure we do
+ * not lose pages
+ */
+ if ( !m_pages.isEmpty() ) {
+ QList<Page> pages = drawPadCanvasXmlHandler.pages();
+ QListIterator<Page> it( pages );
+ Page *p;
+ while ( ( p = it.current() ) ) {
+ ++it;
+ m_pages.append( p );
+ }
+ }else
m_pages = drawPadCanvasXmlHandler.pages();
+
+
if (m_pages.isEmpty()) {
m_pages.append(new Page("",
clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
m_pages.current()->pixmap()->fill(Qt::white);
}
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::initialPage()
{
+ /*
+ * by setDocument we've set a page already so
+ * don't add an empty one. This comes due the delayed initialisation
+ */
+ if (!m_pages.isEmpty() )
+ return;
+
m_pages.append(new Page("",
clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
//236, 232)); no more fixed sizes
m_pages.current()->pixmap()->fill(Qt::white);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}