mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 03:30:20 +00:00
Make the page view a View, able to get and set the zoom level, and register it in the document.
svn path=/trunk/KDE/kdegraphics/okular/; revision=801660
This commit is contained in:
parent
5851ddf6a8
commit
76531028ba
1
part.cpp
1
part.cpp
|
@ -276,6 +276,7 @@ m_cliPresentation(false), m_generatorGuiClient(0)
|
|||
m_document->addObserver( this );
|
||||
m_document->addObserver( m_thumbnailList );
|
||||
m_document->addObserver( m_pageView );
|
||||
m_document->registerView( m_pageView );
|
||||
m_document->addObserver( m_toc );
|
||||
m_document->addObserver( m_miniBar );
|
||||
#ifdef OKULAR_ENABLE_MINIBAR
|
||||
|
|
|
@ -286,6 +286,7 @@ private:
|
|||
*/
|
||||
PageView::PageView( QWidget *parent, Okular::Document *document )
|
||||
: QScrollArea( parent )
|
||||
, Okular::View( QString::fromLatin1( "PageView" ) )
|
||||
{
|
||||
// create and initialize private storage structure
|
||||
d = new PageViewPrivate( this );
|
||||
|
@ -1002,6 +1003,57 @@ bool PageView::canUnloadPixmap( int pageNumber ) const
|
|||
}
|
||||
//END DocumentObserver inherited methods
|
||||
|
||||
//BEGIN View inherited methods
|
||||
bool PageView::supportsCapability( ViewCapability capability ) const
|
||||
{
|
||||
switch ( capability )
|
||||
{
|
||||
case Zoom:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Okular::View::CapabilityFlags PageView::capabilityFlags( ViewCapability capability ) const
|
||||
{
|
||||
switch ( capability )
|
||||
{
|
||||
case Zoom:
|
||||
return CapabilityRead | CapabilityWrite;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QVariant PageView::capability( ViewCapability capability ) const
|
||||
{
|
||||
switch ( capability )
|
||||
{
|
||||
case Zoom:
|
||||
return d->zoomFactor;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void PageView::setCapability( ViewCapability capability, const QVariant &option )
|
||||
{
|
||||
switch ( capability )
|
||||
{
|
||||
case Zoom:
|
||||
{
|
||||
bool ok = true;
|
||||
double factor = option.toDouble( &ok );
|
||||
if ( ok && factor > 0.0 )
|
||||
{
|
||||
d->zoomFactor = static_cast< float >( factor );
|
||||
updateZoom( ZoomRefreshCurrent );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//END View inherited methods
|
||||
|
||||
//BEGIN widget events
|
||||
void PageView::contentsPaintEvent(QPaintEvent *pe)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "ui/pageviewutils.h"
|
||||
#include "core/area.h"
|
||||
#include "core/observer.h"
|
||||
#include "core/view.h"
|
||||
|
||||
class KAction;
|
||||
class KActionCollection;
|
||||
|
@ -45,7 +46,7 @@ class PageViewWidget;
|
|||
* @short display of course :-)
|
||||
* ...
|
||||
*/
|
||||
class PageView : public QScrollArea, public Okular::DocumentObserver
|
||||
class PageView : public QScrollArea, public Okular::DocumentObserver, public Okular::View
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -79,6 +80,12 @@ Q_OBJECT
|
|||
void notifyZoom(int factor);
|
||||
bool canUnloadPixmap( int pageNum ) const;
|
||||
|
||||
// inherited from View
|
||||
bool supportsCapability( ViewCapability capability ) const;
|
||||
CapabilityFlags capabilityFlags( ViewCapability capability ) const;
|
||||
QVariant capability( ViewCapability capability ) const;
|
||||
void setCapability( ViewCapability capability, const QVariant &option );
|
||||
|
||||
QList< Okular::RegularAreaRect * > textSelections( const QPoint& start, const QPoint& end, int& firstpage );
|
||||
Okular::RegularAreaRect * textSelectionForItem( PageViewItem * item, const QPoint & startPoint = QPoint(), const QPoint & endPoint = QPoint() );
|
||||
|
||||
|
|
Loading…
Reference in a new issue