From 6d7b1a9a5f32a0b69c5ee9cc963e8a43a76327cf Mon Sep 17 00:00:00 2001
From: zecke Can't create directory ..."+d1+" ZSafe will now exit. Can't create directory %1 ZSafe will now exit. Can't create directory ...//Documents/application/zsafe ZSafe will now exit.
ZSafe will now exit.
").arg(d2)); -#endif exitZs (1); } } - + filename = zsafeAppDirPath + "/passwords.zsf"; // save the current filename to the config file @@ -553,11 +435,7 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) //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; @@ -577,12 +455,10 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) // 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, @@ -665,31 +541,21 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) 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() ) ); @@ -704,17 +570,11 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) 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; @@ -772,10 +632,6 @@ void ZSafe::editPwd() { // 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"))); @@ -796,22 +652,8 @@ void ZSafe::editPwd() 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 @@ -852,10 +694,6 @@ void ZSafe::newPwd() 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"))); @@ -866,22 +704,9 @@ void ZSafe::newPwd() 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(); @@ -920,12 +745,7 @@ 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 @@ -938,24 +758,16 @@ void ZSafe::findPwd() 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 { @@ -1001,9 +813,6 @@ void ZSafe::findPwd() i != NULL; i = i->nextSibling()) { -#ifndef NO_OPIE - owarn << i->text(0) << oendl; -#endif i->setSelected(FALSE); // step through all subitems @@ -1017,11 +826,6 @@ void ZSafe::findPwd() 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); @@ -1038,11 +842,6 @@ void ZSafe::findPwd() if ((n && u && c ) && !found) { -#ifndef NO_OPIE - owarn << "Found" << oendl; -#else - qWarning ("Found"); -#endif selectedItem = si; si->setSelected(TRUE); ListView->setCurrentItem(si); @@ -1099,46 +898,24 @@ 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; } 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; } @@ -1235,9 +1012,6 @@ void ZSafe::showInfo( QListViewItem *_item) QPEApplication::showDialog( infoForm ); #endif -#ifdef DESKTOP - infoForm->show(); -#endif } } @@ -1250,16 +1024,6 @@ void ZSafe::listViewSelected( QListViewItem *_item) 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"))); @@ -1267,8 +1031,6 @@ void ZSafe::listViewSelected( QListViewItem *_item) 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) @@ -1287,8 +1049,6 @@ void ZSafe::removeAsciiFile() { // QString fn = filename + ".txt"; // open the file dialog -#ifndef DESKTOP -#ifndef NO_OPIE QMapYou must create a new document first. Ok to create?
"), @@ -1962,7 +1631,7 @@ bool ZSafe::openDocument(const char* _filename, const char* ) return false; break; } - + } @@ -2436,9 +2105,6 @@ void ZSafe::setPasswordDialogDone() 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; @@ -2453,21 +2119,14 @@ void ZSafe::getDocPassword(QString title) // 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(); } @@ -2620,10 +2279,6 @@ int ZSafe::saveFinalize(void) void ZSafe::quitMe () { -#ifndef NO_OPIE - owarn << "QUIT..." << oendl; -#endif - if (modified) { switch( QMessageBox::information( this, tr("ZSafe"), @@ -2683,9 +2338,6 @@ void ZSafe::addCategory() 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&)), @@ -2693,10 +2345,6 @@ void ZSafe::addCategory() 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); @@ -2704,29 +2352,12 @@ void ZSafe::addCategory() 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; @@ -2736,18 +2367,9 @@ void ZSafe::addCategory() 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); @@ -2773,11 +2395,7 @@ void ZSafe::addCategory() 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(); @@ -2789,12 +2407,7 @@ void ZSafe::addCategory() 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); @@ -2805,31 +2418,17 @@ void ZSafe::addCategory() 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); @@ -2957,11 +2556,7 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) 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(); @@ -3014,11 +2609,7 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) 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(); @@ -3053,13 +2644,7 @@ 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()); @@ -3070,9 +2655,7 @@ void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); // #endif saveConf(); -#ifndef DESKTOP conf->setGroup ("zsafe"); -#endif } void ZSafe::editCategory() @@ -3092,9 +2675,6 @@ void ZSafe::editCategory() 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&)), @@ -3103,26 +2683,6 @@ void ZSafe::editCategory() } 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); @@ -3136,7 +2696,6 @@ void ZSafe::editCategory() } f.close(); } -#endif QStringList::Iterator it = list.begin(); QString categ; dialog->CategoryField->clear(); // remove all items @@ -3147,18 +2706,9 @@ void ZSafe::editCategory() 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); @@ -3193,11 +2743,7 @@ void ZSafe::editCategory() 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(); @@ -3215,12 +2761,7 @@ void ZSafe::editCategory() 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); @@ -3235,12 +2776,7 @@ void ZSafe::editCategory() } 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(); @@ -3275,17 +2811,11 @@ 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(); QString fullIconPath; QPixmap *pix; - if (result == Accepted) + if (result == QDialog::Accepted) { modified = true; if (category != dialog->CategoryField->currentText()) @@ -3302,12 +2832,6 @@ void ZSafe::editCategory() if (cat) { -#ifndef NO_OPIE - owarn << "Category found" << oendl; -#else - qWarning("Category found"); -#endif - // if (!icon.isEmpty() && !icon.isNull()) if (icon != "predefined.png") { @@ -3340,11 +2864,6 @@ void ZSafe::editCategory() 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)); @@ -3481,14 +3000,11 @@ void ZSafe::newDocument() 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); @@ -3503,8 +3019,6 @@ void ZSafe::loadDocument() { // open the file dialog -#ifndef DESKTOP -#ifndef NO_OPIE QMap