kpilot
pilotComponent.ccGo to the documentation of this file.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
00032 #include "options.h"
00033
00034 #include <time.h>
00035
00036 #include <pi-appinfo.h>
00037
00038 #include <qwidget.h>
00039 #include <qcombobox.h>
00040
00041 #include <kdebug.h>
00042
00043 #include "kpilotConfig.h"
00044 #include "pilotRecord.h"
00045 #include "pilot.h"
00046
00047 #include "pilotComponent.moc"
00048
00049 PilotComponent::PilotComponent(QWidget * parent,
00050 const char *id,
00051 const QString & path) :
00052 QWidget(parent, id),
00053 fDBPath(path),
00054 shown(false)
00055 {
00056 FUNCTIONSETUP;
00057
00058 if (parent)
00059 {
00060 resize(parent->geometry().width(),
00061 parent->geometry().height());
00062 }
00063
00064 }
00065
00066
00067
00068 int PilotComponent::findSelectedCategory(QComboBox * fCatList,
00069 struct CategoryAppInfo *info, bool AllIsUnfiled)
00070 {
00071 FUNCTIONSETUP;
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 int currentCatID = 0;
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 if (fCatList->currentItem() == 0)
00096 {
00097 currentCatID = (-1);
00098 #ifdef DEBUG
00099 DEBUGKPILOT << fname << ": Category 'All' selected.\n";
00100 #endif
00101 }
00102 else
00103 {
00104 QString selectedCategory =
00105 fCatList->text(fCatList->currentItem());
00106 currentCatID = Pilot::findCategory(info, selectedCategory, AllIsUnfiled);
00107 }
00108
00109 if ((currentCatID == -1) && AllIsUnfiled)
00110 currentCatID = 0;
00111 return currentCatID;
00112 }
00113
00114
00115 void PilotComponent::populateCategories(QComboBox * c,
00116 struct CategoryAppInfo *info)
00117 {
00118 FUNCTIONSETUP;
00119
00120 #ifdef DEBUG
00121 DEBUGKPILOT << fname
00122 << ": Combo box @"
00123 << (long) c << " and info @" << (long) info << endl;
00124 #endif
00125
00126 c->clear();
00127
00128 if (!info)
00129 goto CategoryAll;
00130
00131
00132
00133
00134
00135
00136
00137 for (unsigned int i = 0; i < Pilot::CATEGORY_COUNT; i++)
00138 {
00139 if (info->name[i][0])
00140 {
00141 #ifdef DEBUG
00142 DEBUGKPILOT << fname
00143 << ": Adding category: "
00144 << info->name[i]
00145 << " with ID: " << (int) info->ID[i] << endl;
00146 #endif
00147
00148 c->insertItem(Pilot::fromPilot(info->name[i]));
00149 }
00150 }
00151
00152 CategoryAll:
00153 c->insertItem(i18n("All"), 0);
00154 }
00155
00156
00157 void PilotComponent::slotShowComponent()
00158 {
00159 FUNCTIONSETUP;
00160
00161 #ifdef DEBUG
00162 DEBUGKPILOT << fname << ": Showing component @" << (long) this << endl;
00163 #endif
00164
00165 emit showComponent(this);
00166 }
00167
00168 bool PilotComponent::preHotSync(QString &)
00169 {
00170 FUNCTIONSETUP;
00171
00172 return true;
00173 }
00174
00175 void PilotComponent::markDBDirty(const QString db)
00176 {
00177 FUNCTIONSETUP;
00178 KPilotConfig::addDirtyDatabase(db);
00179 KPilotConfig::sync();
00180 }
00181
00182 void PilotComponent::showKPilotComponent( bool toShow )
00183 {
00184 if ( toShow != shown )
00185 {
00186 shown = toShow;
00187 if (shown) showComponent();
00188 else hideComponent();
00189 }
00190 }
|