Provide ways to register & unregister the view from a Document, and to get/set the view capabilities. svn path=/trunk/KDE/kdegraphics/okular/; revision=801657remotes/origin/KDE/4.1
parent
1ed3928811
commit
5851ddf6a8
7 changed files with 283 additions and 0 deletions
@ -0,0 +1,77 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> * |
||||
* * |
||||
* 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. * |
||||
***************************************************************************/ |
||||
|
||||
#include "view.h" |
||||
#include "view_p.h" |
||||
|
||||
// local includes
|
||||
#include "document_p.h" |
||||
|
||||
using namespace Okular; |
||||
|
||||
ViewPrivate::ViewPrivate() |
||||
: document( 0 ) |
||||
{ |
||||
} |
||||
|
||||
ViewPrivate::~ViewPrivate() |
||||
{ |
||||
} |
||||
|
||||
|
||||
View::View( const QString &name ) |
||||
: d_ptr( new ViewPrivate() ) |
||||
{ |
||||
d_ptr->name = name; |
||||
} |
||||
|
||||
View::~View() |
||||
{ |
||||
if ( d_ptr->document ) |
||||
{ |
||||
d_ptr->document->m_views.remove( this ); |
||||
} |
||||
|
||||
delete d_ptr; |
||||
} |
||||
|
||||
Document* View::viewDocument() const |
||||
{ |
||||
return d_ptr->document ? d_ptr->document->m_parent : 0; |
||||
} |
||||
|
||||
QString View::name() const |
||||
{ |
||||
return d_ptr->name; |
||||
} |
||||
|
||||
bool View::supportsCapability( View::ViewCapability capability ) const |
||||
{ |
||||
Q_UNUSED( capability ) |
||||
return false; |
||||
} |
||||
|
||||
View::CapabilityFlags View::capabilityFlags( View::ViewCapability capability ) const |
||||
{ |
||||
Q_UNUSED( capability ) |
||||
return 0; |
||||
} |
||||
|
||||
QVariant View::capability( View::ViewCapability capability ) const |
||||
{ |
||||
Q_UNUSED( capability ) |
||||
return QVariant(); |
||||
} |
||||
|
||||
void View::setCapability( View::ViewCapability capability, const QVariant &option ) |
||||
{ |
||||
Q_UNUSED( capability ) |
||||
Q_UNUSED( option ) |
||||
} |
||||
|
||||
@ -0,0 +1,111 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> * |
||||
* * |
||||
* 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. * |
||||
***************************************************************************/ |
||||
|
||||
#ifndef OKULAR_VIEW_H |
||||
#define OKULAR_VIEW_H |
||||
|
||||
#include "okular_export.h" |
||||
|
||||
class QString; |
||||
class QVariant; |
||||
|
||||
namespace Okular { |
||||
|
||||
class Document; |
||||
class DocumentPrivate; |
||||
class ViewPrivate; |
||||
|
||||
/**
|
||||
* @short View on the document |
||||
* |
||||
* The View class represents a "view" on a document. |
||||
* A view can be registered with only a document at a time. |
||||
* |
||||
* @since 0.7 (KDE 4.1) |
||||
*/ |
||||
class OKULAR_EXPORT View |
||||
{ |
||||
/// @cond PRIVATE
|
||||
friend class Document; |
||||
friend class DocumentPrivate; |
||||
/// @endcond
|
||||
|
||||
public: |
||||
/**
|
||||
* The capabilities of a view |
||||
*/ |
||||
enum ViewCapability |
||||
{ |
||||
Zoom ///< Possibility to get/set the zoom of the view
|
||||
}; |
||||
|
||||
/**
|
||||
* The access type of a capability |
||||
*/ |
||||
enum CapabilityFlag |
||||
{ |
||||
NoFlag = 0, |
||||
CapabilityRead = 0x01, ///< Possibility to read a capability
|
||||
CapabilityWrite = 0x02 ///< Possibility to write a capability
|
||||
}; |
||||
Q_DECLARE_FLAGS( CapabilityFlags, CapabilityFlag ) |
||||
|
||||
virtual ~View(); |
||||
|
||||
/**
|
||||
* Return the document which this view is associated to, |
||||
* or null if it is not associated with any document. |
||||
*/ |
||||
Document* viewDocument() const; |
||||
|
||||
/**
|
||||
* Return the name of this view. |
||||
*/ |
||||
QString name() const; |
||||
|
||||
/**
|
||||
* Query whether the view support the specified @p capability. |
||||
*/ |
||||
virtual bool supportsCapability( ViewCapability capability ) const; |
||||
|
||||
/**
|
||||
* Query the flags for the specified @p capability. |
||||
*/ |
||||
virtual CapabilityFlags capabilityFlags( ViewCapability capability ) const; |
||||
|
||||
/**
|
||||
* Query the value of the specified @p capability. |
||||
*/ |
||||
virtual QVariant capability( ViewCapability capability ) const; |
||||
|
||||
/**
|
||||
* Sets a new value for the specified @p capability. |
||||
*/ |
||||
virtual void setCapability( ViewCapability capability, const QVariant &option ); |
||||
|
||||
protected: |
||||
/**
|
||||
* Construct a new view with the specified @p name. |
||||
*/ |
||||
View( const QString &name ); |
||||
|
||||
/// @cond PRIVATE
|
||||
Q_DECLARE_PRIVATE( View ) |
||||
ViewPrivate *d_ptr; |
||||
/// @endcond
|
||||
|
||||
private: |
||||
Q_DISABLE_COPY( View ) |
||||
}; |
||||
|
||||
} |
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( Okular::View::CapabilityFlags ) |
||||
|
||||
#endif |
||||
@ -0,0 +1,33 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> * |
||||
* * |
||||
* 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. * |
||||
***************************************************************************/ |
||||
|
||||
#ifndef OKULAR_VIEW_P_H |
||||
#define OKULAR_VIEW_P_H |
||||
|
||||
#include <QtCore/QHash> |
||||
#include <QtCore/QString> |
||||
|
||||
namespace Okular { |
||||
|
||||
class DocumentPrivate; |
||||
class View; |
||||
|
||||
class ViewPrivate |
||||
{ |
||||
public: |
||||
ViewPrivate(); |
||||
virtual ~ViewPrivate(); |
||||
|
||||
QString name; |
||||
DocumentPrivate *document; |
||||
}; |
||||
|
||||
} |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue