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
#include "options.h"
00030
00031
#include <qtabwidget.h>
00032
#include <qradiobutton.h>
00033
#include <qcheckbox.h>
00034
#include <qbuttongroup.h>
00035
#include <qlistview.h>
00036
#include <kapplication.h>
00037
#include <kconfig.h>
00038
#include <kurlrequester.h>
00039
00040
#include "sysinfo-setup_dialog.h"
00041
00042
#include "sysinfo-factory.h"
00043
#include "sysinfo-setup.h"
00044
00045
typedef struct {
const char *name;
const char *key; } sysinfoEntry_t;
00046
00047
const sysinfoEntry_t sysinfoEntries[] =
00048 {
00049 { I18N_NOOP(
"Hardware information"),
00050 SysInfoConduitFactory::fHardwareInfo },
00051 { I18N_NOOP(
"User information"),
00052 SysInfoConduitFactory::fUserInfo },
00053 { I18N_NOOP(
"Memory information"),
00054 SysInfoConduitFactory::fMemoryInfo },
00055 { I18N_NOOP(
"Storage info (SD card, memory stick, ...)"),
00056 SysInfoConduitFactory::fStorageInfo },
00057 { I18N_NOOP(
"List of databases on handheld (takes long!)"),
00058 SysInfoConduitFactory::fDBList },
00059 { I18N_NOOP(
"Number of addresses, todos, events and memos"),
00060 SysInfoConduitFactory::fRecordNumber },
00061 { I18N_NOOP(
"Synchronization information"),
00062 SysInfoConduitFactory::fSyncInfo },
00063 { I18N_NOOP(
"Version of KPilot, pilot-link and KDE"),
00064 SysInfoConduitFactory::fKDEVersion },
00065 { I18N_NOOP(
"PalmOS version"),
00066 SysInfoConduitFactory::fPalmOSVersion },
00067 { I18N_NOOP(
"Debug information (for KPilot developers)"),
00068 SysInfoConduitFactory::fDebugInfo },
00069 { 0L,0L }
00070 } ;
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
#define PART_NAME (0)
00085
#define PART_KEY (1)
00086
#define PART_SETTING (2)
00087
00088
00089
00090
00091
#define updateSetting(i) { QCheckListItem *ubbu=(i); \
00092
ubbu->setText(PART_SETTING,(ubbu->isOn() ? CSL1("1") : QString::null)); }
00093
00094
00095 SysInfoWidgetConfig::SysInfoWidgetConfig(QWidget *w,
const char *n) :
00096
ConduitConfigBase(w,n),
00097 fConfigWidget(new SysInfoWidget(w))
00098 {
00099 FUNCTIONSETUP;
00100 UIDialog::addAboutPage(fConfigWidget->tabWidget,SysInfoConduitFactory::about());
00101 fWidget=fConfigWidget;
00102
00103 QObject::connect(fConfigWidget->fOutputFile,SIGNAL(textChanged(
const QString&)),
00104
this,SLOT(modified()));
00105 QObject::connect(fConfigWidget->fTemplateFile,SIGNAL(textChanged(
const QString&)),
00106
this,SLOT(modified()));
00107 QObject::connect(fConfigWidget->fOutputType,SIGNAL(clicked(
int)),
00108
this,SLOT(modified()));
00109 fConduitName=i18n(
"System Information");
00110 }
00111
00112
void SysInfoWidgetConfig::commit(KConfig *fConfig)
00113 {
00114 FUNCTIONSETUP;
00115 KConfigGroupSaver s(fConfig,SysInfoConduitFactory::fGroup);
00116 fConfig->writePathEntry(SysInfoConduitFactory::fOutputFile,
00117 fConfigWidget->fOutputFile->url());
00118 fConfig->writeEntry(SysInfoConduitFactory::fTemplateFile,
00119 fConfigWidget->fTemplateFile->url());
00120 fConfig->writeEntry(SysInfoConduitFactory::fOutputType,
00121 fConfigWidget->fOutputType->id(fConfigWidget->fOutputType->selected()));
00122
00123 QListViewItem *i = fConfigWidget->fPartsList->firstChild();
00124 QCheckListItem *ci = dynamic_cast<QCheckListItem *>(i);
00125
00126
while(ci)
00127 {
00128
#ifdef DEBUG
00129
DEBUGCONDUIT << fname <<
": Saving " << ci->text(PART_KEY)
00130 << (ci->isOn() ?
" on" :
" off") << endl;
00131
#endif
00132
fConfig->writeEntry(ci->text(PART_KEY),ci->isOn());
00133 updateSetting(ci);
00134 i=i->nextSibling();
00135 ci = dynamic_cast<QCheckListItem *>(i);
00136 }
00137 unmodified();
00138 }
00139
00140
void SysInfoWidgetConfig::load(KConfig *fConfig)
00141 {
00142 FUNCTIONSETUP;
00143 KConfigGroupSaver s(fConfig,SysInfoConduitFactory::fGroup);
00144 fConfigWidget->fOutputFile->setURL(fConfig->readPathEntry(SysInfoConduitFactory::fOutputFile));
00145 fConfigWidget->fTemplateFile->setURL(fConfig->readPathEntry(SysInfoConduitFactory::fTemplateFile));
00146 fConfigWidget->fOutputType->setButton(fConfig->readNumEntry(SysInfoConduitFactory::fOutputType, 0));
00147
00148
const sysinfoEntry_t *p = sysinfoEntries;
00149 QCheckListItem *i = 0L;
00150
while (p && p->name)
00151 {
00152 i =
new QCheckListItem(fConfigWidget->fPartsList,i18n(p->name),QCheckListItem::CheckBox);
00153
00154 i->setOn(fConfig->readBoolEntry(p->key,
true));
00155 i->setText(PART_KEY,QString::fromLatin1(p->key));
00156 updateSetting(i);
00157
#ifdef DEBUG
00158
DEBUGCONDUIT << fname <<
": Loaded " << p->key
00159 << (i->isOn() ?
" on" :
" off") << endl;
00160
#endif
00161
p++;
00162 }
00163 unmodified();
00164 }
00165
00166
bool SysInfoWidgetConfig::isModified()
const
00167
{
00168 FUNCTIONSETUP;
00169
if (fModified)
return true;
00170
00171 QListViewItem *i = fConfigWidget->fPartsList->firstChild();
00172 QCheckListItem *ci = dynamic_cast<QCheckListItem *>(i);
00173
00174
while(ci)
00175 {
00176
bool current = ci->isOn();
00177
bool original = !ci->text(PART_SETTING).isEmpty();
00178
#ifdef DEBUG
00179
DEBUGCONDUIT << fname <<
": Checking " << ci->text(PART_KEY)
00180 <<
" was " << (original ?
" on" :
" off")
00181 <<
" now " << (current ?
" on" :
" off") << endl;
00182
#endif
00183
00184
if (current!=original)
return true;
00185 i=i->nextSibling();
00186 ci = dynamic_cast<QCheckListItem *>(i);
00187 }
00188
return false;
00189 }
00190
00191 SysInfoWidgetSetup::SysInfoWidgetSetup(QWidget *w,
const char *n,
00192
const QStringList & a) :
00193
ConduitConfig(w,n,a)
00194 {
00195 FUNCTIONSETUP;
00196
00197 fConfigBase =
new SysInfoWidgetConfig(widget(),
"ConfigWidget");
00198 fConduitName = i18n(
"System Information");
00199 }
00200
00201 SysInfoWidgetSetup::~SysInfoWidgetSetup()
00202 {
00203 FUNCTIONSETUP;
00204 }
00205
00206
void SysInfoWidgetSetup::commitChanges()
00207 {
00208 FUNCTIONSETUP;
00209
00210
if (!fConfig)
return;
00211 fConfigBase->commit(fConfig);
00212 }
00213
00214
void SysInfoWidgetSetup::readSettings()
00215 {
00216 FUNCTIONSETUP;
00217
00218
if (!fConfig)
return;
00219 fConfigBase->load(fConfig);
00220 }
00221