kaddressbook
comboboxheaderview.h
Go to the documentation of this file.00001 /* 00002 This file is part of KAddressBook. 00003 Copyright (C) 2007 Mathias Soeken <msoeken@tzi.de> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library 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 GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 #ifndef COMBOBOXHEADERVIEW_H 00021 #define COMBOBOXHEADERVIEW_H 00022 00023 #include <QtCore/QRect> 00024 #include <QtCore/QStringList> 00025 #include <QtGui/QHeaderView> 00026 00027 class QAbstractItemModel; 00028 class QComboBox; 00029 class QEvent; 00030 class QMouseEvent; 00031 class QResizeEvent; 00032 class QTableWidget; 00033 00034 class ComboBoxHeaderView : public QHeaderView { 00035 Q_OBJECT 00036 00037 Q_PROPERTY( QStringList items READ items ) 00038 Q_PROPERTY( int margin READ margin WRITE setMargin ) 00039 00040 public: 00041 ComboBoxHeaderView( QStringList items, 00042 QTableWidget *parent, 00043 bool hoverStyle = true ); 00044 virtual ~ComboBoxHeaderView(); 00045 00046 QString headerLabel( int logicalIndex ) const; 00047 QStringList items() const; 00048 int margin() const; 00049 void setMargin( int margin); 00050 int indexOfHeaderLabel( int logicalIndex ) const; 00051 QString valueOfHeaderLabel( int logicalIndex ) const; 00052 00053 public Q_SLOTS: 00054 void adaptMove( int ); 00055 00056 private: 00057 inline QRect sectionRect( int logicalIndex ) const; 00058 inline void adjustComboBoxIndex( QComboBox *comboBox, int logicalIndex ); 00059 void adjustComboBoxIndex( int logicalIndex ); 00060 bool isViewVisible() const; 00061 00062 private Q_SLOTS: 00063 void initialize(); 00064 void slotActivated( const QString &text ); 00065 void setCurrentIndex( int index ); 00066 void slotResetTexts(); 00067 00068 protected: 00069 virtual void mouseMoveEvent( QMouseEvent *event ); 00070 virtual void leaveEvent( QEvent *event ); 00071 virtual void resizeEvent( QResizeEvent *event ); 00072 virtual void setModel( QAbstractItemModel *model ); 00073 00074 private: 00075 //@cond PRIVATE 00076 class Private; 00077 Private *const d; 00078 //@endcond 00079 00080 class ComboBox; 00081 }; 00082 00083 #endif
KDE 4.2 API Reference