Author: JirkaH Date: 2010-02-14 23:16:40 +0100 (Sun, 14 Feb 2010) New Revision: 1724 Modified: branches/client/pdf-presentation-branch/elvys-client/Makefile branches/client/pdf-presentation-branch/elvys-client/bin/appconfig.xml branches/client/pdf-presentation-branch/elvys-client/elvys-client.pro.user branches/client/pdf-presentation-branch/elvys-client/src/Makefile branches/client/pdf-presentation-branch/elvys-client/src/appconfigdata.cpp branches/client/pdf-presentation-branch/elvys-client/src/main.cpp branches/client/pdf-presentation-branch/elvys-client/src/pageselector.h branches/client/pdf-presentation-branch/elvys-client/src/pdfdocument.cpp branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.cpp branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.h branches/client/pdf-presentation-branch/elvys-client/src/pdfpage.cpp branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.cpp branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.cpp branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.h branches/client/pdf-presentation-branch/elvys-client/src/pdfviewer.cpp branches/client/pdf-presentation-branch/elvys-client/src/pdfviewer.h branches/client/pdf-presentation-branch/elvys-client/src/videodocument.cpp Log: a lot of changes - should be more stable (but there are still problems) Modified: branches/client/pdf-presentation-branch/elvys-client/Makefile =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/Makefile 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/Makefile 2010-02-14 22:16:40 UTC (rev 1724) @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: elvys-client -# Generated by qmake (2.01a) (Qt 4.5.3) on: Wed Feb 10 23:04:57 2010 +# Generated by qmake (2.01a) (Qt 4.5.3) on: Sun Feb 14 20:14:17 2010 # Project: elvys-client.pro # Template: subdirs # Command: /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug_and_release -o Makefile elvys-client.pro Modified: branches/client/pdf-presentation-branch/elvys-client/bin/appconfig.xml =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/bin/appconfig.xml 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/bin/appconfig.xml 2010-02-14 22:16:40 UTC (rev 1724) @@ -2,30 +2,30 @@ <a:app_config elvysVersion="1.0-b1" xmlns:a="cz/elvys/jaxbgen/app"> <a:machine_id>13</a:machine_id> <a:data_url> - <a:http_address>http://elvys.farm.particle.cz/dataIntegrationNew/4</a:http_address> + <a:http_address>http://elvys.farm.particle.xx/dataIntegrationNew/4</a:http_address> </a:data_url> <a:statistics> - <a:http_address>http://elvys.farm.particle.cz:8081/dispatcher/statistic</a:http_address> - <a:period>60000</a:period> + <a:http_address>http://elvys.farm.particle.xx:8081/dispatcher/statistic</a:http_address> + <a:period>100000</a:period> </a:statistics> <a:screenshot> - <a:http_address>http://elvys.farm.particle.cz:8081/dispatcher/img</a:http_address> - <a:period>60000</a:period> + <a:http_address>http://elvys.farm.particle.xx:8081/dispatcher/img</a:http_address> + <a:period>100000</a:period> </a:screenshot> <a:category_config> - <a:http_address>http://elvys.farm.particle.cz:8081/dispatcher/categoryConfig</a:http_address> - <a:period>20000</a:period> + <a:http_address>http://elvys.farm.particle.xx:8081/dispatcher/categoryConfig</a:http_address> + <a:period>100000</a:period> </a:category_config> <a:document_config> - <a:http_address>http://elvys.farm.particle.cz:8081/dispatcher/documentConfig</a:http_address> - <a:period>20000</a:period> + <a:http_address>http://elvys.farm.particle.xx:8081/dispatcher/documentConfig</a:http_address> + <a:period>100000</a:period> </a:document_config> <a:filecache_config> - <a:http_address>http://elvys.farm.particle.cz:8081/dispatcher/filecacheConfig</a:http_address> - <a:period>10000</a:period> + <a:http_address>http://elvys.farm.particle.xx:8081/dispatcher/filecacheConfig</a:http_address> + <a:period>100000</a:period> </a:filecache_config> <a:night_mode enabled="false"/> <a:app_config_source> - <a:http_address>http://elvys.farm.particle.cz:8081/dispatcher/appConfig</a:http_address> + <a:http_address>http://elvys.farm.particle.xx:8081/dispatcher/appConfig</a:http_address> </a:app_config_source> </a:app_config> Modified: branches/client/pdf-presentation-branch/elvys-client/elvys-client.pro.user =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/elvys-client.pro.user 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/elvys-client.pro.user 2010-02-14 22:16:40 UTC (rev 1724) @@ -6,7 +6,7 @@ </data> <data> <variable>RunConfiguration0-Executable</variable> - <value type="QString" >/home/keruom/elvys/trunk/client/elvys-client/bin/elvys-client</value> + <value type="QString" >/home/keruom/elvys/branches/client/pdf-presentation-branch/elvys-client/bin/elvys-client</value> </data> <data> <variable>RunConfiguration0-RunConfiguration.name</variable> @@ -30,7 +30,7 @@ </data> <data> <variable>RunConfiguration0-WorkingDirectory</variable> - <value type="QString" >/home/keruom/elvys/trunk/client/elvys-client/bin</value> + <value type="QString" >/home/keruom/elvys/branches/client/pdf-presentation-branch/elvys-client/bin</value> </data> <data> <variable>RunConfiguration0-type</variable> @@ -52,7 +52,7 @@ <value key="ToolChain" type="int" >0</value> <value key="addQDumper" type="" ></value> <value key="buildConfiguration" type="int" >2</value> - <value key="buildDirectory" type="QString" >/home/keruom/elvys/trunk/client/elvys-client</value> + <value key="buildDirectory" type="QString" >/home/keruom/elvys/branches/client/pdf-presentation-branch/elvys-client</value> </valuemap> </data> <data> @@ -88,7 +88,7 @@ <value type="QString" >CONFIG_PROTECT=/usr/share/X11/xkb /var/lib/hsqldb /usr/share/config</value> <value type="QString" >CONFIG_PROTECT_MASK=/etc/sandbox.d /etc/env.d/java/ /etc/php/cli-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/apache2-php5/ext-active/ /etc/udev/rules.d /etc/fonts/fonts.conf /etc/gconf /etc/terminfo /etc/ca-certificates.conf /etc/texmf/web2c /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/revdep-rebuild</value> <value type="QString" >CVS_RSH=ssh</value> - <value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-R2PIKvvtlK,guid=115ae8503f718c05610a77224b71a116</value> + <value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-A0hB8LLrnq,guid=2030e7ed54f71619069908f64b74ffdf</value> <value type="QString" >DESKTOP_SESSION=KDE-4</value> <value type="QString" >DESKTOP_STARTUP_ID=</value> <value type="QString" >DISPLAY=:0.0</value> @@ -127,7 +127,7 @@ <value type="QString" >QT_PLUGIN_PATH=/home/keruom/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/</value> <value type="QString" >RUBYOPT=-rauto_gem</value> <value type="QString" >R_HOME=/usr/lib/R</value> - <value type="QString" >SESSION_MANAGER=local/LenR61:@/tmp/.ICE-unix/7052,unix/LenR61:/tmp/.ICE-unix/7052</value> + <value type="QString" >SESSION_MANAGER=local/LenR61:@/tmp/.ICE-unix/6926,unix/LenR61:/tmp/.ICE-unix/6926</value> <value type="QString" >SGML_CATALOG_FILES=/etc/sgml/sgml-lite.cat:/etc/sgml/openjade-1.3.2.cat:/etc/sgml/dsssl-docbook-stylesheets.cat:/etc/sgml/sgml-docbook.cat:/etc/sgml/sgml-docbook-3.1.cat:/etc/sgml/sgml-ent.cat</value> <value type="QString" >SHELL=/bin/bash</value> <value type="QString" >SHLVL=1</value> @@ -138,12 +138,12 @@ <value type="QString" >XCURSOR_THEME=Oxygen_Black</value> <value type="QString" >XDG_CONFIG_DIRS=/etc/xdg</value> <value type="QString" >XDG_DATA_DIRS=/usr/share:/usr/local/share:/usr/share</value> - <value type="QString" >XDG_SESSION_COOKIE=d9adc4154425c11fe992e29e4870ae75-1265738005.664191-1899895014</value> + <value type="QString" >XDG_SESSION_COOKIE=d9adc4154425c11fe992e29e4870ae75-1265958879.158627-1510381767</value> <value type="QString" >XDM_MANAGED=method=classic</value> <value type="QString" >_=/usr/bin/kdeinit4</value> </valuelist> <valuelist key="abstractProcess.arguments" type="QVariantList" > - <value type="QString" >/home/keruom/elvys/trunk/client/elvys-client/elvys-client.pro</value> + <value type="QString" >/home/keruom/elvys/branches/client/pdf-presentation-branch/elvys-client/elvys-client.pro</value> <value type="QString" >-spec</value> <value type="QString" >/usr/share/qt4/mkspecs/linux-g++</value> <value type="QString" >-r</value> @@ -151,7 +151,7 @@ </valuelist> <value key="abstractProcess.command" type="QString" >/usr/bin/qmake</value> <value key="abstractProcess.enabled" type="bool" >false</value> - <value key="abstractProcess.workingDirectory" type="QString" >/home/keruom/elvys/trunk/client/elvys-client</value> + <value key="abstractProcess.workingDirectory" type="QString" >/home/keruom/elvys/branches/client/pdf-presentation-branch/elvys-client</value> <value key="buildConfiguration" type="" ></value> </valuemap> </data> @@ -165,7 +165,7 @@ <value type="QString" >CONFIG_PROTECT=/usr/share/X11/xkb /var/lib/hsqldb /usr/share/config</value> <value type="QString" >CONFIG_PROTECT_MASK=/etc/sandbox.d /etc/env.d/java/ /etc/php/cli-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/apache2-php5/ext-active/ /etc/udev/rules.d /etc/fonts/fonts.conf /etc/gconf /etc/terminfo /etc/ca-certificates.conf /etc/texmf/web2c /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/revdep-rebuild</value> <value type="QString" >CVS_RSH=ssh</value> - <value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-R2PIKvvtlK,guid=115ae8503f718c05610a77224b71a116</value> + <value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-A0hB8LLrnq,guid=2030e7ed54f71619069908f64b74ffdf</value> <value type="QString" >DESKTOP_SESSION=KDE-4</value> <value type="QString" >DESKTOP_STARTUP_ID=</value> <value type="QString" >DISPLAY=:0.0</value> @@ -204,7 +204,7 @@ <value type="QString" >QT_PLUGIN_PATH=/home/keruom/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/</value> <value type="QString" >RUBYOPT=-rauto_gem</value> <value type="QString" >R_HOME=/usr/lib/R</value> - <value type="QString" >SESSION_MANAGER=local/LenR61:@/tmp/.ICE-unix/7052,unix/LenR61:/tmp/.ICE-unix/7052</value> + <value type="QString" >SESSION_MANAGER=local/LenR61:@/tmp/.ICE-unix/6926,unix/LenR61:/tmp/.ICE-unix/6926</value> <value type="QString" >SGML_CATALOG_FILES=/etc/sgml/sgml-lite.cat:/etc/sgml/openjade-1.3.2.cat:/etc/sgml/dsssl-docbook-stylesheets.cat:/etc/sgml/sgml-docbook.cat:/etc/sgml/sgml-docbook-3.1.cat:/etc/sgml/sgml-ent.cat</value> <value type="QString" >SHELL=/bin/bash</value> <value type="QString" >SHLVL=1</value> @@ -215,7 +215,7 @@ <value type="QString" >XCURSOR_THEME=Oxygen_Black</value> <value type="QString" >XDG_CONFIG_DIRS=/etc/xdg</value> <value type="QString" >XDG_DATA_DIRS=/usr/share:/usr/local/share:/usr/share</value> - <value type="QString" >XDG_SESSION_COOKIE=d9adc4154425c11fe992e29e4870ae75-1265738005.664191-1899895014</value> + <value type="QString" >XDG_SESSION_COOKIE=d9adc4154425c11fe992e29e4870ae75-1265958879.158627-1510381767</value> <value type="QString" >XDM_MANAGED=method=classic</value> <value type="QString" >_=/usr/bin/kdeinit4</value> </valuelist> @@ -225,7 +225,7 @@ </valuelist> <value key="abstractProcess.command" type="QString" >/usr/bin/make</value> <value key="abstractProcess.enabled" type="bool" >true</value> - <value key="abstractProcess.workingDirectory" type="QString" >/home/keruom/elvys/trunk/client/elvys-client</value> + <value key="abstractProcess.workingDirectory" type="QString" >/home/keruom/elvys/branches/client/pdf-presentation-branch/elvys-client</value> </valuemap> </data> <data> @@ -238,8 +238,9 @@ <value type="QString" >CONFIG_PROTECT=/usr/share/X11/xkb /var/lib/hsqldb /usr/share/config</value> <value type="QString" >CONFIG_PROTECT_MASK=/etc/sandbox.d /etc/env.d/java/ /etc/php/cli-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/apache2-php5/ext-active/ /etc/udev/rules.d /etc/fonts/fonts.conf /etc/gconf /etc/terminfo /etc/ca-certificates.conf /etc/texmf/web2c /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/revdep-rebuild</value> <value type="QString" >CVS_RSH=ssh</value> - <value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-1SoPYY2czp,guid=26aa2cfe5b5382bf987831eb4b56bb12</value> + <value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-A0hB8LLrnq,guid=2030e7ed54f71619069908f64b74ffdf</value> <value type="QString" >DESKTOP_SESSION=KDE-4</value> + <value type="QString" >DESKTOP_STARTUP_ID=</value> <value type="QString" >DISPLAY=:0.0</value> <value type="QString" >DM_CONTROL=/var/run/xdmctl</value> <value type="QString" >EDITOR=/usr/bin/vim</value> @@ -273,11 +274,11 @@ <value type="QString" >PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.3.4:/usr/qt/3/bin:/usr/libexec/gpc/i686-pc-linux-gnu/3.4:/usr/games/bin</value> <value type="QString" >PWD=/home/keruom</value> <value type="QString" >QMAKESPEC=linux-g++</value> - <value type="QString" >QTDIR=/usr/share/qt4</value> + <value type="QString" >QTDIR=/usr</value> <value type="QString" >QT_PLUGIN_PATH=/home/keruom/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/</value> <value type="QString" >RUBYOPT=-rauto_gem</value> <value type="QString" >R_HOME=/usr/lib/R</value> - <value type="QString" >SESSION_MANAGER=local/LenR61:@/tmp/.ICE-unix/6151,unix/LenR61:/tmp/.ICE-unix/6151</value> + <value type="QString" >SESSION_MANAGER=local/LenR61:@/tmp/.ICE-unix/6926,unix/LenR61:/tmp/.ICE-unix/6926</value> <value type="QString" >SGML_CATALOG_FILES=/etc/sgml/sgml-lite.cat:/etc/sgml/openjade-1.3.2.cat:/etc/sgml/dsssl-docbook-stylesheets.cat:/etc/sgml/sgml-docbook.cat:/etc/sgml/sgml-docbook-3.1.cat:/etc/sgml/sgml-ent.cat</value> <value type="QString" >SHELL=/bin/bash</value> <value type="QString" >SHLVL=1</value> @@ -288,7 +289,7 @@ <value type="QString" >XCURSOR_THEME=Oxygen_Black</value> <value type="QString" >XDG_CONFIG_DIRS=/etc/xdg</value> <value type="QString" >XDG_DATA_DIRS=/usr/share:/usr/local/share:/usr/share</value> - <value type="QString" >XDG_SESSION_COOKIE=d9adc4154425c11fe992e29e4870ae75-1263975186.463903-863096380</value> + <value type="QString" >XDG_SESSION_COOKIE=d9adc4154425c11fe992e29e4870ae75-1265958879.158627-1510381767</value> <value type="QString" >XDM_MANAGED=method=classic</value> <value type="QString" >_=/usr/bin/kdeinit4</value> </valuelist> @@ -299,7 +300,7 @@ </valuelist> <value key="abstractProcess.command" type="QString" >/usr/bin/make</value> <value key="abstractProcess.enabled" type="bool" >true</value> - <value key="abstractProcess.workingDirectory" type="QString" >/home/keruom/elvys/trunk/client/elvys-client</value> + <value key="abstractProcess.workingDirectory" type="QString" >/home/keruom/elvys/branches/client/pdf-presentation-branch/elvys-client</value> <value key="cleanConfig" type="bool" >true</value> <valuelist key="makeargs" type="QVariantList" > <value type="QString" >clean</value> Modified: branches/client/pdf-presentation-branch/elvys-client/src/Makefile =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/Makefile 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/Makefile 2010-02-14 22:16:40 UTC (rev 1724) @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: ../bin/elvys-client -# Generated by qmake (2.01a) (Qt 4.5.3) on: Sat Feb 13 22:02:48 2010 +# Generated by qmake (2.01a) (Qt 4.5.3) on: Sun Feb 14 20:14:17 2010 # Project: src.pro # Template: app # Command: /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug_and_release -o Makefile src.pro Modified: branches/client/pdf-presentation-branch/elvys-client/src/appconfigdata.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/appconfigdata.cpp 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/appconfigdata.cpp 2010-02-14 22:16:40 UTC (rev 1724) @@ -35,6 +35,7 @@ palFocused.setColor( QPalette::Light, QColor( 0, 120, 255 ) ); //vnejsi vpravo palFocused.setColor( QPalette::Dark, QColor( 0, 200, 255 ) ); //vnitrni vpravo palFocused.setColor( QPalette::Mid, QColor( 0, 80, 255 ) ); //uprostred + palFocused.setColor( QPalette::WindowText, QColor(0, 120, 255)); } Modified: branches/client/pdf-presentation-branch/elvys-client/src/main.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/main.cpp 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/main.cpp 2010-02-14 22:16:40 UTC (rev 1724) @@ -42,7 +42,7 @@ break; } - line2 = "["+ QTime::currentTime().toString("hh:mm:ss") +"] "+ line2; + line2 = "["+ QTime::currentTime().toString("hh:mm:ss.zzz") +"] "+ line2; std::cout << line2.toLocal8Bit().data() << std::endl; } @@ -76,8 +76,9 @@ // Saver * saver = new Saver(); // saver->setWidget(&elvys); - elvys.showFullScreen(); -// elvys.show(); +// elvys.showFullScreen(); + elvys.setGeometry(0,0,400,300); + elvys.show(); return app.exec(); // QObject::connect(&timer, SIGNAL(timeout()), saver, SLOT(render())); Modified: branches/client/pdf-presentation-branch/elvys-client/src/pageselector.h =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pageselector.h 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pageselector.h 2010-02-14 22:16:40 UTC (rev 1724) @@ -9,6 +9,27 @@ inline bool operator== ( PageSelector & other ) const { return ( other.pageNum == pageNum && other.desSize == desSize && other.desc == desc); } + inline bool operator< (const PageSelector & other ) const { + if ( pageNum == other.pageNum ) { + if ( desSize == other.desSize ) { + if (desc == other.desc) { + return false; + } else { + return desc < other.desc; + } + } else { + //QSize doesnt support operator <, so we will "define" one + if (desSize.width() == other.desSize.width()) { + // height cannot be equal, see comparison above + return desSize.height() < other.desSize.height(); + } else { + return desSize.width() < other.desSize.width(); + } + } + } else { + return pageNum < other.pageNum; + } + } int pageNum; QSize desSize; //desired size Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdfdocument.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pdfdocument.cpp 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pdfdocument.cpp 2010-02-14 22:16:40 UTC (rev 1724) @@ -54,9 +54,9 @@ connect(pdfFiller, SIGNAL(badPDF(QString )), this, SLOT(handleBadPDF(QString ))); + connect(pdfViewer, SIGNAL(imageGenerated(PageSelector)), pdfFiller, SLOT(cachePage(PageSelector))); //mtx oriented connects - connect(pdfFiller, SIGNAL(imageGenerationStarted()), this, SLOT(mutexLock())); - connect(pdfFiller, SIGNAL(imageGenerationFinished()), this, SLOT(mutexUnlock())); + connect(pdfFiller, SIGNAL(pagesAboutToDelete()), this, SLOT(mutexLock())); connect(pdfFiller, SIGNAL(pagesDeleted()), this, SLOT(mutexUnlock())); connect(pdfViewer, SIGNAL(imageGenerationStarted()), this, SLOT(mutexLock())); Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.cpp 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.cpp 2010-02-14 22:16:40 UTC (rev 1724) @@ -121,7 +121,10 @@ */ void PDFFiller::clearCache() { + mutexCond.lock(); + qDebug() << "cache size" << cache.keys().size(); cache.clear(); + mutexCond.unlock(); } /** @@ -181,6 +184,22 @@ return true; } + +void PDFFiller::cachePage(PageSelector selector) { + PDFPage * page; + + mutexCond.lock(); + if ( pagesNotCached.contains(selector)) { + page = pagesNotCached.take(selector); + page->height(); + cache.insert(selector, page, page->getImage()->numBytes() / 1024); + mutexCond.unlock(); + } else { + mutexCond.unlock(); + } +} + + /** * Main function of worker thread. This function is called automatically after calling start(). * It makes initialization and waits for commands to load pages. @@ -281,13 +300,18 @@ qDebug() << "Rendering PAGE no." << toLoad << "at size" <<selector.desSize << "from " << filename; - if ( ( page = cache[selector] ) == 0 ) { // still dont have this page loaded + if ( ( page = cache[selector] ) == 0 && ! pagesNotCached.contains(selector)) { // still dont have this page loaded qDebug() << "neni, nacitam " << toLoad ; pageSt = zoom(selector.desSize.width(), selector.desSize.height(), Page, toLoadReal); - page = new PDFPage(pageSt.qImg, pageSt.docW, pageSt.docH); - cache.insert(selector, page, page->getImage()->numBytes() / 1024); - emit pageLoaded(selector, page); + if ( pageSt.qImg != NULL ) { //loading was sucessfull + page = new PDFPage(pageSt.qImg, pageSt.docW, pageSt.docH); + pagesNotCached.insert(selector, page); + emit pageLoaded(selector, page); + } } else { + if (page == 0) { // the page is in pagesNotCached hashMap: + page = pagesNotCached[selector]; + } qDebug() << "je." ; emit pageLoaded(selector, page); } @@ -369,9 +393,10 @@ PageStruct PDFFiller::zoom(int w, int h, PDFRender which, int page) { PageStruct pageSt; - char * pdfImg; - double docW72, docH72; - int limit; + char * pdfImg = NULL; + PDFImageHeader hdr; + double docW72, docH72; + int retval; double dpi = 0; mutexPDF.lock(); @@ -382,20 +407,19 @@ normalizeDimensions(docW72, docH72, w, h, pageSt.docW, pageSt.docH, dpi); if ( which == First ) { - limit = 1; docNormalW = pageSt.docW; docNormalH = pageSt.docH; - } else if ( which == FirstBig ) { - limit = 1; - } else if (which == Page) { - limit = 1; } - pdfConvertPageToBitmap2(pdf, page, dpi, pdfImageRGB, 0, 4, 0, &hdr, &pdfImg); + if ( (retval = pdfConvertPageToBitmap2(pdf, page, dpi, pdfImageRGB, 0, 4, 0, &hdr, &pdfImg)) != pdfOk) { + qWarning() << "Error converting page to bitmap!!!!!! Returned value:" << retval; + pageSt.docH = 0; + pageSt.docW = 0; + pageSt.qImg = NULL; + } + pageSt.qImg =(uchar *) pdfImg; - mutexPDF.unlock(); -// qImg = convertToQRGB(pdfImg, docW, docH, bpl, QImage::Format_RGB32); // nastavi mi qImg -// pdfFreeMemory(pdfImg); + mutexPDF.unlock(); return pageSt; } Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.h =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.h 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.h 2010-02-14 22:16:40 UTC (rev 1724) @@ -6,6 +6,7 @@ #include <QImage> #include <QCache> #include <QHash> +#include <QMap> #include <QList> #include <QWaitCondition> #include "document.h" @@ -46,10 +47,8 @@ void zoomedSizeFirstPage(int width, int height); void zoomedSizeRect(int width, int height); void sizeRect(int maxWidth, int maxHeight); - void pageDimension(int page, int docW, int docH); - void init(); - void imageGenerationStarted(); - void imageGenerationFinished(); + void pageDimension(int page, int docW, int docH); + void init(); void pagesAboutToDelete(); void pagesDeleted(); void badPDF(QString filename); @@ -57,6 +56,7 @@ public slots: void loadPage(int pageNum, QSize size, QString desc); + void cachePage(PageSelector selector); public: @@ -103,8 +103,7 @@ // pdf-specific promenne: - PDFHandle pdf; - PDFImageHeader hdr; + PDFHandle pdf; int docNormalW; int docNormalH; @@ -112,6 +111,7 @@ PDFPage * pageNormal; QCache<PageSelector, PDFPage> cache; + QMap<PageSelector, PDFPage *> pagesNotCached; }; #endif Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdfpage.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pdfpage.cpp 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pdfpage.cpp 2010-02-14 22:16:40 UTC (rev 1724) @@ -40,7 +40,7 @@ */ PDFPage::~PDFPage() { - qDebug() << "DELETING PAGE" ; + qDebug() << "DELETING PAGE"; delete image; pdfFreeMemory(qImg); } Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.cpp 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.cpp 2010-02-14 22:16:40 UTC (rev 1724) @@ -25,9 +25,10 @@ connect(pdfFiller, SIGNAL(badPDF(QString )), this, SLOT(handleBadPDF(QString ))); - //mtx oriented connects - connect(pdfFiller, SIGNAL(imageGenerationStarted()), this, SLOT(mutexLock())); - connect(pdfFiller, SIGNAL(imageGenerationFinished()), this, SLOT(mutexUnlock())); + connect(pdfPresViewer, SIGNAL(imageGenerated(PageSelector)), pdfFiller, SLOT(cachePage(PageSelector))); + + + //mtx oriented connects connect(pdfFiller, SIGNAL(pagesAboutToDelete()), this, SLOT(mutexLock())); connect(pdfFiller, SIGNAL(pagesDeleted()), this, SLOT(mutexUnlock())); connect(pdfPresViewer, SIGNAL(imageGenerationStarted()), this, SLOT(mutexLock())); @@ -106,7 +107,7 @@ void PDFPresentationDocument::mutexLock() { if (imgMtx.tryLock() == false) { - qWarning() << Q_FUNC_INFO << "...........................................POTENTIONAL DEAD LOCK PREVENTED!!!!......................................."; + qWarning() << Q_FUNC_INFO << "........................................................POTENTIONAL DEAD LOCK PREVENTED!!!!............................................................"; imgMtx.lock(); } } @@ -171,10 +172,9 @@ pdfPresViewer->setGeometry(geometry()); } -void PDFPresentationDocument::hideEvent(QHideEvent * event) { - Q_UNUSED(event); - - pdfFiller->clearCache(); +void PDFPresentationDocument::hideEvent(QHideEvent * event) { + pdfPresViewer->setAutoRotating(false); + pdfFiller->clearCache(); } void PDFPresentationDocument::zoomEventHandler() { Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.cpp 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.cpp 2010-02-14 22:16:40 UTC (rev 1724) @@ -22,6 +22,7 @@ PDFPresentationViewer::PDFPresentationViewer(QWidget * parent, const QRect & rect) : QLabel (parent) { + closed = false; origSize = rect; currentPage = 0; _period = 10; @@ -60,6 +61,7 @@ } PDFPresentationViewer::~PDFPresentationViewer() { + closed = true; if (nextTimer.isActive()) { nextTimer.stop(); } @@ -218,30 +220,46 @@ void PDFPresentationViewer::pageReady(PageSelector selector, PDFPage * page) { QPixmap myPixmap; + QString key; + if (closed) { + return; + } + if ( ! selector.desc.contains(pageKeyBase)) { //this page was not requested by us return; } qDebug() << Q_FUNC_INFO << selector.desc << selector.desSize << selector.pageNum; + if (selector.desc.contains(pageKeyCur)) { + key = getPageKey(size(), pageKeyCur); + } else if (selector.desc.contains(pageKeyNext)) { + key = getPageKey(size(), pageKeyCur); + } else if (selector.desc.contains(pageKeyPrev)) { + key = getPageKey(size(), pageKeyCur); + } + + if (QPixmapCache::find(key, myPixmap) == true) { //we have it already + return; + } + emit imageGenerationStarted(); myPixmap = QPixmap::fromImage(*page->getImage()); ///< @todo better observe this place, as it may fail here (image inside page could have already been deleted) emit imageGenerationFinished(); + emit imageGenerated(selector); - if (selector.desc.contains(pageKeyCur)) { - QPixmapCache::insert(getPageKey(size(), pageKeyCur), myPixmap); + if (selector.desc.contains(pageKeyCur)) { + QPixmapCache::insert(key, myPixmap); currentPixmap = myPixmap; showPDF(); update(); - } else if (selector.desc.contains(pageKeyNext)) { - QPixmapCache::insert(getPageKey(size(), pageKeyNext), myPixmap); + } else if (selector.desc.contains(pageKeyNext)) { + QPixmapCache::insert(key, myPixmap); nextPixmap = myPixmap; - - } else if (selector.desc.contains(pageKeyPrev)) { - QPixmapCache::insert(getPageKey(size(), pageKeyPrev), myPixmap); + } else if (selector.desc.contains(pageKeyPrev)) { + QPixmapCache::insert(key, myPixmap); previousPixmap = myPixmap; - } manageMovements(); @@ -420,13 +438,27 @@ } } +/** Stops or start rotating the pages. It does nothing if rotating is already stopped/started. + @arg enabled wheter rotating of pages should start or stop. + */ +void PDFPresentationViewer::setAutoRotating(bool enabled) { + if ( ! enabled) { + nextTimer.stop(); + } else { + if ( ! nextTimer.isActive()) { + nextTimer.start(_period); + } + } +} + + /** Hide event reimplementation. It stops changing of pages. @param event structure containing event information */ void PDFPresentationViewer::hideEvent(QHideEvent * event) { - Q_UNUSED(event); + nextTimer.stop(); } @@ -467,12 +499,13 @@ setGeometry(getZoomedGeometry()); getCurrentPage(); setBorder(false); + raise(); showPDF(); } } void PDFPresentationViewer::manageMovements() { - if (inPageTransition) { //there are already other movements queued + if (inPageTransition) { return; } if ( ! pageChanges.empty() ) { @@ -501,11 +534,9 @@ } void PDFPresentationViewer::setBorder(bool focused) { - if (focused) { - //setFrameStyle(QFrame::Box | QFrame::Raised); + if (focused) { setFrameStyle(QFrame::Panel | QFrame::Plain); - setLineWidth(3); - setMidLineWidth(0); + setLineWidth(AppConfig::getInstance()->getAppWidth() / 380); setPalette( AppConfig::getInstance()->getPaletteFocused() ); } else { setLineWidth(1); @@ -650,17 +681,19 @@ } void PDFPresentationViewer::close() { + closed = true; zoomable = false; - update(); setPixmap(NULL); setFocusPolicy(Qt::NoFocus); clearFocus(); + update(); } void PDFPresentationViewer::load(QString & filename) { Q_UNUSED(filename); zoomable = true; + closed = false; setFocusPolicy(Qt::StrongFocus); if ( QApplication::focusWidget() == NULL ) { Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.h =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.h 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.h 2010-02-14 22:16:40 UTC (rev 1724) @@ -32,6 +32,7 @@ void getPage(int pageNum, QSize size, QString desc); void imageGenerationStarted(); void imageGenerationFinished(); + void imageGenerated(PageSelector selector); void unZoomEvent(); void zoomEvent(); @@ -58,6 +59,7 @@ void load(QString & filename); void setPeriod(int period); int period(); + void setAutoRotating(bool enabled); void setPages(QList <int> & _pageNumbers); @@ -99,6 +101,7 @@ int currentPage; int _period; bool inPageTransition; + bool closed; ElvysNs::Position pageMovement; QList<ElvysNs::Position> pageChanges; Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdfviewer.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pdfviewer.cpp 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pdfviewer.cpp 2010-02-14 22:16:40 UTC (rev 1724) @@ -29,6 +29,7 @@ zoomed = false; zoomable = true; toBeZoomed = false; + closed = false; scaled = 0; @@ -78,11 +79,17 @@ return; } + if (closed) { + return; + } + qDebug() << Q_FUNC_INFO << selector.desc << selector.desSize << selector.pageNum; emit imageGenerationStarted(); myPixmap = QPixmap::fromImage(*page->getImage()); ///< @todo better observe this place, as it fails here emit imageGenerationFinished(); + emit imageGenerated(selector); + if (selector.desc.contains(SMALL_PAGE_IDENTIFIER)) { //small page QPixmapCache::insert(getPageKey(myPixmap.size(), SMALL_PAGE_IDENTIFIER) ,myPixmap); if ( ! zoomed ) { @@ -338,9 +345,8 @@ void PDFViewer::setBorder(bool focused) { if (focused) { - setFrameStyle(QFrame::Box | QFrame::Raised); - setLineWidth(3); - setMidLineWidth(3); + setFrameStyle(QFrame::Panel | QFrame::Plain); + setLineWidth(AppConfig::getInstance()->getAppWidth() / 380); setPalette( AppConfig::getInstance()->getPaletteFocused() ); } else { setLineWidth(1); @@ -472,17 +478,19 @@ } void PDFViewer::close() { - zoomable = false; - update(); + closed = true; + zoomable = false; setPixmap(NULL); setFocusPolicy(Qt::NoFocus); clearFocus(); + update(); } void PDFViewer::load(QString & filename) { Q_UNUSED(filename); zoomable = true; + closed = false; setFocusPolicy(Qt::StrongFocus); if ( QApplication::focusWidget() == NULL ) { Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdfviewer.h =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/pdfviewer.h 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/pdfviewer.h 2010-02-14 22:16:40 UTC (rev 1724) @@ -30,6 +30,7 @@ void getPage(int pageNum, QSize size, QString desc); void imageGenerationStarted(); void imageGenerationFinished(); + void imageGenerated(PageSelector selector); void unZoomEvent(); void zoomEvent(); void scale(double scaleFactor); @@ -89,6 +90,7 @@ bool toBeZoomed; bool zoomable; // pokud uz je nactena aspon first page big stranka a nejakej ten buffer bool zoomed; + bool closed; int alfa; Modified: branches/client/pdf-presentation-branch/elvys-client/src/videodocument.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/videodocument.cpp 2010-02-14 16:06:15 UTC (rev 1723) +++ branches/client/pdf-presentation-branch/elvys-client/src/videodocument.cpp 2010-02-14 22:16:40 UTC (rev 1724) @@ -285,10 +285,9 @@ void VideoDocument::setBorder(bool focused) { if (focused) { - setPalette( AppConfig::getInstance()->getPaletteFocused()); - setFrameStyle(QFrame::Box | QFrame::Raised); - setLineWidth(3); - setMidLineWidth(3); + setFrameStyle(QFrame::Panel | QFrame::Plain); + setLineWidth(AppConfig::getInstance()->getAppWidth() / 380); + setPalette( AppConfig::getInstance()->getPaletteFocused() ); } else { setPalette( AppConfig::getInstance()->getPaletteNotFocused()); setLineWidth(1);