MultiDB-factory.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 #include "options.h"
00031
00032 #include <kinstance.h>
00033 #include <kaboutdata.h>
00034 #include "kpilotlink.h"
00035 #include "MultiDB-factory.h"
00036 #include "MultiDB-factory.moc"
00037
00038
00039 KPilotSyncType::KPilotSyncType(){
00040 ShortName="";
00041 LongName="";
00042 id=st_ask;
00043 flags=0;
00044 }
00045 KPilotSyncType::KPilotSyncType(QString sn="", QString ln="", int i=st_ask, int flg=0) {
00046 ShortName=sn;
00047 LongName=ln;
00048 id=i;
00049 flags=flg;
00050 }
00051 KPilotSyncType::KPilotSyncType(KPilotSyncType*tp) {
00052 ShortName=tp->ShortName;
00053 LongName=tp->LongName;
00054 id=tp->id;
00055 flags=tp->flags;
00056 }
00057
00058 KAboutData *MultiDBConduitFactory::fAbout = 0L;
00059 SyncTypeList_t *MultiDBConduitFactory::synctypes = 0L;
00060 QString MultiDBConduitFactory::conflictResolution = "ConflictResolution";
00061 QString MultiDBConduitFactory::archive = "ArchiveDeletedEntries";
00062 QString MultiDBConduitFactory::fullSyncOnPCChange = "FullSyncOnPCChange";
00063
00064 MultiDBConduitFactory::MultiDBConduitFactory(QObject *p, const char *n) :
00065 KLibFactory(p,n) {
00066 FUNCTIONSETUP;
00067
00068 fInstance = new KInstance(n);
00069 synctypes=new SyncTypeList_t();
00070 synctypes->setAutoDelete( TRUE );
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 }
00084
00085 void MultiDBConduitFactory::buildConduitInfo() {
00086 synctypes->clear();
00087
00088 synctypes->append( new KPilotSyncType(i18n("ignore"), i18n("Completely ignore database"), st_ignore, 0) );
00089 synctypes->append( new KPilotSyncType(i18n("backup"), i18n("Only do a backup"), st_backup, 0) );
00090 synctypes->append( new KPilotSyncType(i18n("pdb"), i18n("Save as .pdb database"), st_pdb, SYNC_NEEDSFILE) );
00091 customConduitInfo();
00092 }
00093
00094
00095 MultiDBConduitFactory::~MultiDBConduitFactory() {
00096 FUNCTIONSETUP;
00097
00098 KPILOT_DELETE(fInstance);
00099 KPILOT_DELETE(fAbout);
00100 }
00101
00102 QObject *MultiDBConduitFactory::createObject( QObject *p,
00103 const char *n, const char *c, const QStringList &a) {
00104 FUNCTIONSETUP;
00105
00106 #ifdef DEBUG
00107 DEBUGCONDUIT << fname << ": Creating object of class " << c << endl;
00108 #endif
00109
00110 if (!synctypes || synctypes->isEmpty()) {
00111 synctypes=new SyncTypeList_t();
00112 buildConduitInfo();
00113 }
00114
00115
00116
00117 if (qstrcmp(c,"ConduitConfig")==0) {
00118 QWidget *w = dynamic_cast<QWidget *>(p);
00119
00120 if (w) {
00121 return createSetupWidget(w,n,a);
00122 } else {
00123 #ifdef DEBUG
00124 DEBUGCONDUIT << fname << ": Couldn't cast parent to widget." << endl;
00125 #endif
00126 return 0L;
00127 }
00128 }
00129
00130 if (qstrcmp(c,"SyncAction")==0) {
00131 KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
00132
00133 if (d) {
00134 return createConduit(d,n,a);
00135 } else {
00136 kdError() << k_funcinfo
00137 << ": Couldn't cast to KPilotDeviceLink."
00138 << endl;
00139 }
00140 }
00141
00142 return 0L;
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
This file is part of the documentation for kdelibs Version 3.1.4.