From 8f5fecfd5b3e674c9b5d3f5d23c2c3990e75282f Mon Sep 17 00:00:00 2001 From: Saheb Preet Singh Date: Sun, 12 Jul 2015 17:02:34 +0530 Subject: [PATCH] Revert "added layer-visible-on and layer-visible-off icon instead of checkboxes" This reverts commit 288d3e4c1baeee3924c1bb63c0531f0e15d15ef2. --- CMakeLists.txt | 1 - ui/layers.cpp | 12 ------------ ui/layers.h | 1 - ui/layersitemdelegate.cpp | 37 ------------------------------------- ui/layersitemdelegate.h | 26 -------------------------- 5 files changed, 77 deletions(-) delete mode 100644 ui/layersitemdelegate.cpp delete mode 100644 ui/layersitemdelegate.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 90861e683..8e6658481 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/ui/layers.cpp b/ui/layers.cpp index 6051f46f0..8b4770da9 100644 --- a/ui/layers.cpp +++ b/ui/layers.cpp @@ -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" diff --git a/ui/layers.h b/ui/layers.h index cf0e8c9a5..4c2a08f26 100644 --- a/ui/layers.h +++ b/ui/layers.h @@ -41,7 +41,6 @@ Q_OBJECT private slots: void saveSearchOptions(); - void repaintItems( const QModelIndex &topLeft, const QModelIndex &bottomRight ); private: diff --git a/ui/layersitemdelegate.cpp b/ui/layersitemdelegate.cpp deleted file mode 100644 index 52f284871..000000000 --- a/ui/layersitemdelegate.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015 by Saheb Preet Singh * - * * - * 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 -#include -#include - -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( 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( 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 ); -} \ No newline at end of file diff --git a/ui/layersitemdelegate.h b/ui/layersitemdelegate.h deleted file mode 100644 index b21dc9fa5..000000000 --- a/ui/layersitemdelegate.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015 by Saheb Preet Singh * - * * - * 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 - -#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 \ No newline at end of file