mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-24 18:35:37 +00:00
cleanups and scroll api
svn path=/trunk/kdegraphics/kpdf/; revision=385040
This commit is contained in:
parent
aa5cdd7c8a
commit
d1e074058b
|
@ -442,7 +442,7 @@ void KPDFDocument::setPrevPage()
|
|||
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]
|
||||
if ( page < 0 )
|
||||
|
@ -451,10 +451,10 @@ void KPDFDocument::setViewportPage( int page, int excludeId )
|
|||
page = pages_vector.count() - 1;
|
||||
|
||||
// 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
|
||||
DocumentViewport & oldViewport = *d->viewportIterator;
|
||||
|
@ -484,7 +484,7 @@ void KPDFDocument::setViewport( const DocumentViewport & viewport, int excludeId
|
|||
QMap< int, DocumentObserver * >::iterator it = d->observers.begin(), end = d->observers.end();
|
||||
for ( ; it != end ; ++ it )
|
||||
if ( it.key() != excludeId )
|
||||
(*it)->notifyViewportChanged();
|
||||
(*it)->notifyViewportChanged( smoothMove );
|
||||
|
||||
// [MEM] raise position of currently viewed page in allocation queue
|
||||
if ( d->allocatedPixmapsFifo.count() > 1 )
|
||||
|
@ -515,7 +515,7 @@ void KPDFDocument::setPrevViewport()
|
|||
{
|
||||
// restore previous viewport and notify it to observers
|
||||
--d->viewportIterator;
|
||||
foreachObserver( notifyViewportChanged() );
|
||||
foreachObserver( notifyViewportChanged( true ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ void KPDFDocument::setNextViewport()
|
|||
{
|
||||
// restore next viewport and notify it to observers
|
||||
++d->viewportIterator;
|
||||
foreachObserver( notifyViewportChanged() );
|
||||
foreachObserver( notifyViewportChanged( true ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,7 +592,7 @@ bool KPDFDocument::findText( const QString & string, bool keepCase, bool findAhe
|
|||
searchViewport.reCenter.enabled = true;
|
||||
searchViewport.reCenter.normalizedCenterX = (double)center.x() / foundPage->width();
|
||||
searchViewport.reCenter.normalizedCenterY = (double)center.y() / foundPage->height();
|
||||
setViewport( searchViewport );
|
||||
setViewport( searchViewport, -1, true );
|
||||
// notify all observers about hilighting chages
|
||||
foreachObserver( notifyPageChanged( pageNumber, DocumentObserver::Highlights ) );
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class KPrinter;
|
|||
* For a better understanding of hieracies @see README.internals.png
|
||||
* @see DocumentObserver, KPDFPage
|
||||
*/
|
||||
class KPDFDocument : public QObject // only for a private slot..
|
||||
class KPDFDocument : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -73,8 +73,8 @@ class KPDFDocument : public QObject // only for a private slot..
|
|||
QString getMetaData( const QString & key, const QString & option = QString() ) const;
|
||||
|
||||
// perform actions on document / pages
|
||||
void setViewportPage( int page, int excludeId = -1 );
|
||||
void setViewport( const DocumentViewport & viewport, int excludeId = -1 );
|
||||
void setViewportPage( int page, int excludeId = -1, bool smoothMove = false );
|
||||
void setViewport( const DocumentViewport & viewport, int excludeId = -1, bool smoothMove = false );
|
||||
void setPrevViewport();
|
||||
void setNextViewport();
|
||||
void requestPixmaps( const QValueList< PixmapRequest * > & requests );
|
||||
|
|
|
@ -46,7 +46,7 @@ class DocumentObserver
|
|||
// commands from the Document to all observers
|
||||
enum ChangedFlags { Pixmap = 1, Bookmark = 2, Highlights = 4 };
|
||||
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 notifyContentsCleared( int /*changedFlags*/ ) {};
|
||||
|
||||
|
|
9
part.cpp
9
part.cpp
|
@ -215,7 +215,8 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
|
|||
|
||||
m_saveAs = KStdAction::saveAs( this, SLOT( slotSaveFileAs() ), ac, "save" );
|
||||
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->setEnabled( false );
|
||||
|
||||
|
@ -270,7 +271,7 @@ Part::~Part()
|
|||
delete globalParams;
|
||||
}
|
||||
|
||||
void Part::notifyViewportChanged()
|
||||
void Part::notifyViewportChanged( bool /*smoothMove*/ )
|
||||
{
|
||||
// update actions if the page is changed
|
||||
static int lastPage = -1;
|
||||
|
@ -341,6 +342,10 @@ bool Part::openFile()
|
|||
|
||||
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
|
||||
bool b = KParts::ReadOnlyPart::openURL(url);
|
||||
if ( !b )
|
||||
|
|
2
part.h
2
part.h
|
@ -68,7 +68,7 @@ public:
|
|||
|
||||
// inherited from DocumentObserver
|
||||
uint observerId() const { return PART_ID; }
|
||||
void notifyViewportChanged();
|
||||
void notifyViewportChanged( bool smoothMove );
|
||||
|
||||
static KAboutData* createAboutData();
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ void MiniBar::notifySetup( const QValueVector< KPDFPage * > & pageVector, bool c
|
|||
static_cast<QWidget*>( parent() )->show();
|
||||
}
|
||||
|
||||
void MiniBar::notifyViewportChanged()
|
||||
void MiniBar::notifyViewportChanged( bool /*smoothMove*/ )
|
||||
{
|
||||
// get current page number
|
||||
int page = m_document->viewport().pageNumber;
|
||||
|
|
|
@ -30,7 +30,7 @@ class MiniBar : public QFrame, public DocumentObserver
|
|||
// [INHERITED] from DocumentObserver
|
||||
uint observerId() const { return MINIBAR_ID; }
|
||||
void notifySetup( const QValueVector< KPDFPage * > & pages, bool );
|
||||
void notifyViewportChanged();
|
||||
void notifyViewportChanged( bool smoothMove );
|
||||
|
||||
signals:
|
||||
void gotoPage();
|
||||
|
|
|
@ -275,7 +275,7 @@ void PageView::notifySetup( const QValueVector< KPDFPage * > & pageSet, bool doc
|
|||
PageViewMessage::Info, 4000 );
|
||||
}
|
||||
|
||||
void PageView::notifyViewportChanged()
|
||||
void PageView::notifyViewportChanged( bool /*smoothMove*/ )
|
||||
{
|
||||
// if we are the one changing viewport, skip this nofity
|
||||
if ( d->blockViewport )
|
||||
|
|
|
@ -58,7 +58,7 @@ class PageView : public QScrollView, public DocumentObserver
|
|||
// inherited from DocumentObserver
|
||||
uint observerId() const { return PAGEVIEW_ID; }
|
||||
void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged );
|
||||
void notifyViewportChanged();
|
||||
void notifyViewportChanged( bool smoothMove );
|
||||
void notifyPageChanged( int pageNumber, int changedFlags );
|
||||
void notifyContentsCleared( int changedFlags );
|
||||
bool canUnloadPixmap( int pageNum );
|
||||
|
|
|
@ -160,7 +160,7 @@ void PresentationWidget::notifySetup( const QValueVector< KPDFPage * > & pageSet
|
|||
m_metaStrings += i18n( "Click to begin" );
|
||||
}
|
||||
|
||||
void PresentationWidget::notifyViewportChanged()
|
||||
void PresentationWidget::notifyViewportChanged( bool /*smoothMove*/ )
|
||||
{
|
||||
changePage( m_document->viewport().pageNumber );
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class PresentationWidget : public QWidget, public DocumentObserver
|
|||
// inherited from DocumentObserver
|
||||
uint observerId() const { return PRESENTATION_ID; }
|
||||
void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged );
|
||||
void notifyViewportChanged();
|
||||
void notifyViewportChanged( bool smoothMove );
|
||||
void notifyPageChanged( int pageNumber, int changedFlags );
|
||||
bool canUnloadPixmap( int pageNumber );
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ void ThumbnailList::notifySetup( const QValueVector< KPDFPage * > & pages, bool
|
|||
delayedRequestVisiblePixmaps( 200 );
|
||||
}
|
||||
|
||||
void ThumbnailList::notifyViewportChanged()
|
||||
void ThumbnailList::notifyViewportChanged( bool /*smoothMove*/ )
|
||||
{
|
||||
// skip notifies for the current page (already selected)
|
||||
int newPage = m_document->viewport().pageNumber;
|
||||
|
|
|
@ -39,7 +39,7 @@ Q_OBJECT
|
|||
// inherited: create thumbnails ( inherited as a DocumentObserver )
|
||||
void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged );
|
||||
// inherited: hilihght current thumbnail ( inherited as DocumentObserver )
|
||||
void notifyViewportChanged();
|
||||
void notifyViewportChanged( bool smoothMove );
|
||||
// inherited: redraw thumbnail ( inherited as DocumentObserver )
|
||||
void notifyPageChanged( int pageNumber, int changedFlags );
|
||||
// inherited: request all visible pixmap (due to a global shange or so..)
|
||||
|
|
Loading…
Reference in a new issue