kpilot Library API Documentation

DatabaseAction.cc

00001 /* MultiDB-setup.cc                        KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone
00004 ** Copyright (C) 2002 by Reinhold Kainhofer
00005 **
00006 ** This file defines the factory for the MultiDB-conduit plugin.
00007 */
00008 
00009 /*
00010 ** This program is free software; you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation; either version 2 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 ** GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program in a file called COPYING; if not, write to
00022 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 ** MA 02111-1307, USA.
00024 */
00025 
00026 /*
00027 ** Bug reports and questions can be sent to kde-pim@kde.org
00028 */
00029 
00030 #include "options.h"
00031 
00032 #include <qpushbutton.h>
00033 /*#include <qtabwidget.h>*/
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 /*#include <kinstance.h>
00042 #include <kaboutdata.h>*/
00043 #include <kfiledialog.h>
00044 
00045 #include "DatabaseAction.h"
00046 #include "DatabaseAction.moc"
00047 //#include "DatabaseActionDialog.h"
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 // $Log: DatabaseAction.cc,v $
00129 // Revision 1.2.4.1  2003/03/12 23:31:09  adridg
00130 // CVS_SILENT: FSF address change
00131 //
00132 // Revision 1.2  2002/04/07 20:19:48  cschumac
00133 // Compile fixes.
00134 //
00135 // Revision 1.1  2002/04/07 12:09:42  kainhofe
00136 // Initial checkin of the conduit. The gui works mostly, but syncing crashes KPilot...
00137 //
00138 // Revision 1.2  2002/04/07 11:56:19  reinhold
00139 // Last version before moving to KDE CVS
00140 //
00141 // Revision 1.1  2002/04/07 01:03:52  reinhold
00142 // the list of possible actions is now created dynamically
00143 //
00144 // Revision 1.7  2002/04/05 21:17:00  reinhold
00145 // *** empty log message ***
00146 //
00147 // Revision 1.6  2002/03/28 13:47:53  reinhold
00148 // Added the list of synctypes, aboutbox is now directly passed on to the setup dlg (instead of being a static var)
00149 //
00150 // Revision 1.5  2002/03/15 20:43:17  reinhold
00151 // Fixed the crash on loading (member function not defined)...
00152 //
00153 // Revision 1.4  2002/03/13 22:14:40  reinhold
00154 // GUI should work now...
00155 //
00156 // Revision 1.3  2002/03/10 23:58:32  reinhold
00157 // Made the conduit compile...
00158 //
00159 // Revision 1.2  2002/03/10 16:06:43  reinhold
00160 // Cleaned up the class hierarchy, implemented some more features (should be quite finished now...)
00161 //
00162 // Revision 1.1.1.1  2002/03/09 15:38:45  reinhold
00163 // Initial checin of the  project manager / List manager conduit.
00164 //
00165 //
00166 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:14 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001