Blokkal
an Extendable KDE Blogging Client
SourceForge.net Logo

checkboxdelegate.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 - 2008 by Martin Mueller                           *
00003  *   orvio@orvio.de                                                        *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef BLOKKALUICHECKBOXDELEGATE_H
00021 #define BLOKKALUICHECKBOXDELEGATE_H
00022 
00023 #include <QtGui/QItemDelegate>
00024 
00025 #include "../blokkal_export.h"
00026 
00027 namespace Blokkal {
00028 namespace Ui {
00029 class CheckBoxView;
00030 
00037 class BLOKKAL_EXPORT CheckBoxDelegate : public QItemDelegate
00038 {
00039 Q_OBJECT
00040 public:
00044         CheckBoxDelegate( QObject * parent = 0 );
00045         ~CheckBoxDelegate( void );
00046 
00047 protected:
00052         int checkBoxSize( const QFontMetrics & metrics ) const;
00053 
00059         virtual QRect checkBoxRect( const QStyleOptionViewItem & option,
00060                                     const QModelIndex & index ) const;
00061 
00066         virtual void paint( QPainter * painter,
00067                             const QStyleOptionViewItem & option,
00068                             const QModelIndex &index) const;
00074         virtual QSize sizeHint(const QStyleOptionViewItem & option,
00075                                const QModelIndex & index) const;
00076 
00080         void setView( Blokkal::Ui::CheckBoxView * view );
00081 
00086         Blokkal::Ui::CheckBoxView * view( void ) const;
00087 
00092         virtual bool editorEvent(QEvent * event,
00093                                  QAbstractItemModel * model,
00094                                  const QStyleOptionViewItem & option,
00095                                  const QModelIndex & index );
00096 
00102         virtual void stateChanged( QAbstractItemModel * model,
00103                                    const QModelIndex & index,
00104                                    Qt::CheckState newState );
00105 
00111         void layoutPlainItem( const QStyleOptionViewItem & option,
00112                               const QModelIndex & index,
00113                               QRect & textRect ) const;
00114         
00115 private:
00116         friend class CheckBoxView;
00117         class Private;
00118         Private * const d;
00119 };
00120 }
00121 }
00122 #endif