summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -6,19 +6,19 @@
**
** $Id$
**
** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html
**
** Compile Flags:
** Zaurus arm : -DNO_OPIE
** 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
**
****************************************************************************/
#include "zsafe.h"
#include "newdialog.h"
#include "searchdialog.h"
#include "categorydialog.h"
#include "passworddialog.h"
@@ -38,29 +38,29 @@ using namespace Opie::Ui;
#endif
#include <qclipboard.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
-#ifndef WIN32
+#ifndef Q_WS_WIN
#include <unistd.h>
#endif
#include <string.h>
#include <errno.h>
#include <qmenubar.h>
#include <qpopupmenu.h>
#ifdef DESKTOP
#include <qfiledialog.h>
#include <qdragobject.h>
-#ifndef WIN32
+#ifndef Q_WS_WIN
#include <qsettings.h>
#else
#include "qsettings.h"
#endif
#include <qapplication.h>
#else
#include <qfile.h>
#include <qpe/fileselector.h>
@@ -92,28 +92,28 @@ using namespace Opie::Ui;
#include <qcombobox.h>
#include "krc2.h"
#include "wait.h"
extern int DeskW, DeskH;
#ifdef DESKTOP
-extern QApplication *appl;
+extern QApplication *appl;
#else
extern QPEApplication *appl;
#endif
#ifdef JPATCH_HDE
#define tr(arg) arg
#endif
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
const QString APP_KEY="/.zsafe/";
#else
const QString APP_KEY="";
#endif
#else
const QString APP_KEY="";
#endif
@@ -360,17 +360,17 @@ static const char* const general_data[] = {
// save the configuration into the file
void ZSafe::saveConf ()
{
if (conf)
{
delete conf;
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
conf = new QSettings ();
conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
#else
conf = new QSettings (cfgFile);
conf->insertSearchPath (QSettings::Unix, cfgFile);
#endif
#else
conf = new Config (cfgFile, Config::File);
@@ -412,29 +412,29 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
if (qpedir.isEmpty())
iconPath = "/home/QtPalmtop/pics/";
else
iconPath = qpedir + "/pics/";
#endif
// create a zsafe configuration object
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
conf = new QSettings ();
conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
#else
conf = new QSettings (cfgFile);
conf->insertSearchPath (QSettings::Unix, cfgFile);
#endif
#else
conf = new Config (cfgFile, Config::File);
conf->setGroup ("zsafePrefs");
#endif
#ifdef DESKTOP
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false);
// #endif
#else
expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0);
#endif
#ifndef DESKTOP
conf->setGroup ("zsafe");
#endif
@@ -459,17 +459,17 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
QPixmap passwords( ( const char** ) passwords_data );
QPixmap software( ( const char** ) software_data );
QPixmap general( ( const char** ) general_data );
QPixmap image0( ( const char** ) zsafe_xpm );
if ( !name )
setName( "ZSafe" );
#ifdef DESKTOP
-#ifdef WIN32
+#ifdef Q_WS_WIN
setGeometry(100, 150, DeskW, DeskH-30 );
#else
resize( DeskW, DeskH-30 );
#endif
#else
#ifdef JPATCH_HDE
@@ -493,17 +493,17 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
setCaption( tr( "ZSafe" ) );
QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe";
QString filename = conf->readEntry(APP_KEY+"document");
if (filename.isEmpty() || filename.isNull())
{
// check if the directory application exists, if not
// create it
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
// QString d1("Documents/application");
// #else
QString d1(QDir::homeDirPath() + "/Documents/application");
// #endif
QDir pd1(d1);
if (!pd1.exists())
{
@@ -520,17 +520,17 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
#ifdef JPATCH_HDE
tr("<P>Can't create directory ..."+d1+"</P><P>ZSafe will now exit.</P>"));
#else
tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1));
#endif
exitZs (1);
}
}
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
// QString d2("Documents/application/zsafe");
// #else
QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
// #endif
QDir pd2(d2);
if (!pd2.exists())
{
if (!pd1.mkdir("zsafe", FALSE))
@@ -551,30 +551,30 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
}
//if (filename == "INVALIDPWD")
//filename = "";
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
selectedItem = NULL;
lastSearchedCategory = NULL;
lastSearchedItem = NULL;
lastSearchedName = "";
lastSearchedUsername = "";
lastSearchedComment = "";
- infoForm = new InfoForm();
+ infoForm = new InfoForm(this, "show_info", TRUE);
categoryDialog = NULL;
infoForm->setIcon( image0);
// add a menu bar
QMenuBar *menu = new QMenuBar( this );
// add file menu
// QPopupMenu *file = new QPopupMenu( this );
@@ -765,18 +765,18 @@ void ZSafe::deletePwd()
void ZSafe::editPwd()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
{
// 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"));
dialog->setGeometry(200, 250, 220, 310 );
#endif
// set the labels
dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
@@ -790,20 +790,30 @@ void ZSafe::editPwd()
dialog->PasswordField->setText(selectedItem->text (2));
QString comment = selectedItem->text (3);
comment.replace (QRegExp("<br>"), "\n");
dialog->Field5->setText(selectedItem->text (4));
dialog->Field6->setText(selectedItem->text (5));
dialog->CommentField->insertLine(comment);
dialog->CommentField->setCursorPosition(0,0);
+#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
if (result == Accepted)
{
modified = true;
// edit the selected item
QString name = dialog->NameField->text();
selectedItem->setText (0, tr (name));
QString user = dialog->UsernameField->text();
@@ -835,33 +845,44 @@ void ZSafe::newPwd()
if (!isCategory(selectedItem))
selectedItem = selectedItem->parent();
if (isCategory(selectedItem))
{
QString cat = selectedItem->text(0);
// 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"));
dialog->setGeometry(200, 250, 220, 310 );
#endif
// set the labels
dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
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
if (result == Accepted)
{
QString name = dialog->NameField->text();
if (cat == name)
{
@@ -893,17 +914,17 @@ retype:
}
}
void ZSafe::findPwd()
{
// open the 'Search' dialog
SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE);
-#ifdef WIN32
+#ifdef Q_WS_WIN
dialog->setCaption ("Qt " + tr("Search"));
#endif
#ifdef DESKTOP
#endif
if (lastSearchedName)
dialog->NameField->setText(lastSearchedName);
else
@@ -1073,25 +1094,25 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
}
else
{
return def;
}
QString app_key = APP_KEY;
#ifndef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
conf->setGroup ("fieldDefs");
#endif
#else
-#ifndef WIN32
+#ifndef Q_WS_WIN
app_key += "/fieldDefs/";
#endif
#endif
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
QString label = conf->readEntry(app_key+category+"-field"+field,def);
// #else
// QString label(def);
// #endif
#ifndef DESKTOP
conf->setGroup ("zsafe");
#endif
@@ -1099,21 +1120,21 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
}
QString ZSafe::getFieldLabel (QString category, QString field, QString def)
{
QString app_key = APP_KEY;
#ifndef DESKTOP
conf->setGroup ("fieldDefs");
#else
-#ifndef WIN32
+#ifndef Q_WS_WIN
app_key += "/fieldDefs/";
#endif
#endif
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
QString label = conf->readEntry(app_key+category+"-field"+field,
def);
// #else
// QString label(def);
// #endif
#ifndef DESKTOP
conf->setGroup ("zsafe");
#endif
@@ -1203,18 +1224,24 @@ void ZSafe::showInfo( QListViewItem *_item)
comment.replace (QRegExp("\n"), "<br>");
text += comment;
// text += "<br>";
}
text += "</body></html>";
infoForm->InfoText->setText(text);
- infoForm->hide();
+// infoForm->hide();
+#ifdef Q_WS_QWS
QPEApplication::showDialog( infoForm );
+#endif
+
+#ifdef DESKTOP
+ infoForm->show();
+#endif
}
}
void ZSafe::listViewSelected( QListViewItem *_item)
{
if (!_item)
return;
if (selectedItem != NULL)
@@ -1226,17 +1253,17 @@ void ZSafe::listViewSelected( QListViewItem *_item)
// set the column text dependent on the selected item
ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
#endif
-#ifdef WIN32
+#ifdef Q_WS_WIN
// set the column text dependent on the selected item
ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
#endif
@@ -1481,17 +1508,17 @@ void ZSafe::readAllEntries()
#endif
QTextStream t(&f);
while ( !t.eof() )
{
QString s = t.readLine();
s.replace (QRegExp("\";\""), "\"|\"");
// char buffer[1024];
-#ifndef WIN32
+#ifndef Q_WS_WIN
char buffer[s.length()+1];
#else
char buffer[4048];
#endif
/* modify QString -> QCString::utf8 */
@@ -1580,17 +1607,17 @@ void ZSafe::readAllEntries()
catI->setOpen( TRUE );
Category *c1 = new Category();
c1->setCategoryName(category);
QString icon;
QString fullIconPath;
QPixmap *pix;
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
icon = conf->readEntry(APP_KEY+category);
// #endif
bool isIconAv = false;
if (!icon.isEmpty() && !icon.isNull())
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
@@ -1733,17 +1760,17 @@ void ZSafe::readAllEntries()
#endif
QTextStream t(&f);
while ( !t.eof() )
{
QString s = t.readLine();
s.replace (QRegExp("\";\""), "\"|\"");
// char buffer[1024];
int len=s.length()+1;
-#ifdef WIN32
+#ifdef Q_WS_WIN
char buffer[512];
#else
char buffer[len];
#endif
strcpy (buffer, s);
QString name;
QString user;
@@ -1813,17 +1840,17 @@ void ZSafe::readAllEntries()
catI->setOpen( TRUE );
Category *c1 = new Category();
c1->setCategoryName(category);
QString icon;
QString fullIconPath;
QPixmap *pix;
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
icon = conf->readEntry(APP_KEY+category);
// #endif
bool isIconAv = false;
if (!icon.isEmpty() && !icon.isNull())
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
@@ -1891,17 +1918,17 @@ void ZSafe::resume(int)
//---------------------------------------------
bool ZSafe::openDocument(const char* _filename, const char* )
{
int retval;
char* entry[FIELD_SIZE];
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1);
// #else
// int validationFlag = 1;
// #endif
int pwdOk = 0;
int numberOfTries = 3;
for (int i=0; i < numberOfTries; i++)
@@ -1932,17 +1959,17 @@ bool ZSafe::openDocument(const char* _filename, const char* )
#else
qWarning ("Error loading Document");
#endif
return false;
}
}
else
{
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe");
#else
this->setCaption("ZSafe");
#endif
filename = "";
return false;
}
@@ -2049,17 +2076,17 @@ bool ZSafe::openDocument(const char* _filename, const char* )
catI->setOpen( TRUE );
Category *c1 = new Category();
c1->setCategoryName(category);
QString icon;
QString fullIconPath;
QPixmap *pix;
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
icon = conf->readEntry(APP_KEY+category);
// #endif
bool isIconAv = false;
if (!icon.isEmpty() && !icon.isNull())
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
@@ -2135,34 +2162,34 @@ int ZSafe::loadInit(const char* _filename, const char *password)
buffer = (char *)malloc(load_buffer_length);
for (j = 0; password[j] != '\0'; j++) {
key[j] = password[j];
}
keylength = j;
krc2->rc2_expandkey (key, keylength, 128);
-#ifndef WIN32
+#ifndef Q_WS_WIN
size = read(fileno (fd), (unsigned char *) (charbuf + count), 8);
#else
size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
#endif
if (size < 8)
return PWERR_DATA;
for (count = 0; count < 4; count++) {
count2 = count << 1;
iv[count] = charbuf[count2] << 8;
iv[count] += charbuf[count2 + 1];
}
size = 0;
bufferIndex = 0;
-#ifndef WIN32
+#ifndef Q_WS_WIN
while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) {
while (count < 8) {
count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8);
#else
while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) {
while (count < 8) {
count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
#endif
@@ -2334,17 +2361,17 @@ bool ZSafe::saveDocument(const char* _filename,
#ifndef NO_OPIE
owarn << "1: Error writing file, contents not saved" << oendl;
#else
qWarning("1: Error writing file, contents not saved");
#endif
saveFinalize();
return false;
}
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry(APP_KEY+"valzsafe", 1);
// #endif
saveConf();
}
QListViewItem *i;
// step through all categories
for (i = ListView->firstChild();
@@ -2429,17 +2456,17 @@ void ZSafe::getDocPassword(QString title)
dialog->setIcon( image0);
connect( dialog->PasswordField, SIGNAL( returnPressed() ),
this, SLOT( setPasswordDialogDone() ) );
// CS: !!!
// int pos = filename.findRev ('/');
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
dialog->setCaption("Qt " + ti);
#else
dialog->setCaption(ti);
#endif
// dialog->setCaption(title);
dialog->PasswordField->setFocus();
DialogCode result = (DialogCode) dialog->exec();
@@ -2659,28 +2686,28 @@ void ZSafe::addCategory()
CategoryDialog *dialog;
if (categoryDialog)
{
dialog = categoryDialog;
}
else
{
categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
-#ifdef WIN32
+#ifdef Q_WS_WIN
categoryDialog->setCaption ("Qt " + tr("Category"));
#endif
dialog = categoryDialog;
connect( dialog->CategoryField,
SIGNAL( activated(const QString&)),
this, SLOT( categoryFieldActivated(const QString&) ) );
initIcons = true;
}
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
@@ -2713,17 +2740,17 @@ void ZSafe::addCategory()
QString firstCategory;
dialog->CategoryField->clear(); // remove all items
while( it != list.end() )
{
QString *cat = new QString (*it);
if (cat->contains("-field1", FALSE))
{
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
categ = cat->section ("-field1", 0, 0);
#else
int pos = cat->find ("-field1");
categ = cat->left (pos);
#endif
#else
int pos = cat->find ("-field1");
cat->truncate(pos);
@@ -2781,17 +2808,17 @@ void ZSafe::addCategory()
imageOfFile.convertFromImage(foo);
dialog->IconField->insertItem(imageOfFile,fileName);
}
++it;
}
waitDialog.hide();
}
-#ifndef WIN32
+#ifndef Q_WS_WIN
dialog->show();
#endif
#ifndef DESKTOP
// dialog->move (20, 100);
#endif
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
@@ -2820,17 +2847,17 @@ void ZSafe::addCategory()
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
// pix->resize(14, 14);
if (!pix->isNull())
{
// save the full pixmap name into the config file
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry(APP_KEY+category, icon);
// #endif
saveConf();
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIcon (*pix);
c1->setIconName(icon);
}
@@ -2872,17 +2899,17 @@ void ZSafe::delCategory()
tr("Do you want to delete?"),
tr("&Delete"), tr("D&on't Delete"),
0 // Enter == button 0
) ) { // Escape == button 2
case 0: // Delete clicked, Alt-S or Enter pressed.
// Delete from the category list
modified = true;
categories.remove (selectedItem->text(0));
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->removeEntry (selectedItem->text(0));
// #endif
saveConf();
// Delete the selected item and all subitems
// step through all subitems
QListViewItem *si;
for (si = selectedItem->firstChild();
@@ -3032,22 +3059,22 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category)
}
void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog)
{
QString app_key = APP_KEY;
#ifndef DESKTOP
conf->setGroup ("fieldDefs");
#else
-#ifndef WIN32
+#ifndef Q_WS_WIN
app_key += "/fieldDefs/";
#endif
#endif
QString category = dialog->CategoryField->currentText();
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry(app_key+category+"-field1", dialog->Field1->text());
conf->writeEntry(app_key+category+"-field2", dialog->Field2->text());
conf->writeEntry(app_key+category+"-field3", dialog->Field3->text());
conf->writeEntry(app_key+category+"-field4", dialog->Field4->text());
conf->writeEntry(app_key+category+"-field5", dialog->Field5->text());
conf->writeEntry(app_key+category+"-field6", dialog->Field6->text());
// #endif
saveConf();
@@ -3068,29 +3095,29 @@ void ZSafe::editCategory()
CategoryDialog *dialog;
if (categoryDialog)
{
dialog = categoryDialog;
}
else
{
categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
-#ifdef WIN32
+#ifdef Q_WS_WIN
categoryDialog->setCaption ("Qt " + tr("Category"));
#endif
dialog = categoryDialog;
connect( dialog->CategoryField,
SIGNAL( activated(const QString&)),
this, SLOT( categoryFieldActivated(const QString&) ) );
initIcons = true;
}
setCategoryDialogFields(dialog);
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
@@ -3124,17 +3151,17 @@ void ZSafe::editCategory()
int i=0;
bool foundCategory = false;
while( it != list.end() )
{
QString *cat = new QString (*it);
if (cat->contains("-field1", FALSE))
{
#ifdef DESKTOP
-#ifndef WIN32
+#ifndef Q_WS_WIN
categ = cat->section ("-field1", 0, 0);
#else
int pos = cat->find ("-field1");
categ = cat->left (pos);
#endif
#else
int pos = cat->find ("-field1");
cat->truncate(pos);
@@ -3267,17 +3294,17 @@ void ZSafe::editCategory()
QString fullIconPath;
QPixmap *pix;
if (result == Accepted)
{
modified = true;
if (category != dialog->CategoryField->currentText())
{
categories.remove (category);
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->removeEntry(category);
// #endif
saveConf();
}
category = dialog->CategoryField->currentText();
icon = dialog->IconField->currentText()+".png";
@@ -3293,29 +3320,29 @@ void ZSafe::editCategory()
if (icon != "predefined.png")
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
if (!pix->isNull())
{
// save the full pixmap name into the config file
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry(APP_KEY+category, icon);
// #endif
saveConf();
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
cat->setIconName (icon);
cat->setIcon (*pix);
}
}
else
{
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->removeEntry (category);
// #endif
saveConf();
cat->setIcon (*getPredefinedIcon(category));
}
// change the category name of the selected category
QListViewItem *catItem = cat->getListItem();
@@ -3484,17 +3511,17 @@ void ZSafe::newDocument()
selectedItem = NULL;
filename = newFile;
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
// openDocument(filename);
QMessageBox::information( this, tr("ZSafe"),
@@ -3568,17 +3595,17 @@ void ZSafe::loadDocument()
m_password = "";
selectedItem = NULL;
filename = newFile;
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
openDocument(filename);
}
}
@@ -3622,17 +3649,17 @@ void ZSafe::saveDocumentAs()
selectedItem = NULL;
filename = newFile;
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
QMessageBox::information( this, tr("ZSafe"),
tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0);
@@ -3701,17 +3728,17 @@ void ZSafe::about()
void ZSafe::setExpandFlag()
{
expandTree = !expandTree;
file->setItemChecked('o', expandTree);
#ifndef DESKTOP
conf->setGroup ("zsafePrefs");
#endif
-// #ifndef WIN32
+// #ifndef Q_WS_WIN
conf->writeEntry (APP_KEY+"expandTree", expandTree);
// #endif
saveConf();
}
void ZSafe::paintEvent( QPaintEvent * )
{
@@ -3786,17 +3813,17 @@ void ZSafe::setDocument(const QString& fileref)
// if (filename != fileref)
// saveDocument(filename, FALSE);
filename = fileref;
}
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
-#ifdef WIN32
+#ifdef Q_WS_WIN
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
// clear the password list
QListViewItem *i;
QListViewItem *c = NULL;