Commit 1cd101b4 authored by Albert Astals Cid's avatar Albert Astals Cid

Small cleanup of the layer support feature

Tab replacing, function naming, include removal, @since addition, etc
parent f5f0947d
......@@ -36,7 +36,6 @@
#include <QtGui/QPrintDialog>
#include <QStack>
#include <QUndoCommand>
#include <QAbstractItemModel>
#include <kaboutdata.h>
#include <kauthorized.h>
......
......@@ -844,7 +844,9 @@ class OKULAR_EXPORT Document : public QObject
void walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const;
/**
* Returns the model for rendering layer or NULL if no layer is present
* Returns the model for rendering layers (NULL if the document has no layers)
*
* @since 0.24
*/
QAbstractItemModel * layersModel() const;
......@@ -925,7 +927,9 @@ class OKULAR_EXPORT Document : public QObject
const QList< bool > & newButtonStates );
/**
* This slot is called to reload the pixmaps for whole document
* Reloads the pixmaps for whole document
*
* @since 0.24
*/
void reloadDocument() const;
......
......@@ -435,6 +435,8 @@ class OKULAR_EXPORT Generator : public QObject
/**
* Returns the 'layers model' object of the document or NULL if
* layers model is not available.
*
* @since 0.24
*/
virtual QAbstractItemModel * layersModel() const;
......
......@@ -1946,7 +1946,7 @@ void Part::slotRebuildBookmarkMenu()
void Part::enableLayers(bool enable)
{
m_sidebar->hideItem( 1, !enable );
m_sidebar->setItemVisible( 1, enable );
}
void Part::slotShowFindBar()
......
......@@ -37,19 +37,7 @@ Layers::Layers(QWidget *parent, Okular::Document *document) : QWidget(parent), m
m_treeView = new QTreeView( this );
mainlay->addWidget( m_treeView );
QAbstractItemModel * layersModel = m_document->layersModel();
if( layersModel )
{
m_treeView->setModel( layersModel );
m_searchLine->addTreeView( m_treeView );
emit hasLayers( true );
connect( layersModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), m_document, SLOT(reloadDocument()) );
}
else
{
emit hasLayers( false );
}
emit hasLayers( false );
m_treeView->setSortingEnabled( false );
m_treeView->setRootIsDecorated( true );
m_treeView->setAlternatingRowColors( true );
......@@ -64,17 +52,18 @@ Layers::~Layers()
void Layers::notifySetup( const QVector< Okular::Page * > & /*pages*/, int /*setupFlags*/ )
{
QAbstractItemModel * layersModel = m_document->layersModel();
if( layersModel )
{
m_treeView->setModel( layersModel );
m_searchLine->addTreeView( m_treeView );
emit hasLayers( true );
connect( layersModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), m_document, SLOT(reloadDocument()) );
connect( layersModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), m_pageView, SLOT(reloadForms()) );
m_treeView->setModel( layersModel );
m_searchLine->addTreeView( m_treeView );
emit hasLayers( true );
connect( layersModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), m_document, SLOT(reloadDocument()) );
connect( layersModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), m_pageView, SLOT(reloadForms()) );
}
else
{
emit hasLayers( false );
emit hasLayers( false );
}
}
......
......@@ -37,10 +37,10 @@ Q_OBJECT
// inherited from DocumentObserver
void notifySetup( const QVector< Okular::Page * > & pages, int setupFlags );
void setPageView( PageView *pageView );
void setPageView( PageView *pageView );
signals:
void hasLayers(bool has);
void hasLayers(bool has);
private slots:
void saveSearchOptions();
......@@ -50,7 +50,7 @@ Q_OBJECT
Okular::Document *m_document;
QTreeView *m_treeView;
KTreeViewSearchLine *m_searchLine;
PageView *m_pageView;
PageView *m_pageView;
};
#endif
......@@ -1353,7 +1353,6 @@ void PageView::notifyCurrentPageChanged( int previous, int current )
// update zoom text and factor if in a ZoomFit/* zoom mode
if ( d->zoomMode != ZoomFixed )
updateZoomText();
}
}
......
......@@ -211,10 +211,9 @@ bool PageViewItem::setFormWidgetsVisible( bool visible )
void PageViewItem::reloadFormWidgetsState()
{
QHash<int, FormWidgetIface*>::iterator it = m_formWidgets.begin(), itEnd = m_formWidgets.end();
for ( ; it != itEnd; ++it )
foreach(FormWidgetIface *fwi, m_formWidgets)
{
(*it)->setVisibility( (*it)->formField()->isVisible() );
fwi->setVisibility( fwi->formField()->isVisible() );
}
}
......
......@@ -78,7 +78,7 @@ class PageViewItem
void setVisible( bool visible );
void invalidate();
bool setFormWidgetsVisible( bool visible );
void reloadFormWidgetsState();
void reloadFormWidgetsState();
private:
const Okular::Page * m_page;
......
......@@ -653,10 +653,10 @@ void Sidebar::moveSplitter(int sideWidgetSize)
d->splitter->setSizes( splitterSizeList );
}
void Sidebar::hideItem( int index, bool hide )
void Sidebar::setItemVisible( int index, bool visible )
{
d->list->setRowHidden( index, hide );
setItemEnabled( index, ! hide );
d->list->setRowHidden( index, !visible );
setItemEnabled( index, visible );
}
void Sidebar::itemClicked( QListWidgetItem *item )
......
......@@ -31,6 +31,8 @@ class Sidebar : public QWidget
void setItemEnabled( int index, bool enabled );
bool isItemEnabled( int index ) const;
void setItemVisible( int index, bool visible );
enum SetCurrentIndexBehaviour { UncollapseIfCollapsed, DoNotUncollapseIfCollapsed };
void setCurrentIndex( int index, SetCurrentIndexBehaviour b = UncollapseIfCollapsed );
......@@ -42,9 +44,7 @@ class Sidebar : public QWidget
void setCollapsed( bool collapsed );
bool isCollapsed() const;
void moveSplitter( int sideWidgetSize );
void hideItem( int index, bool hide );
void moveSplitter( int sideWidgetSize );
signals:
void urlsDropped( const KUrl::List& urls );
......
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