Revert "added layer-visible-on and layer-visible-off icon instead of checkboxes"

This reverts commit 288d3e4c1b.
This commit is contained in:
Saheb Preet Singh 2015-07-12 17:02:34 +05:30
parent 288d3e4c1b
commit 8f5fecfd5b
5 changed files with 0 additions and 77 deletions

View file

@ -205,7 +205,6 @@ set(okularpart_SRCS
ui/tts.cpp
ui/videowidget.cpp
ui/layers.cpp
ui/layersitemdelegate.cpp
)
kde4_add_ui_files(okularpart_SRCS

View file

@ -18,7 +18,6 @@
// local includes
#include "core/document.h"
#include "ktreeviewsearchline.h"
#include "layersitemdelegate.h"
Layers::Layers(QWidget *parent, Okular::Document *document) : QWidget(parent), m_document(document)
{
@ -39,16 +38,12 @@ Layers::Layers(QWidget *parent, Okular::Document *document) : QWidget(parent), m
QAbstractItemModel * layersModel = m_document->layersModel();
QAbstractItemDelegate * delegate = new LayersItemDelegate( this );
m_treeView->setItemDelegate( delegate );
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)), this, SLOT(repaintItems(QModelIndex,QModelIndex)) );
}
else
{
@ -74,7 +69,6 @@ void Layers::notifySetup( const QVector< Okular::Page * > & /*pages*/, int /*set
m_searchLine->addTreeView( m_treeView );
emit hasLayers( true );
connect( layersModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), m_document, SLOT(reloadDocument()) );
connect( layersModel, SIGNAL(dataChanged(const QModelIndex,const QModelIndex)), this, SLOT(repaintItems(const QModelIndex,const QModelIndex)) );
}
else
{
@ -89,10 +83,4 @@ void Layers::saveSearchOptions()
Okular::Settings::self()->writeConfig();
}
void Layers::repaintItems(const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
if( topLeft == bottomRight )
m_treeView->update( topLeft );
}
#include "layers.moc"

View file

@ -41,7 +41,6 @@ Q_OBJECT
private slots:
void saveSearchOptions();
void repaintItems( const QModelIndex &topLeft, const QModelIndex &bottomRight );
private:

View file

@ -1,37 +0,0 @@
/***************************************************************************
* Copyright (C) 2015 by Saheb Preet Singh <saheb.preet@gmail.com> *
* *
* 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 "layersitemdelegate.h"
#include <kicon.h>
#include <QPainter>
#include <QDebug>
Q_DECLARE_METATYPE( Qt::CheckState );
LayersItemDelegate::LayersItemDelegate( QWidget * parent )
: QStyledItemDelegate( parent )
{
}
void LayersItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
Qt::CheckState state = (Qt::CheckState ) qvariant_cast<int>( index.data( Qt::CheckStateRole ) );
if( option.state & QStyle::State_Selected )
painter->fillRect( option.rect, option.palette.highlight() );
KIcon icon = state == Qt::Checked ? KIcon( "layer-visible-on" ) : KIcon( "layer-visible-off" );
QRect iconRect = option.rect;
iconRect.setWidth( iconRect.height() );
painter->drawPixmap( iconRect, icon.pixmap( iconRect.size() ) );
QString text = qvariant_cast<QString>( index.data( Qt::DisplayRole ) );
QRect textRect = QRect( iconRect.topRight() + QPoint( 5, 0 ), QSize( option.rect.width() - iconRect.width(), option.rect.height() ) );
painter->drawText( textRect, Qt::AlignVCenter, text );
}

View file

@ -1,26 +0,0 @@
/***************************************************************************
* Copyright (C) 2015 by Saheb Preet Singh <saheb.preet@gmail.com> *
* *
* 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_LAYERSITEMDELEGATE_H_
#define _OKULAR_LAYERSITEMDELEGATE_H_
#include <QStyledItemDelegate>
#include "okular_part_export.h"
class OKULAR_PART_EXPORT LayersItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
LayersItemDelegate( QWidget * parent);
virtual void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
};
#endif