kwidgetlistbox.h

00001 /*
00002  * Copyright (C) 2005 Petri Damstén <petri.damsten@iki.fi>
00003  *
00004  * This file is part of SuperKaramba.
00005  *
00006  *  SuperKaramba is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  SuperKaramba 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
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with SuperKaramba; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  ****************************************************************************/
00020 #ifndef KWIDGETLISTBOX_H
00021 #define KWIDGETLISTBOX_H
00022 
00023 #include <qtable.h>
00024 
00029 typedef bool (*show_callback) (int index, QWidget* widget, void* data);
00030 
00031 class KWidgetListbox : public QTable
00032 {
00033     Q_OBJECT
00034 
00035   public:
00036     KWidgetListbox(QWidget *parent = 0, const char *name = 0);
00037     ~KWidgetListbox();
00038 
00039     int insertItem(QWidget* item, int index = -1);
00040     void setSelected(QWidget* item);
00041     void setSelected(int index);
00042     void removeItem(QWidget* item);
00043     void removeItem(int index);
00044     void clear();
00045     int selected() const;
00046     QWidget* selectedItem() const;
00047     QWidget* item(int index) const;
00048     int index(QWidget* itm) const;
00049     uint count() const { return numRows(); };
00050 
00051     void showItems(show_callback func = 0, void* data = 0);
00052 
00053     void paintCell(QPainter* p, int row, int col, const QRect& cr,
00054                    bool selected, const QColorGroup& cg);
00055   protected:
00056     void setItemColors(int index, bool even);
00057     void updateColors();
00058     bool even(int index);
00059     virtual void showEvent(QShowEvent* e);
00060 
00061   protected slots:
00062     void selectionChanged(int row, int col);
00063 
00064   signals:
00065     void selected(int index);
00066 };
00067 
00068 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys