kpilot

listCat.h

Go to the documentation of this file.
00001 #ifndef LISTCAT_H
00002 #define LISTCAT_H
00003 /* listCat.h            KPilot
00004 **
00005 ** Copyright (C) 2000-2001 by Adriaan de Groot
00006 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 **
00008 */
00009 
00016 /*
00017 ** This program is free software; you can redistribute it and/or modify
00018 ** it under the terms of the GNU General Public License as published by
00019 ** the Free Software Foundation; either version 2 of the License, or
00020 ** (at your option) any later version.
00021 **
00022 ** This program is distributed in the hope that it will be useful,
00023 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00025 ** GNU General Public License for more details.
00026 **
00027 ** You should have received a copy of the GNU General Public License
00028 ** along with this program in a file called COPYING; if not, write to
00029 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00030 ** MA 02110-1301, USA.
00031 */
00032 
00033 /*
00034 ** Bug reports and questions can be sent to kde-pim@kde.org
00035 */
00036 
00037 #include <klistview.h>
00038 class QStringList;
00039 
00064 class ListCategorizer : public KListView
00065 {
00066     Q_OBJECT
00067 
00068 public:
00076     ListCategorizer(QWidget *parent,
00077         const char *name = 0);
00085     ListCategorizer(const QStringList& categories,
00086         bool startOpen,
00087         QWidget *parent,
00088         const char *name = 0);
00089 
00095     void addCategories(const QStringList&);
00105     QListViewItem *addCategory(const QString& name,
00106         const QString& description = QString::null);
00111     QStringList categories() const
00112     {
00113         return listSiblings(firstChild());
00114     } ;
00115 
00124     QListViewItem *addItem(const QString& category,
00125         const QString& name,
00126         const QString& description = QString::null);
00135     QStringList items(const QString& category,int column=0) const
00136     {
00137         return listSiblings(findCategory(category),column);
00138     }
00139 
00146     QListViewItem *findCategory(const QString& categoryName) const;
00157     QStringList listSiblings(const QListViewItem *p,int column=0) const;
00158 
00165     bool startOpen() const { return fStartOpen; } ;
00171     void setStartOpen(bool b) { fStartOpen=b; } ;
00172 
00173 protected:
00177     virtual bool acceptDrag (QDropEvent* event) const;
00181     virtual void startDrag();
00185     virtual void contentsDropEvent (QDropEvent*);
00186 
00187 
00188 
00189 private:
00194     void setupWidget();
00195 
00196     bool fStartOpen:1;
00197 } ;
00198 
00199 
00200 class RichListViewItem : public QListViewItem
00201 {
00202 public:
00203     RichListViewItem(QListViewItem *parent,
00204         QString,
00205         int);
00206     virtual ~RichListViewItem();
00207 
00208     virtual void paintCell(QPainter *,
00209         const QColorGroup &,
00210         int column,
00211         int width,
00212         int alignment);
00213 
00214     virtual void setup();
00215 
00216     bool isRich(int c) const { return fIsRich[c]; } ;
00217     void setRich(int c,bool b) { fIsRich[c]=b; } ;
00218 
00219 protected:
00220     void computeHeight(int c);
00221 
00222 protected:
00223     bool *fIsRich;
00224     QRect *fRect;
00225     int fColumns;
00226 
00227 } ;
00228 
00229 #endif