listItems.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 static const char *listitems_id =
00031 "$Id: listItems.cc,v 1.12 2003/06/19 21:58:04 kainhofe Exp $";
00032
00033 #include "options.h"
00034
00035
00036 #include <qstring.h>
00037 #include <qlistbox.h>
00038 #include <qlistview.h>
00039
00040
00041 #ifndef _KPILOT_LISTITEMS_H
00042 #include "listItems.h"
00043 #endif
00044
00045 #ifdef DEBUG
00046 int PilotListItem::crt = 0;
00047 int PilotListItem::del = 0;
00048 int PilotListItem::count = 0;
00049
00050 void PilotListItem::counts()
00051 {
00052 FUNCTIONSETUP;
00053 DEBUGKPILOT << fname
00054 << ": created=" << crt << " deletions=" << del << endl;
00055 }
00056 #endif
00057
00058 PilotListItem::PilotListItem(const QString & text,
00059 recordid_t pilotid, void *r) :
00060 QListBoxText(text),
00061 fid(pilotid),
00062 fr(r)
00063 {
00064
00065 #ifdef DEBUG
00066 crt++;
00067 count++;
00068 if (!(count & 0xff))
00069 counts();
00070 #endif
00071 (void) listitems_id;
00072 }
00073
00074 PilotListItem::~PilotListItem()
00075 {
00076
00077 #ifdef DEBUG
00078 del++;
00079 count++;
00080 if (!(count & 0xff))
00081 counts();
00082 #endif
00083 }
00084
00085
00086
00087
00088 #ifdef DEBUG
00089 int PilotCheckListItem::crt = 0;
00090 int PilotCheckListItem::del = 0;
00091 int PilotCheckListItem::count = 0;
00092
00093 void PilotCheckListItem::counts()
00094 {
00095 FUNCTIONSETUP;
00096 DEBUGKPILOT << fname
00097 << ": created=" << crt << " deletions=" << del << endl;
00098 }
00099 #endif
00100
00101 PilotCheckListItem::PilotCheckListItem(QListView * parent, const QString & text, recordid_t pilotid, void *r) :
00102 QCheckListItem(parent, text, QCheckListItem::CheckBox),
00103 fid(pilotid),
00104 fr(r)
00105 {
00106
00107 #ifdef DEBUG
00108 crt++;
00109 count++;
00110 if (!(count & 0xff))
00111 counts();
00112 #endif
00113 (void) listitems_id;
00114 }
00115
00116 PilotCheckListItem::~PilotCheckListItem()
00117 {
00118
00119 #ifdef DEBUG
00120 del++;
00121 count++;
00122 if (!(count & 0xff))
00123 counts();
00124 #endif
00125 }
00126
00127 void PilotCheckListItem::stateChange ( bool on)
00128 {
00129
00130 QCheckListItem::stateChange(on);
00131
00132 }
00133
00134
00135
00136
00137 #ifdef DEBUG
00138 int PilotListViewItem::crt = 0;
00139 int PilotListViewItem::del = 0;
00140 int PilotListViewItem::count = 0;
00141
00142 void PilotListViewItem::counts()
00143 {
00144 FUNCTIONSETUP;
00145 DEBUGKPILOT << fname
00146 << ": created=" << crt << " deletions=" << del << endl;
00147 }
00148 #endif
00149
00150 PilotListViewItem::PilotListViewItem( QListView * parent,
00151 QString label1, QString label2, QString label3, QString label4,
00152 recordid_t pilotid, void *r):
00153 QListViewItem(parent, label1, label2, label3, label4,
00154 QString::null, QString::null, QString::null, QString::null),
00155 fid(pilotid),
00156 fr(r),
00157 d(new PilotListViewItemData)
00158 {
00159
00160 if (d) d->valCol=-1;
00161 #ifdef DEBUG
00162 crt++;
00163 count++;
00164 if (!(count & 0xff))
00165 counts();
00166 #endif
00167 (void) listitems_id;
00168 }
00169
00170 PilotListViewItem::~PilotListViewItem()
00171 {
00172
00173 #ifdef DEBUG
00174 del++;
00175 count++;
00176 if (!(count & 0xff))
00177 counts();
00178 #endif
00179 }
00180 void PilotListViewItem::setNumericCol(int col, bool numeric)
00181 {
00182
00183 if (numeric)
00184 {
00185 if (!numericCols.contains(col))
00186 numericCols.append(col);
00187 }
00188 else
00189 {
00190 if (numericCols.contains(col))
00191 numericCols.remove(col);
00192 }
00193 }
00194
00195 unsigned long PilotListViewItem::colValue(int col, bool *ok) const
00196 {
00197
00198
00199
00200
00201
00202
00203 if (d->valCol!=col)
00204 {
00205
00206 d->val=key(col, true).toULong(&d->valOk);
00207 d->valCol=col;
00208 }
00209 if (ok) (*ok)=d->valOk;
00210 return d->val;
00211 }
00212
00213 int PilotListViewItem::compare( QListViewItem *i, int col, bool ascending ) const
00214 {
00215
00216 PilotListViewItem*item=dynamic_cast<PilotListViewItem*>(i);
00217
00218
00219
00220 if (item && numericCols.contains(col))
00221 {
00222
00223
00224
00225 bool ok1, ok2;
00227 unsigned long l1=colValue(col, &ok1);
00228 unsigned long l2=item->colValue(col, &ok2);
00229
00230
00231
00232 if (ok1 && ok2)
00233 {
00234
00235
00236 int res=0;
00237 if (l1<l2) res=-1;
00238 else if (l1>l2) res=1;
00239
00240
00241
00242
00243 return res;
00244 }
00245 }
00246 return QListViewItem::compare(i, col, ascending);
00247 }
00248
This file is part of the documentation for kpilot Library Version 3.2.2.