kitchensync
kwidgetlist.h
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef KWIDGETLIST_H 00023 #define KWIDGETLIST_H 00024 00025 #include <qscrollview.h> 00026 00027 class KWidgetListItem; 00028 00029 class KWidgetList : public QScrollView 00030 { 00031 Q_OBJECT 00032 00033 public: 00034 KWidgetList( QWidget *parent = 0, const char *name = 0 ); 00035 ~KWidgetList(); 00036 00037 uint count() const; 00038 00039 void appendItem( KWidgetListItem *item ); 00040 void removeItem( int index ); 00041 void takeItem( KWidgetListItem *item ); 00042 00043 void setSelected( KWidgetListItem *item ); 00044 void setSelected( int index ); 00045 00046 bool isSelected( KWidgetListItem *item ) const; 00047 bool isSelected( int index ) const; 00048 00049 KWidgetListItem *selectedItem() const; 00050 KWidgetListItem *item( int index ) const; 00051 00052 int index( KWidgetListItem *item ) const; 00053 00054 virtual bool eventFilter( QObject *object, QEvent *event ); 00055 00056 public slots: 00057 void clear(); 00058 virtual void setFocus(); 00059 00060 signals: 00061 void selectionChanged( KWidgetListItem *item ); 00062 void doubleClicked( KWidgetListItem *item ); 00063 00064 private: 00065 class Private; 00066 Private *d; 00067 }; 00068 00069 class KWidgetListItem : public QWidget 00070 { 00071 public: 00072 KWidgetListItem( KWidgetList *parent, const char *name = 0 ); 00073 ~KWidgetListItem(); 00074 00075 void setSelected( bool selected ); 00076 00077 protected: 00078 void setForegroundColor( const QColor& ); 00079 void setBackgroundColor( const QColor& ); 00080 void setSelectionForegroundColor( const QColor& ); 00081 void setSelectionBackgroundColor( const QColor& ); 00082 00083 private: 00084 QColor mForegroundColor; 00085 QColor mBackgroundColor; 00086 QColor mSelectionForegroundColor; 00087 QColor mSelectionBackgroundColor; 00088 }; 00089 00090 #endif