pilotComponent.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
00031 #include "options.h"
00032
00033 #include <time.h>
00034
00035 #ifndef _PILOT_APPINFO_H_
00036 #include <pi-appinfo.h>
00037 #endif
00038
00039 #ifndef QWIDGET_H
00040 #include <qwidget.h>
00041 #endif
00042
00043 #ifndef QCOMBOBOX_H
00044 #include <qcombobox.h>
00045 #endif
00046
00047 #ifndef _KDEBUG_H
00048 #include <kdebug.h>
00049 #endif
00050
00051 #include "pilotComponent.moc"
00052
00053 static const char *pilotComponent_id =
00054 "$Id: pilotComponent.cc,v 1.23.6.4 2003/03/12 23:31:14 adridg Exp $";
00055
00056
00057
00058
00059 #define MAX_CATEGORIES (15)
00060
00061 PilotComponent::PilotComponent(QWidget * parent,
00062 const char *id,
00063 const QString & path) :
00064 QWidget(parent, id),
00065 fDBPath(path)
00066 {
00067 FUNCTIONSETUP;
00068
00069 if (parent)
00070 {
00071 resize(parent->geometry().width(),
00072 parent->geometry().height());
00073 }
00074
00075 (void) pilotComponent_id;
00076 }
00077
00078
00079
00080 int PilotComponent::findSelectedCategory(QComboBox * fCatList,
00081 struct CategoryAppInfo *info, bool AllIsUnfiled)
00082 {
00083 FUNCTIONSETUP;
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 int currentCatID = 0;
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 if (fCatList->currentItem() == 0)
00108 {
00109 currentCatID = (-1);
00110 #ifdef DEBUG
00111 DEBUGKPILOT << fname << ": Category 'All' selected.\n";
00112 #endif
00113 }
00114 else
00115 {
00116 QString selectedCategory =
00117 fCatList->text(fCatList->currentItem());
00118
00119 #ifdef DEBUG
00120 DEBUGKPILOT << fname
00121 << ": List item "
00122 << fCatList->currentItem()
00123 << " (of "
00124 << fCatList->count()
00125 << ") "
00126 << " selected, text=" << selectedCategory << endl;
00127 #endif
00128
00129 currentCatID = 0;
00130 while (strcmp(info->name[currentCatID],
00131 selectedCategory.latin1()) &&
00132 (currentCatID < MAX_CATEGORIES))
00133 {
00134 #ifdef DEBUG
00135 DEBUGKPILOT << fname
00136 << ": Didn't match category "
00137 << currentCatID
00138 << "=" << info->name[currentCatID] << endl;
00139 #endif
00140
00141 currentCatID++;
00142 }
00143
00144 if (!(currentCatID < MAX_CATEGORIES))
00145 {
00146 currentCatID = 0;
00147 while (strcmp(info->name[currentCatID],
00148 selectedCategory.latin1()) &&
00149 (currentCatID < MAX_CATEGORIES))
00150 {
00151 currentCatID++;
00152 }
00153 }
00154
00155 if (!(currentCatID < MAX_CATEGORIES))
00156 {
00157 currentCatID = 0;
00158 while (strcmp(info->name[currentCatID],
00159 selectedCategory.ascii()) &&
00160 (currentCatID < MAX_CATEGORIES))
00161 {
00162 currentCatID++;
00163 }
00164 }
00165
00166 if (!(currentCatID < MAX_CATEGORIES))
00167 {
00168 currentCatID = 0;
00169 while ((info->name[currentCatID][0]) &&
00170 (currentCatID < MAX_CATEGORIES))
00171 {
00172 if (selectedCategory ==
00173 QString::fromLatin1(info->
00174 name[currentCatID]))
00175 {
00176 #ifdef DEBUG
00177 DEBUGKPILOT << fname
00178 << ": Matched "
00179 << currentCatID << endl;
00180 #endif
00181
00182 break;
00183 }
00184 currentCatID++;
00185 }
00186 }
00187
00188 if (currentCatID < MAX_CATEGORIES)
00189 {
00190 #ifdef DEBUG
00191 DEBUGKPILOT << fname
00192 << ": Matched category "
00193 << currentCatID
00194 << "=" << info->name[currentCatID] << endl;
00195 #endif
00196 }
00197 else
00198 {
00199 #ifdef DEBUG // necessary for Tru64 unix
00200 kdWarning() << k_funcinfo
00201 << ": Selected category didn't match "
00202 "any name!\n";
00203 kdWarning() << k_funcinfo
00204 << ": Number of listed categories "
00205 << fCatList->count() << endl;
00206 kdWarning() << k_funcinfo
00207 << ": Selected category ("
00208 << selectedCategory
00209 << ") expands to "
00210 << qstringExpansion(selectedCategory) << endl;
00211 kdWarning() << k_funcinfo
00212 << ": Categories expand to " << endl;
00213 #endif
00214 currentCatID = 0;
00215 while ((info->name[currentCatID][0]) &&
00216 (currentCatID < MAX_CATEGORIES))
00217 {
00218 #ifdef DEBUG
00219 kdWarning() << k_funcinfo
00220 << ": Category ["
00221 << currentCatID
00222 << "] = "
00223 << charExpansion(info->
00224 name[currentCatID]) << endl;
00225 #endif
00226 currentCatID++;
00227 }
00228
00229 currentCatID = (-1);
00230 }
00231 }
00232
00233 if ((currentCatID == -1) && AllIsUnfiled)
00234 currentCatID = 0;
00235 return currentCatID;
00236 }
00237
00238
00239 void PilotComponent::populateCategories(QComboBox * c,
00240 struct CategoryAppInfo *info)
00241 {
00242 FUNCTIONSETUP;
00243
00244 #ifdef DEBUG
00245 DEBUGKPILOT << fname
00246 << ": Combo box @"
00247 << (int) c << " and info @" << (int) info << endl;
00248 #endif
00249
00250 c->clear();
00251
00252 if (!info)
00253 goto CategoryAll;
00254
00255
00256
00257
00258
00259
00260
00261 for (int i = 0; i < 15; i++)
00262 {
00263 if (info->name[i][0])
00264 {
00265 #ifdef DEBUG
00266 DEBUGKPILOT << fname
00267 << ": Adding category: "
00268 << info->name[i]
00269 << " with ID: " << (int) info->ID[i] << endl;
00270 #endif
00271
00272 c->insertItem(QString::fromLatin1(info->name[i]));
00273 }
00274 }
00275
00276 CategoryAll:
00277 c->insertItem(i18n("All"), 0);
00278 }
00279
00280
00281 void PilotComponent::slotShowComponent()
00282 {
00283 FUNCTIONSETUP;
00284
00285 #ifdef DEBUG
00286 DEBUGKPILOT << fname << ": Showing component @" << (int) this << endl;
00287 #endif
00288
00289 emit showComponent(this);
00290 }
00291
00292 bool PilotComponent::preHotSync(QString &)
00293 {
00294 FUNCTIONSETUP;
00295
00296 return true;
00297 }
00298
This file is part of the documentation for kdelibs Version 3.1.5.