kpilot

listItems.h

Go to the documentation of this file.
00001 /* listItems.h          KPilot
00002 **
00003 ** Copyright (C) 1998-2001 by Dan Pilone
00004 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00005 **
00006 ** This file defines a subclasse of QListBoxText that carries
00007 ** additional information useful for Pilot records. In particular it
00008 ** carries an int (for the pilot's uid?) and a void * (for pilotrecord?)
00009 */
00010 
00011 /*
00012 ** This program is free software; you can redistribute it and/or modify
00013 ** it under the terms of the GNU General Public License as published by
00014 ** the Free Software Foundation; either version 2 of the License, or
00015 ** (at your option) any later version.
00016 **
00017 ** This program is distributed in the hope that it will be useful,
00018 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 ** GNU General Public License for more details.
00021 **
00022 ** You should have received a copy of the GNU General Public License
00023 ** along with this program in a file called COPYING; if not, write to
00024 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 ** MA 02110-1301, USA.
00026 */
00027 
00028 /*
00029 ** Bug reports and questions can be sent to kde-pim@kde.org
00030 */
00031 
00032 #ifndef _KPILOT_LISTITEMS_H
00033 #define _KPILOT_LISTITEMS_H
00034 
00035 #include <qlistview.h>
00036 #include <pi-dlp.h>
00037 
00038 class PilotListItem : public QListBoxText
00039 {
00040 public:
00041     PilotListItem(const QString &text, recordid_t pilotid=0, void *r=0);
00042     virtual ~PilotListItem();
00043     recordid_t id() const {return fid;};
00044     const void *rec() const {return fr;};
00045 
00046 
00047 protected:
00048     recordid_t fid;
00049     void *fr;
00050 
00051 #ifdef DEBUG
00052 public:
00053     static void counts();
00054 private:
00055     static int crt,del,bal,count;
00056 #endif
00057 };
00058 
00059 class PilotCheckListItem : public QCheckListItem
00060 {
00061 public:
00062     PilotCheckListItem( QListView * parent, const QString & text, recordid_t pilotid=0, void *r=0);
00063     virtual ~PilotCheckListItem();
00064     recordid_t id() const {return fid;};
00065     const void  *rec() const {return fr;};
00066 protected:
00067     virtual void stateChange ( bool );
00068     recordid_t fid;
00069     void *fr;
00070 #ifdef DEBUG
00071 public:
00072     static void counts();
00073 private:
00074     static int crt, del, bal, count;
00075 #endif
00076 };
00077 
00078 struct PilotListViewItemData
00079 {
00080     int valCol;
00081     bool valOk;
00082     unsigned long val;
00083 };
00084 
00085 class PilotListViewItem : public QListViewItem
00086 {
00087 public:
00088     PilotListViewItem( QListView * parent,
00089         QString label1, QString label2 = QString::null,
00090         QString label3 = QString::null, QString label4 = QString::null,
00091         recordid_t pilotid=0, void *r=0);
00092     virtual ~PilotListViewItem();
00093     recordid_t id() const {return fid;};
00094     const void  *rec() const {return fr;};
00095 public:
00096     void setNumericCol(int col, bool numeric);
00097     int compare( QListViewItem *i, int col, bool ascending ) const;
00098 protected:
00099     QValueList<int> numericCols;
00100     recordid_t fid;
00101     void *fr;
00102     // Caching to make sorting faster:
00103     PilotListViewItemData*d;
00104     unsigned long colValue(int col, bool *ok) const;
00105 #ifdef DEBUG
00106 public:
00107     static void counts();
00108 private:
00109     static int crt, del, bal, count;
00110 #endif
00111 };
00112 
00113 
00114 #endif