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
00037 #include <kaboutdata.h>
00038 #include <kapplication.h>
00039 #include <kurlrequester.h>
00040
00041 #include "sysinfo-setup_dialog.h"
00042
00043 #include "sysinfo-factory.h"
00044 #include "sysinfo-setup.h"
00045 #include "sysinfoSettings.h"
00046
00047
00048 typedef struct { const char *name; bool (*accessor)(); void (*mutator)(bool); } sysinfoEntry_t;
00049
00050 const sysinfoEntry_t sysinfoEntries[] =
00051 {
00052 { I18N_NOOP("HardwareInfo"), SysinfoSettings::hardwareInfo, SysinfoSettings::setHardwareInfo },
00053 { I18N_NOOP("UserInfo"), SysinfoSettings::userInfo, SysinfoSettings::setUserInfo },
00054 { I18N_NOOP("MemoryInfo"), SysinfoSettings::memoryInfo, SysinfoSettings::setMemoryInfo },
00055 { I18N_NOOP("StorageInfo"), SysinfoSettings::storageInfo, SysinfoSettings::setStorageInfo },
00056 { I18N_NOOP("DatabaseList"), SysinfoSettings::databaseList, SysinfoSettings::setDatabaseList },
00057 { I18N_NOOP("RecordNumbers"), SysinfoSettings::recordNumbers, SysinfoSettings::setRecordNumbers},
00058 { I18N_NOOP("SyncInfo"), SysinfoSettings::syncInfo, SysinfoSettings::setSyncInfo },
00059 { I18N_NOOP("KDEVersion"), SysinfoSettings::kDEVersion, SysinfoSettings::setKDEVersion },
00060 { I18N_NOOP("PalmOSVersion"), SysinfoSettings::palmOSVersion, SysinfoSettings::setPalmOSVersion },
00061 { I18N_NOOP("DebugInformation"), SysinfoSettings::debugInformation, SysinfoSettings::setDebugInformation },
00062 { 0L, 0L, 0L }
00063 } ;
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 #define PART_NAME (0)
00078 #define PART_KEY (1)
00079 #define PART_SETTING (2)
00080
00081
00082
00083
00084 #define updateSetting(i) { QCheckListItem *ubbu=(i); \
00085 ubbu->setText(PART_SETTING,(ubbu->isOn() ? CSL1("1") : QString::null)); }
00086
00087
00088 SysInfoWidgetConfig::SysInfoWidgetConfig(QWidget *w, const char *n) :
00089 ConduitConfigBase(w,n),
00090 fConfigWidget(new SysInfoWidget(w))
00091 {
00092 FUNCTIONSETUP;
00093
00094 KAboutData *fAbout = new KAboutData("SysInfoConduit",
00095 I18N_NOOP("KPilot System Information conduit"),
00096 KPILOT_VERSION,
00097 I18N_NOOP("Retrieves System, Hardware, and User Info from the Handheld and stores them to a file."),
00098 KAboutData::License_GPL,
00099 "(C) 2003, Reinhold Kainhofer");
00100 fAbout->addAuthor("Reinhold Kainhofer",
00101 I18N_NOOP("Primary Author"), "reinhold@kainhofer.com", "http://reinhold.kainhofer.com/");
00102
00103 ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget,fAbout);
00104 fWidget=fConfigWidget;
00105
00106 QObject::connect(fConfigWidget->fOutputFile,SIGNAL(textChanged(const QString&)),
00107 this,SLOT(modified()));
00108 QObject::connect(fConfigWidget->fTemplateFile,SIGNAL(textChanged(const QString&)),
00109 this,SLOT(modified()));
00110 QObject::connect(fConfigWidget->fOutputType,SIGNAL(clicked(int)),
00111 this,SLOT(modified()));
00112 fConduitName=i18n("System Information");
00113 }
00114
00115 void SysInfoWidgetConfig::commit()
00116 {
00117 FUNCTIONSETUP;
00118
00119 SysinfoSettings::setOutputFile(
00120 fConfigWidget->fOutputFile->url() );
00121 SysinfoSettings::setTemplateFile(
00122 fConfigWidget->fTemplateFile->url() );
00123 SysinfoSettings::setOutputFormat(
00124 fConfigWidget->fOutputType->id(fConfigWidget->fOutputType->selected()));
00125
00126 QListViewItem *i = fConfigWidget->fPartsList->firstChild();
00127 QCheckListItem *ci = dynamic_cast<QCheckListItem *>(i);
00128 while(ci)
00129 {
00130 #ifdef DEBUG
00131 DEBUGKPILOT << fname << ": Saving " << ci->text(PART_NAME)
00132 << (ci->isOn() ? " on" : " off") << endl;
00133 #endif
00134 int index=ci->text(PART_KEY).toInt();
00135 if (0<=index && index<=10)
00136 {
00137 const sysinfoEntry_t *p = sysinfoEntries+index;
00138 p->mutator(ci->isOn());
00139 }
00140 updateSetting(ci);
00141 i=i->nextSibling();
00142 ci = dynamic_cast<QCheckListItem *>(i);
00143 }
00144 SysinfoSettings::self()->writeConfig();
00145 unmodified();
00146 }
00147
00148 void SysInfoWidgetConfig::load()
00149 {
00150 FUNCTIONSETUP;
00151 SysinfoSettings::self()->readConfig();
00152
00153 const sysinfoEntry_t *p = sysinfoEntries;
00154 QCheckListItem *i = 0L;
00155 while (p && p->name)
00156 {
00157 i = new QCheckListItem(fConfigWidget->fPartsList,i18n(p->name),QCheckListItem::CheckBox);
00158
00159 i->setOn( p->accessor() );
00160 i->setText(PART_KEY, QString::number(p-sysinfoEntries));
00161 updateSetting(i);
00162 #ifdef DEBUG
00163 DEBUGKPILOT << fname << ": Loaded " << p->name
00164 << (i->isOn() ? " on" : " off") << endl;
00165 #endif
00166
00167 p++;
00168 }
00169 fConfigWidget->fOutputFile->setURL( SysinfoSettings::outputFile() );
00170 fConfigWidget->fTemplateFile->setURL( SysinfoSettings::templateFile() );
00171 fConfigWidget->fOutputType->setButton( SysinfoSettings::outputFormat() );
00172 unmodified();
00173 }
00174
00175 bool SysInfoWidgetConfig::isModified() const
00176 {
00177 FUNCTIONSETUP;
00178 if (fModified) return true;
00179
00180 QListViewItem *i = fConfigWidget->fPartsList->firstChild();
00181 QCheckListItem *ci = dynamic_cast<QCheckListItem *>(i);
00182
00183 while(ci)
00184 {
00185 bool current = ci->isOn();
00186 bool original = !ci->text(PART_SETTING).isEmpty();
00187 #ifdef DEBUG
00188 DEBUGKPILOT << fname << ": Checking " << ci->text(PART_KEY)
00189 << " was " << (original ? " on" : " off")
00190 << " now " << (current ? " on" : " off") << endl;
00191 #endif
00192
00193 if (current!=original) return true;
00194 i=i->nextSibling();
00195 ci = dynamic_cast<QCheckListItem *>(i);
00196 }
00197 return false;
00198 }