-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 691 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.h | 10 |
2 files changed, 72 insertions, 629 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 1ae3b15..2b182f9 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp @@ -10,9 +10,2 @@ ** -** Compile Flags: -** Zaurus arm : -DNO_OPIE -** Zaurus Opie arm: none -** Linux Desktop : -DDESKTOP -DNO_OPIE -** Windows Desktop: -DDESKTOP -DNO_OPIE -** use qmake -** for japanese version additional use: -DJPATCH_HDE ** @@ -28,4 +21,2 @@ -#ifndef DESKTOP -#ifndef NO_OPIE #include <opie2/ofiledialog.h> @@ -34,6 +25,2 @@ using namespace Opie::Core; using namespace Opie::Ui; -#else -#include "scqtfileedit.h" -#endif -#endif @@ -45,5 +32,3 @@ using namespace Opie::Ui; #include <stdlib.h> -#ifndef Q_WS_WIN #include <unistd.h> -#endif #include <string.h> @@ -54,12 +39,2 @@ using namespace Opie::Ui; -#ifdef DESKTOP -#include <qfiledialog.h> -#include <qdragobject.h> -#ifndef Q_WS_WIN -#include <qsettings.h> -#else -#include "qsettings.h" -#endif -#include <qapplication.h> -#else #include <qfile.h> @@ -70,3 +45,2 @@ using namespace Opie::Ui; #include <qpe/config.h> -#endif @@ -97,23 +71,7 @@ using namespace Opie::Ui; -extern int DeskW, DeskH; -#ifdef DESKTOP -extern QApplication *appl; -#else -extern QPEApplication *appl; -#endif - -#ifdef JPATCH_HDE -#define tr(arg) arg -#endif - +int DeskW, DeskH; +QApplication *appl; +ZSafe *zs; -#ifdef DESKTOP -#ifndef Q_WS_WIN -const QString APP_KEY="/.zsafe/"; -#else -const QString APP_KEY=""; -#endif -#else -const QString APP_KEY=""; -#endif +const QString APP_KEY = ""; @@ -366,14 +324,4 @@ static const char* const general_data[] = { -#ifdef DESKTOP -#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 + conf = new Config ("zsafe"); + conf->setGroup ("zsafe"); } @@ -389,6 +337,11 @@ static const char* const general_data[] = { */ -ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, name, modal, fl ), +ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl), Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) { + zs = this; + appl = qApp; + DeskW = qApp->desktop()->width(); + DeskH = qApp->desktop()->height(); + IsCut = false; @@ -402,40 +355,10 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) // set the icon path -#ifdef NO_OPIE - QString qpedir ((const char *)getenv("QPEDIR")); -#else - QString qpedir ((const char *)getenv("OPIEDIR")); -#endif -#ifdef DESKTOP - iconPath = QDir::homeDirPath() + "/pics/"; -#else - if (qpedir.isEmpty()) - iconPath = "/home/QtPalmtop/pics/"; - else - iconPath = qpedir + "/pics/"; -#endif + QString qpeDir = QPEApplication::qpeDir(); - // create a zsafe configuration object -#ifdef DESKTOP -#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 = new Config ("zsafe"); conf->setGroup ("zsafePrefs"); -#endif -#ifdef DESKTOP -// #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 @@ -462,34 +385,9 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) QPixmap image0( ( const char** ) zsafe_xpm ); - if ( !name ) - setName( "ZSafe" ); - -#ifdef DESKTOP -#ifdef Q_WS_WIN - setGeometry(100, 150, DeskW, DeskH-30 ); -#else - resize( DeskW, DeskH-30 ); -#endif - -#else -#ifdef JPATCH_HDE - int DeskS; - if(DeskW > DeskH) - { - DeskS = DeskW; - } - else - { - DeskS = DeskH; - } - resize( DeskW, DeskH ); - setMinimumSize( QSize( DeskS, DeskS ) ); - setMaximumSize( QSize( DeskS, DeskS ) ); -#else - resize( DeskW, DeskH-30 ); -#endif + if ( !name ) + setName( "ZSafe" ); -#endif setCaption( tr( "ZSafe" ) ); QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; + filename = conf->readEntry(APP_KEY+"document"); @@ -499,7 +397,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) // create it -// #ifndef Q_WS_WIN - // QString d1("Documents/application"); -// #else QString d1(QDir::homeDirPath() + "/Documents/application"); -// #endif QDir pd1(d1); @@ -513,3 +407,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) } - + if (!pd2.mkdir("application", FALSE)) @@ -517,7 +411,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) QMessageBox::critical( 0, tr("ZSafe"), -#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); @@ -525,7 +415,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) } -// #ifndef Q_WS_WIN - // QString d2("Documents/application/zsafe"); -// #else QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); -// #endif QDir pd2(d2); @@ -536,7 +422,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) QMessageBox::critical( 0, tr("ZSafe"), -#ifdef JPATCH_HDE - tr("<P>Can't create directory ...//Documents/application/zsafe</P><P>ZSafe will now exit.</P")); -#else tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2)); -#endif exitZs (1); @@ -544,3 +426,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) } - + filename = zsafeAppDirPath + "/passwords.zsf"; @@ -555,7 +437,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); -#ifdef Q_WS_WIN - this->setCaption("Qt ZSafe: " + ti); -#else - this->setCaption("ZSafe: " + ti); -#endif + this->setCaption(tr("ZSafe: ") + ti); @@ -579,3 +457,2 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) -// #ifdef DESKTOP file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); @@ -584,3 +461,2 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) file->insertSeparator(); -// #endif @@ -667,6 +543,2 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) -#ifdef DESKTOP - // ListView->setResizePolicy(QScrollView::AutoOneFit); - // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); -#else ListView->setResizePolicy(QScrollView::AutoOneFit); @@ -675,3 +547,2 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) // ListView->setMaximumSize( QSize( 440, 290 ) ); -#endif // ListView->setVScrollBarMode( QListView::Auto ); @@ -682,3 +553,2 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) -#ifndef DESKTOP // start a timer (100 ms) to load the default document @@ -688,6 +558,2 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); -#else - // open the default document - openDocument(filename); -#endif @@ -706,5 +572,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) -#ifndef DESKTOP - QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); -#endif + QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), @@ -712,7 +576,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) - this->setIcon( image0);
-#ifdef Q_WS_WIN
- ListView->setSelected( ListView->firstChild() , true);
- ListView->setSelected( ListView->firstChild() , false);
-#endif + this->setIcon( image0); } @@ -774,6 +634,2 @@ void ZSafe::editPwd() 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 @@ -798,18 +654,4 @@ void ZSafe::editPwd() -#ifdef Q_WS_QWS - DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); -#endif - -#ifdef DESKTOP -#ifndef Q_QW_QWIN - dialog->show(); -#endif -#else - dialog->showMaximized(); -#endif -#ifdef DESKTOP - int result = dialog->exec(); - result = QDialog::Accepted; -#endif - if (result == Accepted) + QDialog::DialogCode result = (QDialog::DialogCode) QPEApplication::execDialog( dialog ); + if (result == QDialog::Accepted) { @@ -854,6 +696,2 @@ void ZSafe::newPwd() 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 @@ -868,18 +706,5 @@ retype: #ifdef Q_WS_QWS - DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); -#endif - -#ifdef DESKTOP -#ifndef Q_QW_QWIN - dialog->show(); -#endif -#else - dialog->showMaximized(); -#endif -#ifdef DESKTOP - int result = dialog->exec(); - result = QDialog::Accepted; + QDialog::DialogCode result = (QDialog::DialogCode) QPEApplication::execDialog( dialog ); #endif - - if (result == Accepted) + if (result == QDialog::Accepted) { @@ -922,8 +747,3 @@ void ZSafe::findPwd() SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); -#ifdef Q_WS_WIN - dialog->setCaption ("Qt " + tr("Search")); -#endif -#ifdef DESKTOP -#endif if (lastSearchedName) @@ -940,6 +760,3 @@ void ZSafe::findPwd() dialog->CommentField->setText(""); - DialogCode result = (DialogCode) dialog->exec(); -#ifdef DESKTOP - result = Accepted; -#endif + QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); @@ -948,3 +765,3 @@ void ZSafe::findPwd() QString comment; - if (result == Accepted) + if (result == QDialog::Accepted) { @@ -953,7 +770,2 @@ void ZSafe::findPwd() comment = dialog->CommentField->text(); -#ifndef NO_OPIE - owarn << name << oendl; -#else - qWarning (name); -#endif } @@ -1003,5 +815,2 @@ void ZSafe::findPwd() { -#ifndef NO_OPIE - owarn << i->text(0) << oendl; -#endif i->setSelected(FALSE); @@ -1019,7 +828,2 @@ void ZSafe::findPwd() { -#ifndef NO_OPIE - owarn << si->text(0) << oendl; -#else - qWarning (si->text(0)); -#endif if (si->isSelected()) @@ -1040,7 +844,2 @@ void ZSafe::findPwd() { -#ifndef NO_OPIE - owarn << "Found" << oendl; -#else - qWarning ("Found"); -#endif selectedItem = si; @@ -1101,20 +900,6 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) QString app_key = APP_KEY; -#ifndef DESKTOP -#ifndef Q_WS_WIN - conf->setGroup ("fieldDefs"); -#endif -#else -#ifndef Q_WS_WIN - app_key += "/fieldDefs/"; -#endif -#endif -// #ifndef Q_WS_WIN - QString label = conf->readEntry(app_key+category+"-field"+field,def); -// #else -// QString label(def); -// #endif -#ifndef DESKTOP + conf->setGroup( "fieldDefs" ); + QString label = conf->readEntry(app_key+category+"-field"+field,def); conf->setGroup ("zsafe"); -#endif return label; @@ -1125,10 +910,4 @@ QString ZSafe::getFieldLabel (QString category, QString field, QString def) QString app_key = APP_KEY; -#ifndef DESKTOP - conf->setGroup ("fieldDefs"); -#else -#ifndef Q_WS_WIN - app_key += "/fieldDefs/"; -#endif -#endif // #ifndef Q_WS_WIN + conf->setGroup( "fieldDefs" ); QString label = conf->readEntry(app_key+category+"-field"+field, @@ -1138,5 +917,3 @@ QString ZSafe::getFieldLabel (QString category, QString field, QString def) // #endif -#ifndef DESKTOP conf->setGroup ("zsafe"); -#endif return label; @@ -1237,5 +1014,2 @@ void ZSafe::showInfo( QListViewItem *_item) -#ifdef DESKTOP - infoForm->show(); -#endif } @@ -1252,12 +1026,2 @@ void ZSafe::listViewSelected( QListViewItem *_item) -#ifndef DESKTOP - // 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 Q_WS_WIN // set the column text dependent on the selected item @@ -1269,4 +1033,2 @@ void ZSafe::listViewSelected( QListViewItem *_item) ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); -#endif - } @@ -1289,4 +1051,2 @@ void ZSafe::removeAsciiFile() // open the file dialog -#ifndef DESKTOP -#ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; @@ -1300,16 +1060,2 @@ void ZSafe::removeAsciiFile() tr ("Remove text file")); -#else - QString fn = ScQtFileEdit::getOpenFileName(this, - tr ("Remove text file"), - QDir::homeDirPath() + "/Documents/application/zsafe", - "*.txt"); -#endif -#else - QString fn = QFileDialog::getOpenFileName( - QDir::homeDirPath() + "/Documents/application/zsafe", - "ZSafe (*.txt)", - this, - "ZSafe File Dialog" - "Choose a text file" ); -#endif @@ -1320,7 +1066,2 @@ void ZSafe::removeAsciiFile() { -#ifndef NO_OPIE - owarn << "Could not remove file " << fn << oendl; -#else - qWarning( QString("Could not remove file %1").arg(fn),2000 ); -#endif QMessageBox::critical( 0, tr("ZSafe"), @@ -1348,7 +1089,2 @@ void ZSafe::writeAllEntries() if ( !f.open( IO_WriteOnly ) ) { -#ifndef NO_OPIE - owarn << "Could not write to file " << fn << oendl; -#else - qWarning( QString("Could not write to file %1").arg(fn),2000 ); -#endif QMessageBox::critical( 0, "ZSafe", @@ -1415,4 +1151,2 @@ void ZSafe::readAllEntries() // open the file dialog -#ifndef DESKTOP -#ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; @@ -1426,16 +1160,2 @@ void ZSafe::readAllEntries() tr ("Import text file")); -#else - QString fn = ScQtFileEdit::getOpenFileName(this, - tr ("Import text file"), - QDir::homeDirPath() + "/Documents/application/zsafe", - "*.txt"); -#endif -#else - QString fn = QFileDialog::getOpenFileName( - QDir::homeDirPath() + "/Documents/application/zsafe", - "ZSafe (*.txt)", - this, - "ZSafe File Dialog" - "Choose a text file" ); -#endif @@ -1446,7 +1166,2 @@ void ZSafe::readAllEntries() { -#ifndef NO_OPIE - owarn << "Could not read file " << fn << oendl; -#else - qWarning( QString("Could not read file %1").arg(fn), 2000 ); -#endif QMessageBox::critical( 0, "ZSafe", @@ -1479,8 +1194,2 @@ void ZSafe::readAllEntries() -#ifndef NO_OPIE - owarn << "ReadAllEntries(): " << oendl; -#else - qWarning ("ReadAllEntries(): "); -#endif - QTextStream t(&f); @@ -1491,7 +1200,3 @@ void ZSafe::readAllEntries() // char buffer[1024]; -#ifndef Q_WS_WIN char buffer[s.length()+1]; -#else - char buffer[4048]; -#endif @@ -1641,7 +1346,2 @@ void ZSafe::writeAllEntries() if ( !f.open( IO_WriteOnly ) ) { -#ifndef NO_OPIE - owarn << "Could not write to file " << fn << oendl; -#else - qWarning( QString("Could not write to file %1").arg(fn), 2000 ); -#endif QMessageBox::critical( 0, tr("ZSafe"), @@ -1698,7 +1398,2 @@ void ZSafe::readAllEntries() { -#ifndef NO_OPIE - owarn << "Could not read file " << fn << oendl; -#else - qWarning( QString("Could not read file %1").arg(fn), 2000 ); -#endif QMessageBox::critical( 0, tr("ZSafe"), @@ -1731,7 +1426,2 @@ void ZSafe::readAllEntries() -#ifndef NO_OPIE - owarn << "ReadAllEntries(): " << oendl; -#else - qWarning ("ReadAllEntries(): "); -#endif QTextStream t(&f); @@ -1743,7 +1433,3 @@ void ZSafe::readAllEntries() int len=s.length()+1; -#ifdef Q_WS_WIN - char buffer[512]; -#else char buffer[len]; -#endif strcpy (buffer, s); @@ -1858,5 +1544,2 @@ void ZSafe::resume(int) { -#ifndef NO_OPIE - owarn << "Resume" << oendl; -#endif // hide the main window @@ -1921,7 +1604,2 @@ bool ZSafe::openDocument(const char* _filename, const char* ) { -#ifndef NO_OPIE - owarn << "Wrong password" << oendl; -#else - qWarning ("Wrong password"); -#endif QMessageBox::critical( 0, tr("ZSafe"), @@ -1934,7 +1612,2 @@ bool ZSafe::openDocument(const char* _filename, const char* ) { -#ifndef NO_OPIE - owarn << "Error loading Document" << oendl; -#else - qWarning ("Error loading Document"); -#endif return false; @@ -1944,7 +1617,3 @@ bool ZSafe::openDocument(const char* _filename, const char* ) { -#ifdef Q_WS_WIN - this->setCaption("Qt ZSafe"); -#else - this->setCaption("ZSafe"); -#endif + this->setCaption(tr("ZSafe")); filename = ""; @@ -1964,3 +1633,3 @@ bool ZSafe::openDocument(const char* _filename, const char* ) } - + } @@ -2438,5 +2107,2 @@ void ZSafe::getDocPassword(QString title) { -#ifndef NO_OPIE - owarn << "getDocPassword" << oendl; -#endif // open the 'Password' dialog @@ -2455,7 +2121,3 @@ void ZSafe::getDocPassword(QString title) QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); -#ifdef Q_WS_WIN - dialog->setCaption("Qt " + ti); -#else dialog->setCaption(ti); -#endif // dialog->setCaption(title); @@ -2463,9 +2125,6 @@ void ZSafe::getDocPassword(QString title) dialog->PasswordField->setFocus(); - DialogCode result = (DialogCode) dialog->exec(); -#ifdef DESKTOP - result = Accepted; -#endif + QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); QString password; - if (result == Accepted || newPwdDialogResult) + if (result == QDialog::Accepted || newPwdDialogResult) { @@ -2622,6 +2281,2 @@ void ZSafe::quitMe () { -#ifndef NO_OPIE - owarn << "QUIT..." << oendl; -#endif - if (modified) @@ -2685,5 +2340,2 @@ void ZSafe::addCategory() categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); -#ifdef Q_WS_WIN - categoryDialog->setCaption ("Qt " + tr("Category")); -#endif dialog = categoryDialog; @@ -2695,6 +2347,2 @@ void ZSafe::addCategory() -#ifdef DESKTOP -#ifndef Q_WS_WIN - QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); -#else // read all categories from the config file and store @@ -2706,3 +2354,2 @@ void ZSafe::addCategory() QString s; - int n = 1; while ( !t.eof() ) { // until end of file... @@ -2713,18 +2360,2 @@ void ZSafe::addCategory() } -#endif -#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 - QString s; - while ( !t.eof() ) { // until end of file... - s = t.readLine(); // line of text excluding '\n' - list.append(s); - } - f.close(); - } -#endif QStringList::Iterator it = list.begin(); @@ -2738,10 +2369,2 @@ void ZSafe::addCategory() { -#ifdef DESKTOP -#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"); @@ -2749,3 +2372,2 @@ void ZSafe::addCategory() categ = *cat; -#endif if (!categ.isEmpty()) @@ -2775,7 +2397,3 @@ void ZSafe::addCategory() -#ifdef DESKTOP - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); @@ -2791,8 +2409,3 @@ void ZSafe::addCategory() fileName = fileName.mid(0,fileName.length()-4); -#ifdef DESKTOP - QPixmap imageOfFile; - imageOfFile.load(iconPath + fi->fileName()); -#else QPixmap imageOfFile(Resource::loadPixmap(fileName)); -#endif QImage foo = imageOfFile.convertToImage(); @@ -2807,13 +2420,3 @@ void ZSafe::addCategory() -#ifndef Q_WS_WIN - dialog->show(); -#endif -#ifndef DESKTOP - // dialog->move (20, 100); -#endif - DialogCode result = (DialogCode) dialog->exec(); -#ifdef DESKTOP - result = Accepted; -#endif - + QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); QString category; @@ -2822,3 +2425,3 @@ void ZSafe::addCategory() QPixmap *pix; - if (result == Accepted) + if (result == QDialog::Accepted) { @@ -2828,6 +2431,2 @@ void ZSafe::addCategory() -#ifndef NO_OPIE - owarn << category << oendl; -#endif - QListViewItem *li = new ShadedListItem( 1, ListView ); @@ -2959,7 +2558,3 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) -#ifdef DESKTOP - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); @@ -3016,7 +2611,3 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) -#ifdef DESKTOP - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); @@ -3055,9 +2646,3 @@ void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) QString app_key = APP_KEY; -#ifndef DESKTOP - conf->setGroup ("fieldDefs"); -#else -#ifndef Q_WS_WIN - app_key += "/fieldDefs/"; -#endif -#endif + conf->setGroup( "fieldDefs" ); QString category = dialog->CategoryField->currentText(); @@ -3072,5 +2657,3 @@ void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) saveConf(); -#ifndef DESKTOP conf->setGroup ("zsafe"); -#endif } @@ -3094,5 +2677,2 @@ void ZSafe::editCategory() categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); -#ifdef Q_WS_WIN - categoryDialog->setCaption ("Qt " + tr("Category")); -#endif dialog = categoryDialog; @@ -3105,22 +2685,2 @@ void ZSafe::editCategory() -#ifdef DESKTOP -#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 - QString s; - int n = 1; - while ( !t.eof() ) { // until end of file... - s = t.readLine(); // line of text excluding '\n' - list.append(s); - } - f.close(); - } -#endif -#else // read all categories from the config file and store @@ -3138,3 +2698,2 @@ void ZSafe::editCategory() } -#endif QStringList::Iterator it = list.begin(); @@ -3149,10 +2708,2 @@ void ZSafe::editCategory() { -#ifdef DESKTOP -#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"); @@ -3160,3 +2711,2 @@ void ZSafe::editCategory() categ = *cat; -#endif if (!categ.isEmpty()) @@ -3195,7 +2745,3 @@ void ZSafe::editCategory() -#ifdef DESKTOP - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); @@ -3217,8 +2763,3 @@ void ZSafe::editCategory() fileName = fileName.mid(0,fileName.length()-4); -#ifdef DESKTOP - QPixmap imageOfFile; - imageOfFile.load(iconPath + fi->fileName()); -#else QPixmap imageOfFile(Resource::loadPixmap(fileName)); -#endif QImage foo = imageOfFile.convertToImage(); @@ -3237,8 +2778,3 @@ void ZSafe::editCategory() { -#ifdef DESKTOP - // QDir d(QDir::homeDirPath() + "/pics/"); - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); @@ -3277,9 +2813,3 @@ void ZSafe::editCategory() // dialog->show(); -#ifndef DESKTOP - // dialog->move (20, 100); -#endif - DialogCode result = (DialogCode) dialog->exec(); -#ifdef DESKTOP - result = Accepted; -#endif + QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); @@ -3287,3 +2817,3 @@ void ZSafe::editCategory() QPixmap *pix; - if (result == Accepted) + if (result == QDialog::Accepted) { @@ -3304,8 +2834,2 @@ void ZSafe::editCategory() { -#ifndef NO_OPIE - owarn << "Category found" << oendl; -#else - qWarning("Category found"); -#endif - // if (!icon.isEmpty() && !icon.isNull()) @@ -3342,7 +2866,2 @@ void ZSafe::editCategory() { -#ifndef NO_OPIE - owarn << category << oendl; -#else - qWarning (category); -#endif catItem->setText( 0, tr( category ) ); @@ -3483,2 +3002,3 @@ void ZSafe::newDocument() // save the current filename to the config file + conf->setGroup("zsafe"); conf->writeEntry(APP_KEY+"document", filename); @@ -3486,7 +3006,3 @@ void ZSafe::newDocument() QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); -#ifdef Q_WS_WIN - this->setCaption("Qt ZSafe: " + ti); -#else - this->setCaption("ZSafe: " + ti); -#endif + this->setCaption(tr("ZSafe: ") + ti); @@ -3505,4 +3021,2 @@ void ZSafe::loadDocument() // open the file dialog -#ifndef DESKTOP -#ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; @@ -3516,16 +3030,2 @@ void ZSafe::loadDocument() tr ("Open ZSafe document")); -#else - QString newFile = ScQtFileEdit::getOpenFileName(this, - tr ("Open ZSafe document"), - QDir::homeDirPath() + "/Documents/application/zsafe", - "*.zsf"); -#endif -#else - QString newFile = QFileDialog::getOpenFileName( - QDir::homeDirPath() + "/Documents/application/zsafe", - "ZSafe (*.zsf)", - this, - "ZSafe File Dialog" - "Choose a ZSafe file" ); -#endif @@ -3567,2 +3067,3 @@ void ZSafe::loadDocument() // save the current filename to the config file + conf->setGroup("zsafe"); conf->writeEntry(APP_KEY+"document", filename); @@ -3570,7 +3071,3 @@ void ZSafe::loadDocument() QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); -#ifdef Q_WS_WIN - this->setCaption("Qt ZSafe: " + ti); -#else - this->setCaption("ZSafe: " + ti); -#endif + this->setCaption(tr("ZSafe: ") + ti); @@ -3595,2 +3092,3 @@ QString newFile = zsaveDialog(); // save the current filename to the config file + conf->setGroup("zsafe"); conf->writeEntry(APP_KEY+"document", filename); @@ -3598,7 +3096,3 @@ QString newFile = zsaveDialog(); QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); -#ifdef Q_WS_WIN - this->setCaption("Qt ZSafe: " + ti); -#else - this->setCaption("ZSafe: " + ti); -#endif + this->setCaption(tr("ZSafe: ") + ti); @@ -3624,37 +3118,15 @@ void ZSafe::about() QString info; -#ifdef JPATCH_HDE - info = "<html><body><div align=""center"">"; - info += "<b>"; - info += tr("Zaurus Password Manager<br>"); - info += tr("ZSafe version 2.1.2-jv01b<br>"); - info += "</b>"; - info += tr("by Carsten Schneider<br>"); - info += "zcarsten@gmx.net<br>"; - info += "http://z-soft.z-portal.info/zsafe"; - info += "<br>"; - info += tr("Translations by Robert Ernst<br>"); - info += "robert.ernst@linux-solutions.at<br>"; - - info += "<br><br>"; - info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>"); - info += "HADECO R&D<br>"; - info += "r&d@hadeco.co.jp<br>"; - info += "http://www.hadeco.co.jp/r&d/<br>"; - info += "<br></div>"; - info += "</body></html>"; -#else - info = "<html><body><div align=""center"">"; - info += "<b>"; - info += tr("Zaurus Password Manager<br>"); - info += tr("ZSafe version 2.1.2<br>"); - info += "</b>"; - info += tr("by Carsten Schneider<br>"); - info += "zcarsten@gmx.net<br>"; - info += "http://z-soft.z-portal.info/zsafe"; - info += "<br>"; - info += tr("Translations by Robert Ernst<br>"); - info += "robert.ernst@linux-solutions.at<br>"; - info += "<br></div>"; - info += "</body></html>"; -#endif + info = tr("<html><body><div align=""center"">" + "<b>" + "Zaurus Password Manager<br>" + "ZSafe version 2.1.2<br>" + "</b>" + "by Carsten Schneider<br>" + "zcarsten@gmx.net<br>" + "http://z-soft.z-portal.info/zsafe" + "<br>" + "Translations by Robert Ernst<br>" + "robert.ernst@linux-solutions.at<br>" + "<br></div>" + "</body></html>"); @@ -3674,5 +3146,3 @@ void ZSafe::setExpandFlag() file->setItemChecked('o', expandTree); -#ifndef DESKTOP conf->setGroup ("zsafePrefs"); -#endif // #ifndef Q_WS_WIN @@ -3698,9 +3168,4 @@ void ZSafe::resizeEvent ( QResizeEvent * ) // owarn << "resizeEvent" << oendl; -#ifndef DESKTOP DeskW = appl->desktop()->width(); DeskH = appl->desktop()->height(); -#else - DeskW = this->width(); - DeskH = this->height(); -#endif @@ -3741,3 +3206,2 @@ void ZSafe::setDocument(const QString& fileref) { -#ifndef DESKTOP // stop the timer to prevent loading of the default document @@ -3759,2 +3223,3 @@ void ZSafe::setDocument(const QString& fileref) // save the current filename to the config file + conf->setGroup("zsafe"); conf->writeEntry(APP_KEY+"document", filename); @@ -3762,7 +3227,3 @@ void ZSafe::setDocument(const QString& fileref) QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); -#ifdef Q_WS_WIN - this->setCaption("Qt ZSafe: " + ti); -#else - this->setCaption("ZSafe: " + ti); -#endif + this->setCaption(tr("ZSafe: ") + ti); @@ -3797,5 +3258,2 @@ void ZSafe::setDocument(const QString& fileref) openDocument(filename); -#else -Q_UNUSED(fileref); -#endif } @@ -3807,8 +3265,2 @@ void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int colum case 1: - { -#ifdef DESKTOP - QDragObject *d = new QTextDrag( item->text(column) , this ); - d->dragCopy(); -#endif - } break; @@ -3853,4 +3305,2 @@ QString ZSafe::zsaveDialog() { QString fn; -#ifndef DESKTOP -#ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; @@ -3864,16 +3314,3 @@ QString ZSafe::zsaveDialog() { tr ("Export text file")); -#else - fn = ScQtFileEdit::getSaveAsFileName(this, - tr ("Export text file"), - QDir::homeDirPath() + "/Documents/application/zsafe", - "*.txt"); -#endif -#else - fn = QFileDialog::getSaveFileName( - QDir::homeDirPath() + "/Documents/application/zsafe", - "ZSafe (*.txt)", - this, - "ZSafe"); -#endif - return fn; + return fn; } diff --git a/noncore/apps/zsafe/zsafe.h b/noncore/apps/zsafe/zsafe.h index 7419797..3d812f8 100644 --- a/noncore/apps/zsafe/zsafe.h +++ b/noncore/apps/zsafe/zsafe.h @@ -48,3 +48,3 @@ class QPixmap; -class ZSafe : public QDialog +class ZSafe : public QWidget { @@ -60,4 +60,5 @@ protected: public: - ZSafe( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = WDestructiveClose ); + ZSafe( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~ZSafe(); + static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); } @@ -197,2 +198,7 @@ private slots: + +extern ZSafe *zs; +extern QApplication *appl; +extern int DeskW; +extern int DeskH; #endif // ZSAFE_H |