-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 @@ -5,73 +5,47 @@ ** Author: Carsten Schneider <CarstenSchneider@t-online.de> ** ** $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 -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" #include "infoform.h" #include "zlistview.h" #include "shadedlistitem.h" -#ifndef DESKTOP -#ifndef NO_OPIE #include <opie2/ofiledialog.h> #include <opie2/odebug.h> using namespace Opie::Core; using namespace Opie::Ui; -#else -#include "scqtfileedit.h" -#endif -#endif #include <qclipboard.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> -#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 Q_WS_WIN -#include <qsettings.h> -#else -#include "qsettings.h" -#endif -#include <qapplication.h> -#else #include <qfile.h> #include <qpe/fileselector.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> -#endif #include <qtimer.h> #include <qlayout.h> #include <qmessagebox.h> #include <qfile.h> #include <qtextstream.h> @@ -92,33 +66,17 @@ using namespace Opie::Ui; #include <qcombobox.h> #include "krc2.h" #include "wait.h" -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 = ""; // include xmp images #include "pics/zsafe/copy.xpm" #include "pics/zsafe/cut.xpm" #include "pics/zsafe/edit.xpm" #include "pics/zsafe/editdelete.xpm" @@ -361,86 +319,51 @@ static const char* const general_data[] = { void ZSafe::saveConf () { if (conf) { delete conf; -#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"); } } /* * Constructs a ZSafe which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ -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; IsCopy = false; modified = false; showpwd = false; // set the config file cfgFile=QDir::homeDirPath(); cfgFile += "/.zsafe.cfg"; // 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 QPixmap copy_img((const char**) copy_xpm); QPixmap cut_img((const char**) cut_xpm); QPixmap edit_img((const char**) edit_xpm); QPixmap editdelete_img((const char**) editdelete_xpm); QPixmap find_img((const char**) find_xpm); @@ -457,110 +380,65 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) QPixmap bank_cards( ( const char** ) bank_cards_data ); 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 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"); if ( !QFileInfo(filename).exists() || !QDir(zsafeAppDirPath).exists() ) { // check if the directory application exists, if not // create it -// #ifndef Q_WS_WIN - // QString d1("Documents/application"); -// #else QString d1(QDir::homeDirPath() + "/Documents/application"); -// #endif QDir pd1(d1); if (!pd1.exists()) { QDir pd2(QDir::homeDirPath() + "/Documents"); if (!pd2.exists()) { QDir pd3(QDir::homeDirPath()); if (!pd3.mkdir("Documents", FALSE)) { } } - + if (!pd2.mkdir("application", FALSE)) { 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); } } -// #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)) { 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); } } - + filename = zsafeAppDirPath + "/passwords.zsf"; // 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 Q_WS_WIN - this->setCaption("Qt ZSafe: " + ti); -#else - this->setCaption("ZSafe: " + ti); -#endif + this->setCaption(tr("ZSafe: ") + ti); selectedItem = NULL; lastSearchedCategory = NULL; lastSearchedItem = NULL; lastSearchedName = ""; lastSearchedUsername = ""; @@ -574,18 +452,16 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) QMenuBar *menu = new QMenuBar( this ); // add file menu // QPopupMenu *file = new QPopupMenu( this ); file = new QPopupMenu( this ); -// #ifdef DESKTOP file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); file->insertSeparator(); -// #endif file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); file->insertItem( save_img, tr("S&ave document with new Password"), this, SLOT(saveDocumentWithPwd()) ); file->insertSeparator(); file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); @@ -662,37 +538,27 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) ListView->addColumn( tr( "Field 3" ) ); ListView->addColumn( tr( "Comment" ) ); ListView->addColumn( tr( "Field 4" ) ); ListView->addColumn( tr( "Field 5" ) ); ListView->setAllColumnsShowFocus(TRUE); -#ifdef DESKTOP - // ListView->setResizePolicy(QScrollView::AutoOneFit); - // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); -#else ListView->setResizePolicy(QScrollView::AutoOneFit); // ListView->setGeometry( QRect( 0, 22, // this->width(), this->height() - 30 ) ); // ListView->setMaximumSize( QSize( 440, 290 ) ); -#endif // ListView->setVScrollBarMode( QListView::Auto ); QBoxLayout * l = new QVBoxLayout( this ); l->addWidget (menu); l->addWidget (ListView); -#ifndef DESKTOP // start a timer (100 ms) to load the default document docuTimer.start( 100, true ); connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); raiseFlag = true; connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); -#else - // open the default document - openDocument(filename); -#endif // signals and slots connections for QTollButton connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); @@ -701,23 +567,17 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) this, SLOT( listViewSelected(QListViewItem*) ) ); connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( showInfo(QListViewItem*) ) ); connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( showInfo(QListViewItem*) ) ); -#ifndef DESKTOP - QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); -#endif + QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); - this->setIcon( image0);
-#ifdef Q_WS_WIN
- ListView->setSelected( ListView->firstChild() , true);
- ListView->setSelected( ListView->firstChild() , false);
-#endif + this->setIcon( image0); } const QColor *ZSafe::evenRowColor = &Qt::white; // const QColor *ZSafe::oddRowColor = &Qt::lightGray; const QColor *ZSafe::oddRowColor = new QColor(216,240,255); @@ -769,16 +629,12 @@ void ZSafe::editPwd() if (!selectedItem) return; if (!isCategory(selectedItem)) { // open the 'New Entry' dialog 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"))); dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); @@ -793,28 +649,14 @@ void ZSafe::editPwd() 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 -#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) { modified = true; // edit the selected item QString name = dialog->NameField->text(); selectedItem->setText (0, tr (name)); QString user = dialog->UsernameField->text(); @@ -849,42 +691,25 @@ void ZSafe::newPwd() if (isCategory(selectedItem)) { QString cat = selectedItem->text(0); qWarning(cat); // open the 'New Entry' dialog 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 -#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) { QString name = dialog->NameField->text(); if (cat == name) { QMessageBox::critical( 0, tr("ZSafe"), @@ -917,48 +742,35 @@ retype: void ZSafe::findPwd() { // open the 'Search' dialog SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); -#ifdef Q_WS_WIN - dialog->setCaption ("Qt " + tr("Search")); -#endif -#ifdef DESKTOP -#endif if (lastSearchedName) dialog->NameField->setText(lastSearchedName); else dialog->NameField->setText(""); if (lastSearchedUsername) dialog->UsernameField->setText(lastSearchedUsername); else dialog->UsernameField->setText(""); if (lastSearchedComment) dialog->CommentField->setText(lastSearchedComment); else dialog->CommentField->setText(""); - DialogCode result = (DialogCode) dialog->exec(); -#ifdef DESKTOP - result = Accepted; -#endif + QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); QString name; QString username; QString comment; - if (result == Accepted) + if (result == QDialog::Accepted) { name = dialog->NameField->text(); username = dialog->UsernameField->text(); comment = dialog->CommentField->text(); -#ifndef NO_OPIE - owarn << name << oendl; -#else - qWarning (name); -#endif } else { delete dialog; return; } @@ -998,15 +810,12 @@ void ZSafe::findPwd() else i = ListView->firstChild(); for (; i != NULL; i = i->nextSibling()) { -#ifndef NO_OPIE - owarn << i->text(0) << oendl; -#endif i->setSelected(FALSE); // step through all subitems QListViewItem *si; if (lastSearchedItem) si = lastSearchedItem; @@ -1014,17 +823,12 @@ void ZSafe::findPwd() si = i->firstChild(); // for (si = i->firstChild(); for (; si != NULL; si = si->nextSibling()) { -#ifndef NO_OPIE - owarn << si->text(0) << oendl; -#else - qWarning (si->text(0)); -#endif if (si->isSelected()) si->setSelected(FALSE); // ListView->repaintItem(si); bool n=TRUE; bool u=TRUE; @@ -1035,17 +839,12 @@ void ZSafe::findPwd() u = (si->text(1)).contains (username, FALSE); if (!comment.isEmpty()) c = (si->text(3)).contains (comment, FALSE); if ((n && u && c ) && !found) { -#ifndef NO_OPIE - owarn << "Found" << oendl; -#else - qWarning ("Found"); -#endif selectedItem = si; si->setSelected(TRUE); ListView->setCurrentItem(si); ListView->ensureItemVisible(si); ListView->triggerUpdate(); @@ -1096,52 +895,30 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) else { return 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; } 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, def); // #else // QString label(def); // #endif -#ifndef DESKTOP conf->setGroup ("zsafe"); -#endif return label; } void ZSafe::showInfo( QListViewItem *_item) { if (!_item) @@ -1232,46 +1009,31 @@ void ZSafe::showInfo( QListViewItem *_item) infoForm->InfoText->setText(text); // 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) selectedItem->setSelected(FALSE); selectedItem = _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 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 - } bool ZSafe::isCategory(QListViewItem *_item) { if (_item == NULL) return FALSE; @@ -1284,48 +1046,27 @@ bool ZSafe::isCategory(QListViewItem *_item) } void ZSafe::removeAsciiFile() { // QString fn = filename + ".txt"; // open the file dialog -#ifndef DESKTOP -#ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; mimeTypes.insert(tr("All"), QStringList() ); mimeTypes.insert(tr("Text"), "text/*" ); QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, QDir::homeDirPath() + "/Documents/application/zsafe", QString::null, mimeTypes, this, 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 if (fn && fn.length() > 0 ) { QFile f( fn ); if ( !f.remove() ) { -#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"), tr("Could not remove text file.") ); return; } } } @@ -1343,17 +1084,12 @@ void ZSafe::writeAllEntries() QString fn = zsaveDialog(); // open the new document if (fn && fn.length() > 0 ) { QFile f( fn ); 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", QString("Could not export to text file.") ); return; } QTextStream t( &f ); @@ -1410,48 +1146,27 @@ void ZSafe::readAllEntries() QMessageBox::critical( 0, tr("ZSafe"), tr("No document defined.\nYou have to create a new document")); return; } // open the file dialog -#ifndef DESKTOP -#ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; mimeTypes.insert(tr("All"), QStringList() ); mimeTypes.insert(tr("Text"), "text/*" ); QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, QDir::homeDirPath() + "/Documents/application/zsafe", QString::null, mimeTypes, this, 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 if (fn && fn.length() > 0 ) { QFile f( fn ); if ( !f.open( IO_ReadOnly ) ) { -#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", QString("Could not import text file.") ); return; } modified = true; @@ -1474,29 +1189,19 @@ void ZSafe::readAllEntries() si = si->nextSibling(); i->takeItem(_si); // remove from view list if (_si) delete _si; } } -#ifndef NO_OPIE - owarn << "ReadAllEntries(): " << oendl; -#else - qWarning ("ReadAllEntries(): "); -#endif - QTextStream t(&f); while ( !t.eof() ) { QString s = t.readLine(); s.replace (QRegExp("\";\""), "\"|\""); // char buffer[1024]; -#ifndef Q_WS_WIN char buffer[s.length()+1]; -#else - char buffer[4048]; -#endif /* modify QString -> QCString::utf8 */ strcpy (buffer, s.utf8()); @@ -1636,17 +1341,12 @@ void ZSafe::writeAllEntries() } // open the file for writing QString fn = filename + ".txt"; QFile f( fn ); 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"), tr("Could not export to text file.") ); return; } QTextStream t( &f ); @@ -1693,17 +1393,12 @@ void ZSafe::writeAllEntries() void ZSafe::readAllEntries() { QString fn = filename + ".txt"; QFile f( fn ); if ( !f.open( IO_ReadOnly ) ) { -#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"), tr("Could not import text file.") ); return; } modified = true; @@ -1726,29 +1421,20 @@ void ZSafe::readAllEntries() si = si->nextSibling(); i->takeItem(_si); // remove from view list if (_si) delete _si; } } -#ifndef NO_OPIE - owarn << "ReadAllEntries(): " << oendl; -#else - qWarning ("ReadAllEntries(): "); -#endif QTextStream t(&f); while ( !t.eof() ) { QString s = t.readLine(); s.replace (QRegExp("\";\""), "\"|\""); // char buffer[1024]; int len=s.length()+1; -#ifdef Q_WS_WIN - char buffer[512]; -#else char buffer[len]; -#endif strcpy (buffer, s); QString name; QString user; QString password; QString comment; @@ -1853,15 +1539,12 @@ void ZSafe::readAllEntries() } #endif // UNUSED void ZSafe::resume(int) { -#ifndef NO_OPIE - owarn << "Resume" << oendl; -#endif // hide the main window if ( !showpwd ) { infoForm->hide(); // open zsafe again @@ -1916,40 +1599,26 @@ bool ZSafe::openDocument(const char* _filename, const char* ) { // ask with a dialog for the password if (m_password.isEmpty()) getDocPassword(tr("Enter Password")); if (m_password.isEmpty() && validationFlag == 0) { -#ifndef NO_OPIE - owarn << "Wrong password" << oendl; -#else - qWarning ("Wrong password"); -#endif QMessageBox::critical( 0, tr("ZSafe"), tr("Wrong password.\n\nZSafe will now exit.") ); exitZs (1); } retval = loadInit(_filename, m_password); if (retval != PWERR_GOOD) { -#ifndef NO_OPIE - owarn << "Error loading Document" << oendl; -#else - qWarning ("Error loading Document"); -#endif return false; } } else { -#ifdef Q_WS_WIN - this->setCaption("Qt ZSafe"); -#else - this->setCaption("ZSafe"); -#endif + this->setCaption(tr("ZSafe")); filename = ""; switch( QMessageBox::warning( this, tr("ZSafe"), tr("<P>You must create a new document first. Ok to create?</P>"), tr("&Yes"), tr("&No."), 0 ) ) @@ -1959,13 +1628,13 @@ bool ZSafe::openDocument(const char* _filename, const char* ) break; case 0: // Yes newDocument(); return false; break; } - + } // load the validation entry if (validationFlag == 0) { @@ -2433,15 +2102,12 @@ void ZSafe::setPasswordDialogDone() newPwdDialogResult = true; newPwdDialog->close(); } void ZSafe::getDocPassword(QString title) { -#ifndef NO_OPIE - owarn << "getDocPassword" << oendl; -#endif // open the 'Password' dialog PasswordForm *dialog = new PasswordForm(this, title, TRUE); newPwdDialog = dialog; newPwdDialogResult = false; QPixmap image0( ( const char** ) zsafe_xpm ); @@ -2450,27 +2116,20 @@ void ZSafe::getDocPassword(QString title) connect( dialog->PasswordField, SIGNAL( returnPressed() ), this, SLOT( setPasswordDialogDone() ) ); // CS: !!! // int pos = filename.findRev ('/'); 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); 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) { m_password = dialog->PasswordField->text(); } else { exitZs (1); @@ -2617,16 +2276,12 @@ int ZSafe::saveFinalize(void) free(buffer); return retval; } void ZSafe::quitMe () { -#ifndef NO_OPIE - owarn << "QUIT..." << oendl; -#endif - if (modified) { switch( QMessageBox::information( this, tr("ZSafe"), tr("Do you want to save\nbefore exiting?"), tr("&Save"), tr("S&ave with\nnew\npassword"), @@ -2680,77 +2335,44 @@ void ZSafe::addCategory() { dialog = categoryDialog; } else { categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); -#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 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 - // 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(); QString categ; 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 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); categ = *cat; -#endif if (!categ.isEmpty()) { dialog->CategoryField->insertItem (categ, -1); if (firstCategory.isEmpty()) firstCategory = categ; } @@ -2770,69 +2392,46 @@ void ZSafe::addCategory() { Wait waitDialog(this, tr("Wait dialog")); waitDialog.waitLabel->setText(tr("Gathering icons...")); waitDialog.show(); qApp->processEvents(); -#ifdef DESKTOP - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); // create list iterator QFileInfo *fi; // pointer for traversing dialog->IconField->insertItem("predefined"); while ( (fi=it.current()) ) { // for each file... QString fileName = fi->fileName(); if(fileName.right(4) == ".png"){ 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(); foo = foo.smoothScale(16,16); imageOfFile.convertFromImage(foo); dialog->IconField->insertItem(imageOfFile,fileName); } ++it; } waitDialog.hide(); } -#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; QString icon; QString fullIconPath; QPixmap *pix; - if (result == Accepted) + if (result == QDialog::Accepted) { modified = true; category = dialog->CategoryField->currentText(); icon = dialog->IconField->currentText()+".png"; -#ifndef NO_OPIE - owarn << category << oendl; -#endif - QListViewItem *li = new ShadedListItem( 1, ListView ); Category *c1 = new Category(); c1->setCategoryName(category); // if (!icon.isEmpty() && !icon.isNull()) if (icon != "predefined.png") @@ -2954,17 +2553,13 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) dialog->Field3->setText(tr("Password")); dialog->Field4->setText(tr("Comment")); dialog->Field5->setText(tr("Field 4")); dialog->Field6->setText(tr("Field 5")); } -#ifdef DESKTOP - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); const QFileInfoList *list = d.entryInfoList(); int i=0; QFileInfoListIterator it( *list ); // create list iterator QFileInfo *fi; // pointer for traversing @@ -3011,17 +2606,13 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) { icon = cat->getIconName(); } else icon = conf->readEntry(APP_KEY+category); -#ifdef DESKTOP - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); const QFileInfoList *list = d.entryInfoList(); int i=0; QFileInfoListIterator it( *list ); // create list iterator QFileInfo *fi; // pointer for traversing @@ -3050,32 +2641,24 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) } } 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(); // #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(); -#ifndef DESKTOP conf->setGroup ("zsafe"); -#endif } void ZSafe::editCategory() { if (!selectedItem) return; @@ -3089,43 +2672,20 @@ void ZSafe::editCategory() { dialog = categoryDialog; } else { categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); -#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 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 // into a list QFile f (cfgFile); QStringList list; if ( f.open(IO_ReadOnly) ) { // file opened successfully QTextStream t( &f ); // use a text stream @@ -3133,35 +2693,25 @@ void ZSafe::editCategory() 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(); QString categ; dialog->CategoryField->clear(); // remove all items int i=0; bool foundCategory = false; while( it != list.end() ) { QString *cat = new QString (*it); if (cat->contains("-field1", FALSE)) { -#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"); cat->truncate(pos); categ = *cat; -#endif if (!categ.isEmpty()) { dialog->CategoryField->insertItem (categ, i); if (category.compare(categ) == 0) { dialog->CategoryField->setCurrentItem(i); @@ -3190,17 +2740,13 @@ void ZSafe::editCategory() Wait waitDialog(this, tr("Wait dialog")); waitDialog.waitLabel->setText(tr("Gathering icons...")); waitDialog.show(); qApp->processEvents(); -#ifdef DESKTOP - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); const QFileInfoList *list = d.entryInfoList(); int i=0; QFileInfoListIterator it( *list ); // create list iterator QFileInfo *fi; // pointer for traversing @@ -3212,18 +2758,13 @@ void ZSafe::editCategory() dialog->IconField->insertItem("predefined"); while ( (fi=it.current()) ) { // for each file... QString fileName = fi->fileName(); if(fileName.right(4) == ".png") { 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(); foo = foo.smoothScale(16,16); imageOfFile.convertFromImage(foo); dialog->IconField->insertItem(imageOfFile,fileName); if(fileName+".png"==icon) dialog->IconField->setCurrentItem(i+1); @@ -3232,18 +2773,13 @@ void ZSafe::editCategory() ++it; } waitDialog.hide(); } else { -#ifdef DESKTOP - // QDir d(QDir::homeDirPath() + "/pics/"); - QDir d(iconPath); -#else QDir d(QPEApplication::qpeDir() + "pics/"); -#endif d.setFilter( QDir::Files); const QFileInfoList *list = d.entryInfoList(); int i=0; QFileInfoListIterator it( *list ); // create list iterator QFileInfo *fi; // pointer for traversing @@ -3272,23 +2808,17 @@ void ZSafe::editCategory() ++it; } } } // 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(); QString fullIconPath; QPixmap *pix; - if (result == Accepted) + if (result == QDialog::Accepted) { modified = true; if (category != dialog->CategoryField->currentText()) { categories.remove (category); // #ifndef Q_WS_WIN @@ -3299,18 +2829,12 @@ void ZSafe::editCategory() category = dialog->CategoryField->currentText(); icon = dialog->IconField->currentText()+".png"; if (cat) { -#ifndef NO_OPIE - owarn << "Category found" << oendl; -#else - qWarning("Category found"); -#endif - // if (!icon.isEmpty() && !icon.isNull()) if (icon != "predefined.png") { // build the full path fullIconPath = iconPath + icon; pix = new QPixmap (fullIconPath); @@ -3337,17 +2861,12 @@ void ZSafe::editCategory() } // change the category name of the selected category QListViewItem *catItem = cat->getListItem(); if (catItem) { -#ifndef NO_OPIE - owarn << category << oendl; -#else - qWarning (category); -#endif catItem->setText( 0, tr( category ) ); cat->setCategoryName (tr(category)); cat->initListItem(); categories.insert (category, cat); } @@ -3478,20 +2997,17 @@ void ZSafe::newDocument() // m_password = ""; selectedItem = NULL; filename = newFile; // save the current filename to the config file + conf->setGroup("zsafe"); conf->writeEntry(APP_KEY+"document", filename); saveConf(); 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); // openDocument(filename); QMessageBox::information( this, tr("ZSafe"), tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); @@ -3500,37 +3016,21 @@ void ZSafe::newDocument() } void ZSafe::loadDocument() { // open the file dialog -#ifndef DESKTOP -#ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; mimeTypes.insert(tr("All"), QStringList() ); mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, QDir::homeDirPath() + "/Documents/application/zsafe", QString::null, mimeTypes, this, 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 // open the new document if (newFile && newFile.length() > 0 ) { // save the previous opened document if (!filename.isEmpty()) @@ -3562,20 +3062,17 @@ void ZSafe::loadDocument() categories.clear(); m_password = ""; selectedItem = NULL; filename = newFile; // save the current filename to the config file + conf->setGroup("zsafe"); conf->writeEntry(APP_KEY+"document", filename); saveConf(); 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); openDocument(filename); } } void ZSafe::saveDocumentAs() @@ -3590,20 +3087,17 @@ QString newFile = zsaveDialog(); saveDocument(filename, FALSE); selectedItem = NULL; filename = newFile; // save the current filename to the config file + conf->setGroup("zsafe"); conf->writeEntry(APP_KEY+"document", filename); saveConf(); 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); QMessageBox::information( this, tr("ZSafe"), tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); saveDocumentWithPwd(); } @@ -3619,47 +3113,25 @@ void ZSafe::saveDocumentWithPwd() saveDocument(filename, TRUE); } 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>"); // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); QMessageBox mb( this, tr("ZSafe")); mb.setText (info); mb.setButtonText (QMessageBox::Ok, tr ("&OK")); @@ -3669,15 +3141,13 @@ void ZSafe::about() } void ZSafe::setExpandFlag() { expandTree = !expandTree; file->setItemChecked('o', expandTree); -#ifndef DESKTOP conf->setGroup ("zsafePrefs"); -#endif // #ifndef Q_WS_WIN conf->writeEntry (APP_KEY+"expandTree", expandTree); // #endif saveConf(); } @@ -3693,19 +3163,14 @@ void ZSafe::paintEvent( QPaintEvent * ) } } 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 if (New) New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); if (Edit) Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); if (Delete) @@ -3736,13 +3201,12 @@ QPixmap * ZSafe::getPredefinedIcon(QString category) pm = new QPixmap((const char**)general_data); return pm; } void ZSafe::setDocument(const QString& fileref) { -#ifndef DESKTOP // stop the timer to prevent loading of the default document docuTimer.stop(); DocLnk link(fileref); if ( link.isValid() ) { @@ -3754,20 +3218,17 @@ void ZSafe::setDocument(const QString& fileref) { // if (filename != fileref) // saveDocument(filename, FALSE); filename = fileref; } // save the current filename to the config file + conf->setGroup("zsafe"); conf->writeEntry(APP_KEY+"document", filename); saveConf(); 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); // clear the password list QListViewItem *i; QListViewItem *c = NULL; // step through all categories for (i = ListView->firstChild(); @@ -3792,28 +3253,19 @@ void ZSafe::setDocument(const QString& fileref) categories.clear(); m_password = ""; selectedItem = NULL; openDocument(filename); -#else -Q_UNUSED(fileref); -#endif } void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int column) { if(item ==0) return; switch (mouse) { case 1: - { -#ifdef DESKTOP - QDragObject *d = new QTextDrag( item->text(column) , this ); - d->dragCopy(); -#endif - } break; case 2: { QClipboard *cb = QApplication::clipboard(); QIconSet copy_img((const char**) copy_xpm); @@ -3848,32 +3300,17 @@ void ZSafe::copyClip( const QString &text) { } QString ZSafe::zsaveDialog() { QString fn; -#ifndef DESKTOP -#ifndef NO_OPIE QMap<QString, QStringList> mimeTypes; mimeTypes.insert(tr("All"), QStringList() ); mimeTypes.insert(tr("Text"), "text/*" ); fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, QDir::homeDirPath() + "/Documents/application/zsafe", QString::null, mimeTypes, this, 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 @@ -43,26 +43,27 @@ class Config; class CategoryDialog; class QPixmap; // number of fields for one entry #define FIELD_SIZE 7 -class ZSafe : public QDialog +class ZSafe : public QWidget { Q_OBJECT protected: void paintEvent( QPaintEvent * e ); void resizeEvent ( QResizeEvent * ); bool raiseFlag; QTimer raiseTimer; 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 ); } static const QColor *evenRowColor; static const QColor *oddRowColor; QToolButton* Edit; QToolButton* Delete; @@ -192,7 +193,12 @@ private slots: void setDocument(const QString& fileref); void slotLoadDocu(); void slotRaiseTimer(); }; + +extern ZSafe *zs; +extern QApplication *appl; +extern int DeskW; +extern int DeskH; #endif // ZSAFE_H |