DatabaseAction.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 <qpushbutton.h>
00033
00034 #include <qlineedit.h>
00035 #include <qbuttongroup.h>
00036 #include <qradiobutton.h>
00037 #include <qwidget.h>
00038 #include <qhbox.h>
00039
00040 #include <kconfig.h>
00041
00042
00043 #include <kfiledialog.h>
00044
00045 #include "DatabaseAction.h"
00046 #include "DatabaseAction.moc"
00047
00048
00049
00050 DBSettings::DBSettings(QWidget *w, const char *n, DBSyncInfo*itm, SyncTypeList_t *tps,
00051 bool changeDBName, bool allowask) :
00052 KDialogBase(w, n, true, QString::null,
00053 KDialogBase::Ok | KDialogBase::Cancel,
00054 KDialogBase::Ok, true) {
00055 FUNCTIONSETUP;
00056 item=itm;
00057 synctypes=tps;
00058
00059 fMainWidget = makeHBoxMainWidget();
00060 fConfigWidget = new DatabaseActionDlgPrivate(widget());
00061
00062 SyncTypeIterator_t it(*synctypes);
00063 KPilotSyncType *st;
00064 while ( (st = it.current()) != 0 ) {
00065 ++it;
00066 QRadioButton*btn=fConfigWidget->InsertRadioButton(st->LongName, st->ShortName.latin1());
00067 if (st->getFlag(SYNC_NEEDSFILE)) {
00068 QObject::connect(btn, SIGNAL(toggled(bool)), fConfigWidget->TextFileName, SLOT(setEnabled(bool)));
00069 } else {
00070 QObject::connect(btn, SIGNAL(toggled(bool)), fConfigWidget->TextFileName, SLOT(setDisabled(bool)));
00071 }
00072 }
00073
00074 QObject::connect(fConfigWidget->PushBrowse,SIGNAL(clicked()), this,SLOT(slotBrowseFile()));
00075
00076 fConfigWidget->EditDatabaseName->setText(item->dbname);
00077 fConfigWidget->DefaultSyncTypeGroup->setButton(SyncTypeToId(item->syncaction));
00078 fConfigWidget->TextFileName->setText(item->filename);
00079 fConfigWidget->EditDatabaseName->setEnabled(changeDBName);
00080 fConfigWidget->RadioAsk->setEnabled(allowask);
00081 }
00082
00083 DBSettings::~DBSettings() {
00084 FUNCTIONSETUP;
00085 }
00086
00087 void DBSettings::slotBrowseFile() {
00088 FUNCTIONSETUP;
00089 if (fConfigWidget->TextFileName->isEnabled()) {
00090 QString fileName = fConfigWidget->TextFileName->text();
00091 QString fn=KFileDialog::getOpenFileName(fileName, i18n("*.vcs *.ics|ICalendars\n*.pdb|Palm Database file (*.pdb)\n*.*|All files"), this);
00092 if(fn.isNull()) return;
00093 fConfigWidget->TextFileName->setText(fn);
00094 }
00095 }
00096
00097 void DBSettings::slotOk() {
00098 commitChanges();
00099 KDialogBase::slotOk();
00100 }
00101
00102 void DBSettings::slotApply() {
00103 FUNCTIONSETUP;
00104 commitChanges();
00105 }
00106
00107 void DBSettings::commitChanges() {
00108 FUNCTIONSETUP;
00109 item->dbname=fConfigWidget->EditDatabaseName->text();
00110 item->filename=fConfigWidget->TextFileName->text();
00111 item->syncaction=IdToSyncType(fConfigWidget->DefaultSyncTypeGroup->id(fConfigWidget->DefaultSyncTypeGroup->selected()));
00112 }
00113
00114 int DBSettings::IdToSyncType(int tp) {
00115 if (synctypes->at(tp)) return synctypes->at(tp)->id; else return st_ask;
00116 };
00117
00118 int DBSettings::SyncTypeToId(int tt) {
00119 KPilotSyncType*st=synctypes->first();
00120 while (st) {
00121 if (st->id==tt) return synctypes->at();
00122 st=synctypes->next();
00123 }
00124 return -1;
00125 }
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
This file is part of the documentation for kdelibs Version 3.1.5.