author | zcarsten <zcarsten> | 2003-07-31 16:28:04 (UTC) |
---|---|---|
committer | zcarsten <zcarsten> | 2003-07-31 16:28:04 (UTC) |
commit | 274bfafbda8d1d9af6cc5d1ced828a97a47c3f55 (patch) (side-by-side diff) | |
tree | fce22d8d08ddccfe828009ca2fe9f66dfd268d55 | |
parent | e5bed303e50298d91a6adf9e0b5cf7dd3d975ed3 (diff) | |
download | opie-274bfafbda8d1d9af6cc5d1ced828a97a47c3f55.zip opie-274bfafbda8d1d9af6cc5d1ced828a97a47c3f55.tar.gz opie-274bfafbda8d1d9af6cc5d1ced828a97a47c3f55.tar.bz2 |
usage of OFileDialog
-rw-r--r-- | noncore/apps/zsafe/config.in | 2 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 85 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.pro | 2 |
3 files changed, 85 insertions, 4 deletions
diff --git a/noncore/apps/zsafe/config.in b/noncore/apps/zsafe/config.in index 53956ad..4b1e968 100644 --- a/noncore/apps/zsafe/config.in +++ b/noncore/apps/zsafe/config.in @@ -1,5 +1,5 @@ config ZSAFE boolean "zsafe (Zaurus Password Manager)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index bd03031..abf6511 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp @@ -4,33 +4,38 @@ ** ** Author: Carsten Schneider <CarstenSchneider@t-online.de> ** ** $Id$ ** ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html ** ** Compile Flags: -** Zaurus arm : none +** Zaurus arm : -DNO_OPIE +** Zaurus Opie arm: none ** Linux Desktop : -DDESKTOP ** Windows Desktop: -DDESKTOP -DWIN32 ** ****************************************************************************/ #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 <opie/ofiledialog.h> +#else #include "scqtfileedit.h" #endif +#endif #include <qclipboard.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -1190,32 +1195,47 @@ void ZSafe::listViewSelected( QListViewItem *_item) 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; + QString categoryName = _item->text (0); if (categories.find ((const char *)categoryName)) return TRUE; else return FALSE; } 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 @@ -1240,20 +1260,32 @@ void ZSafe::writeAllEntries() { 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::getSaveFileName( OFileSelector::EXTENDED_ALL, + QDir::homeDirPath() + "/Documents/application/zsafe", + QString::null, + mimeTypes, + this, + tr ("Export text file")); +#else QString fn = ScQtFileEdit::getSaveAsFileName(this, tr ("Export text file"), QDir::homeDirPath() + "/Documents/application/zsafe", "*.txt"); +#endif #else QString fn = QFileDialog::getSaveFileName( QDir::homeDirPath() + "/Documents/application/zsafe", "ZSafe (*.txt)", this, "ZSafe File Dialog" "Choose a text file" ); #endif @@ -1323,20 +1355,32 @@ 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 @@ -3136,20 +3180,32 @@ void ZSafe::pasteItem() IsCopy = false; } void ZSafe::newDocument() { // 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::getSaveFileName( OFileSelector::EXTENDED_ALL, + QDir::homeDirPath() + "/Documents/application/zsafe", + QString::null, + mimeTypes, + this, + tr ("Create new ZSafe document")); +#else QString newFile = ScQtFileEdit::getSaveAsFileName(this, tr ("Create new ZSafe document"), QDir::homeDirPath() + "/Documents/application/zsafe", "*.zsf"); +#endif #else QString newFile = QFileDialog::getSaveFileName( QDir::homeDirPath() + "/Documents/application/zsafe", "ZSafe (*.zsf)", this, "ZSafe File Dialog" "Choose a ZSafe file" ); #endif @@ -3184,17 +3240,17 @@ void ZSafe::newDocument() i->takeItem(_si); // remove from view list if (_si) delete _si; } } if (c) delete c; // delete the previous category categories.clear(); // m_password = ""; - // selectedItem = NULL; + selectedItem = NULL; filename = newFile; // save the current filename to the config file conf->writeEntry(APP_KEY+"document", filename); saveConf(); QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); #ifdef WIN32 @@ -3212,20 +3268,32 @@ 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 @@ -3278,20 +3346,32 @@ void ZSafe::loadDocument() openDocument(filename); } } void ZSafe::saveDocumentAs() { #ifndef DESKTOP +#ifndef NO_OPIE + QMap<QString, QStringList> mimeTypes; + mimeTypes.insert(tr("All"), QStringList() ); + mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); + QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, + QDir::homeDirPath() + "/Documents/application/zsafe", + QString::null, + mimeTypes, + this, + tr ("Save ZSafe document as..")); +#else QString newFile = ScQtFileEdit::getSaveAsFileName(this, tr ("Save ZSafe document as.."), QDir::homeDirPath() + "/Documents/application/zsafe", "*.zsf"); +#endif #else // open the file dialog QString newFile = QFileDialog::getSaveFileName( QDir::homeDirPath() + "/Documents/application/zsafe", "ZSafe (*.zsf)", this, "ZSafe File Dialog" "Choose a ZSafe file" ); @@ -3299,16 +3379,17 @@ void ZSafe::saveDocumentAs() // open the new document if (newFile && newFile.length() > 0 ) { // save the previous opened document if (!filename.isEmpty()) saveDocument(filename, FALSE); + selectedItem = NULL; filename = newFile; // save the current filename to the config file conf->writeEntry(APP_KEY+"document", filename); saveConf(); QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); #ifdef WIN32 this->setCaption("Qt ZSafe: " + ti); diff --git a/noncore/apps/zsafe/zsafe.pro b/noncore/apps/zsafe/zsafe.pro index ae4c793..5cb74dd 100644 --- a/noncore/apps/zsafe/zsafe.pro +++ b/noncore/apps/zsafe/zsafe.pro @@ -9,14 +9,14 @@ SOURCES = main.cpp zsafe.cpp krc2.cpp category.cpp \ scqtfiledlg.cpp INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui INTERFACES += infoform.ui wait.ui INCLUDEPATH += $(OPIEDIR)/include INCLUDEPATH += . INCLUDEPATH += $(OPIEDIR)/noncore/apps/zsafe DEPENDPATH += $(OPIEDIR)/include -LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe +LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopie TARGET = zsafe TRANSLATIONS = $(OPIEDIR)/noncore/apps/zsafe/i18n/de/zsafe.ts #include ( $(OPIEDIR)/include.pro ) |