summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-13 10:35:23 (UTC)
committer llornkcor <llornkcor>2004-07-13 10:35:23 (UTC)
commit37e0e077b51841971c3d4c25b287f4d39e750e2d (patch) (side-by-side diff)
treec1b499dd6e544207c6ff7047acd8170d6ea63f94
parent5d2ec2e9b1dce49e914c260fe16a82ddccbaa92d (diff)
downloadopie-37e0e077b51841971c3d4c25b287f4d39e750e2d.zip
opie-37e0e077b51841971c3d4c25b287f4d39e750e2d.tar.gz
opie-37e0e077b51841971c3d4c25b287f4d39e750e2d.tar.bz2
fix ups, and move qsettings files away
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--[-rwxr-xr-x]noncore/apps/zsafe/extra/qsettings.cpp (renamed from noncore/apps/zsafe/qsettings.cpp)308
-rw-r--r--[-rwxr-xr-x]noncore/apps/zsafe/extra/qsettings.h (renamed from noncore/apps/zsafe/qsettings.h)0
-rw-r--r--noncore/apps/zsafe/zsafe.cpp147
3 files changed, 243 insertions, 212 deletions
diff --git a/noncore/apps/zsafe/qsettings.cpp b/noncore/apps/zsafe/extra/qsettings.cpp
index ee55339..def2e2d 100755..100644
--- a/noncore/apps/zsafe/qsettings.cpp
+++ b/noncore/apps/zsafe/extra/qsettings.cpp
@@ -1,152 +1,156 @@
-/*
-** $Id$
-*/
-
-#include "qsettings.h"
-#include <stdio.h>
-#include <qfile.h>
-#include <qtextstream.h>
-
-
-QSettings::QSettings(const QString &_fn)
-{
- // read the prefs from the file
- fn = _fn;
-
- QFile f(_fn);
- if ( f.open(IO_ReadOnly) ) { // file opened successfully
- QTextStream t( &f ); // use a text stream
- QString s;
- while ( !t.eof() ) { // until end of file...
- s = t.readLine(); // line of text excluding '\n'
- char buf[256];
- sprintf (buf, "%s", (const char *) s);
- int pos = s.find (" = ");
- QString key = s.left (pos);
- QString val = s.right (s.length() - pos - 3);
- writeEntry (key, val);
-
- sprintf (buf, "%s|%s", (const char *)key, (const char *)val);
- }
- f.close();
- }
-
-
-}
-
-QSettings::~QSettings()
-{
- // write out the prefs to the file
- QAsciiDictIterator <QString> it( prefs ); // iterator for dict
- QFile f(fn);
- f.open(IO_WriteOnly);
- QTextStream ts( &f );
-
- while ( it.current() )
- {
- QString *key = new QString(it.currentKey());
- char buf[256];
- sprintf (buf, "%s", (const char *) *( it.current()));
- QString *val = new QString(buf);
- sprintf (buf, "%s %s", (const char *)*key, (const char *)*val);
- ts << *key << " = " << *val << endl;
- ++it;
- }
-
- f.close();
- prefs.clear();
-}
-
-void QSettings::insertSearchPath (System sys, const QString &str)
-{
- fn = str;
-}
-
-QString QSettings::readEntry (const QString &key, const QString &def)
-{
-
- QString *s = prefs.find((const char *)key);
- if (!s)
- return def;
- else
- return *s;
-
-}
-
-int QSettings::readNumEntry (const QString &key, int def)
-{
- QString *s = prefs[key];
- if (!s) return def;
- return s->toInt();
-}
-
-bool QSettings::readBoolEntry (const QString &key, bool def)
-{
- QString *s = prefs[key];
- if (!s) return def;
- if (*s == "1")
- return true;
- else
- return false;
-}
-
-bool QSettings::writeEntry (const QString &key, int val)
-{
- char buf[64];
- sprintf (buf, "%d", val);
- QString *v = new QString(buf);
- prefs.replace ((const char *)key, v);
- return true;
-}
-
-bool QSettings::writeEntry (const QString &key, bool val)
-{
- QString *v;
- if (val)
- v = new QString("1");
- else
- v = new QString("0");
- prefs.replace ((const char *)key, v);
- return true;
-}
-
-bool QSettings::writeEntry (const QString &key, const QString &val)
-{
- QString *v = new QString (val);
- prefs.replace ((const char *)key, v);
- return true;
-}
-
-bool QSettings::writeEntry (const QString &key, const char *val)
-{
- QString *v = new QString (val);
- prefs.replace ((const char *)key, v);
- return true;
-}
-
-bool QSettings::removeEntry (const QString &key)
-{
- prefs.remove (key);
- return true;
-}
-
-QStringList QSettings::entryList (const QString &key) const
-{
- QAsciiDictIterator <QString> it( prefs ); // iterator for dict
- QStringList list;
-
- while ( it.current() )
- {
- char buf[512];
- sprintf (buf, "%s", (const char *) *( it.current()));
- QString *val = new QString(buf);
- sprintf(buf, "%s -> %s\n", it.currentKey(), (const char *)*val );
- QString *cat = new QString(it.currentKey());
- if (cat->contains("-field", FALSE))
- list.append (it.currentKey());
- ++it;
-
- }
- return list;
-}
-
+/*
+** $Id$
+*/
+
+#include "qsettings.h"
+#include <stdio.h>
+#include <qfile.h>
+#include <qtextstream.h>
+
+
+QSettings::QSettings(const QString &_fn)
+{
+ qWarning("Settings "+_fn);
+ // read the prefs from the file
+ fn = _fn;
+
+ QFile f(_fn);
+ if ( f.open(IO_ReadOnly) ) { // file opened successfully
+ QTextStream t( &f ); // use a text stream
+ QString s;
+ while ( !t.eof() ) { // until end of file...
+ s = t.readLine(); // line of text excluding '\n'
+ char buf[256];
+ sprintf (buf, "%s", (const char *) s);
+ int pos = s.find (" = ");
+ QString key = s.left (pos);
+ QString val = s.right (s.length() - pos - 3);
+ writeEntry (key, val);
+
+ sprintf (buf, "%s|%s", (const char *)key, (const char *)val);
+ }
+ f.close();
+ }
+
+
+}
+
+QSettings::~QSettings()
+{
+ // write out the prefs to the file
+ QAsciiDictIterator <QString> it( prefs ); // iterator for dict
+ QFile f(fn);
+ f.open(IO_WriteOnly);
+ QTextStream ts( &f );
+
+ while ( it.current() )
+ {
+ QString *key = new QString(it.currentKey());
+ char buf[256];
+ sprintf (buf, "%s", (const char *) *( it.current()));
+ QString *val = new QString(buf);
+ sprintf (buf, "%s %s", (const char *)*key, (const char *)*val);
+ ts << *key << " = " << *val << endl;
+ ++it;
+ }
+
+ f.close();
+ prefs.clear();
+}
+
+void QSettings::insertSearchPath (System sys, const QString &str)
+{
+ fn = str;
+}
+
+QString QSettings::readEntry (const QString &key, const QString &def)
+{
+
+ QString *s = prefs.find((const char *)key);
+ if (!s)
+ return def;
+ else
+ return *s;
+
+}
+
+int QSettings::readNumEntry (const QString &key, int def)
+{
+ QString *s = prefs[key];
+ if (!s) return def;
+ return s->toInt();
+}
+
+bool QSettings::readBoolEntry (const QString &key, bool def)
+{
+ QString *s = prefs[key];
+ if (!s) return def;
+ if (*s == "1")
+ return true;
+ else
+ return false;
+}
+
+bool QSettings::writeEntry (const QString &key, int val)
+{
+ char buf[64];
+ sprintf (buf, "%d", val);
+ QString *v = new QString(buf);
+ prefs.replace ((const char *)key, v);
+ return true;
+}
+
+bool QSettings::writeEntry (const QString &key, bool val)
+{
+ QString *v;
+ if (val)
+ v = new QString("1");
+ else
+ v = new QString("0");
+ prefs.replace ((const char *)key, v);
+ return true;
+}
+
+bool QSettings::writeEntry (const QString &key, const QString &val)
+{
+ QString *v = new QString (val);
+ prefs.replace ((const char *)key, v);
+ return true;
+}
+
+bool QSettings::writeEntry (const QString &key, const char *val)
+{
+ QString *v = new QString (val);
+ prefs.replace ((const char *)key, v);
+ return true;
+}
+
+bool QSettings::removeEntry (const QString &key)
+{
+ prefs.remove (key);
+ return true;
+}
+
+QStringList QSettings::entryList (const QString &key) const
+{
+ qDebug("entryList: "+key);
+ QStringList list;
+ if(!prefs.isEmpty()) {
+ QAsciiDictIterator <QString> it( prefs ); // iterator for dict
+ qDebug("ready");
+ while ( it.current() )
+ {
+ char buf[512];
+ sprintf(buf, "%s", (const char *) *( it.current()));
+ QString *val = new QString(buf);
+ sprintf(buf, "%s -> %s\n", it.currentKey(), (const char *)*val );
+ QString *cat = new QString(it.currentKey());
+ if (cat->contains("-field", FALSE))
+ list.append (it.currentKey());
+ ++it;
+ }
+ }
+ qWarning("Return here");
+ return list;
+}
+
diff --git a/noncore/apps/zsafe/qsettings.h b/noncore/apps/zsafe/extra/qsettings.h
index 95e87b5..95e87b5 100755..100644
--- a/noncore/apps/zsafe/qsettings.h
+++ b/noncore/apps/zsafe/extra/qsettings.h
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index 0864293..f3d57f8 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -13,5 +13,5 @@
** Zaurus Opie arm: none
-** Linux Desktop : -DDESKTOP
-** Windows Desktop: -DDESKTOP -DWIN32
-**
+** Linux Desktop : -DDESKTOP -DNO_OPIE
+** Windows Desktop: -DDESKTOP -DNO_OPIE
+** use qmake
** for japanese version additional use: -DJPATCH_HDE
@@ -45,3 +45,3 @@ using namespace Opie::Ui;
#include <stdlib.h>
-#ifndef WIN32
+#ifndef Q_WS_WIN
#include <unistd.h>
@@ -57,3 +57,3 @@ using namespace Opie::Ui;
#include <qdragobject.h>
-#ifndef WIN32
+#ifndef Q_WS_WIN
#include <qsettings.h>
@@ -99,3 +99,3 @@ extern int DeskW, DeskH;
#ifdef DESKTOP
-extern QApplication *appl;
+extern QApplication *appl;
#else
@@ -110,3 +110,3 @@ extern QPEApplication *appl;
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
const QString APP_KEY="/.zsafe/";
@@ -367,3 +367,3 @@ static const char* const general_data[] = {
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
conf = new QSettings ();
@@ -419,3 +419,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
conf = new QSettings ();
@@ -431,3 +431,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
#ifdef DESKTOP
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false);
@@ -466,3 +466,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
#ifdef DESKTOP
-#ifdef WIN32
+#ifdef Q_WS_WIN
setGeometry(100, 150, DeskW, DeskH-30 );
@@ -500,3 +500,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
// create it
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
// QString d1("Documents/application");
@@ -527,3 +527,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
}
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
// QString d2("Documents/application/zsafe");
@@ -558,3 +558,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);
@@ -571,3 +571,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
- infoForm = new InfoForm();
+ infoForm = new InfoForm(this, "show_info", TRUE);
categoryDialog = NULL;
@@ -772,4 +772,4 @@ void ZSafe::editPwd()
// open the 'New Entry' dialog
- NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE);
-#ifdef WIN32
+ NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE);
+#ifdef Q_WS_WIN
dialog->setCaption ("Qt " + tr("Edit Entry"));
@@ -797,6 +797,16 @@ void ZSafe::editPwd()
+#ifdef Q_WS_QWS
DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
-
+#endif
+
#ifdef DESKTOP
- result = Accepted;
+#ifndef Q_QW_QWIN
+ dialog->show();
+#endif
+#else
+ dialog->showMaximized();
+#endif
+ int result = dialog->exec();
+#ifdef DESKTOP
+// result = QDialog::Accepted;
#endif
@@ -842,4 +852,4 @@ void ZSafe::newPwd()
// open the 'New Entry' dialog
- NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE);
-#ifdef WIN32
+ NewDialog *dialog = new NewDialog(this, "new_entry", TRUE);
+#ifdef Q_WS_WIN
dialog->setCaption ("Qt " + tr("New Entry"));
@@ -856,5 +866,16 @@ retype:
+#ifdef Q_WS_QWS
DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
+#endif
+
#ifdef DESKTOP
- result = Accepted;
+#ifndef Q_QW_QWIN
+ dialog->show();
+#endif
+#else
+ dialog->showMaximized();
+#endif
+#ifdef DESKTOP
+ int result = dialog->exec();
+// result = QDialog::Accepted;
#endif
@@ -900,3 +921,3 @@ void ZSafe::findPwd()
SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE);
-#ifdef WIN32
+#ifdef Q_WS_WIN
dialog->setCaption ("Qt " + tr("Search"));
@@ -1080,3 +1101,3 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
#ifndef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
conf->setGroup ("fieldDefs");
@@ -1084,3 +1105,3 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
#else
-#ifndef WIN32
+#ifndef Q_WS_WIN
app_key += "/fieldDefs/";
@@ -1088,3 +1109,3 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
#endif
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
QString label = conf->readEntry(app_key+category+"-field"+field,def);
@@ -1106,3 +1127,3 @@ QString ZSafe::getFieldLabel (QString category, QString field, QString def)
#else
-#ifndef WIN32
+#ifndef Q_WS_WIN
app_key += "/fieldDefs/";
@@ -1110,3 +1131,3 @@ QString ZSafe::getFieldLabel (QString category, QString field, QString def)
#endif
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
QString label = conf->readEntry(app_key+category+"-field"+field,
@@ -1210,4 +1231,10 @@ void ZSafe::showInfo( QListViewItem *_item)
infoForm->InfoText->setText(text);
- infoForm->hide();
+// infoForm->hide();
+#ifdef Q_WS_QWS
QPEApplication::showDialog( infoForm );
+#endif
+
+#ifdef DESKTOP
+ infoForm->show();
+#endif
}
@@ -1233,3 +1260,3 @@ void ZSafe::listViewSelected( QListViewItem *_item)
#endif
-#ifdef WIN32
+#ifdef Q_WS_WIN
// set the column text dependent on the selected item
@@ -1488,3 +1515,3 @@ void ZSafe::readAllEntries()
// char buffer[1024];
-#ifndef WIN32
+#ifndef Q_WS_WIN
char buffer[s.length()+1];
@@ -1587,3 +1614,3 @@ void ZSafe::readAllEntries()
QPixmap *pix;
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
icon = conf->readEntry(APP_KEY+category);
@@ -1740,3 +1767,3 @@ void ZSafe::readAllEntries()
int len=s.length()+1;
-#ifdef WIN32
+#ifdef Q_WS_WIN
char buffer[512];
@@ -1820,3 +1847,3 @@ void ZSafe::readAllEntries()
QPixmap *pix;
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
icon = conf->readEntry(APP_KEY+category);
@@ -1898,3 +1925,3 @@ bool ZSafe::openDocument(const char* _filename, const char* )
char* entry[FIELD_SIZE];
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1);
@@ -1939,3 +1966,3 @@ bool ZSafe::openDocument(const char* _filename, const char* )
{
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe");
@@ -2056,3 +2083,3 @@ bool ZSafe::openDocument(const char* _filename, const char* )
QPixmap *pix;
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
icon = conf->readEntry(APP_KEY+category);
@@ -2142,3 +2169,3 @@ int ZSafe::loadInit(const char* _filename, const char *password)
-#ifndef WIN32
+#ifndef Q_WS_WIN
size = read(fileno (fd), (unsigned char *) (charbuf + count), 8);
@@ -2159,3 +2186,3 @@ int ZSafe::loadInit(const char* _filename, const char *password)
bufferIndex = 0;
-#ifndef WIN32
+#ifndef Q_WS_WIN
while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) {
@@ -2341,3 +2368,3 @@ bool ZSafe::saveDocument(const char* _filename,
}
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry(APP_KEY+"valzsafe", 1);
@@ -2436,3 +2463,3 @@ void ZSafe::getDocPassword(QString title)
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
dialog->setCaption("Qt " + ti);
@@ -2666,3 +2693,3 @@ void ZSafe::addCategory()
categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
-#ifdef WIN32
+#ifdef Q_WS_WIN
categoryDialog->setCaption ("Qt " + tr("Category"));
@@ -2677,3 +2704,3 @@ void ZSafe::addCategory()
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
@@ -2720,3 +2747,3 @@ void ZSafe::addCategory()
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
categ = cat->section ("-field1", 0, 0);
@@ -2788,3 +2815,3 @@ void ZSafe::addCategory()
-#ifndef WIN32
+#ifndef Q_WS_WIN
dialog->show();
@@ -2827,3 +2854,3 @@ void ZSafe::addCategory()
// save the full pixmap name into the config file
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry(APP_KEY+category, icon);
@@ -2879,3 +2906,3 @@ void ZSafe::delCategory()
categories.remove (selectedItem->text(0));
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->removeEntry (selectedItem->text(0));
@@ -3039,3 +3066,3 @@ void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog)
#else
-#ifndef WIN32
+#ifndef Q_WS_WIN
app_key += "/fieldDefs/";
@@ -3044,3 +3071,3 @@ void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog)
QString category = dialog->CategoryField->currentText();
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry(app_key+category+"-field1", dialog->Field1->text());
@@ -3075,3 +3102,3 @@ void ZSafe::editCategory()
categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
-#ifdef WIN32
+#ifdef Q_WS_WIN
categoryDialog->setCaption ("Qt " + tr("Category"));
@@ -3087,3 +3114,3 @@ void ZSafe::editCategory()
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
@@ -3131,3 +3158,3 @@ void ZSafe::editCategory()
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
categ = cat->section ("-field1", 0, 0);
@@ -3274,3 +3301,3 @@ void ZSafe::editCategory()
categories.remove (category);
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->removeEntry(category);
@@ -3300,3 +3327,3 @@ void ZSafe::editCategory()
// save the full pixmap name into the config file
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry(APP_KEY+category, icon);
@@ -3312,3 +3339,3 @@ void ZSafe::editCategory()
{
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->removeEntry (category);
@@ -3491,3 +3518,3 @@ void ZSafe::newDocument()
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);
@@ -3575,3 +3602,3 @@ void ZSafe::loadDocument()
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);
@@ -3629,3 +3656,3 @@ void ZSafe::saveDocumentAs()
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);
@@ -3708,3 +3735,3 @@ void ZSafe::setExpandFlag()
#endif
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry (APP_KEY+"expandTree", expandTree);
@@ -3793,3 +3820,3 @@ void ZSafe::setDocument(const QString& fileref)
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);