Author: JirkaH Date: 2010-04-11 13:34:22 +0200 (Sun, 11 Apr 2010) New Revision: 2229 Modified: trunk/client/elvys-client/src/abstractmaintainer.cpp trunk/client/elvys-client/src/category.cpp trunk/client/elvys-client/src/category.h trunk/client/elvys-client/src/layoutmaintainer.cpp trunk/client/elvys-client/src/panel.cpp trunk/client/elvys-client/src/pdfviewer.cpp trunk/client/elvys-client/src/textdocument.cpp trunk/client/elvys-client/src/xmlabstractparser.cpp trunk/client/elvys-client/src/xmllayoutparser.cpp Log: layout changing fixed. Some @todos introduced. Modified: trunk/client/elvys-client/src/abstractmaintainer.cpp =================================================================== --- trunk/client/elvys-client/src/abstractmaintainer.cpp 2010-04-08 20:00:20 UTC (rev 2228) +++ trunk/client/elvys-client/src/abstractmaintainer.cpp 2010-04-11 11:34:22 UTC (rev 2229) @@ -36,7 +36,7 @@ connect(parser, SIGNAL(readCompleted()), this, SLOT(readSuccessful())); } -void AbstractMaintainer::readSuccessful() { +void AbstractMaintainer::readSuccessful() { emit maintananceFinished(); } Modified: trunk/client/elvys-client/src/category.cpp =================================================================== --- trunk/client/elvys-client/src/category.cpp 2010-04-08 20:00:20 UTC (rev 2228) +++ trunk/client/elvys-client/src/category.cpp 2010-04-11 11:34:22 UTC (rev 2229) @@ -13,10 +13,12 @@ QWidget::setObjectName(QString::number(_id)); setName(_name); + panelLayoutsToDestroy = 0; + layoutMaint = new LayoutMaintainer(this); layoutMaint->allowNewLayout(true); - dummyPanel = new Panel(0); + dummyPanel = new Panel(DUMMY_PANEL_ID); docParser = new XMLPanelDocParser(); connect(this, SIGNAL(docuMaintananceStarted()), this, SLOT(docMaintananceStarted())); connect(this, SIGNAL(docuMaintananceFinished()), this, SLOT(docMaintananceFinished())); @@ -127,6 +129,7 @@ } void Category::newLayout() { + //qDebug() << Q_FUNC_INFO << "disallowing new layout, why?" << objectName(); emit allowNewLayout(false); } @@ -159,6 +162,7 @@ */ void Category::addLayoutDocument(QString & id, QRectF & rect) { + qDebug() << Q_FUNC_INFO << "adding document" << id << rect << "to category" << objectName(); dummyPanel->newDummyDocument(id, rect); } @@ -177,8 +181,10 @@ */ void Category::panelLayoutDestroyed() { --panelLayoutsToDestroy; + + qDebug() << "some panel destroyed" << "panel to destroy:" << panelLayoutsToDestroy; if (panelLayoutsToDestroy == 0) { - //qDebug() << "all panels successfully destroyed"; + qDebug() << "all panels successfully destroyed"; emit allowNewLayout(true); } } @@ -189,6 +195,7 @@ */ Panel * Category::newPanel(int id) { + qDebug() << "newPanel" << "id"; if (!enabled) { return NULL; } @@ -214,7 +221,6 @@ } } - /** Deletes panel with id @a panelId. */ @@ -231,7 +237,7 @@ if (panel->hasZoomedDocument()) { panel->setToBeDeleted(true); panelsToDelete.insert(panelId, true); - QTimer::singleShot(AppConfig::getInstance()->getDocumentPeriod()*100, this, SLOT(deleteOldPanels())); + QTimer::singleShot(AppConfig::getInstance()->getDocumentPeriod()/3, this, SLOT(deleteOldPanels())); return; } else { removeTab(index); @@ -336,6 +342,15 @@ } +void Category::setLayoutIdRevision(int id, int revision) { + if (panelsToDelete.count() != 0) {// there are still some documents to delete. We don't want to set new layout id yet. + return; + } + layoutMaint->setIdRevision(id, revision); +} + + + /** Destroys layout of this category. After deleting all layouts and documents. */ @@ -343,15 +358,24 @@ Panel * panel; QList<Panel *> panels = findChildren<Panel *>(); - panelLayoutsToDestroy = panels.count(); + if (panelsToDelete.count() != 0) { + qDebug() << "Already destroying some panels, doing nothing (" << panelLayoutsToDestroy << ")"; + return; + } - //qDebug() << "Category" << objectName() << "destroying current layout" ; + panelLayoutsToDestroy = panels.count(); //+1 because of dummy document which is our child + qDebug() << "Category" << objectName() << "destroying current layout. Panels to destroy" << panelLayoutsToDestroy; + foreach(panel, panels) { - panel->destroyLayout(); + deletePanel(panel->id()); } - dummyPanel->destroyLayout(); + //we probably could use dummyPanel->destroyLayout() method, but it is disabled as whole (for a good reason. however this reason doesn't apply to dummyPanel) + //So do it in the BAD way :-) + delete dummyPanel; + dummyPanel = new Panel(DUMMY_PANEL_ID); + //dummyPanel->destroyLayout(); } /** Starts reading document config @a fileName at @charOffset position. It should be position where document related Modified: trunk/client/elvys-client/src/category.h =================================================================== --- trunk/client/elvys-client/src/category.h 2010-04-08 20:00:20 UTC (rev 2228) +++ trunk/client/elvys-client/src/category.h 2010-04-11 11:34:22 UTC (rev 2229) @@ -11,6 +11,7 @@ #include "panel.h" +#define DUMMY_PANEL_ID -2 #define SPARE_PANEL_ID -1 class Category : public QTabWidget { @@ -25,6 +26,7 @@ public slots: void panelLayoutDestroyed(); + void setLayoutIdRevision(int id, int revision); void newPanelDocuments(int panelId); void destroyLayout(); void newLayout(); Modified: trunk/client/elvys-client/src/layoutmaintainer.cpp =================================================================== --- trunk/client/elvys-client/src/layoutmaintainer.cpp 2010-04-08 20:00:20 UTC (rev 2228) +++ trunk/client/elvys-client/src/layoutmaintainer.cpp 2010-04-11 11:34:22 UTC (rev 2229) @@ -27,7 +27,7 @@ newLayoutAllowed = false; connect((XMLLayoutParser *)parser, SIGNAL(haveIdRevision(int, int)), this, SLOT(manageIdRevision(int, int))); - connect(this, SIGNAL(newIdRevision(int, int)), this, SLOT(setIdRevision(int, int))); + connect(this, SIGNAL(newIdRevision(int, int)), docuManager, SLOT(setLayoutIdRevision(int, int))); connect(this, SIGNAL(newId(int)), this, SLOT(setId(int))); connect(this, SIGNAL(newRevision(int)), this, SLOT(setRevision(int))); @@ -43,6 +43,8 @@ void LayoutMaintainer::allowNewLayout(bool allow) { + qDebug() << Q_FUNC_INFO << allow; + if (allow) { if ( newLayoutAllowed ) { //already allowed return; @@ -53,9 +55,10 @@ connect((XMLLayoutParser *)parser, SIGNAL(newDocument(QString &, QRectF &)), docuManager, SLOT(addLayoutDocument(QString &, QRectF &))); } else { - if ( ! newLayoutAllowed ) { // uz to mam zakazane + if ( ! newLayoutAllowed ) { // already disabled return; } + qDebug() << "layout maintainer disallowed" ; newLayoutAllowed = false; disconnect((XMLLayoutParser *)parser, SIGNAL(newDocument(QString &, QRectF &)), docuManager, SLOT(addLayoutDocument(QString &, QRectF &))); } Modified: trunk/client/elvys-client/src/panel.cpp =================================================================== --- trunk/client/elvys-client/src/panel.cpp 2010-04-08 20:00:20 UTC (rev 2228) +++ trunk/client/elvys-client/src/panel.cpp 2010-04-11 11:34:22 UTC (rev 2229) @@ -250,7 +250,15 @@ doc = new DummyDocument(this, id, rectF, rect); } +/** Destroys current layout - ie, it deletes all documents... + @todo this can cause several issues, as new documents in the panel are not going to be added automatically. Disabling this function now. + Thats why it is much more easier to just delete whole panel and create a new one... + + */ + void Panel::destroyLayout() { + + qWarning() << Q_FUNC_INFO << "This function is disabled. Try to delete the panel instead. See @todo in function description."; QList<Document *> documents = findChildren<Document *>(); QList<Document *>::iterator it = documents.begin(); Modified: trunk/client/elvys-client/src/pdfviewer.cpp =================================================================== --- trunk/client/elvys-client/src/pdfviewer.cpp 2010-04-08 20:00:20 UTC (rev 2228) +++ trunk/client/elvys-client/src/pdfviewer.cpp 2010-04-11 11:34:22 UTC (rev 2229) @@ -443,6 +443,7 @@ void PDFViewer::focusInEvent( QFocusEvent * event ) { Q_UNUSED(event); + qDebug() << "focus in, parent name:" << parent()->objectName(); if ( zoomed ) { //nechceme nastavovat ramecek return; } @@ -452,6 +453,7 @@ void PDFViewer::focusOutEvent( QFocusEvent * event ) { Q_UNUSED(event); + qDebug() << "focus out, parent name:" << parent()->objectName(); setBorderFocused(); if ( zoomed ) { setFocus(); Modified: trunk/client/elvys-client/src/textdocument.cpp =================================================================== --- trunk/client/elvys-client/src/textdocument.cpp 2010-04-08 20:00:20 UTC (rev 2228) +++ trunk/client/elvys-client/src/textdocument.cpp 2010-04-11 11:34:22 UTC (rev 2229) @@ -43,7 +43,10 @@ double ratio; double sizePercentPoint; + qDebug() << "managing font for document" << objectName(); realFont = QFont(font, baseSize); + qDebug() << "realFont size is " << realFont.pointSizeF(); + qDebug() << "current widget's font size is" << QWidget::font().pointSizeF(); QFontMetrics fontM(realFont); textHeight = fontM.height(); @@ -57,7 +60,12 @@ textHeight = fontM2.height(); textWidth = fontM2.width(text); + //style()->unpolish(this); + qDebug() << "new computed realFont size is " << realFont.pointSizeF(); QWidget::setFont(realFont); + qDebug() << "new current widget's font size before polish is" << QWidget::font().pointSizeF(); + //style()->polish(this); + qDebug() << "new current widget's font size is" << QWidget::font().pointSizeF(); update(); } Modified: trunk/client/elvys-client/src/xmlabstractparser.cpp =================================================================== --- trunk/client/elvys-client/src/xmlabstractparser.cpp 2010-04-08 20:00:20 UTC (rev 2228) +++ trunk/client/elvys-client/src/xmlabstractparser.cpp 2010-04-11 11:34:22 UTC (rev 2229) @@ -16,6 +16,7 @@ clear(); + if ( ok ) { emit readCompleted(); } else { @@ -58,9 +59,6 @@ retval = readXML(); - if ( stopped ) { - emit readCompleted(); - } if ( !stopped && error() ) { //qDebug() << "ERROR:" << errorString(); emit readFailed(); Modified: trunk/client/elvys-client/src/xmllayoutparser.cpp =================================================================== --- trunk/client/elvys-client/src/xmllayoutparser.cpp 2010-04-08 20:00:20 UTC (rev 2228) +++ trunk/client/elvys-client/src/xmllayoutparser.cpp 2010-04-11 11:34:22 UTC (rev 2229) @@ -85,11 +85,12 @@ } else if (name() == "doc") { readDocument(); } else { - //qDebug() << "XMLLayoutParser - NOT IMPLEMENTED??? " << name().toString().toLocal8Bit().constData(); + qDebug() << "XMLLayoutParser - NOT IMPLEMENTED??? " << name(); return false; } } } + qDebug() << "XMLLayoutParser - readLayout end()"; return true; } @@ -149,6 +150,7 @@ } } } + emit newDocument(id, rect); return true; }