Commit d1e07405 authored by Enrico Ros's avatar Enrico Ros

cleanups and scroll api

svn path=/trunk/kdegraphics/kpdf/; revision=385040
parent aa5cdd7c
...@@ -442,7 +442,7 @@ void KPDFDocument::setPrevPage() ...@@ -442,7 +442,7 @@ void KPDFDocument::setPrevPage()
setViewport( DocumentViewport( (*d->viewportIterator).pageNumber - 1 ) ); setViewport( DocumentViewport( (*d->viewportIterator).pageNumber - 1 ) );
} }
*/ */
void KPDFDocument::setViewportPage( int page, int excludeId ) void KPDFDocument::setViewportPage( int page, int excludeId, bool smoothMove )
{ {
// clamp page in range [0 ... numPages-1] // clamp page in range [0 ... numPages-1]
if ( page < 0 ) if ( page < 0 )
...@@ -451,10 +451,10 @@ void KPDFDocument::setViewportPage( int page, int excludeId ) ...@@ -451,10 +451,10 @@ void KPDFDocument::setViewportPage( int page, int excludeId )
page = pages_vector.count() - 1; page = pages_vector.count() - 1;
// make a viewport from the page and broadcast it // make a viewport from the page and broadcast it
setViewport( DocumentViewport( page ), excludeId ); setViewport( DocumentViewport( page ), excludeId, smoothMove );
} }
void KPDFDocument::setViewport( const DocumentViewport & viewport, int excludeId ) void KPDFDocument::setViewport( const DocumentViewport & viewport, int excludeId, bool smoothMove )
{ {
// if already broadcasted, don't redo it // if already broadcasted, don't redo it
DocumentViewport & oldViewport = *d->viewportIterator; DocumentViewport & oldViewport = *d->viewportIterator;
...@@ -484,7 +484,7 @@ void KPDFDocument::setViewport( const DocumentViewport & viewport, int excludeId ...@@ -484,7 +484,7 @@ void KPDFDocument::setViewport( const DocumentViewport & viewport, int excludeId
QMap< int, DocumentObserver * >::iterator it = d->observers.begin(), end = d->observers.end(); QMap< int, DocumentObserver * >::iterator it = d->observers.begin(), end = d->observers.end();
for ( ; it != end ; ++ it ) for ( ; it != end ; ++ it )
if ( it.key() != excludeId ) if ( it.key() != excludeId )
(*it)->notifyViewportChanged(); (*it)->notifyViewportChanged( smoothMove );
// [MEM] raise position of currently viewed page in allocation queue // [MEM] raise position of currently viewed page in allocation queue
if ( d->allocatedPixmapsFifo.count() > 1 ) if ( d->allocatedPixmapsFifo.count() > 1 )
...@@ -515,7 +515,7 @@ void KPDFDocument::setPrevViewport() ...@@ -515,7 +515,7 @@ void KPDFDocument::setPrevViewport()
{ {
// restore previous viewport and notify it to observers // restore previous viewport and notify it to observers
--d->viewportIterator; --d->viewportIterator;
foreachObserver( notifyViewportChanged() ); foreachObserver( notifyViewportChanged( true ) );
} }
} }
...@@ -528,7 +528,7 @@ void KPDFDocument::setNextViewport() ...@@ -528,7 +528,7 @@ void KPDFDocument::setNextViewport()
{ {
// restore next viewport and notify it to observers // restore next viewport and notify it to observers
++d->viewportIterator; ++d->viewportIterator;
foreachObserver( notifyViewportChanged() ); foreachObserver( notifyViewportChanged( true ) );
} }
} }
...@@ -592,7 +592,7 @@ bool KPDFDocument::findText( const QString & string, bool keepCase, bool findAhe ...@@ -592,7 +592,7 @@ bool KPDFDocument::findText( const QString & string, bool keepCase, bool findAhe
searchViewport.reCenter.enabled = true; searchViewport.reCenter.enabled = true;
searchViewport.reCenter.normalizedCenterX = (double)center.x() / foundPage->width(); searchViewport.reCenter.normalizedCenterX = (double)center.x() / foundPage->width();
searchViewport.reCenter.normalizedCenterY = (double)center.y() / foundPage->height(); searchViewport.reCenter.normalizedCenterY = (double)center.y() / foundPage->height();
setViewport( searchViewport ); setViewport( searchViewport, -1, true );
// notify all observers about hilighting chages // notify all observers about hilighting chages
foreachObserver( notifyPageChanged( pageNumber, DocumentObserver::Highlights ) ); foreachObserver( notifyPageChanged( pageNumber, DocumentObserver::Highlights ) );
} }
......
...@@ -43,7 +43,7 @@ class KPrinter; ...@@ -43,7 +43,7 @@ class KPrinter;
* For a better understanding of hieracies @see README.internals.png * For a better understanding of hieracies @see README.internals.png
* @see DocumentObserver, KPDFPage * @see DocumentObserver, KPDFPage
*/ */
class KPDFDocument : public QObject // only for a private slot.. class KPDFDocument : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
...@@ -73,8 +73,8 @@ class KPDFDocument : public QObject // only for a private slot.. ...@@ -73,8 +73,8 @@ class KPDFDocument : public QObject // only for a private slot..
QString getMetaData( const QString & key, const QString & option = QString() ) const; QString getMetaData( const QString & key, const QString & option = QString() ) const;
// perform actions on document / pages // perform actions on document / pages
void setViewportPage( int page, int excludeId = -1 ); void setViewportPage( int page, int excludeId = -1, bool smoothMove = false );
void setViewport( const DocumentViewport & viewport, int excludeId = -1 ); void setViewport( const DocumentViewport & viewport, int excludeId = -1, bool smoothMove = false );
void setPrevViewport(); void setPrevViewport();
void setNextViewport(); void setNextViewport();
void requestPixmaps( const QValueList< PixmapRequest * > & requests ); void requestPixmaps( const QValueList< PixmapRequest * > & requests );
......
...@@ -46,7 +46,7 @@ class DocumentObserver ...@@ -46,7 +46,7 @@ class DocumentObserver
// commands from the Document to all observers // commands from the Document to all observers
enum ChangedFlags { Pixmap = 1, Bookmark = 2, Highlights = 4 }; enum ChangedFlags { Pixmap = 1, Bookmark = 2, Highlights = 4 };
virtual void notifySetup( const QValueVector< KPDFPage * > & /*pages*/, bool /*documentChanged*/ ) {}; virtual void notifySetup( const QValueVector< KPDFPage * > & /*pages*/, bool /*documentChanged*/ ) {};
virtual void notifyViewportChanged() {}; virtual void notifyViewportChanged( bool /*smoothMove*/ ) {};
virtual void notifyPageChanged( int /*pageNumber*/, int /*changedFlags*/ ) {}; virtual void notifyPageChanged( int /*pageNumber*/, int /*changedFlags*/ ) {};
virtual void notifyContentsCleared( int /*changedFlags*/ ) {}; virtual void notifyContentsCleared( int /*changedFlags*/ ) {};
......
...@@ -215,7 +215,8 @@ Part::Part(QWidget *parentWidget, const char *widgetName, ...@@ -215,7 +215,8 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_saveAs = KStdAction::saveAs( this, SLOT( slotSaveFileAs() ), ac, "save" ); m_saveAs = KStdAction::saveAs( this, SLOT( slotSaveFileAs() ), ac, "save" );
m_saveAs->setEnabled( false ); m_saveAs->setEnabled( false );
KStdAction::preferences( this, SLOT( slotPreferences() ), ac, "preferences" ); KAction * prefs = KStdAction::preferences( this, SLOT( slotPreferences() ), ac, "preferences" );
prefs->setText( i18n( "Configure PDF Viewer..." ) );
m_printPreview = KStdAction::printPreview( this, SLOT( slotPrintPreview() ), ac ); m_printPreview = KStdAction::printPreview( this, SLOT( slotPrintPreview() ), ac );
m_printPreview->setEnabled( false ); m_printPreview->setEnabled( false );
...@@ -270,7 +271,7 @@ Part::~Part() ...@@ -270,7 +271,7 @@ Part::~Part()
delete globalParams; delete globalParams;
} }
void Part::notifyViewportChanged() void Part::notifyViewportChanged( bool /*smoothMove*/ )
{ {
// update actions if the page is changed // update actions if the page is changed
static int lastPage = -1; static int lastPage = -1;
...@@ -341,6 +342,10 @@ bool Part::openFile() ...@@ -341,6 +342,10 @@ bool Part::openFile()
bool Part::openURL(const KURL &url) bool Part::openURL(const KURL &url)
{ {
// note: this can be the right place to check the file for gz or bz2 extension
// if it matches then: download it (if not local) extract to a temp file using
// KTar and proceed with the URL of the temporary file
// this calls the above 'openURL' method // this calls the above 'openURL' method
bool b = KParts::ReadOnlyPart::openURL(url); bool b = KParts::ReadOnlyPart::openURL(url);
if ( !b ) if ( !b )
......
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
// inherited from DocumentObserver // inherited from DocumentObserver
uint observerId() const { return PART_ID; } uint observerId() const { return PART_ID; }
void notifyViewportChanged(); void notifyViewportChanged( bool smoothMove );
static KAboutData* createAboutData(); static KAboutData* createAboutData();
......
...@@ -170,7 +170,7 @@ void MiniBar::notifySetup( const QValueVector< KPDFPage * > & pageVector, bool c ...@@ -170,7 +170,7 @@ void MiniBar::notifySetup( const QValueVector< KPDFPage * > & pageVector, bool c
static_cast<QWidget*>( parent() )->show(); static_cast<QWidget*>( parent() )->show();
} }
void MiniBar::notifyViewportChanged() void MiniBar::notifyViewportChanged( bool /*smoothMove*/ )
{ {
// get current page number // get current page number
int page = m_document->viewport().pageNumber; int page = m_document->viewport().pageNumber;
......
...@@ -30,7 +30,7 @@ class MiniBar : public QFrame, public DocumentObserver ...@@ -30,7 +30,7 @@ class MiniBar : public QFrame, public DocumentObserver
// [INHERITED] from DocumentObserver // [INHERITED] from DocumentObserver
uint observerId() const { return MINIBAR_ID; } uint observerId() const { return MINIBAR_ID; }
void notifySetup( const QValueVector< KPDFPage * > & pages, bool ); void notifySetup( const QValueVector< KPDFPage * > & pages, bool );
void notifyViewportChanged(); void notifyViewportChanged( bool smoothMove );
signals: signals:
void gotoPage(); void gotoPage();
......
...@@ -275,7 +275,7 @@ void PageView::notifySetup( const QValueVector< KPDFPage * > & pageSet, bool doc ...@@ -275,7 +275,7 @@ void PageView::notifySetup( const QValueVector< KPDFPage * > & pageSet, bool doc
PageViewMessage::Info, 4000 ); PageViewMessage::Info, 4000 );
} }
void PageView::notifyViewportChanged() void PageView::notifyViewportChanged( bool /*smoothMove*/ )
{ {
// if we are the one changing viewport, skip this nofity // if we are the one changing viewport, skip this nofity
if ( d->blockViewport ) if ( d->blockViewport )
......
...@@ -58,7 +58,7 @@ class PageView : public QScrollView, public DocumentObserver ...@@ -58,7 +58,7 @@ class PageView : public QScrollView, public DocumentObserver
// inherited from DocumentObserver // inherited from DocumentObserver
uint observerId() const { return PAGEVIEW_ID; } uint observerId() const { return PAGEVIEW_ID; }
void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged ); void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged );
void notifyViewportChanged(); void notifyViewportChanged( bool smoothMove );
void notifyPageChanged( int pageNumber, int changedFlags ); void notifyPageChanged( int pageNumber, int changedFlags );
void notifyContentsCleared( int changedFlags ); void notifyContentsCleared( int changedFlags );
bool canUnloadPixmap( int pageNum ); bool canUnloadPixmap( int pageNum );
......
...@@ -160,7 +160,7 @@ void PresentationWidget::notifySetup( const QValueVector< KPDFPage * > & pageSet ...@@ -160,7 +160,7 @@ void PresentationWidget::notifySetup( const QValueVector< KPDFPage * > & pageSet
m_metaStrings += i18n( "Click to begin" ); m_metaStrings += i18n( "Click to begin" );
} }
void PresentationWidget::notifyViewportChanged() void PresentationWidget::notifyViewportChanged( bool /*smoothMove*/ )
{ {
changePage( m_document->viewport().pageNumber ); changePage( m_document->viewport().pageNumber );
} }
......
...@@ -39,7 +39,7 @@ class PresentationWidget : public QWidget, public DocumentObserver ...@@ -39,7 +39,7 @@ class PresentationWidget : public QWidget, public DocumentObserver
// inherited from DocumentObserver // inherited from DocumentObserver
uint observerId() const { return PRESENTATION_ID; } uint observerId() const { return PRESENTATION_ID; }
void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged ); void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged );
void notifyViewportChanged(); void notifyViewportChanged( bool smoothMove );
void notifyPageChanged( int pageNumber, int changedFlags ); void notifyPageChanged( int pageNumber, int changedFlags );
bool canUnloadPixmap( int pageNumber ); bool canUnloadPixmap( int pageNumber );
......
...@@ -141,7 +141,7 @@ void ThumbnailList::notifySetup( const QValueVector< KPDFPage * > & pages, bool ...@@ -141,7 +141,7 @@ void ThumbnailList::notifySetup( const QValueVector< KPDFPage * > & pages, bool
delayedRequestVisiblePixmaps( 200 ); delayedRequestVisiblePixmaps( 200 );
} }
void ThumbnailList::notifyViewportChanged() void ThumbnailList::notifyViewportChanged( bool /*smoothMove*/ )
{ {
// skip notifies for the current page (already selected) // skip notifies for the current page (already selected)
int newPage = m_document->viewport().pageNumber; int newPage = m_document->viewport().pageNumber;
......
...@@ -39,7 +39,7 @@ Q_OBJECT ...@@ -39,7 +39,7 @@ Q_OBJECT
// inherited: create thumbnails ( inherited as a DocumentObserver ) // inherited: create thumbnails ( inherited as a DocumentObserver )
void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged ); void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged );
// inherited: hilihght current thumbnail ( inherited as DocumentObserver ) // inherited: hilihght current thumbnail ( inherited as DocumentObserver )
void notifyViewportChanged(); void notifyViewportChanged( bool smoothMove );
// inherited: redraw thumbnail ( inherited as DocumentObserver ) // inherited: redraw thumbnail ( inherited as DocumentObserver )
void notifyPageChanged( int pageNumber, int changedFlags ); void notifyPageChanged( int pageNumber, int changedFlags );
// inherited: request all visible pixmap (due to a global shange or so..) // inherited: request all visible pixmap (due to a global shange or so..)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment