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