2004-09-08 12:41:14 +00:00
/***************************************************************************
2005-02-20 16:04:40 +00:00
* Copyright ( C ) 2004 - 2005 by Enrico Ros < eros . kde @ email . it > *
2005-01-15 01:08:35 +00:00
* Copyright ( C ) 2004 - 2005 by Albert Astals Cid < tsdgeos @ terra . es > *
2004-09-08 12:41:14 +00:00
* *
* This program is free software ; you can redistribute it and / or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation ; either version 2 of the License , or *
* ( at your option ) any later version . *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2004-10-06 00:05:49 +00:00
// qt/kde/system includes
2006-09-21 08:45:36 +00:00
# include <QtCore/QtAlgorithms>
# include <QtCore/QFile>
# include <QtCore/QFileInfo>
# include <QtCore/QMap>
2006-11-17 22:15:15 +00:00
# include <QtCore/QProcess>
2006-09-21 08:45:36 +00:00
# include <QtCore/QTextStream>
# include <QtCore/QTimer>
# include <QtGui/QApplication>
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
# include <kconfigdialog.h>
2004-09-12 23:19:18 +00:00
# include <kdebug.h>
2004-09-16 21:04:49 +00:00
# include <kfinddialog.h>
2006-09-21 08:45:36 +00:00
# include <klibloader.h>
# include <klocale.h>
2004-09-16 21:04:49 +00:00
# include <kmessagebox.h>
2006-05-22 14:02:24 +00:00
# include <kmimetypetrader.h>
2004-12-10 16:04:45 +00:00
# include <krun.h>
2005-01-03 00:28:46 +00:00
# include <kstandarddirs.h>
2006-09-21 08:45:36 +00:00
# include <ktoolinvocation.h>
2004-09-08 12:41:14 +00:00
// local includes
2006-09-21 08:45:36 +00:00
# include "chooseenginedialog.h"
2004-09-08 12:41:14 +00:00
# include "document.h"
2005-07-15 18:20:57 +00:00
# include "generator.h"
2006-09-21 08:45:36 +00:00
# include "link.h"
2005-01-02 14:55:14 +00:00
# include "observer.h"
2004-09-08 12:41:14 +00:00
# include "page.h"
2006-03-28 22:22:10 +00:00
# include "settings.h"
2004-09-09 13:25:40 +00:00
2006-09-21 08:45:36 +00:00
using namespace Okular ;
// structures used internally by Document for local variables storage
2005-02-02 18:18:26 +00:00
class AllocatedPixmap ;
class RunningSearch ;
2006-09-21 08:45:36 +00:00
class Okular : : DocumentPrivate
2004-09-08 12:41:14 +00:00
{
2004-12-10 16:04:45 +00:00
public :
2006-11-10 23:52:02 +00:00
DocumentPrivate ( )
: m_lastSearchID ( - 1 ) ,
allocatedPixmapsTotalMemory ( 0 ) ,
warnedOutOfMemory ( false ) ,
rotation ( 0 ) ,
memCheckTimer ( 0 ) ,
saveBookmarksTimer ( 0 )
{ }
2005-02-02 18:18:26 +00:00
// find descriptors, mapped by ID (we handle multiple searches)
QMap < int , RunningSearch * > searches ;
2006-07-11 19:57:17 +00:00
int m_lastSearchID ;
2004-12-10 16:04:45 +00:00
2005-02-04 22:35:44 +00:00
// needed because for remote documents docFileName is a local file and
// we want the remote url when the document refers to relativeNames
2006-03-20 22:51:56 +00:00
KUrl url ;
2005-02-04 22:35:44 +00:00
2004-12-10 16:04:45 +00:00
// cached stuff
2005-01-13 11:03:48 +00:00
QString docFileName ;
QString xmlFileName ;
2004-12-10 16:04:45 +00:00
2005-01-27 17:31:07 +00:00
// viewport stuff
2006-03-20 22:51:56 +00:00
QLinkedList < DocumentViewport > viewportHistory ;
QLinkedList < DocumentViewport > : : iterator viewportIterator ;
2006-09-21 08:45:36 +00:00
DocumentViewport nextDocumentViewport ; // see Link::Goto for an explanation
2005-01-27 17:31:07 +00:00
2005-01-26 10:42:07 +00:00
// observers / requests / allocator stuff
2005-01-20 17:33:05 +00:00
QMap < int , DocumentObserver * > observers ;
2006-03-20 22:51:56 +00:00
QLinkedList < PixmapRequest * > pixmapRequestsStack ;
QLinkedList < AllocatedPixmap * > allocatedPixmapsFifo ;
2005-01-20 17:33:05 +00:00
int allocatedPixmapsTotalMemory ;
2005-04-07 20:26:49 +00:00
bool warnedOutOfMemory ;
2004-12-24 10:24:10 +00:00
2006-06-02 20:42:57 +00:00
// the rotation applied to the document, 0,1,2,3 * 90 degrees
int rotation ;
2005-01-13 11:03:48 +00:00
// timers (memory checking / info saver)
QTimer * memCheckTimer ;
2005-01-03 00:28:46 +00:00
QTimer * saveBookmarksTimer ;
2004-12-21 12:38:52 +00:00
} ;
2005-01-20 17:33:05 +00:00
struct AllocatedPixmap
2004-12-21 12:38:52 +00:00
{
2005-01-20 17:33:05 +00:00
// owner of the page
int id ;
int page ;
int memory ;
2004-12-21 12:38:52 +00:00
// public constructor: initialize data
2005-01-20 17:33:05 +00:00
AllocatedPixmap ( int i , int p , int m ) : id ( i ) , page ( p ) , memory ( m ) { } ;
2004-09-08 12:41:14 +00:00
} ;
2005-02-01 18:26:56 +00:00
struct RunningSearch
{
2005-02-02 18:18:26 +00:00
// store search properties
int continueOnPage ;
2005-07-15 18:20:57 +00:00
RegularAreaRect continueOnMatch ;
2006-03-20 22:51:56 +00:00
QLinkedList < int > highlightedPages ;
2005-02-02 18:18:26 +00:00
// fields related to previous searches (used for 'continueSearch')
QString cachedString ;
2006-09-21 08:45:36 +00:00
Document : : SearchType cachedType ;
2005-02-02 18:18:26 +00:00
bool cachedCaseSensitive ;
bool cachedViewportMove ;
bool cachedNoDialogs ;
QColor cachedColor ;
2005-02-01 18:26:56 +00:00
} ;
2004-09-08 12:41:14 +00:00
# define foreachObserver( cmd ) {\
2005-01-20 17:33:05 +00:00
QMap < int , DocumentObserver * > : : iterator it = d - > observers . begin ( ) , end = d - > observers . end ( ) ; \
for ( ; it ! = end ; + + it ) { ( * it ) - > cmd ; } }
2004-09-08 12:41:14 +00:00
2005-01-26 10:42:07 +00:00
2006-09-21 08:45:36 +00:00
/** Document **/
2005-01-26 10:42:07 +00:00
2006-09-21 08:45:36 +00:00
Document : : Document ( QHash < QString , Generator * > * genList )
: m_loadedGenerators ( genList ) , generator ( 0 ) , d ( new DocumentPrivate )
2004-09-08 12:41:14 +00:00
{
2006-05-13 16:06:54 +00:00
m_usingCachedGenerator = false ;
2004-09-08 12:41:14 +00:00
}
2004-09-12 23:19:18 +00:00
2006-09-21 08:45:36 +00:00
Document : : ~ Document ( )
2004-09-08 12:41:14 +00:00
{
2005-01-20 17:33:05 +00:00
// delete generator, pages, and related stuff
2004-09-17 17:58:42 +00:00
closeDocument ( ) ;
2005-01-17 18:27:31 +00:00
2005-01-20 17:33:05 +00:00
// delete the private structure
2004-09-08 12:41:14 +00:00
delete d ;
}
2006-07-07 14:28:21 +00:00
static bool kserviceMoreThan ( const KService : : Ptr & s1 , const KService : : Ptr & s2 )
{
return s1 - > property ( " X-KDE-Priority " ) . toInt ( ) > s2 - > property ( " X-KDE-Priority " ) . toInt ( ) ;
}
2004-10-27 14:07:24 +00:00
2006-09-21 08:45:36 +00:00
bool Document : : openDocument ( const QString & docFile , const KUrl & url , const KMimeType : : Ptr & mime )
2004-09-08 12:41:14 +00:00
{
// docFile is always local so we can use QFile on it
QFile fileReadTest ( docFile ) ;
2006-05-15 21:31:53 +00:00
if ( ! fileReadTest . open ( QIODevice : : ReadOnly ) )
2005-01-03 00:28:46 +00:00
{
2006-05-13 11:17:24 +00:00
d - > docFileName . clear ( ) ;
2004-09-08 12:41:14 +00:00
return false ;
2005-01-03 00:28:46 +00:00
}
2005-01-13 11:03:48 +00:00
// determine the related "xml document-info" filename
2005-02-04 22:35:44 +00:00
d - > url = url ;
2005-01-13 11:03:48 +00:00
d - > docFileName = docFile ;
QString fn = docFile . contains ( ' / ' ) ? docFile . section ( ' / ' , - 1 , - 1 ) : docFile ;
2006-11-18 21:36:56 +00:00
fn = " kpdf/ " + QString : : number ( fileReadTest . size ( ) ) + ' . ' + fn + " .xml " ;
2004-09-08 12:41:14 +00:00
fileReadTest . close ( ) ;
2006-07-04 23:09:39 +00:00
d - > xmlFileName = KStandardDirs : : locateLocal ( " data " , fn ) ;
2004-09-08 12:41:14 +00:00
2005-07-15 18:20:57 +00:00
if ( mime . count ( ) < = 0 )
return false ;
// 0. load Generator
// request only valid non-disabled plugins suitable for the mimetype
QString constraint ( " ([X-KDE-Priority] > 0) and ( exist Library ) " ) ;
2006-06-12 18:25:18 +00:00
KService : : List offers = KMimeTypeTrader : : self ( ) - > query ( mime - > name ( ) , " okular/Generator " , constraint ) ;
2005-07-15 18:20:57 +00:00
if ( offers . isEmpty ( ) )
2005-06-24 16:45:25 +00:00
{
2006-07-07 14:28:21 +00:00
kWarning ( ) < < " No plugin for mimetype ' " < < mime - > name ( ) < < " '. " < < endl ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
return false ;
2005-07-15 18:20:57 +00:00
}
int hRank = 0 ;
2006-07-07 14:28:21 +00:00
// order the offers: the offers with an higher priority come before
qStableSort ( offers . begin ( ) , offers . end ( ) , kserviceMoreThan ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
// best ranked offer search
2006-09-21 08:45:36 +00:00
if ( offers . count ( ) > 1 & & Settings : : chooseGenerators ( ) )
2005-07-15 18:20:57 +00:00
{
2006-03-30 18:06:18 +00:00
QStringList list ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
int count = offers . count ( ) ;
2006-03-30 18:06:18 +00:00
for ( int i = 0 ; i < count ; + + i )
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
{
2006-07-07 14:32:09 +00:00
list < < offers . at ( i ) - > name ( ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
}
2006-11-11 00:08:35 +00:00
ChooseEngineDialog choose ( list , mime , 0 ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
2006-11-11 00:08:35 +00:00
int retval = choose . exec ( ) ;
int index = choose . selectedGenerator ( ) ;
2006-03-30 18:06:18 +00:00
switch ( retval )
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
{
case QDialog : : Accepted :
2006-03-30 18:06:18 +00:00
hRank = index ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
break ;
case QDialog : : Rejected :
return false ;
break ;
}
2005-06-24 16:45:25 +00:00
}
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
2006-10-22 10:09:38 +00:00
QString propName = offers . at ( hRank ) - > name ( ) ;
2005-08-31 18:27:16 +00:00
m_usingCachedGenerator = false ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
generator = m_loadedGenerators - > take ( propName ) ;
if ( ! generator )
2005-07-15 18:20:57 +00:00
{
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
KLibLoader * loader = KLibLoader : : self ( ) ;
if ( ! loader )
{
2006-03-20 22:51:56 +00:00
kWarning ( ) < < " Could not start library loader: ' " < < loader - > lastErrorMessage ( ) < < " '. " < < endl ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
return false ;
}
2006-10-22 10:09:38 +00:00
KLibrary * lib = loader - > globalLibrary ( QFile : : encodeName ( offers . at ( hRank ) - > library ( ) ) ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
if ( ! lib )
{
2006-10-22 10:09:38 +00:00
kWarning ( ) < < " Could not load ' " < < offers . at ( hRank ) - > library ( ) < < " ' library. " < < endl ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
return false ;
}
2006-10-22 11:25:08 +00:00
Generator * ( * create_plugin ) ( ) = ( Generator * ( * ) ( ) ) lib - > symbol ( " create_plugin " ) ;
generator = create_plugin ( ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
if ( ! generator )
{
2006-03-20 22:51:56 +00:00
kWarning ( ) < < " Sth broke. " < < endl ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
return false ;
}
2006-07-12 17:19:26 +00:00
if ( offers . at ( hRank ) - > property ( " X-KDE-okularHasInternalSettings " ) . toBool ( ) )
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
{
m_loadedGenerators - > insert ( propName , generator ) ;
2005-08-31 18:13:59 +00:00
m_usingCachedGenerator = true ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
}
// end
2005-07-15 18:20:57 +00:00
}
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
else
2004-12-21 12:38:52 +00:00
{
2005-08-31 18:13:59 +00:00
m_usingCachedGenerator = true ;
2004-12-21 12:38:52 +00:00
}
2006-10-22 11:25:08 +00:00
generator - > setDocument ( this ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
// connect error reporting signals
2006-06-10 12:59:09 +00:00
connect ( generator , SIGNAL ( error ( const QString & , int ) ) , this , SIGNAL ( error ( const QString & , int ) ) ) ;
connect ( generator , SIGNAL ( warning ( const QString & , int ) ) , this , SIGNAL ( warning ( const QString & , int ) ) ) ;
connect ( generator , SIGNAL ( notice ( const QString & , int ) ) , this , SIGNAL ( notice ( const QString & , int ) ) ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
2005-01-10 13:43:44 +00:00
// 1. load Document (and set busy cursor while loading)
2006-06-03 13:01:15 +00:00
QApplication : : setOverrideCursor ( Qt : : WaitCursor ) ;
2004-12-10 16:04:45 +00:00
bool openOk = generator - > loadDocument ( docFile , pages_vector ) ;
2005-01-10 13:43:44 +00:00
QApplication : : restoreOverrideCursor ( ) ;
2005-01-03 15:51:05 +00:00
if ( ! openOk | | pages_vector . size ( ) < = 0 )
2005-01-15 01:08:35 +00:00
{
2005-08-31 18:13:59 +00:00
if ( ! m_usingCachedGenerator )
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
{
delete generator ;
}
2005-01-15 01:08:35 +00:00
generator = 0 ;
2005-01-03 15:51:05 +00:00
return openOk ;
2005-01-15 01:08:35 +00:00
}
2005-01-03 00:45:47 +00:00
2005-01-03 15:51:05 +00:00
// 2. load Additional Data (our bookmarks and metadata) about the document
2005-01-03 00:45:47 +00:00
loadDocumentInfo ( ) ;
2005-01-03 15:51:05 +00:00
// 3. setup observers inernal lists and data
2005-02-03 17:09:33 +00:00
foreachObserver ( notifySetup ( pages_vector , true ) ) ;
2005-01-03 15:51:05 +00:00
2005-01-27 17:31:07 +00:00
// 4. set initial page (restoring the page saved in xml if loaded)
DocumentViewport loadedViewport = ( * d - > viewportIterator ) ;
if ( loadedViewport . pageNumber ! = - 1 )
2005-06-24 16:39:57 +00:00
{
2005-01-27 17:31:07 +00:00
( * d - > viewportIterator ) = DocumentViewport ( ) ;
2005-06-24 16:39:57 +00:00
if ( loadedViewport . pageNumber > = ( int ) pages_vector . size ( ) )
loadedViewport . pageNumber = pages_vector . size ( ) - 1 ;
}
2005-01-09 23:37:07 +00:00
else
2005-01-27 17:31:07 +00:00
loadedViewport . pageNumber = 0 ;
2005-01-09 23:37:07 +00:00
setViewport ( loadedViewport ) ;
2005-01-03 15:51:05 +00:00
2005-01-03 00:45:47 +00:00
// start bookmark saver timer
2005-01-21 20:05:36 +00:00
if ( ! d - > saveBookmarksTimer )
{
d - > saveBookmarksTimer = new QTimer ( this ) ;
connect ( d - > saveBookmarksTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( saveDocumentInfo ( ) ) ) ;
}
2005-01-03 00:45:47 +00:00
d - > saveBookmarksTimer - > start ( 5 * 60 * 1000 ) ;
// start memory check timer
2005-01-21 20:05:36 +00:00
if ( ! d - > memCheckTimer )
{
d - > memCheckTimer = new QTimer ( this ) ;
connect ( d - > memCheckTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( slotTimedMemoryCheck ( ) ) ) ;
}
2005-01-03 00:45:47 +00:00
d - > memCheckTimer - > start ( 2000 ) ;
2005-02-04 22:35:44 +00:00
if ( d - > nextDocumentViewport . pageNumber ! = - 1 )
{
setViewport ( d - > nextDocumentViewport ) ;
d - > nextDocumentViewport = DocumentViewport ( ) ;
}
2004-09-08 12:41:14 +00:00
return true ;
}
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
2006-09-21 08:45:36 +00:00
QString Document : : getXMLFile ( )
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
{
if ( generator )
return generator - > getXMLFile ( ) ;
2006-11-18 21:36:56 +00:00
return QString ( ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : setupGUI ( KActionCollection * ac , QToolBox * tBox )
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
{
if ( generator )
generator - > setupGUI ( ac , tBox ) ;
}
2006-09-21 08:45:36 +00:00
void Document : : closeDocument ( )
2004-09-08 12:41:14 +00:00
{
2006-07-14 10:54:29 +00:00
// close the current document and save document info if a document is still opened
2005-01-03 15:51:05 +00:00
if ( generator & & pages_vector . size ( ) > 0 )
2006-07-14 10:54:29 +00:00
{
generator - > closeDocument ( ) ;
2005-01-03 15:51:05 +00:00
saveDocumentInfo ( ) ;
2006-07-14 10:54:29 +00:00
}
2005-01-03 00:28:46 +00:00
2005-01-21 20:05:36 +00:00
// stop timers
if ( d - > memCheckTimer )
d - > memCheckTimer - > stop ( ) ;
if ( d - > saveBookmarksTimer )
d - > saveBookmarksTimer - > stop ( ) ;
2004-12-24 10:24:10 +00:00
2005-08-31 18:57:37 +00:00
if ( generator )
generator - > freeGUI ( ) ;
2005-08-31 18:13:59 +00:00
if ( ! m_usingCachedGenerator )
{
// delete contents generator
delete generator ;
}
2005-01-03 00:24:59 +00:00
generator = 0 ;
2006-03-20 22:51:56 +00:00
d - > url = KUrl ( ) ;
2005-01-18 16:43:36 +00:00
// remove requests left in queue
2006-03-20 22:51:56 +00:00
QLinkedList < PixmapRequest * > : : iterator sIt = d - > pixmapRequestsStack . begin ( ) ;
QLinkedList < PixmapRequest * > : : iterator sEnd = d - > pixmapRequestsStack . end ( ) ;
2005-01-18 16:43:36 +00:00
for ( ; sIt ! = sEnd ; + + sIt )
delete * sIt ;
d - > pixmapRequestsStack . clear ( ) ;
2005-01-03 00:24:59 +00:00
// send an empty list to observers (to free their data)
2006-09-21 08:45:36 +00:00
foreachObserver ( notifySetup ( QVector < Page * > ( ) , true ) ) ;
2005-01-03 00:24:59 +00:00
2004-12-10 16:04:45 +00:00
// delete pages and clear 'pages_vector' container
2006-09-21 08:45:36 +00:00
QVector < Page * > : : iterator pIt = pages_vector . begin ( ) ;
QVector < Page * > : : iterator pEnd = pages_vector . end ( ) ;
2005-01-20 17:33:05 +00:00
for ( ; pIt ! = pEnd ; + + pIt )
delete * pIt ;
2004-12-10 16:04:45 +00:00
pages_vector . clear ( ) ;
2005-01-26 10:42:07 +00:00
// clear 'memory allocation' descriptors
2006-03-20 22:51:56 +00:00
QLinkedList < AllocatedPixmap * > : : iterator aIt = d - > allocatedPixmapsFifo . begin ( ) ;
QLinkedList < AllocatedPixmap * > : : iterator aEnd = d - > allocatedPixmapsFifo . end ( ) ;
2005-01-20 17:33:05 +00:00
for ( ; aIt ! = aEnd ; + + aIt )
delete * aIt ;
d - > allocatedPixmapsFifo . clear ( ) ;
2004-12-22 18:21:36 +00:00
2005-02-01 18:26:56 +00:00
// clear 'running searches' descriptors
QMap < int , RunningSearch * > : : iterator rIt = d - > searches . begin ( ) ;
QMap < int , RunningSearch * > : : iterator rEnd = d - > searches . end ( ) ;
for ( ; rIt ! = rEnd ; + + rIt )
delete * rIt ;
d - > searches . clear ( ) ;
2006-06-24 10:03:12 +00:00
// clear the visible areas and notify the observers
QVector < VisiblePageRect * > : : iterator vIt = page_rects . begin ( ) ;
QVector < VisiblePageRect * > : : iterator vEnd = page_rects . end ( ) ;
for ( ; vIt ! = vEnd ; + + vIt )
delete * vIt ;
page_rects . clear ( ) ;
foreachObserver ( notifyVisibleRectsChanged ( ) ) ;
2004-09-17 17:58:42 +00:00
// reset internal variables
2005-07-15 18:20:57 +00:00
2005-01-27 17:31:07 +00:00
d - > viewportHistory . clear ( ) ;
d - > viewportHistory . append ( DocumentViewport ( ) ) ;
d - > viewportIterator = d - > viewportHistory . begin ( ) ;
2005-01-20 17:33:05 +00:00
d - > allocatedPixmapsTotalMemory = 0 ;
2004-09-08 12:41:14 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : addObserver ( DocumentObserver * pObserver )
2004-09-08 12:41:14 +00:00
{
2004-12-17 17:14:46 +00:00
// keep the pointer to the observer in a map
2005-01-20 17:33:05 +00:00
d - > observers [ pObserver - > observerId ( ) ] = pObserver ;
2004-12-17 17:14:46 +00:00
// if the observer is added while a document is already opened, tell it
if ( ! pages_vector . isEmpty ( ) )
2005-02-12 17:42:54 +00:00
{
2005-01-09 23:37:07 +00:00
pObserver - > notifySetup ( pages_vector , true ) ;
2005-02-12 17:42:54 +00:00
pObserver - > notifyViewportChanged ( false /*disables smoothMove*/ ) ;
}
2004-12-17 17:14:46 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : notifyObservers ( NotifyRequest * request )
2005-07-20 22:28:23 +00:00
{
2005-11-04 11:59:51 +00:00
switch ( request - > type )
2005-07-20 22:28:23 +00:00
{
2005-11-04 11:59:51 +00:00
case DocumentObserver : : Setup :
foreachObserver ( notifySetup ( pages_vector , request - > toggle ) ) ;
break ;
case DocumentObserver : : Viewport :
foreachObserver ( notifyViewportChanged ( request - > toggle ) ) ;
break ;
case DocumentObserver : : Page :
foreachObserver ( notifyPageChanged ( request - > page , request - > flags ) ) ;
break ;
case DocumentObserver : : Contents :
foreachObserver ( notifyContentsCleared ( request - > flags ) ) ;
break ;
2006-06-23 21:11:52 +00:00
case DocumentObserver : : VisibleAreas :
qDeleteAll ( page_rects ) ;
page_rects = request - > rects ;
foreachObserver ( notifyVisibleRectsChanged ( ) ) ;
break ;
2005-07-20 22:28:23 +00:00
}
}
2006-09-21 08:45:36 +00:00
void Document : : removeObserver ( DocumentObserver * pObserver )
2004-12-17 17:14:46 +00:00
{
// remove observer from the map. it won't receive notifications anymore
2004-12-21 12:38:52 +00:00
if ( d - > observers . contains ( pObserver - > observerId ( ) ) )
{
2005-01-03 15:51:05 +00:00
// free observer's pixmap data
2004-12-21 12:38:52 +00:00
int observerId = pObserver - > observerId ( ) ;
2006-09-21 08:45:36 +00:00
QVector < Page * > : : iterator it = pages_vector . begin ( ) , end = pages_vector . end ( ) ;
2004-12-21 12:38:52 +00:00
for ( ; it ! = end ; + + it )
2006-11-03 17:57:32 +00:00
( * it ) - > deleteImage ( observerId ) ;
2004-12-24 10:24:10 +00:00
2005-01-28 18:18:48 +00:00
// [MEM] free observer's allocation descriptors
2006-03-20 22:51:56 +00:00
QLinkedList < AllocatedPixmap * > : : iterator aIt = d - > allocatedPixmapsFifo . begin ( ) ;
QLinkedList < AllocatedPixmap * > : : iterator aEnd = d - > allocatedPixmapsFifo . end ( ) ;
2005-01-28 18:18:48 +00:00
while ( aIt ! = aEnd )
{
AllocatedPixmap * p = * aIt ;
if ( p - > id = = observerId )
{
2006-03-29 16:46:09 +00:00
aIt = d - > allocatedPixmapsFifo . erase ( aIt ) ;
2005-01-28 18:18:48 +00:00
delete p ;
}
else
+ + aIt ;
}
2005-01-20 17:33:05 +00:00
// delete observer entry from the map
2004-12-21 12:38:52 +00:00
d - > observers . remove ( observerId ) ;
}
2004-09-08 12:41:14 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : reparseConfig ( )
2004-09-08 12:41:14 +00:00
{
2006-09-21 08:45:36 +00:00
// reparse generator config and if something changed clear Pages
2004-12-10 16:04:45 +00:00
if ( generator & & generator - > reparseConfig ( ) )
2004-11-09 17:20:19 +00:00
{
2005-01-21 20:05:36 +00:00
// invalidate pixmaps
2006-09-21 08:45:36 +00:00
QVector < Page * > : : iterator it = pages_vector . begin ( ) , end = pages_vector . end ( ) ;
2006-11-03 17:57:32 +00:00
for ( ; it ! = end ; + + it ) {
( * it ) - > deleteImages ( ) ;
( * it ) - > deleteRects ( ) ;
}
2005-01-21 20:05:36 +00:00
// [MEM] remove allocation descriptors
2006-03-20 22:51:56 +00:00
QLinkedList < AllocatedPixmap * > : : iterator aIt = d - > allocatedPixmapsFifo . begin ( ) ;
QLinkedList < AllocatedPixmap * > : : iterator aEnd = d - > allocatedPixmapsFifo . end ( ) ;
2005-01-21 20:05:36 +00:00
for ( ; aIt ! = aEnd ; + + aIt )
delete * aIt ;
d - > allocatedPixmapsFifo . clear ( ) ;
d - > allocatedPixmapsTotalMemory = 0 ;
// send reload signals to observers
2005-01-26 10:42:07 +00:00
foreachObserver ( notifyContentsCleared ( DocumentObserver : : Pixmap ) ) ;
2004-11-09 17:20:19 +00:00
}
2005-01-21 20:05:36 +00:00
// free memory if in 'low' profile
2006-09-21 08:45:36 +00:00
if ( Settings : : memoryLevel ( ) = = Settings : : EnumMemoryLevel : : Low & &
2005-01-21 20:05:36 +00:00
! d - > allocatedPixmapsFifo . isEmpty ( ) & & ! pages_vector . isEmpty ( ) )
cleanupPixmapMemory ( ) ;
2004-09-08 12:41:14 +00:00
}
2004-11-09 17:20:19 +00:00
2006-09-21 08:45:36 +00:00
bool Document : : isOpened ( ) const
2005-01-15 01:08:35 +00:00
{
return generator ;
}
2006-09-21 08:45:36 +00:00
bool Document : : canConfigurePrinter ( ) const
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
{
return generator ? generator - > canConfigurePrinter ( ) : false ;
}
2006-09-21 08:45:36 +00:00
const DocumentInfo * Document : : documentInfo ( ) const
2004-12-05 22:47:32 +00:00
{
2006-10-15 19:37:14 +00:00
if ( generator )
{
DocumentInfo * info = const_cast < DocumentInfo * > ( generator - > generateDocumentInfo ( ) ) ;
QString pagesSize = pagesSizeString ( ) ;
if ( ! pagesSize . isEmpty ( ) )
{
info - > set ( " pagesSize " , pagesSize , i18n ( " Pages Size " ) ) ;
}
return info ;
}
else return NULL ;
2004-12-11 17:25:03 +00:00
}
2006-09-21 08:45:36 +00:00
const DocumentSynopsis * Document : : documentSynopsis ( ) const
2004-12-11 17:25:03 +00:00
{
2005-01-18 16:43:36 +00:00
return generator ? generator - > generateDocumentSynopsis ( ) : NULL ;
2004-12-05 22:47:32 +00:00
}
2006-09-21 08:45:36 +00:00
const DocumentFonts * Document : : documentFonts ( ) const
2005-06-13 15:46:23 +00:00
{
return generator ? generator - > generateDocumentFonts ( ) : NULL ;
}
2006-09-21 08:45:36 +00:00
const QList < EmbeddedFile * > * Document : : embeddedFiles ( ) const
2006-05-28 16:54:54 +00:00
{
return generator ? generator - > embeddedFiles ( ) : NULL ;
}
2006-09-21 08:45:36 +00:00
const Page * Document : : page ( int n ) const
2004-12-05 22:47:32 +00:00
{
2004-12-10 16:04:45 +00:00
return ( n < pages_vector . count ( ) ) ? pages_vector [ n ] : 0 ;
2004-12-05 22:47:32 +00:00
}
2006-09-21 08:45:36 +00:00
const DocumentViewport & Document : : viewport ( ) const
2005-01-09 23:37:07 +00:00
{
2005-01-27 17:31:07 +00:00
return ( * d - > viewportIterator ) ;
2005-01-09 23:37:07 +00:00
}
2006-09-21 08:45:36 +00:00
const QVector < VisiblePageRect * > & Document : : visiblePageRects ( ) const
2006-06-23 21:11:52 +00:00
{
return page_rects ;
}
2006-09-21 08:45:36 +00:00
void Document : : setVisiblePageRects ( const QVector < VisiblePageRect * > & visiblePageRects , int excludeId )
2006-06-23 21:11:52 +00:00
{
QVector < VisiblePageRect * > : : iterator vIt = page_rects . begin ( ) ;
QVector < VisiblePageRect * > : : iterator vEnd = page_rects . end ( ) ;
for ( ; vIt ! = vEnd ; + + vIt )
delete * vIt ;
page_rects = visiblePageRects ;
// notify change to all other (different from id) observers
QMap < int , DocumentObserver * > : : iterator it = d - > observers . begin ( ) , end = d - > observers . end ( ) ;
for ( ; it ! = end ; + + it )
if ( it . key ( ) ! = excludeId )
( * it ) - > notifyVisibleRectsChanged ( ) ;
}
2006-09-21 08:45:36 +00:00
uint Document : : currentPage ( ) const
2004-12-05 22:47:32 +00:00
{
2005-01-27 17:31:07 +00:00
return ( * d - > viewportIterator ) . pageNumber ;
2004-12-05 22:47:32 +00:00
}
2006-09-21 08:45:36 +00:00
uint Document : : pages ( ) const
2004-12-05 22:47:32 +00:00
{
2004-12-10 16:04:45 +00:00
return pages_vector . size ( ) ;
2004-12-05 22:47:32 +00:00
}
2006-09-21 08:45:36 +00:00
KUrl Document : : currentDocument ( ) const
2005-06-13 17:39:58 +00:00
{
return d - > url ;
}
2006-09-21 08:45:36 +00:00
bool Document : : isAllowed ( int flags ) const
2004-09-09 13:25:40 +00:00
{
2005-03-05 15:59:15 +00:00
return generator ? generator - > isAllowed ( flags ) : false ;
2004-09-09 13:25:40 +00:00
}
2006-09-21 08:45:36 +00:00
bool Document : : supportsSearching ( ) const
2005-06-24 16:45:25 +00:00
{
2005-07-15 18:20:57 +00:00
return generator ? generator - > supportsSearching ( ) : false ;
2005-06-24 16:45:25 +00:00
}
2006-09-21 08:45:36 +00:00
bool Document : : supportsRotation ( ) const
2005-07-20 22:28:23 +00:00
{
return generator ? generator - > supportsRotation ( ) : false ;
}
2006-09-21 08:45:36 +00:00
bool Document : : supportsPaperSizes ( ) const
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
{
return generator ? generator - > supportsPaperSizes ( ) : false ;
}
2006-09-21 08:45:36 +00:00
QStringList Document : : paperSizes ( ) const
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
{
return generator ? generator - > paperSizes ( ) : QStringList ( ) ;
}
2006-09-21 08:45:36 +00:00
bool Document : : canExportToText ( ) const
2006-07-01 22:17:53 +00:00
{
2006-10-25 15:35:53 +00:00
if ( ! generator )
return false ;
const ExportFormat : : List formats = generator - > exportFormats ( ) ;
for ( int i = 0 ; i < formats . count ( ) ; + + i ) {
if ( formats [ i ] . mimeType ( ) - > name ( ) = = QLatin1String ( " text/plain " ) )
return true ;
}
return false ;
2006-07-01 22:17:53 +00:00
}
2006-09-21 08:45:36 +00:00
bool Document : : exportToText ( const QString & fileName ) const
2006-07-01 22:17:53 +00:00
{
2006-10-25 15:35:53 +00:00
if ( ! generator )
return false ;
const ExportFormat : : List formats = generator - > exportFormats ( ) ;
for ( int i = 0 ; i < formats . count ( ) ; + + i ) {
if ( formats [ i ] . mimeType ( ) - > name ( ) = = QLatin1String ( " text/plain " ) )
return generator - > exportTo ( fileName , formats [ i ] ) ;
}
return false ;
2006-07-01 22:17:53 +00:00
}
2006-10-25 15:35:53 +00:00
ExportFormat : : List Document : : exportFormats ( ) const
2006-07-01 22:17:53 +00:00
{
2006-10-25 15:35:53 +00:00
return generator ? generator - > exportFormats ( ) : ExportFormat : : List ( ) ;
2006-07-01 22:17:53 +00:00
}
2006-10-25 15:35:53 +00:00
bool Document : : exportTo ( const QString & fileName , const ExportFormat & format ) const
2006-07-01 22:17:53 +00:00
{
2006-10-25 15:35:53 +00:00
return generator ? generator - > exportTo ( fileName , format ) : false ;
2006-07-01 22:17:53 +00:00
}
2006-09-21 08:45:36 +00:00
bool Document : : historyAtBegin ( ) const
2005-01-27 17:31:07 +00:00
{
return d - > viewportIterator = = d - > viewportHistory . begin ( ) ;
}
2006-09-21 08:45:36 +00:00
bool Document : : historyAtEnd ( ) const
2005-01-27 17:31:07 +00:00
{
return d - > viewportIterator = = - - ( d - > viewportHistory . end ( ) ) ;
}
2006-10-28 19:18:36 +00:00
QVariant Document : : getMetaData ( const QString & key , const QVariant & option ) const
2005-01-01 15:44:44 +00:00
{
2006-10-28 19:18:36 +00:00
return generator ? generator - > metaData ( key , option ) : QVariant ( ) ;
2005-01-01 15:44:44 +00:00
}
2004-11-09 17:20:19 +00:00
2006-09-21 08:45:36 +00:00
int Document : : rotation ( ) const
2006-06-02 20:42:57 +00:00
{
return d - > rotation ;
}
2006-10-15 19:37:14 +00:00
QSizeF Document : : allPagesSize ( ) const
{
bool allPagesSameSize = true ;
QSizeF size ;
for ( int i = 0 ; allPagesSameSize & & i < pages_vector . count ( ) ; + + i )
{
Page * p = pages_vector [ i ] ;
if ( i = = 0 ) size = QSizeF ( p - > width ( ) , p - > height ( ) ) ;
else
{
allPagesSameSize = ( size = = QSizeF ( p - > width ( ) , p - > height ( ) ) ) ;
}
}
if ( allPagesSameSize ) return size ;
else return QSizeF ( ) ;
}
QString Document : : pageSizeString ( int page ) const
{
if ( generator )
{
if ( generator - > pagesSizeMetric ( ) ! = Generator : : None )
{
Page * p = pages_vector [ page ] ;
return localizedSize ( QSizeF ( p - > width ( ) , p - > height ( ) ) ) ;
}
}
return QString ( ) ;
}
2006-09-21 08:45:36 +00:00
void Document : : requestPixmaps ( const QLinkedList < PixmapRequest * > & requests )
2004-09-15 20:45:00 +00:00
{
2005-01-27 17:31:07 +00:00
if ( ! generator )
{
// delete requests..
2006-03-20 22:51:56 +00:00
QLinkedList < PixmapRequest * > : : const_iterator rIt = requests . begin ( ) , rEnd = requests . end ( ) ;
2005-01-27 17:31:07 +00:00
for ( ; rIt ! = rEnd ; + + rIt )
delete * rIt ;
// ..and return
2004-09-15 20:45:00 +00:00
return ;
2005-01-27 17:31:07 +00:00
}
2004-09-15 20:45:00 +00:00
2005-01-18 16:43:36 +00:00
// 1. [CLEAN STACK] remove previous requests of requesterID
2006-10-25 15:35:53 +00:00
int requesterID = requests . first ( ) - > id ( ) ;
2006-03-20 22:51:56 +00:00
QLinkedList < PixmapRequest * > : : iterator sIt = d - > pixmapRequestsStack . begin ( ) , sEnd = d - > pixmapRequestsStack . end ( ) ;
2005-01-18 16:43:36 +00:00
while ( sIt ! = sEnd )
{
2006-10-25 15:35:53 +00:00
if ( ( * sIt ) - > id ( ) = = requesterID )
2005-01-27 17:31:07 +00:00
{
// delete request and remove it from stack
delete * sIt ;
2006-03-29 16:46:09 +00:00
sIt = d - > pixmapRequestsStack . erase ( sIt ) ;
2005-01-27 17:31:07 +00:00
}
2005-01-18 16:43:36 +00:00
else
+ + sIt ;
}
// 2. [ADD TO STACK] add requests to stack
2006-09-21 08:45:36 +00:00
bool threadingDisabled = ! Settings : : enableThreading ( ) ;
2006-03-20 22:51:56 +00:00
QLinkedList < PixmapRequest * > : : const_iterator rIt = requests . begin ( ) , rEnd = requests . end ( ) ;
2004-12-22 18:21:36 +00:00
for ( ; rIt ! = rEnd ; + + rIt )
2004-12-21 12:38:52 +00:00
{
2005-01-18 16:43:36 +00:00
// set the 'page field' (see PixmapRequest) and check if it is valid
2004-12-22 18:21:36 +00:00
PixmapRequest * request = * rIt ;
2006-10-25 15:35:53 +00:00
kWarning ( ) < < " request id= " < < request - > id ( ) < < " " < < request - > width ( ) < < " x " < < request - > height ( ) < < " @ " < < request - > pageNumber ( ) < < endl ;
if ( pages_vector . value ( request - > pageNumber ( ) ) = = 0 )
2005-01-27 17:31:07 +00:00
{
// skip requests referencing an invalid page (must not happen)
delete request ;
2004-12-22 18:21:36 +00:00
continue ;
2006-10-25 17:29:24 +00:00
}
2004-12-22 18:21:36 +00:00
2006-10-25 15:35:53 +00:00
request - > setPage ( pages_vector . value ( request - > pageNumber ( ) ) ) ;
2006-06-02 20:42:57 +00:00
2006-10-25 15:35:53 +00:00
if ( ! request - > asynchronous ( ) )
request - > setPriority ( 0 ) ;
2004-12-22 18:21:36 +00:00
2006-10-25 15:35:53 +00:00
if ( request - > asynchronous ( ) & & threadingDisabled )
request - > setAsynchronous ( false ) ;
2004-12-22 18:21:36 +00:00
2005-01-18 16:43:36 +00:00
// add request to the 'stack' at the right place
2006-10-25 15:35:53 +00:00
if ( ! request - > priority ( ) )
2005-01-18 16:43:36 +00:00
// add priority zero requests to the top of the stack
2005-02-02 18:18:26 +00:00
d - > pixmapRequestsStack . append ( request ) ;
2005-01-18 16:43:36 +00:00
else
{
// insert in stack sorted by priority
sIt = d - > pixmapRequestsStack . begin ( ) ;
sEnd = d - > pixmapRequestsStack . end ( ) ;
2006-10-25 15:35:53 +00:00
while ( sIt ! = sEnd & & ( * sIt ) - > priority ( ) > = request - > priority ( ) )
2005-01-18 16:43:36 +00:00
+ + sIt ;
d - > pixmapRequestsStack . insert ( sIt , request ) ;
}
2004-12-21 12:38:52 +00:00
}
2005-01-18 16:43:36 +00:00
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
// 3. [START FIRST GENERATION] if <NO>generator is ready, start a new generation,
2005-01-18 16:43:36 +00:00
// or else (if gen is running) it will be started when the new contents will
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
//come from generator (in requestDone())</NO>
// all handling of requests put into sendGeneratorRequest
// if ( generator->canGeneratePixmap() )
2005-01-18 16:43:36 +00:00
sendGeneratorRequest ( ) ;
2004-09-15 20:45:00 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : requestTextPage ( uint page )
2004-10-09 08:10:56 +00:00
{
2006-09-21 08:45:36 +00:00
Page * kp = pages_vector [ page ] ;
2004-12-10 16:04:45 +00:00
if ( ! generator | | ! kp )
return ;
2004-12-21 12:38:52 +00:00
// Memory management for TextPages
2005-01-18 16:43:36 +00:00
generator - > generateSyncTextPage ( kp ) ;
2004-10-09 08:10:56 +00:00
}
2005-02-18 18:24:45 +00:00
2006-09-21 08:45:36 +00:00
void Document : : addPageAnnotation ( int page , Annotation * annotation )
2005-02-18 18:24:45 +00:00
{
// find out the page to attach annotation
2006-09-21 08:45:36 +00:00
Page * kp = pages_vector [ page ] ;
2005-02-18 18:24:45 +00:00
if ( ! generator | | ! kp )
return ;
// add annotation to the page
kp - > addAnnotation ( annotation ) ;
// notify observers about the change
foreachObserver ( notifyPageChanged ( page , DocumentObserver : : Annotations ) ) ;
}
2006-08-08 15:31:13 +00:00
2006-09-21 08:45:36 +00:00
void Document : : modifyPageAnnotation ( int page , Annotation * newannotation )
2006-08-08 15:31:13 +00:00
{
2006-08-10 06:32:03 +00:00
//TODO: modify annotations
// find out the page
2006-09-21 08:45:36 +00:00
Page * kp = pages_vector [ page ] ;
2006-08-10 06:32:03 +00:00
if ( ! generator | | ! kp )
return ;
kp - > modifyAnnotation ( newannotation ) ;
// notify observers about the change
foreachObserver ( notifyPageChanged ( page , DocumentObserver : : Annotations ) ) ;
}
2006-09-21 08:45:36 +00:00
void Document : : removePageAnnotation ( int page , Annotation * annotation )
2006-08-10 06:32:03 +00:00
{
// find out the page
2006-09-21 08:45:36 +00:00
Page * kp = pages_vector [ page ] ;
2006-08-10 06:32:03 +00:00
if ( ! generator | | ! kp )
return ;
2006-09-14 18:42:28 +00:00
// try to remove the annotation
if ( kp - > removeAnnotation ( annotation ) )
{
// in case of success, notify observers about the change
foreachObserver ( notifyPageChanged ( page , DocumentObserver : : Annotations ) ) ;
}
2006-08-08 15:31:13 +00:00
}
2006-11-01 15:17:22 +00:00
void Document : : removePageAnnotations ( int page , QList < Annotation * > annotations )
{
// find out the page
Page * kp = pages_vector [ page ] ;
if ( ! generator | | ! kp )
return ;
bool changed = false ;
foreach ( Annotation * annotation , annotations )
{
// try to remove the annotation
if ( kp - > removeAnnotation ( annotation ) )
{
changed = true ;
}
}
if ( changed )
{
// in case we removed even only one annotation, notify observers about the change
foreachObserver ( notifyPageChanged ( page , DocumentObserver : : Annotations ) ) ;
}
}
2006-09-26 22:22:01 +00:00
void Document : : setPageTextSelection ( int page , RegularAreaRect * rect , const QColor & color )
{
Page * kp = pages_vector [ page ] ;
if ( ! generator | | ! kp )
return ;
// add or remove the selection basing whether rect is null or not
if ( rect )
kp - > setTextSelections ( rect , color ) ;
else
kp - > deleteTextSelections ( ) ;
// notify observers about the change
foreachObserver ( notifyPageChanged ( page , DocumentObserver : : TextSelection ) ) ;
}
2005-01-09 23:37:07 +00:00
/* REFERENCE IMPLEMENTATION: better calling setViewport from other code
2006-09-21 08:45:36 +00:00
void Document : : setNextPage ( )
2005-01-09 23:37:07 +00:00
{
// advance page and set viewport on observers
2005-01-27 17:31:07 +00:00
if ( ( * d - > viewportIterator ) . pageNumber < ( int ) pages_vector . count ( ) - 1 )
setViewport ( DocumentViewport ( ( * d - > viewportIterator ) . pageNumber + 1 ) ) ;
2005-01-09 23:37:07 +00:00
}
2004-10-09 08:10:56 +00:00
2006-09-21 08:45:36 +00:00
void Document : : setPrevPage ( )
2004-09-09 13:25:40 +00:00
{
2005-01-09 23:37:07 +00:00
// go to previous page and set viewport on observers
2005-01-27 17:31:07 +00:00
if ( ( * d - > viewportIterator ) . pageNumber > 0 )
setViewport ( DocumentViewport ( ( * d - > viewportIterator ) . pageNumber - 1 ) ) ;
2005-01-09 23:37:07 +00:00
}
*/
2006-09-21 08:45:36 +00:00
void Document : : setViewportPage ( int page , int excludeId , bool smoothMove )
2005-01-09 23:37:07 +00:00
{
// clamp page in range [0 ... numPages-1]
2004-10-10 13:21:30 +00:00
if ( page < 0 )
2004-10-09 08:10:56 +00:00
page = 0 ;
2004-12-10 16:04:45 +00:00
else if ( page > ( int ) pages_vector . count ( ) )
page = pages_vector . count ( ) - 1 ;
2005-01-09 23:37:07 +00:00
// make a viewport from the page and broadcast it
2005-02-01 18:23:55 +00:00
setViewport ( DocumentViewport ( page ) , excludeId , smoothMove ) ;
2005-01-09 23:37:07 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : setViewport ( const DocumentViewport & viewport , int excludeId , bool smoothMove )
2005-01-09 23:37:07 +00:00
{
// if already broadcasted, don't redo it
2005-01-27 17:31:07 +00:00
DocumentViewport & oldViewport = * d - > viewportIterator ;
2005-03-18 18:49:45 +00:00
// disabled by enrico on 2005-03-18 (less debug output)
//if ( viewport == oldViewport )
2006-03-20 22:51:56 +00:00
// kDebug() << "setViewport with the same viewport." << endl;
2005-01-09 23:37:07 +00:00
2005-01-27 17:31:07 +00:00
// set internal viewport taking care of history
if ( oldViewport . pageNumber = = viewport . pageNumber | | oldViewport . pageNumber = = - 1 )
{
// if page is unchanged save the viewport at current position in queue
oldViewport = viewport ;
}
else
{
// remove elements after viewportIterator in queue
d - > viewportHistory . erase ( + + d - > viewportIterator , d - > viewportHistory . end ( ) ) ;
// keep the list to a reasonable size by removing head when needed
if ( d - > viewportHistory . count ( ) > = 100 )
d - > viewportHistory . pop_front ( ) ;
2005-01-10 13:43:44 +00:00
2005-01-27 17:31:07 +00:00
// add the item at the end of the queue
2006-03-21 20:00:24 +00:00
d - > viewportIterator = d - > viewportHistory . insert ( d - > viewportHistory . end ( ) , viewport ) ;
2005-01-27 17:31:07 +00:00
}
// notify change to all other (different from id) observers
2005-01-20 17:33:05 +00:00
QMap < int , DocumentObserver * > : : iterator it = d - > observers . begin ( ) , end = d - > observers . end ( ) ;
2005-01-10 13:43:44 +00:00
for ( ; it ! = end ; + + it )
2005-01-27 17:31:07 +00:00
if ( it . key ( ) ! = excludeId )
2005-02-01 18:23:55 +00:00
( * it ) - > notifyViewportChanged ( smoothMove ) ;
2005-01-20 17:33:05 +00:00
2005-01-26 10:42:07 +00:00
// [MEM] raise position of currently viewed page in allocation queue
2005-01-20 17:33:05 +00:00
if ( d - > allocatedPixmapsFifo . count ( ) > 1 )
{
2005-01-26 10:42:07 +00:00
const int page = viewport . pageNumber ;
2006-03-20 22:51:56 +00:00
QLinkedList < AllocatedPixmap * > viewportPixmaps ;
QLinkedList < AllocatedPixmap * > : : iterator aIt = d - > allocatedPixmapsFifo . begin ( ) ;
QLinkedList < AllocatedPixmap * > : : iterator aEnd = d - > allocatedPixmapsFifo . end ( ) ;
2005-01-26 10:42:07 +00:00
while ( aIt ! = aEnd )
2005-01-20 17:33:05 +00:00
{
2005-01-26 10:42:07 +00:00
if ( ( * aIt ) - > page = = page )
2005-01-20 17:33:05 +00:00
{
2005-01-26 10:42:07 +00:00
viewportPixmaps . append ( * aIt ) ;
2006-03-29 16:46:09 +00:00
aIt = d - > allocatedPixmapsFifo . erase ( aIt ) ;
2005-01-26 10:42:07 +00:00
continue ;
2005-01-20 17:33:05 +00:00
}
2005-01-26 10:42:07 +00:00
+ + aIt ;
2005-01-20 17:33:05 +00:00
}
2005-01-26 10:42:07 +00:00
if ( ! viewportPixmaps . isEmpty ( ) )
d - > allocatedPixmapsFifo + = viewportPixmaps ;
}
2004-09-08 12:41:14 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : setPrevViewport ( )
2005-01-27 17:31:07 +00:00
// restore viewport from the history
{
if ( d - > viewportIterator ! = d - > viewportHistory . begin ( ) )
{
// restore previous viewport and notify it to observers
- - d - > viewportIterator ;
2005-02-01 18:23:55 +00:00
foreachObserver ( notifyViewportChanged ( true ) ) ;
2005-01-27 17:31:07 +00:00
}
}
2006-09-21 08:45:36 +00:00
void Document : : setNextViewport ( )
2005-01-27 17:31:07 +00:00
// restore next viewport from the history
{
2006-03-20 22:51:56 +00:00
QLinkedList < DocumentViewport > : : iterator nextIterator = d - > viewportIterator ;
2005-01-27 17:31:07 +00:00
+ + nextIterator ;
if ( nextIterator ! = d - > viewportHistory . end ( ) )
{
// restore next viewport and notify it to observers
+ + d - > viewportIterator ;
2005-02-01 18:23:55 +00:00
foreachObserver ( notifyViewportChanged ( true ) ) ;
2005-01-27 17:31:07 +00:00
}
}
2006-09-21 08:45:36 +00:00
void Document : : setNextDocumentViewport ( const DocumentViewport & viewport )
2006-09-15 21:08:48 +00:00
{
d - > nextDocumentViewport = viewport ;
}
2005-02-01 18:26:56 +00:00
2006-09-21 08:45:36 +00:00
bool Document : : searchText ( int searchID , const QString & text , bool fromStart , bool caseSensitive ,
2005-02-02 18:18:26 +00:00
SearchType type , bool moveViewport , const QColor & color , bool noDialogs )
2004-09-16 21:04:49 +00:00
{
2005-06-24 16:47:47 +00:00
// safety checks: don't perform searches on empty or unsearchable docs
2005-07-15 18:20:57 +00:00
if ( ! generator | | ! generator - > supportsSearching ( ) | | pages_vector . isEmpty ( ) )
2005-02-03 17:09:33 +00:00
return false ;
2005-02-02 18:18:26 +00:00
// if searchID search not recorded, create new descriptor and init params
2005-02-01 18:26:56 +00:00
if ( ! d - > searches . contains ( searchID ) )
{
RunningSearch * search = new RunningSearch ( ) ;
2005-02-02 18:18:26 +00:00
search - > continueOnPage = - 1 ;
2005-02-01 18:26:56 +00:00
d - > searches [ searchID ] = search ;
}
2006-07-11 19:57:17 +00:00
if ( d - > m_lastSearchID ! = searchID )
{
resetSearch ( d - > m_lastSearchID ) ;
}
d - > m_lastSearchID = searchID ;
2005-02-01 18:26:56 +00:00
RunningSearch * s = d - > searches [ searchID ] ;
2005-02-02 18:18:26 +00:00
// update search stucture
bool newText = text ! = s - > cachedString ;
s - > cachedString = text ;
s - > cachedType = type ;
s - > cachedCaseSensitive = caseSensitive ;
s - > cachedViewportMove = moveViewport ;
s - > cachedNoDialogs = noDialogs ;
s - > cachedColor = color ;
2005-02-01 18:26:56 +00:00
2005-02-02 18:18:26 +00:00
// global data for search
bool foundAMatch = false ;
2006-03-20 22:51:56 +00:00
QLinkedList < int > pagesToNotify ;
2005-02-02 18:18:26 +00:00
// remove highlights from pages and queue them for notifying changes
pagesToNotify + = s - > highlightedPages ;
2006-03-20 22:51:56 +00:00
QLinkedList < int > : : iterator it = s - > highlightedPages . begin ( ) , end = s - > highlightedPages . end ( ) ;
2005-02-01 18:26:56 +00:00
for ( ; it ! = end ; + + it )
2005-02-02 18:18:26 +00:00
pages_vector [ * it ] - > deleteHighlights ( searchID ) ;
s - > highlightedPages . clear ( ) ;
2005-02-01 18:26:56 +00:00
2005-02-02 18:18:26 +00:00
// set hourglass cursor
2006-06-03 13:01:15 +00:00
QApplication : : setOverrideCursor ( Qt : : WaitCursor ) ;
2005-02-01 18:26:56 +00:00
2005-02-02 18:18:26 +00:00
// 1. ALLDOC - proces all document marking pages
2005-02-01 18:26:56 +00:00
if ( type = = AllDoc )
{
2005-02-20 16:04:40 +00:00
// search and highlight 'text' (as a solid phrase) on all pages
2006-09-21 08:45:36 +00:00
QVector < Page * > : : iterator it = pages_vector . begin ( ) , end = pages_vector . end ( ) ;
2005-02-01 18:26:56 +00:00
for ( ; it ! = end ; + + it )
{
2005-02-02 18:18:26 +00:00
// get page (from the first to the last)
2006-09-21 08:45:36 +00:00
Page * page = * it ;
2005-02-02 18:18:26 +00:00
int pageNumber = page - > number ( ) ;
// request search page if needed
2005-02-01 18:26:56 +00:00
if ( ! page - > hasSearchPage ( ) )
2005-02-02 18:18:26 +00:00
requestTextPage ( pageNumber ) ;
2004-09-08 12:41:14 +00:00
2005-02-02 18:18:26 +00:00
// loop on a page adding highlights for all found items
bool addedHighlights = false ;
2005-07-15 18:20:57 +00:00
RegularAreaRect * lastMatch = 0 ;
2005-02-01 18:26:56 +00:00
while ( 1 )
{
if ( lastMatch )
2006-05-27 10:06:31 +00:00
lastMatch = page - > findText ( searchID , text , NextRes , caseSensitive , lastMatch ) ;
2005-02-01 18:26:56 +00:00
else
2006-05-27 10:06:31 +00:00
lastMatch = page - > findText ( searchID , text , FromTop , caseSensitive ) ;
2005-02-01 18:26:56 +00:00
if ( ! lastMatch )
break ;
2005-02-02 18:18:26 +00:00
// add highligh rect to the page
2005-02-08 15:24:23 +00:00
page - > setHighlight ( searchID , lastMatch , color ) ;
2005-02-02 18:18:26 +00:00
addedHighlights = true ;
2005-02-01 18:26:56 +00:00
}
2005-02-02 18:18:26 +00:00
// if added highlights, udpate internals and queue page for notify
if ( addedHighlights )
2005-02-01 18:26:56 +00:00
{
foundAMatch = true ;
2005-02-02 18:18:26 +00:00
s - > highlightedPages . append ( pageNumber ) ;
if ( ! pagesToNotify . contains ( pageNumber ) )
pagesToNotify . append ( pageNumber ) ;
2005-02-01 18:26:56 +00:00
}
}
2005-02-02 18:18:26 +00:00
// reset cursor to previous shape
QApplication : : restoreOverrideCursor ( ) ;
2005-07-15 18:20:57 +00:00
// send page lists if found anything new
//if ( foundAMatch ) ?maybe?
2005-02-20 16:04:40 +00:00
foreachObserver ( notifySetup ( pages_vector , false ) ) ;
2005-02-01 18:26:56 +00:00
}
2005-02-02 18:18:26 +00:00
// 2. NEXTMATCH - find next matching item (or start from top)
else if ( type = = NextMatch )
2005-02-01 18:26:56 +00:00
{
// find out from where to start/resume search from
int viewportPage = ( * d - > viewportIterator ) . pageNumber ;
2005-02-02 18:18:26 +00:00
int currentPage = fromStart ? 0 : ( ( s - > continueOnPage ! = - 1 ) ? s - > continueOnPage : viewportPage ) ;
2006-09-21 08:45:36 +00:00
Page * lastPage = fromStart ? 0 : pages_vector [ currentPage ] ;
2005-02-01 18:26:56 +00:00
// continue checking last SearchPage first (if it is the current page)
2005-07-15 18:20:57 +00:00
RegularAreaRect * match = 0 ;
2005-02-02 18:18:26 +00:00
if ( lastPage & & lastPage - > number ( ) = = s - > continueOnPage )
2004-09-13 08:51:36 +00:00
{
2005-02-02 18:18:26 +00:00
if ( newText )
2006-05-27 10:06:31 +00:00
match = lastPage - > findText ( searchID , text , FromTop , caseSensitive ) ;
2005-02-02 18:18:26 +00:00
else
2006-05-27 10:06:31 +00:00
match = lastPage - > findText ( searchID , text , NextRes , caseSensitive , & s - > continueOnMatch ) ;
2005-02-08 15:24:23 +00:00
if ( ! match )
2005-02-02 18:18:26 +00:00
currentPage + + ;
2004-09-13 08:51:36 +00:00
}
2005-02-02 18:18:26 +00:00
// if no match found, loop through the whole doc, starting from currentPage
2005-02-08 15:24:23 +00:00
if ( ! match )
2005-02-01 18:26:56 +00:00
{
const int pageCount = pages_vector . count ( ) ;
for ( int i = 0 ; i < pageCount ; i + + )
{
if ( currentPage > = pageCount )
{
2005-11-04 11:59:51 +00:00
if ( noDialogs | | KMessageBox : : questionYesNo ( 0 , i18n ( " End of document reached. \n Continue from the beginning? " ) , QString : : null , KStdGuiItem : : cont ( ) , KStdGuiItem : : cancel ( ) ) = = KMessageBox : : Yes )
2005-02-01 18:26:56 +00:00
currentPage = 0 ;
else
break ;
}
2005-02-08 15:24:23 +00:00
// get page
2006-09-21 08:45:36 +00:00
Page * page = pages_vector [ currentPage ] ;
2005-02-08 15:24:23 +00:00
// request search page if needed
2005-02-01 18:26:56 +00:00
if ( ! page - > hasSearchPage ( ) )
requestTextPage ( page - > number ( ) ) ;
2005-02-08 15:24:23 +00:00
// if found a match on the current page, end the loop
2006-05-27 10:06:31 +00:00
if ( ( match = page - > findText ( searchID , text , FromTop , caseSensitive ) ) )
2005-02-01 18:26:56 +00:00
break ;
currentPage + + ;
}
}
2005-02-02 18:18:26 +00:00
// reset cursor to previous shape
QApplication : : restoreOverrideCursor ( ) ;
// if a match has been found..
2005-02-08 15:24:23 +00:00
if ( match )
2005-02-01 18:26:56 +00:00
{
2005-02-08 15:24:23 +00:00
// update the RunningSearch structure adding this match..
2005-02-02 18:18:26 +00:00
foundAMatch = true ;
2005-02-08 15:24:23 +00:00
s - > continueOnPage = currentPage ;
s - > continueOnMatch = * match ;
s - > highlightedPages . append ( currentPage ) ;
2005-02-02 18:18:26 +00:00
// ..add highlight to the page..
2005-02-08 15:24:23 +00:00
pages_vector [ currentPage ] - > setHighlight ( searchID , match , color ) ;
2005-02-01 18:26:56 +00:00
2005-02-02 18:18:26 +00:00
// ..queue page for notifying changes..
2005-02-08 15:24:23 +00:00
if ( ! pagesToNotify . contains ( currentPage ) )
pagesToNotify . append ( currentPage ) ;
2005-02-01 18:26:56 +00:00
2005-07-15 18:20:57 +00:00
// ..move the viewport to show the first of the searched word sequence centered
2005-02-02 18:18:26 +00:00
if ( moveViewport )
{
2005-02-08 15:24:23 +00:00
DocumentViewport searchViewport ( currentPage ) ;
2005-06-13 11:53:47 +00:00
searchViewport . rePos . enabled = true ;
2005-07-15 18:20:57 +00:00
searchViewport . rePos . normalizedX = ( match - > first ( ) - > left + match - > first ( ) - > right ) / 2.0 ;
searchViewport . rePos . normalizedY = ( match - > first ( ) - > top + match - > first ( ) - > bottom ) / 2.0 ;
2005-02-02 18:18:26 +00:00
setViewport ( searchViewport , - 1 , true ) ;
}
2005-02-01 18:26:56 +00:00
}
2005-02-02 18:18:26 +00:00
else if ( ! noDialogs )
2006-04-10 19:50:00 +00:00
KMessageBox : : information ( 0 , i18n ( " No matches found for '%1'. " , text ) ) ;
2005-02-01 18:26:56 +00:00
}
2005-02-02 18:18:26 +00:00
// 3. PREVMATCH //TODO
2005-02-01 18:26:56 +00:00
else if ( type = = PrevMatch )
2004-09-08 12:41:14 +00:00
{
2005-02-01 18:26:56 +00:00
}
2005-02-20 16:04:40 +00:00
// 4. GOOGLE* - process all document marking pages
else if ( type = = GoogleAll | | type = = GoogleAny )
2005-02-01 18:26:56 +00:00
{
2005-02-20 16:04:40 +00:00
// search and highlight every word in 'text' on all pages
bool matchAll = type = = GoogleAll ;
2006-03-29 16:46:09 +00:00
QStringList words = text . split ( " " , QString : : SkipEmptyParts ) ;
2005-02-20 16:04:40 +00:00
int wordsCount = words . count ( ) ,
hueStep = ( wordsCount > 1 ) ? ( 60 / ( wordsCount - 1 ) ) : 60 ,
baseHue , baseSat , baseVal ;
color . getHsv ( & baseHue , & baseSat , & baseVal ) ;
2006-09-21 08:45:36 +00:00
QVector < Page * > : : iterator it = pages_vector . begin ( ) , end = pages_vector . end ( ) ;
2005-02-20 16:04:40 +00:00
for ( ; it ! = end ; + + it )
{
// get page (from the first to the last)
2006-09-21 08:45:36 +00:00
Page * page = * it ;
2005-02-20 16:04:40 +00:00
int pageNumber = page - > number ( ) ;
// request search page if needed
if ( ! page - > hasSearchPage ( ) )
requestTextPage ( pageNumber ) ;
// loop on a page adding highlights for all found items
bool allMatched = wordsCount > 0 ,
anyMatched = false ;
for ( int w = 0 ; w < wordsCount ; w + + )
{
QString word = words [ w ] ;
int newHue = baseHue - w * hueStep ;
if ( newHue < 0 )
newHue + = 360 ;
2006-03-29 19:48:53 +00:00
QColor wordColor = QColor : : fromHsv ( newHue , baseSat , baseVal ) ;
2005-07-15 18:20:57 +00:00
RegularAreaRect * lastMatch = 0 ;
2005-02-20 16:04:40 +00:00
// add all highlights for current word
bool wordMatched = false ;
while ( 1 )
{
if ( lastMatch )
2006-05-27 10:06:31 +00:00
lastMatch = page - > findText ( searchID , word , NextRes , caseSensitive , lastMatch ) ;
2005-02-20 16:04:40 +00:00
else
2006-05-27 10:06:31 +00:00
lastMatch = page - > findText ( searchID , word , FromTop , caseSensitive ) ;
2005-02-20 16:04:40 +00:00
if ( ! lastMatch )
break ;
// add highligh rect to the page
page - > setHighlight ( searchID , lastMatch , wordColor ) ;
wordMatched = true ;
}
allMatched = allMatched & & wordMatched ;
anyMatched = anyMatched | | wordMatched ;
}
// if not all words are present in page, remove partial highlights
if ( ! allMatched & & matchAll )
page - > deleteHighlights ( searchID ) ;
// if page contains all words, udpate internals and queue page for notify
if ( ( allMatched & & matchAll ) | | ( anyMatched & & ! matchAll ) )
{
foundAMatch = true ;
s - > highlightedPages . append ( pageNumber ) ;
if ( ! pagesToNotify . contains ( pageNumber ) )
pagesToNotify . append ( pageNumber ) ;
}
}
// reset cursor to previous shape
QApplication : : restoreOverrideCursor ( ) ;
// send page lists to update observers (since some filter on bookmarks)
foreachObserver ( notifySetup ( pages_vector , false ) ) ;
2004-09-08 12:41:14 +00:00
}
2005-02-01 18:26:56 +00:00
2005-02-02 18:18:26 +00:00
// notify observers about highlights changes
2006-03-20 22:51:56 +00:00
QLinkedList < int > : : iterator nIt = pagesToNotify . begin ( ) , nEnd = pagesToNotify . end ( ) ;
2005-02-02 18:18:26 +00:00
for ( ; nIt ! = nEnd ; + + nIt )
foreachObserver ( notifyPageChanged ( * nIt , DocumentObserver : : Highlights ) ) ;
2005-02-01 18:26:56 +00:00
2005-02-02 18:18:26 +00:00
// return if search has found one or more matches
2005-02-01 18:26:56 +00:00
return foundAMatch ;
2004-09-08 12:41:14 +00:00
}
2006-09-21 08:45:36 +00:00
bool Document : : continueSearch ( int searchID )
2004-11-09 17:20:19 +00:00
{
2005-02-01 18:26:56 +00:00
// check if searchID is present in runningSearches
if ( ! d - > searches . contains ( searchID ) )
return false ;
2004-12-13 18:21:37 +00:00
2005-02-02 18:18:26 +00:00
// start search with cached parameters from last search by searchID
2005-02-01 18:26:56 +00:00
RunningSearch * p = d - > searches [ searchID ] ;
2005-02-02 18:18:26 +00:00
return searchText ( searchID , p - > cachedString , false , p - > cachedCaseSensitive ,
p - > cachedType , p - > cachedViewportMove , p - > cachedColor ,
p - > cachedNoDialogs ) ;
2004-11-09 17:20:19 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : resetSearch ( int searchID )
2005-02-01 18:26:56 +00:00
{
// check if searchID is present in runningSearches
if ( ! d - > searches . contains ( searchID ) )
return ;
// get previous parameters for search
RunningSearch * s = d - > searches [ searchID ] ;
// unhighlight pages and inform observers about that
2006-03-20 22:51:56 +00:00
QLinkedList < int > : : iterator it = s - > highlightedPages . begin ( ) , end = s - > highlightedPages . end ( ) ;
2005-02-01 18:26:56 +00:00
for ( ; it ! = end ; + + it )
{
int pageNumber = * it ;
pages_vector [ pageNumber ] - > deleteHighlights ( searchID ) ;
foreachObserver ( notifyPageChanged ( pageNumber , DocumentObserver : : Highlights ) ) ;
}
2005-02-02 18:18:26 +00:00
// send the setup signal too (to update views that filter on matches)
foreachObserver ( notifySetup ( pages_vector , false ) ) ;
2005-02-01 18:26:56 +00:00
// remove serch from the runningSearches list and delete it
d - > searches . remove ( searchID ) ;
delete s ;
}
2006-09-21 08:45:36 +00:00
bool Document : : continueLastSearch ( )
2006-07-11 19:57:17 +00:00
{
return continueSearch ( d - > m_lastSearchID ) ;
}
2005-02-01 18:26:56 +00:00
2006-09-21 08:45:36 +00:00
void Document : : toggleBookmark ( int n )
2004-11-09 17:20:19 +00:00
{
2006-09-21 08:45:36 +00:00
Page * page = ( n < ( int ) pages_vector . count ( ) ) ? pages_vector [ n ] : 0 ;
2004-11-09 17:20:19 +00:00
if ( page )
{
2005-02-01 18:26:56 +00:00
page - > setBookmark ( ! page - > hasBookmark ( ) ) ;
2005-01-09 23:37:07 +00:00
foreachObserver ( notifyPageChanged ( n , DocumentObserver : : Bookmark ) ) ;
2004-11-09 17:20:19 +00:00
}
}
2006-09-21 08:45:36 +00:00
void Document : : processLink ( const Link * link )
2004-09-08 12:41:14 +00:00
{
2004-10-06 00:05:49 +00:00
if ( ! link )
return ;
2004-12-10 16:04:45 +00:00
switch ( link - > linkType ( ) )
2004-10-06 00:05:49 +00:00
{
2006-09-21 08:45:36 +00:00
case Link : : Goto : {
const LinkGoto * go = static_cast < const LinkGoto * > ( link ) ;
2005-02-04 22:35:44 +00:00
d - > nextDocumentViewport = go - > destViewport ( ) ;
2005-06-13 11:53:47 +00:00
// Explanation of why d->nextDocumentViewport is needed:
2005-02-04 22:35:44 +00:00
// all openRelativeFile does is launch a signal telling we
// want to open another URL, the problem is that when the file is
// non local, the loading is done assynchronously so you can't
// do a setViewport after the if as it was because you are doing the setViewport
// on the old file and when the new arrives there is no setViewport for it and
// it does not show anything
2004-12-10 16:04:45 +00:00
// first open filename if link is pointing outside this document
if ( go - > isExternal ( ) & & ! openRelativeFile ( go - > fileName ( ) ) )
2004-10-06 00:05:49 +00:00
{
2006-03-20 22:51:56 +00:00
kWarning ( ) < < " Link: Error opening ' " < < go - > fileName ( ) < < " '. " < < endl ;
2004-10-06 00:05:49 +00:00
return ;
}
2005-02-08 15:24:23 +00:00
else
{
2005-06-13 17:44:33 +00:00
// skip local links that point to nowhere (broken ones)
if ( d - > nextDocumentViewport . pageNumber = = - 1 )
return ;
2005-06-13 11:53:47 +00:00
setViewport ( d - > nextDocumentViewport , - 1 , true ) ;
2005-02-08 15:24:23 +00:00
d - > nextDocumentViewport = DocumentViewport ( ) ;
}
2004-10-06 00:05:49 +00:00
2004-12-10 16:04:45 +00:00
} break ;
2006-09-21 08:45:36 +00:00
case Link : : Execute : {
const LinkExecute * exe = static_cast < const LinkExecute * > ( link ) ;
2004-12-10 16:04:45 +00:00
QString fileName = exe - > fileName ( ) ;
if ( fileName . endsWith ( " .pdf " ) | | fileName . endsWith ( " .PDF " ) )
2004-10-09 08:10:56 +00:00
{
2004-12-10 16:04:45 +00:00
openRelativeFile ( fileName ) ;
return ;
2004-10-09 08:10:56 +00:00
}
2004-12-10 16:04:45 +00:00
// Albert: the only pdf i have that has that kind of link don't define
// an application and use the fileName as the file to open
fileName = giveAbsolutePath ( fileName ) ;
KMimeType : : Ptr mime = KMimeType : : findByPath ( fileName ) ;
// Check executables
if ( KRun : : isExecutableFile ( fileName , mime - > name ( ) ) )
2004-10-09 08:10:56 +00:00
{
2004-12-10 16:04:45 +00:00
// Don't have any pdf that uses this code path, just a guess on how it should work
if ( ! exe - > parameters ( ) . isEmpty ( ) )
{
fileName = giveAbsolutePath ( exe - > parameters ( ) ) ;
mime = KMimeType : : findByPath ( fileName ) ;
if ( KRun : : isExecutableFile ( fileName , mime - > name ( ) ) )
{
// this case is a link pointing to an executable with a parameter
// that also is an executable, possibly a hand-crafted pdf
2006-06-12 18:25:18 +00:00
KMessageBox : : information ( 0 , i18n ( " The pdf file is trying to execute an external application and for your safety okular does not allow that. " ) ) ;
2004-12-10 16:04:45 +00:00
return ;
}
}
else
{
// this case is a link pointing to an executable with no parameters
// core developers find unacceptable executing it even after asking the user
2006-06-12 18:25:18 +00:00
KMessageBox : : information ( 0 , i18n ( " The pdf file is trying to execute an external application and for your safety okular does not allow that. " ) ) ;
2004-12-10 16:04:45 +00:00
return ;
}
}
2006-05-22 14:02:24 +00:00
KService : : Ptr ptr = KMimeTypeTrader : : self ( ) - > preferredService ( mime - > name ( ) , " Application " ) ;
2004-12-10 16:04:45 +00:00
if ( ptr )
{
2006-03-20 22:51:56 +00:00
KUrl : : List lst ;
2004-12-10 16:04:45 +00:00
lst . append ( fileName ) ;
2006-05-22 14:02:24 +00:00
KRun : : run ( * ptr , lst , 0 ) ;
2004-12-10 16:04:45 +00:00
}
else
2006-04-10 19:50:00 +00:00
KMessageBox : : information ( 0 , i18n ( " No application found for opening file of mimetype %1. " , mime - > name ( ) ) ) ;
2004-12-10 16:04:45 +00:00
} break ;
2006-09-21 08:45:36 +00:00
case Link : : Action : {
const LinkAction * action = static_cast < const LinkAction * > ( link ) ;
2004-12-10 16:04:45 +00:00
switch ( action - > actionType ( ) )
{
2006-09-21 08:45:36 +00:00
case LinkAction : : PageFirst :
2005-01-09 23:37:07 +00:00
setViewportPage ( 0 ) ;
2004-12-10 16:04:45 +00:00
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : PagePrev :
2005-01-27 17:31:07 +00:00
if ( ( * d - > viewportIterator ) . pageNumber > 0 )
setViewportPage ( ( * d - > viewportIterator ) . pageNumber - 1 ) ;
2004-12-10 16:04:45 +00:00
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : PageNext :
2005-01-27 17:31:07 +00:00
if ( ( * d - > viewportIterator ) . pageNumber < ( int ) pages_vector . count ( ) - 1 )
setViewportPage ( ( * d - > viewportIterator ) . pageNumber + 1 ) ;
2004-12-10 16:04:45 +00:00
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : PageLast :
2005-01-09 23:37:07 +00:00
setViewportPage ( pages_vector . count ( ) - 1 ) ;
2004-12-10 16:04:45 +00:00
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : HistoryBack :
2005-01-27 17:31:07 +00:00
setPrevViewport ( ) ;
2004-12-10 16:04:45 +00:00
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : HistoryForward :
2005-01-27 17:31:07 +00:00
setNextViewport ( ) ;
2004-12-10 16:04:45 +00:00
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : Quit :
2005-11-04 11:59:51 +00:00
emit quit ( ) ;
2004-12-10 16:04:45 +00:00
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : Presentation :
2005-04-07 09:53:15 +00:00
emit linkPresentation ( ) ;
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : EndPresentation :
2005-04-07 09:53:15 +00:00
emit linkEndPresentation ( ) ;
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : Find :
2005-01-01 21:50:34 +00:00
emit linkFind ( ) ;
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : GoToPage :
2005-01-01 21:50:34 +00:00
emit linkGoToPage ( ) ;
break ;
2006-09-21 08:45:36 +00:00
case LinkAction : : Close :
2005-11-04 11:59:51 +00:00
emit close ( ) ;
break ;
2004-12-10 16:04:45 +00:00
}
} break ;
2006-09-21 08:45:36 +00:00
case Link : : Browse : {
const LinkBrowse * browse = static_cast < const LinkBrowse * > ( link ) ;
2005-01-27 17:31:07 +00:00
// if the url is a mailto one, invoke mailer
2006-03-29 16:46:09 +00:00
if ( browse - > url ( ) . startsWith ( " mailto: " , Qt : : CaseInsensitive ) )
2006-03-21 20:00:24 +00:00
KToolInvocation : : invokeMailer ( browse - > url ( ) ) ;
2005-01-27 17:31:07 +00:00
else
{
2005-03-05 15:59:15 +00:00
QString url = browse - > url ( ) ;
// fix for #100366, documents with relative links that are the form of http:foo.pdf
2006-03-29 19:48:53 +00:00
if ( url . indexOf ( " http: " ) = = 0 & & url . indexOf ( " http:// " ) = = - 1 & & url . right ( 4 ) = = " .pdf " )
2005-03-05 15:59:15 +00:00
{
openRelativeFile ( url . mid ( 5 ) ) ;
return ;
}
2006-07-09 14:38:35 +00:00
// Albert: this is not a leak!
// TODO: find a widget to pass as second parameter
new KRun ( KUrl ( url ) , 0 ) ;
2005-01-27 17:31:07 +00:00
}
2004-12-10 16:04:45 +00:00
} break ;
2006-09-21 08:45:36 +00:00
case Link : : Movie :
//const LinkMovie * browse = static_cast< const LinkMovie * >( link );
2005-01-27 17:31:07 +00:00
// TODO this (Movie link)
2004-12-10 16:04:45 +00:00
break ;
2004-10-06 00:05:49 +00:00
}
2004-09-09 13:25:40 +00:00
}
2004-11-09 17:20:19 +00:00
2006-11-17 22:15:15 +00:00
void Document : : processSourceReference ( const SourceReference * ref )
{
if ( ! ref )
return ;
2006-11-18 15:16:16 +00:00
if ( ! QFile : : exists ( ref - > fileName ( ) ) )
{
kDebug ( ) < < " No such file: ' " < < ref - > fileName ( ) < < " ' " < < endl ;
return ;
}
2006-11-17 22:15:15 +00:00
static QHash < int , QString > editors ;
// init the editors table if empty (on first run, usually)
if ( editors . isEmpty ( ) )
{
editors [ Settings : : EnumExternalEditor : : Kate ] =
QLatin1String ( " kate --use --line %l --column %c " ) ;
editors [ Settings : : EnumExternalEditor : : Scite ] =
QLatin1String ( " scite %f \" -goto:%l,%c \" " ) ;
}
QHash < int , QString > : : iterator it = editors . find ( Settings : : externalEditor ( ) ) ;
QString p ;
if ( it ! = editors . end ( ) )
p = * it ;
else
p = Settings : : externalEditorCommand ( ) ;
// custom editor not yet configured
if ( p . isEmpty ( ) )
return ;
// replacing the placeholders
p . replace ( QLatin1String ( " %l " ) , QString : : number ( ref - > row ( ) ) ) ;
p . replace ( QLatin1String ( " %c " ) , QString : : number ( ref - > column ( ) ) ) ;
if ( p . indexOf ( QLatin1String ( " %f " ) ) > - 1 )
p . replace ( QLatin1String ( " %f " ) , ref - > fileName ( ) ) ;
else
p . append ( QLatin1String ( " " ) + ref - > fileName ( ) ) ;
// paranoic checks
if ( p . isEmpty ( ) | | p . trimmed ( ) = = ref - > fileName ( ) )
return ;
QProcess : : startDetached ( p ) ;
}
2006-09-21 08:45:36 +00:00
bool Document : : print ( KPrinter & printer )
2004-11-09 17:20:19 +00:00
{
2004-12-10 16:04:45 +00:00
return generator ? generator - > print ( printer ) : false ;
2004-11-09 17:20:19 +00:00
}
2004-12-10 16:04:45 +00:00
2006-09-21 08:45:36 +00:00
void Document : : requestDone ( PixmapRequest * req )
2005-01-18 16:43:36 +00:00
{
# ifndef NDEBUG
2006-10-25 15:35:53 +00:00
if ( ! generator - > canGeneratePixmap ( req - > asynchronous ( ) ) )
2006-03-20 22:51:56 +00:00
kDebug ( ) < < " requestDone with generator not in READY state. " < < endl ;
2005-01-18 16:43:36 +00:00
# endif
2005-01-20 17:33:05 +00:00
// [MEM] 1.1 find and remove a previous entry for the same page and id
2006-03-20 22:51:56 +00:00
QLinkedList < AllocatedPixmap * > : : iterator aIt = d - > allocatedPixmapsFifo . begin ( ) ;
QLinkedList < AllocatedPixmap * > : : iterator aEnd = d - > allocatedPixmapsFifo . end ( ) ;
2005-01-20 17:33:05 +00:00
for ( ; aIt ! = aEnd ; + + aIt )
2006-10-25 15:35:53 +00:00
if ( ( * aIt ) - > page = = req - > pageNumber ( ) & & ( * aIt ) - > id = = req - > id ( ) )
2005-01-20 17:33:05 +00:00
{
AllocatedPixmap * p = * aIt ;
2006-03-29 16:46:09 +00:00
d - > allocatedPixmapsFifo . erase ( aIt ) ;
2005-01-20 17:33:05 +00:00
d - > allocatedPixmapsTotalMemory - = p - > memory ;
delete p ;
break ;
}
// [MEM] 1.2 append memory allocation descriptor to the FIFO
2006-10-25 15:35:53 +00:00
int memoryBytes = 4 * req - > width ( ) * req - > height ( ) ;
AllocatedPixmap * memoryPage = new AllocatedPixmap ( req - > id ( ) , req - > pageNumber ( ) , memoryBytes ) ;
2005-01-20 17:33:05 +00:00
d - > allocatedPixmapsFifo . append ( memoryPage ) ;
d - > allocatedPixmapsTotalMemory + = memoryBytes ;
// 2. notify an observer that its pixmap changed
2006-10-25 15:35:53 +00:00
if ( d - > observers . contains ( req - > id ( ) ) )
d - > observers [ req - > id ( ) ] - > notifyPageChanged ( req - > pageNumber ( ) , DocumentObserver : : Pixmap ) ;
2005-01-20 17:33:05 +00:00
// 3. delete request
delete req ;
// 4. start a new generation if some is pending
if ( ! d - > pixmapRequestsStack . isEmpty ( ) )
sendGeneratorRequest ( ) ;
2005-01-18 16:43:36 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : sendGeneratorRequest ( )
2005-01-18 16:43:36 +00:00
{
// find a request
PixmapRequest * request = 0 ;
while ( ! d - > pixmapRequestsStack . isEmpty ( ) & & ! request )
{
PixmapRequest * r = d - > pixmapRequestsStack . last ( ) ;
2006-05-24 09:05:32 +00:00
if ( ! r )
{
d - > pixmapRequestsStack . pop_back ( ) ;
}
2006-02-15 21:02:13 +00:00
// request only if page isn't already present or request has invalid id
2006-11-03 17:57:32 +00:00
else if ( r - > page ( ) - > hasImage ( r - > id ( ) , r - > width ( ) , r - > height ( ) ) | | r - > id ( ) < = 0 | | r - > id ( ) > = MAX_OBSERVER_ID )
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
{
d - > pixmapRequestsStack . pop_back ( ) ;
2005-01-18 16:43:36 +00:00
delete r ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
}
2006-10-25 15:35:53 +00:00
else if ( ( long ) r - > width ( ) * ( long ) r - > height ( ) > 20000000L )
2005-04-07 20:26:49 +00:00
{
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
d - > pixmapRequestsStack . pop_back ( ) ;
2005-04-07 20:26:49 +00:00
if ( ! d - > warnedOutOfMemory )
{
2006-10-25 15:35:53 +00:00
kWarning ( ) < < " Running out of memory on page " < < r - > pageNumber ( )
< < " ( " < < r - > width ( ) < < " x " < < r - > height ( ) < < " px); " < < endl ;
2006-03-20 22:51:56 +00:00
kWarning ( ) < < " this message will be reported only once. " < < endl ;
2005-04-07 20:26:49 +00:00
d - > warnedOutOfMemory = true ;
}
2006-10-25 15:35:53 +00:00
delete r ;
2005-04-07 20:26:49 +00:00
}
else
request = r ;
2005-01-18 16:43:36 +00:00
}
// if no request found (or already generated), return
if ( ! request )
return ;
2005-01-20 17:33:05 +00:00
// [MEM] preventive memory freeing
2006-10-25 15:35:53 +00:00
int pixmapBytes = 4 * request - > width ( ) * request - > height ( ) ;
2005-01-20 17:33:05 +00:00
if ( pixmapBytes > ( 1024 * 1024 ) )
2005-01-21 20:05:36 +00:00
cleanupPixmapMemory ( pixmapBytes ) ;
2005-01-18 16:43:36 +00:00
// submit the request to the generator
2006-10-25 15:35:53 +00:00
if ( generator - > canGeneratePixmap ( request - > asynchronous ( ) ) )
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
{
2006-10-25 15:35:53 +00:00
kWarning ( ) < < " sending request id= " < < request - > id ( ) < < " " < < request - > width ( ) < < " x " < < request - > height ( ) < < " @ " < < request - > pageNumber ( ) < < " async == " < < request - > asynchronous ( ) < < endl ;
2006-03-21 20:00:24 +00:00
d - > pixmapRequestsStack . removeAll ( request ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
generator - > generatePixmap ( request ) ;
}
else
2006-07-04 17:54:05 +00:00
// pino (7/4/2006): set the polling interval from 10 to 30
QTimer : : singleShot ( 30 , this , SLOT ( sendGeneratorRequest ( ) ) ) ;
2005-01-18 16:43:36 +00:00
}
2004-09-08 12:41:14 +00:00
2006-10-15 19:37:14 +00:00
QString Document : : pagesSizeString ( ) const
{
if ( generator )
{
if ( generator - > pagesSizeMetric ( ) ! = Generator : : None )
{
QSizeF size = allPagesSize ( ) ;
if ( size . isValid ( ) ) return localizedSize ( size ) ;
else return QString ( ) ;
}
else return QString ( ) ;
}
else return QString ( ) ;
}
QString Document : : localizedSize ( const QSizeF & size ) const
{
double inchesWidth , inchesHeight ;
switch ( generator - > pagesSizeMetric ( ) )
{
case Generator : : Points :
inchesWidth = size . width ( ) / 72.0 ;
inchesHeight = size . height ( ) / 72.0 ;
break ;
case Generator : : None :
break ;
}
if ( KGlobal : : locale ( ) - > measureSystem ( ) = = KLocale : : Imperial )
{
return i18n ( " %1 x %2 in " , inchesWidth , inchesHeight ) ;
}
else
{
return i18n ( " %1 x %2 mm " , inchesWidth * 25.4 , inchesHeight * 25.4 ) ;
}
}
2006-09-21 08:45:36 +00:00
void Document : : cleanupPixmapMemory ( int /*sure? bytesOffset*/ )
2004-12-22 18:21:36 +00:00
{
2005-01-21 20:05:36 +00:00
// [MEM] choose memory parameters based on configuration profile
2005-01-20 17:33:05 +00:00
int clipValue = - 1 ;
int memoryToFree = - 1 ;
2006-09-21 08:45:36 +00:00
switch ( Settings : : memoryLevel ( ) )
2004-12-22 18:21:36 +00:00
{
2006-09-21 08:45:36 +00:00
case Settings : : EnumMemoryLevel : : Low :
2005-01-20 17:33:05 +00:00
memoryToFree = d - > allocatedPixmapsTotalMemory ;
2004-12-22 18:21:36 +00:00
break ;
2006-09-21 08:45:36 +00:00
case Settings : : EnumMemoryLevel : : Normal :
2005-01-21 20:05:36 +00:00
memoryToFree = d - > allocatedPixmapsTotalMemory - getTotalMemory ( ) / 3 ;
clipValue = ( d - > allocatedPixmapsTotalMemory - getFreeMemory ( ) ) / 2 ;
2004-12-22 18:21:36 +00:00
break ;
2006-09-21 08:45:36 +00:00
case Settings : : EnumMemoryLevel : : Aggressive :
2005-01-21 20:05:36 +00:00
clipValue = ( d - > allocatedPixmapsTotalMemory - getFreeMemory ( ) ) / 2 ;
2004-12-22 18:21:36 +00:00
break ;
}
2004-12-24 10:24:10 +00:00
if ( clipValue > memoryToFree )
memoryToFree = clipValue ;
2005-01-20 17:33:05 +00:00
if ( memoryToFree > 0 )
2004-12-22 18:21:36 +00:00
{
2005-01-21 20:05:36 +00:00
// [MEM] free memory starting from older pixmaps
int pagesFreed = 0 ;
2006-03-20 22:51:56 +00:00
QLinkedList < AllocatedPixmap * > : : iterator pIt = d - > allocatedPixmapsFifo . begin ( ) ;
QLinkedList < AllocatedPixmap * > : : iterator pEnd = d - > allocatedPixmapsFifo . end ( ) ;
2005-01-21 20:05:36 +00:00
while ( ( pIt ! = pEnd ) & & ( memoryToFree > 0 ) )
2004-12-22 18:21:36 +00:00
{
2005-01-21 20:05:36 +00:00
AllocatedPixmap * p = * pIt ;
if ( d - > observers [ p - > id ] - > canUnloadPixmap ( p - > page ) )
{
// update internal variables
2006-03-29 16:46:09 +00:00
pIt = d - > allocatedPixmapsFifo . erase ( pIt ) ;
2005-01-21 20:05:36 +00:00
d - > allocatedPixmapsTotalMemory - = p - > memory ;
memoryToFree - = p - > memory ;
pagesFreed + + ;
// delete pixmap
2006-11-03 17:57:32 +00:00
pages_vector [ p - > page ] - > deleteImage ( p - > id ) ;
2005-01-21 20:05:36 +00:00
// delete allocation descriptor
delete p ;
} else
+ + pIt ;
}
//p--rintf("freeMemory A:[%d -%d = %d] \n", d->allocatedPixmapsFifo.count() + pagesFreed, pagesFreed, d->allocatedPixmapsFifo.count() );
2004-12-22 18:21:36 +00:00
}
}
2006-09-21 08:45:36 +00:00
int Document : : getTotalMemory ( )
2004-12-21 12:38:52 +00:00
{
2004-12-22 18:21:36 +00:00
static int cachedValue = 0 ;
if ( cachedValue )
return cachedValue ;
2004-12-21 12:38:52 +00:00
# ifdef __linux__
// if /proc/meminfo doesn't exist, return 128MB
QFile memFile ( " /proc/meminfo " ) ;
2006-05-15 21:31:53 +00:00
if ( ! memFile . open ( QIODevice : : ReadOnly ) )
2005-01-20 17:33:05 +00:00
return ( cachedValue = 134217728 ) ;
2004-12-21 12:38:52 +00:00
// read /proc/meminfo and sum up the contents of 'MemFree', 'Buffers'
// and 'Cached' fields. consider swapped memory as used memory.
QTextStream readStream ( & memFile ) ;
while ( ! readStream . atEnd ( ) )
{
QString entry = readStream . readLine ( ) ;
if ( entry . startsWith ( " MemTotal: " ) )
2005-01-20 17:33:05 +00:00
return ( cachedValue = ( 1024 * entry . section ( ' ' , - 2 , - 2 ) . toInt ( ) ) ) ;
2004-12-21 12:38:52 +00:00
}
# endif
2005-01-20 17:33:05 +00:00
return ( cachedValue = 134217728 ) ;
2004-12-21 12:38:52 +00:00
}
2006-09-21 08:45:36 +00:00
int Document : : getFreeMemory ( )
2004-12-21 12:38:52 +00:00
{
2006-11-15 19:39:39 +00:00
static QTime lastUpdate = QTime : : currentTime ( ) ;
static int cachedValue = 0 ;
if ( lastUpdate . secsTo ( QTime : : currentTime ( ) ) < = 2 )
return cachedValue ;
2004-12-21 12:38:52 +00:00
# ifdef __linux__
2004-12-24 10:24:10 +00:00
// if /proc/meminfo doesn't exist, return MEMORY FULL
2004-12-21 12:38:52 +00:00
QFile memFile ( " /proc/meminfo " ) ;
2006-05-15 21:31:53 +00:00
if ( ! memFile . open ( QIODevice : : ReadOnly ) )
2004-12-24 10:24:10 +00:00
return 0 ;
2004-12-21 12:38:52 +00:00
// read /proc/meminfo and sum up the contents of 'MemFree', 'Buffers'
// and 'Cached' fields. consider swapped memory as used memory.
int memoryFree = 0 ;
QString entry ;
QTextStream readStream ( & memFile ) ;
while ( ! readStream . atEnd ( ) )
{
entry = readStream . readLine ( ) ;
if ( entry . startsWith ( " MemFree: " ) | |
entry . startsWith ( " Buffers: " ) | |
entry . startsWith ( " Cached: " ) | |
entry . startsWith ( " SwapFree: " ) )
memoryFree + = entry . section ( ' ' , - 2 , - 2 ) . toInt ( ) ;
if ( entry . startsWith ( " SwapTotal: " ) )
memoryFree - = entry . section ( ' ' , - 2 , - 2 ) . toInt ( ) ;
}
memFile . close ( ) ;
2006-11-15 19:39:39 +00:00
lastUpdate = QTime : : currentTime ( ) ;
return ( cachedValue = ( 1024 * memoryFree ) ) ;
2004-12-21 12:38:52 +00:00
# else
2004-12-24 10:24:10 +00:00
// tell the memory is full.. will act as in LOW profile
return 0 ;
2004-12-21 12:38:52 +00:00
# endif
}
2006-09-21 08:45:36 +00:00
void Document : : loadDocumentInfo ( )
2005-01-03 15:51:05 +00:00
// note: load data and stores it internally (document or pages). observers
// are still uninitialized at this point so don't access them
2005-01-03 00:28:46 +00:00
{
2006-03-20 22:51:56 +00:00
//kDebug() << "Using '" << d->xmlFileName << "' as document info file." << endl;
2005-01-13 11:03:48 +00:00
QFile infoFile ( d - > xmlFileName ) ;
2006-05-15 21:31:53 +00:00
if ( ! infoFile . exists ( ) | | ! infoFile . open ( QIODevice : : ReadOnly ) )
2005-01-28 17:21:51 +00:00
return ;
// Load DOM from XML file
QDomDocument doc ( " documentInfo " ) ;
if ( ! doc . setContent ( & infoFile ) )
2005-01-03 00:28:46 +00:00
{
2006-03-20 22:51:56 +00:00
kDebug ( ) < < " Can't load XML pair! Check for broken xml. " < < endl ;
2005-01-28 17:21:51 +00:00
infoFile . close ( ) ;
return ;
}
infoFile . close ( ) ;
2005-01-03 00:28:46 +00:00
2005-01-28 17:21:51 +00:00
QDomElement root = doc . documentElement ( ) ;
if ( root . tagName ( ) ! = " documentInfo " )
return ;
2005-01-03 00:28:46 +00:00
2005-01-28 17:21:51 +00:00
// Parse the DOM tree
QDomNode topLevelNode = root . firstChild ( ) ;
while ( topLevelNode . isElement ( ) )
{
QString catName = topLevelNode . toElement ( ) . tagName ( ) ;
2005-01-03 00:28:46 +00:00
2005-03-13 13:14:44 +00:00
// Restore page attributes (bookmark, annotations, ...) from the DOM
if ( catName = = " pageList " )
2005-01-28 17:21:51 +00:00
{
2005-03-13 13:14:44 +00:00
QDomNode pageNode = topLevelNode . firstChild ( ) ;
while ( pageNode . isElement ( ) )
2005-01-03 15:51:05 +00:00
{
2005-03-13 13:14:44 +00:00
QDomElement pageElement = pageNode . toElement ( ) ;
if ( pageElement . hasAttribute ( " number " ) )
2005-01-03 15:51:05 +00:00
{
2005-03-13 13:14:44 +00:00
// get page number (node's attribute)
bool ok ;
int pageNumber = pageElement . attribute ( " number " ) . toInt ( & ok ) ;
// pass the domElement to the right page, to read config data from
2005-01-28 17:21:51 +00:00
if ( ok & & pageNumber > = 0 & & pageNumber < ( int ) pages_vector . count ( ) )
2005-03-13 13:14:44 +00:00
pages_vector [ pageNumber ] - > restoreLocalContents ( pageElement ) ;
2005-01-03 15:51:05 +00:00
}
2005-03-13 13:14:44 +00:00
pageNode = pageNode . nextSibling ( ) ;
2005-01-03 00:28:46 +00:00
}
2005-03-13 13:14:44 +00:00
}
// Restore 'general info' from the DOM
2005-01-28 17:21:51 +00:00
else if ( catName = = " generalInfo " )
{
QDomNode infoNode = topLevelNode . firstChild ( ) ;
while ( infoNode . isElement ( ) )
2005-01-03 15:51:05 +00:00
{
2005-01-28 17:21:51 +00:00
QDomElement infoElement = infoNode . toElement ( ) ;
// compatibility: [pre-3.4 viewport storage] @remove after 3.4 relase
if ( infoElement . tagName ( ) = = " activePage " )
2005-01-03 15:51:05 +00:00
{
2005-01-28 17:21:51 +00:00
if ( infoElement . hasAttribute ( " viewport " ) )
* d - > viewportIterator = DocumentViewport ( infoElement . attribute ( " viewport " ) ) ;
}
// restore viewports history
if ( infoElement . tagName ( ) = = " history " )
{
// clear history
d - > viewportHistory . clear ( ) ;
// append old viewports
QDomNode historyNode = infoNode . firstChild ( ) ;
while ( historyNode . isElement ( ) )
2005-01-03 15:51:05 +00:00
{
2005-01-28 17:21:51 +00:00
QDomElement historyElement = historyNode . toElement ( ) ;
if ( historyElement . hasAttribute ( " viewport " ) )
{
QString vpString = historyElement . attribute ( " viewport " ) ;
2006-03-21 20:00:24 +00:00
d - > viewportIterator = d - > viewportHistory . insert ( d - > viewportHistory . end ( ) ,
2005-01-28 17:21:51 +00:00
DocumentViewport ( vpString ) ) ;
}
historyNode = historyNode . nextSibling ( ) ;
2005-01-03 15:51:05 +00:00
}
2005-01-28 17:21:51 +00:00
// consistancy check
if ( d - > viewportHistory . isEmpty ( ) )
2006-03-21 20:00:24 +00:00
d - > viewportIterator = d - > viewportHistory . insert ( d - > viewportHistory . end ( ) , DocumentViewport ( ) ) ;
2005-01-03 15:51:05 +00:00
}
2005-01-28 17:21:51 +00:00
infoNode = infoNode . nextSibling ( ) ;
2005-01-03 15:51:05 +00:00
}
2005-03-13 13:14:44 +00:00
}
2005-01-28 17:21:51 +00:00
topLevelNode = topLevelNode . nextSibling ( ) ;
} // </documentInfo>
2005-01-03 00:28:46 +00:00
}
2006-09-21 08:45:36 +00:00
QString Document : : giveAbsolutePath ( const QString & fileName )
2004-10-17 18:40:02 +00:00
{
2005-02-04 22:35:44 +00:00
if ( ! d - > url . isValid ( ) )
2006-11-18 21:36:56 +00:00
return QString ( ) ;
2005-03-13 13:14:44 +00:00
2006-05-22 14:02:24 +00:00
return d - > url . upUrl ( ) . url ( ) + fileName ;
2004-10-17 18:40:02 +00:00
}
2006-09-21 08:45:36 +00:00
bool Document : : openRelativeFile ( const QString & fileName )
2004-10-06 00:05:49 +00:00
{
2004-10-17 18:40:02 +00:00
QString absFileName = giveAbsolutePath ( fileName ) ;
2006-05-13 11:17:24 +00:00
if ( absFileName . isEmpty ( ) )
2004-10-06 00:05:49 +00:00
return false ;
2006-03-20 22:51:56 +00:00
kDebug ( ) < < " openDocument: ' " < < absFileName < < " ' " < < endl ;
2004-10-06 00:05:49 +00:00
2006-08-30 13:02:48 +00:00
emit openUrl ( absFileName ) ;
2005-02-04 22:35:44 +00:00
return true ;
2004-10-06 00:05:49 +00:00
}
2004-12-24 10:24:10 +00:00
2006-09-21 08:45:36 +00:00
void Document : : saveDocumentInfo ( ) const
2005-01-03 00:28:46 +00:00
{
2006-05-13 11:17:24 +00:00
if ( d - > docFileName . isEmpty ( ) )
2005-01-13 11:03:48 +00:00
return ;
2005-01-03 00:28:46 +00:00
2005-01-13 11:03:48 +00:00
QFile infoFile ( d - > xmlFileName ) ;
2006-06-03 13:01:15 +00:00
if ( infoFile . open ( QIODevice : : WriteOnly | QIODevice : : Truncate ) )
2005-01-03 00:28:46 +00:00
{
2005-03-13 13:14:44 +00:00
// 1. Create DOM
2005-01-03 00:28:46 +00:00
QDomDocument doc ( " documentInfo " ) ;
QDomElement root = doc . createElement ( " documentInfo " ) ;
doc . appendChild ( root ) ;
2005-03-13 13:14:44 +00:00
// 2.1. Save page attributes (bookmark state, annotations, ... ) to DOM
QDomElement pageList = doc . createElement ( " pageList " ) ;
root . appendChild ( pageList ) ;
// <page list><page number='x'>.... </page> save pages that hold data
2006-09-21 08:45:36 +00:00
QVector < Page * > : : const_iterator pIt = pages_vector . begin ( ) , pEnd = pages_vector . end ( ) ;
2005-03-13 13:14:44 +00:00
for ( ; pIt ! = pEnd ; + + pIt )
( * pIt ) - > saveLocalContents ( pageList , doc ) ;
2005-01-03 00:28:46 +00:00
2005-03-13 13:14:44 +00:00
// 2.2. Save document info (current viewport, history, ... ) to DOM
2005-01-03 15:51:05 +00:00
QDomElement generalInfo = doc . createElement ( " generalInfo " ) ;
root . appendChild ( generalInfo ) ;
2005-03-13 13:14:44 +00:00
// <general info><history> ... </history> save history up to 10 viewports
2006-03-20 22:51:56 +00:00
QLinkedList < DocumentViewport > : : iterator backIterator = d - > viewportIterator ;
2005-01-28 17:21:51 +00:00
if ( backIterator ! = d - > viewportHistory . end ( ) )
2005-01-27 17:31:07 +00:00
{
2005-01-28 17:21:51 +00:00
// go back up to 10 steps from the current viewportIterator
int backSteps = 10 ;
while ( backSteps - - & & backIterator ! = d - > viewportHistory . begin ( ) )
- - backIterator ;
// create history root node
QDomElement historyNode = doc . createElement ( " history " ) ;
generalInfo . appendChild ( historyNode ) ;
// add old[backIterator] and present[viewportIterator] items
2006-03-20 22:51:56 +00:00
QLinkedList < DocumentViewport > : : iterator endIt = d - > viewportIterator ;
2005-01-28 17:21:51 +00:00
+ + endIt ;
while ( backIterator ! = endIt )
{
QString name = ( backIterator = = d - > viewportIterator ) ? " current " : " oldPage " ;
QDomElement historyEntry = doc . createElement ( name ) ;
historyEntry . setAttribute ( " viewport " , ( * backIterator ) . toString ( ) ) ;
historyNode . appendChild ( historyEntry ) ;
+ + backIterator ;
}
2005-01-27 17:31:07 +00:00
}
2005-01-28 17:21:51 +00:00
2005-03-13 13:14:44 +00:00
// 3. Save DOM to XML file
2005-01-03 00:28:46 +00:00
QString xml = doc . toString ( ) ;
QTextStream os ( & infoFile ) ;
os < < xml ;
}
infoFile . close ( ) ;
}
2006-09-21 08:45:36 +00:00
void Document : : slotTimedMemoryCheck ( )
2004-12-24 10:24:10 +00:00
{
2005-01-20 17:33:05 +00:00
// [MEM] clean memory (for 'free mem dependant' profiles only)
2006-09-21 08:45:36 +00:00
if ( Settings : : memoryLevel ( ) ! = Settings : : EnumMemoryLevel : : Low & &
2005-01-20 17:33:05 +00:00
d - > allocatedPixmapsTotalMemory > 1024 * 1024 )
2005-01-21 20:05:36 +00:00
cleanupPixmapMemory ( ) ;
2004-12-24 10:24:10 +00:00
}
2006-09-21 08:45:36 +00:00
void Document : : slotRotation ( int rotation )
2005-11-04 11:59:51 +00:00
{
2006-10-25 15:35:53 +00:00
// tell the pages to rotate
QVector < Okular : : Page * > : : iterator pIt = pages_vector . begin ( ) ;
QVector < Okular : : Page * > : : iterator pEnd = pages_vector . end ( ) ;
for ( ; pIt ! = pEnd ; + + pIt )
( * pIt ) - > rotateAt ( rotation ) ;
// clear 'memory allocation' descriptors
QLinkedList < AllocatedPixmap * > : : iterator aIt = d - > allocatedPixmapsFifo . begin ( ) ;
QLinkedList < AllocatedPixmap * > : : iterator aEnd = d - > allocatedPixmapsFifo . end ( ) ;
for ( ; aIt ! = aEnd ; + + aIt )
delete * aIt ;
d - > allocatedPixmapsFifo . clear ( ) ;
d - > allocatedPixmapsTotalMemory = 0 ;
// notify the generator that the current rotation has changed
generator - > rotationChanged ( rotation , d - > rotation ) ;
// set the new rotation
d - > rotation = rotation ;
foreachObserver ( notifySetup ( pages_vector , true ) ) ;
foreachObserver ( notifyContentsCleared ( DocumentObserver : : Pixmap | DocumentObserver : : Highlights | DocumentObserver : : Annotations ) ) ;
kDebug ( ) < < " Rotated: " < < rotation < < endl ;
/*
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
if ( generator - > supportsRotation ( ) )
2005-11-04 11:59:51 +00:00
{
2006-10-08 15:07:23 +00:00
// tell the pages to rotate
QVector < Okular : : Page * > : : iterator pIt = pages_vector . begin ( ) ;
QVector < Okular : : Page * > : : iterator pEnd = pages_vector . end ( ) ;
for ( ; pIt ! = pEnd ; + + pIt )
( * pIt ) - > rotateAt ( rotation ) ;
// clear 'memory allocation' descriptors
QLinkedList < AllocatedPixmap * > : : iterator aIt = d - > allocatedPixmapsFifo . begin ( ) ;
QLinkedList < AllocatedPixmap * > : : iterator aEnd = d - > allocatedPixmapsFifo . end ( ) ;
for ( ; aIt ! = aEnd ; + + aIt )
delete * aIt ;
d - > allocatedPixmapsFifo . clear ( ) ;
d - > allocatedPixmapsTotalMemory = 0 ;
// notify the generator that the current rotation has changed
generator - > rotationChanged ( rotation , d - > rotation ) ;
// set the new rotation
2006-06-02 20:42:57 +00:00
d - > rotation = rotation ;
2006-10-08 15:07:23 +00:00
2005-11-04 11:59:51 +00:00
foreachObserver ( notifySetup ( pages_vector , true ) ) ;
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
foreachObserver ( notifyContentsCleared ( DocumentObserver : : Pixmap | DocumentObserver : : Highlights | DocumentObserver : : Annotations ) ) ;
2006-10-25 15:35:53 +00:00
// foreachObserver( notifyViewportChanged( false ));
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
// foreachObserver( notifyPageChanged( ) );
2006-06-02 20:42:57 +00:00
kDebug ( ) < < " Rotated: " < < rotation < < endl ;
2005-11-04 11:59:51 +00:00
}
2006-10-25 15:35:53 +00:00
*/
2005-11-04 11:59:51 +00:00
}
2005-01-09 23:37:07 +00:00
2006-09-21 08:45:36 +00:00
void Document : : slotPaperSizes ( int newsize )
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
{
if ( generator - > supportsPaperSizes ( ) )
{
generator - > setPaperSize ( pages_vector , newsize ) ;
foreachObserver ( notifySetup ( pages_vector , true ) ) ;
2006-03-20 22:51:56 +00:00
kDebug ( ) < < " PaperSize no: " < < newsize < < endl ;
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
}
}
2005-01-09 23:37:07 +00:00
/** DocumentViewport **/
DocumentViewport : : DocumentViewport ( int n )
: pageNumber ( n )
{
// default settings
2005-06-13 11:53:47 +00:00
rePos . enabled = false ;
rePos . normalizedX = 0.5 ;
rePos . normalizedY = 0.0 ;
rePos . pos = Center ;
2005-01-09 23:37:07 +00:00
autoFit . enabled = false ;
autoFit . width = false ;
autoFit . height = false ;
}
DocumentViewport : : DocumentViewport ( const QString & xmlDesc )
: pageNumber ( - 1 )
{
// default settings (maybe overridden below)
2005-06-13 11:53:47 +00:00
rePos . enabled = false ;
rePos . normalizedX = 0.5 ;
rePos . normalizedY = 0.0 ;
rePos . pos = Center ;
2005-01-09 23:37:07 +00:00
autoFit . enabled = false ;
autoFit . width = false ;
autoFit . height = false ;
// check for string presence
if ( xmlDesc . isEmpty ( ) )
return ;
// decode the string
bool ok ;
int field = 0 ;
QString token = xmlDesc . section ( ' ; ' , field , field ) ;
while ( ! token . isEmpty ( ) )
{
// decode the current token
if ( field = = 0 )
{
pageNumber = token . toInt ( & ok ) ;
if ( ! ok )
return ;
}
else if ( token . startsWith ( " C1 " ) )
{
2005-06-13 11:53:47 +00:00
rePos . enabled = true ;
rePos . normalizedX = token . section ( ' : ' , 1 , 1 ) . toDouble ( ) ;
rePos . normalizedY = token . section ( ' : ' , 2 , 2 ) . toDouble ( ) ;
rePos . pos = Center ;
}
else if ( token . startsWith ( " C2 " ) )
{
rePos . enabled = true ;
rePos . normalizedX = token . section ( ' : ' , 1 , 1 ) . toDouble ( ) ;
rePos . normalizedY = token . section ( ' : ' , 2 , 2 ) . toDouble ( ) ;
if ( token . section ( ' : ' , 3 , 3 ) . toInt ( ) = = 1 ) rePos . pos = Center ;
else rePos . pos = TopLeft ;
2005-01-09 23:37:07 +00:00
}
else if ( token . startsWith ( " AF1 " ) )
{
autoFit . enabled = true ;
autoFit . width = token . section ( ' : ' , 1 , 1 ) = = " T " ;
autoFit . height = token . section ( ' : ' , 2 , 2 ) = = " T " ;
}
// proceed tokenizing string
field + + ;
token = xmlDesc . section ( ' ; ' , field , field ) ;
}
2004-12-22 18:21:36 +00:00
}
2005-01-09 23:37:07 +00:00
QString DocumentViewport : : toString ( ) const
{
// start string with page number
QString s = QString : : number ( pageNumber ) ;
// if has center coordinates, save them on string
2005-06-13 11:53:47 +00:00
if ( rePos . enabled )
s + = QString ( " ;C2: " ) + QString : : number ( rePos . normalizedX ) +
' : ' + QString : : number ( rePos . normalizedY ) +
' : ' + QString : : number ( rePos . pos ) ;
2005-01-09 23:37:07 +00:00
// if has autofit enabled, save its state on string
if ( autoFit . enabled )
s + = QString ( " ;AF1: " ) + ( autoFit . width ? " T " : " F " ) +
' : ' + ( autoFit . height ? " T " : " F " ) ;
return s ;
}
bool DocumentViewport : : operator = = ( const DocumentViewport & vp ) const
{
bool equal = ( pageNumber = = vp . pageNumber ) & &
2005-06-13 11:53:47 +00:00
( rePos . enabled = = vp . rePos . enabled ) & &
2005-01-09 23:37:07 +00:00
( autoFit . enabled = = vp . autoFit . enabled ) ;
if ( ! equal )
return false ;
2005-06-13 11:53:47 +00:00
if ( rePos . enabled & &
( ( rePos . normalizedX ! = vp . rePos . normalizedX ) | |
( rePos . normalizedY ! = vp . rePos . normalizedY ) | | rePos . pos ! = vp . rePos . pos ) )
2005-01-09 23:37:07 +00:00
return false ;
if ( autoFit . enabled & &
( ( autoFit . width ! = vp . autoFit . width ) | |
( autoFit . height ! = vp . autoFit . height ) ) )
return false ;
return true ;
}
2005-01-02 22:37:52 +00:00
/** DocumentInfo **/
DocumentInfo : : DocumentInfo ( )
: QDomDocument ( " DocumentInformation " )
{
QDomElement docElement = createElement ( " DocumentInfo " ) ;
appendChild ( docElement ) ;
}
void DocumentInfo : : set ( const QString & key , const QString & value ,
const QString & title )
{
QDomElement docElement = documentElement ( ) ;
QDomElement element ;
// check whether key already exists
QDomNodeList list = docElement . elementsByTagName ( key ) ;
if ( list . count ( ) > 0 )
element = list . item ( 0 ) . toElement ( ) ;
else
element = createElement ( key ) ;
element . setAttribute ( " value " , value ) ;
element . setAttribute ( " title " , title ) ;
if ( list . count ( ) = = 0 )
docElement . appendChild ( element ) ;
}
QString DocumentInfo : : get ( const QString & key ) const
{
QDomElement docElement = documentElement ( ) ;
QDomElement element ;
// check whether key already exists
QDomNodeList list = docElement . elementsByTagName ( key ) ;
if ( list . count ( ) > 0 )
return list . item ( 0 ) . toElement ( ) . attribute ( " value " ) ;
else
return QString ( ) ;
}
2005-01-09 23:37:07 +00:00
2005-01-03 15:51:05 +00:00
/** DocumentSynopsis **/
DocumentSynopsis : : DocumentSynopsis ( )
: QDomDocument ( " DocumentSynopsis " )
{
// void implementation, only subclassed for naming
}
2006-09-20 11:44:58 +00:00
DocumentSynopsis : : DocumentSynopsis ( const QDomDocument & document )
: QDomDocument ( document )
{
}
2005-06-13 15:46:23 +00:00
/** DocumentFonts **/
DocumentFonts : : DocumentFonts ( )
: QDomDocument ( " DocumentFonts " )
{
// void implementation, only subclassed for naming
}
2006-05-28 16:54:54 +00:00
/** EmbeddedFile **/
EmbeddedFile : : EmbeddedFile ( )
{
}
EmbeddedFile : : ~ EmbeddedFile ( )
{
}
2004-12-22 18:21:36 +00:00
# include "document.moc"