author | zcarsten <zcarsten> | 2003-07-31 16:28:04 (UTC) |
---|---|---|
committer | zcarsten <zcarsten> | 2003-07-31 16:28:04 (UTC) |
commit | 274bfafbda8d1d9af6cc5d1ced828a97a47c3f55 (patch) (unidiff) | |
tree | fce22d8d08ddccfe828009ca2fe9f66dfd268d55 /noncore/apps/zsafe/zsafe.cpp | |
parent | e5bed303e50298d91a6adf9e0b5cf7dd3d975ed3 (diff) | |
download | opie-274bfafbda8d1d9af6cc5d1ced828a97a47c3f55.zip opie-274bfafbda8d1d9af6cc5d1ced828a97a47c3f55.tar.gz opie-274bfafbda8d1d9af6cc5d1ced828a97a47c3f55.tar.bz2 |
usage of OFileDialog
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 85 |
1 files changed, 83 insertions, 2 deletions
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 | |||
@@ -6,13 +6,14 @@ | |||
6 | ** | 6 | ** |
7 | ** $Id$ | 7 | ** $Id$ |
8 | ** | 8 | ** |
9 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html | 9 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html |
10 | ** | 10 | ** |
11 | ** Compile Flags: | 11 | ** Compile Flags: |
12 | ** Zaurus arm : none | 12 | ** Zaurus arm : -DNO_OPIE |
13 | ** Zaurus Opie arm: none | ||
13 | ** Linux Desktop : -DDESKTOP | 14 | ** Linux Desktop : -DDESKTOP |
14 | ** Windows Desktop: -DDESKTOP -DWIN32 | 15 | ** Windows Desktop: -DDESKTOP -DWIN32 |
15 | ** | 16 | ** |
16 | ****************************************************************************/ | 17 | ****************************************************************************/ |
17 | #include "zsafe.h" | 18 | #include "zsafe.h" |
18 | #include "newdialog.h" | 19 | #include "newdialog.h" |
@@ -21,14 +22,18 @@ | |||
21 | #include "passworddialog.h" | 22 | #include "passworddialog.h" |
22 | #include "infoform.h" | 23 | #include "infoform.h" |
23 | #include "zlistview.h" | 24 | #include "zlistview.h" |
24 | #include "shadedlistitem.h" | 25 | #include "shadedlistitem.h" |
25 | 26 | ||
26 | #ifndef DESKTOP | 27 | #ifndef DESKTOP |
28 | #ifndef NO_OPIE | ||
29 | #include <opie/ofiledialog.h> | ||
30 | #else | ||
27 | #include "scqtfileedit.h" | 31 | #include "scqtfileedit.h" |
28 | #endif | 32 | #endif |
33 | #endif | ||
29 | 34 | ||
30 | #include <qclipboard.h> | 35 | #include <qclipboard.h> |
31 | 36 | ||
32 | #include <stdio.h> | 37 | #include <stdio.h> |
33 | 38 | ||
34 | #include <sys/types.h> | 39 | #include <sys/types.h> |
@@ -1192,28 +1197,43 @@ void ZSafe::listViewSelected( QListViewItem *_item) | |||
1192 | #endif | 1197 | #endif |
1193 | 1198 | ||
1194 | } | 1199 | } |
1195 | 1200 | ||
1196 | bool ZSafe::isCategory(QListViewItem *_item) | 1201 | bool ZSafe::isCategory(QListViewItem *_item) |
1197 | { | 1202 | { |
1203 | if (_item == NULL) | ||
1204 | return FALSE; | ||
1205 | |||
1198 | QString categoryName = _item->text (0); | 1206 | QString categoryName = _item->text (0); |
1199 | if (categories.find ((const char *)categoryName)) | 1207 | if (categories.find ((const char *)categoryName)) |
1200 | return TRUE; | 1208 | return TRUE; |
1201 | else | 1209 | else |
1202 | return FALSE; | 1210 | return FALSE; |
1203 | } | 1211 | } |
1204 | 1212 | ||
1205 | void ZSafe::removeAsciiFile() | 1213 | void ZSafe::removeAsciiFile() |
1206 | { | 1214 | { |
1207 | // QString fn = filename + ".txt"; | 1215 | // QString fn = filename + ".txt"; |
1208 | // open the file dialog | 1216 | // open the file dialog |
1209 | #ifndef DESKTOP | 1217 | #ifndef DESKTOP |
1218 | #ifndef NO_OPIE | ||
1219 | QMap<QString, QStringList> mimeTypes; | ||
1220 | mimeTypes.insert(tr("All"), QStringList() ); | ||
1221 | mimeTypes.insert(tr("Text"), "text/*" ); | ||
1222 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | ||
1223 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1224 | QString::null, | ||
1225 | mimeTypes, | ||
1226 | this, | ||
1227 | tr ("Remove text file")); | ||
1228 | #else | ||
1210 | QString fn = ScQtFileEdit::getOpenFileName(this, | 1229 | QString fn = ScQtFileEdit::getOpenFileName(this, |
1211 | tr ("Remove text file"), | 1230 | tr ("Remove text file"), |
1212 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1231 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1213 | "*.txt"); | 1232 | "*.txt"); |
1233 | #endif | ||
1214 | #else | 1234 | #else |
1215 | QString fn = QFileDialog::getOpenFileName( | 1235 | QString fn = QFileDialog::getOpenFileName( |
1216 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1236 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1217 | "ZSafe (*.txt)", | 1237 | "ZSafe (*.txt)", |
1218 | this, | 1238 | this, |
1219 | "ZSafe File Dialog" | 1239 | "ZSafe File Dialog" |
@@ -1242,16 +1262,28 @@ void ZSafe::writeAllEntries() | |||
1242 | tr("No document defined.\nYou have to create a new document")); | 1262 | tr("No document defined.\nYou have to create a new document")); |
1243 | return; | 1263 | return; |
1244 | } | 1264 | } |
1245 | 1265 | ||
1246 | // open the file dialog | 1266 | // open the file dialog |
1247 | #ifndef DESKTOP | 1267 | #ifndef DESKTOP |
1268 | #ifndef NO_OPIE | ||
1269 | QMap<QString, QStringList> mimeTypes; | ||
1270 | mimeTypes.insert(tr("All"), QStringList() ); | ||
1271 | mimeTypes.insert(tr("Text"), "text/*" ); | ||
1272 | QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | ||
1273 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1274 | QString::null, | ||
1275 | mimeTypes, | ||
1276 | this, | ||
1277 | tr ("Export text file")); | ||
1278 | #else | ||
1248 | QString fn = ScQtFileEdit::getSaveAsFileName(this, | 1279 | QString fn = ScQtFileEdit::getSaveAsFileName(this, |
1249 | tr ("Export text file"), | 1280 | tr ("Export text file"), |
1250 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1281 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1251 | "*.txt"); | 1282 | "*.txt"); |
1283 | #endif | ||
1252 | #else | 1284 | #else |
1253 | QString fn = QFileDialog::getSaveFileName( | 1285 | QString fn = QFileDialog::getSaveFileName( |
1254 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1286 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1255 | "ZSafe (*.txt)", | 1287 | "ZSafe (*.txt)", |
1256 | this, | 1288 | this, |
1257 | "ZSafe File Dialog" | 1289 | "ZSafe File Dialog" |
@@ -1325,16 +1357,28 @@ void ZSafe::readAllEntries() | |||
1325 | tr("No document defined.\nYou have to create a new document")); | 1357 | tr("No document defined.\nYou have to create a new document")); |
1326 | return; | 1358 | return; |
1327 | } | 1359 | } |
1328 | 1360 | ||
1329 | // open the file dialog | 1361 | // open the file dialog |
1330 | #ifndef DESKTOP | 1362 | #ifndef DESKTOP |
1363 | #ifndef NO_OPIE | ||
1364 | QMap<QString, QStringList> mimeTypes; | ||
1365 | mimeTypes.insert(tr("All"), QStringList() ); | ||
1366 | mimeTypes.insert(tr("Text"), "text/*" ); | ||
1367 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | ||
1368 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1369 | QString::null, | ||
1370 | mimeTypes, | ||
1371 | this, | ||
1372 | tr ("Import text file")); | ||
1373 | #else | ||
1331 | QString fn = ScQtFileEdit::getOpenFileName(this, | 1374 | QString fn = ScQtFileEdit::getOpenFileName(this, |
1332 | tr ("Import text file"), | 1375 | tr ("Import text file"), |
1333 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1376 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1334 | "*.txt"); | 1377 | "*.txt"); |
1378 | #endif | ||
1335 | #else | 1379 | #else |
1336 | QString fn = QFileDialog::getOpenFileName( | 1380 | QString fn = QFileDialog::getOpenFileName( |
1337 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1381 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1338 | "ZSafe (*.txt)", | 1382 | "ZSafe (*.txt)", |
1339 | this, | 1383 | this, |
1340 | "ZSafe File Dialog" | 1384 | "ZSafe File Dialog" |
@@ -3138,16 +3182,28 @@ void ZSafe::pasteItem() | |||
3138 | 3182 | ||
3139 | void ZSafe::newDocument() | 3183 | void ZSafe::newDocument() |
3140 | { | 3184 | { |
3141 | 3185 | ||
3142 | // open the file dialog | 3186 | // open the file dialog |
3143 | #ifndef DESKTOP | 3187 | #ifndef DESKTOP |
3188 | #ifndef NO_OPIE | ||
3189 | QMap<QString, QStringList> mimeTypes; | ||
3190 | mimeTypes.insert(tr("All"), QStringList() ); | ||
3191 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | ||
3192 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | ||
3193 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3194 | QString::null, | ||
3195 | mimeTypes, | ||
3196 | this, | ||
3197 | tr ("Create new ZSafe document")); | ||
3198 | #else | ||
3144 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3199 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3145 | tr ("Create new ZSafe document"), | 3200 | tr ("Create new ZSafe document"), |
3146 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3201 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3147 | "*.zsf"); | 3202 | "*.zsf"); |
3203 | #endif | ||
3148 | #else | 3204 | #else |
3149 | QString newFile = QFileDialog::getSaveFileName( | 3205 | QString newFile = QFileDialog::getSaveFileName( |
3150 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3206 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3151 | "ZSafe (*.zsf)", | 3207 | "ZSafe (*.zsf)", |
3152 | this, | 3208 | this, |
3153 | "ZSafe File Dialog" | 3209 | "ZSafe File Dialog" |
@@ -3186,13 +3242,13 @@ void ZSafe::newDocument() | |||
3186 | } | 3242 | } |
3187 | } | 3243 | } |
3188 | if (c) delete c; // delete the previous category | 3244 | if (c) delete c; // delete the previous category |
3189 | categories.clear(); | 3245 | categories.clear(); |
3190 | 3246 | ||
3191 | // m_password = ""; | 3247 | // m_password = ""; |
3192 | // selectedItem = NULL; | 3248 | selectedItem = NULL; |
3193 | 3249 | ||
3194 | filename = newFile; | 3250 | filename = newFile; |
3195 | 3251 | ||
3196 | // save the current filename to the config file | 3252 | // save the current filename to the config file |
3197 | conf->writeEntry(APP_KEY+"document", filename); | 3253 | conf->writeEntry(APP_KEY+"document", filename); |
3198 | saveConf(); | 3254 | saveConf(); |
@@ -3214,16 +3270,28 @@ void ZSafe::newDocument() | |||
3214 | 3270 | ||
3215 | void ZSafe::loadDocument() | 3271 | void ZSafe::loadDocument() |
3216 | { | 3272 | { |
3217 | 3273 | ||
3218 | // open the file dialog | 3274 | // open the file dialog |
3219 | #ifndef DESKTOP | 3275 | #ifndef DESKTOP |
3276 | #ifndef NO_OPIE | ||
3277 | QMap<QString, QStringList> mimeTypes; | ||
3278 | mimeTypes.insert(tr("All"), QStringList() ); | ||
3279 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | ||
3280 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | ||
3281 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3282 | QString::null, | ||
3283 | mimeTypes, | ||
3284 | this, | ||
3285 | tr ("Open ZSafe document")); | ||
3286 | #else | ||
3220 | QString newFile = ScQtFileEdit::getOpenFileName(this, | 3287 | QString newFile = ScQtFileEdit::getOpenFileName(this, |
3221 | tr ("Open ZSafe document"), | 3288 | tr ("Open ZSafe document"), |
3222 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3289 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3223 | "*.zsf"); | 3290 | "*.zsf"); |
3291 | #endif | ||
3224 | #else | 3292 | #else |
3225 | QString newFile = QFileDialog::getOpenFileName( | 3293 | QString newFile = QFileDialog::getOpenFileName( |
3226 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3294 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3227 | "ZSafe (*.zsf)", | 3295 | "ZSafe (*.zsf)", |
3228 | this, | 3296 | this, |
3229 | "ZSafe File Dialog" | 3297 | "ZSafe File Dialog" |
@@ -3280,16 +3348,28 @@ void ZSafe::loadDocument() | |||
3280 | } | 3348 | } |
3281 | 3349 | ||
3282 | void ZSafe::saveDocumentAs() | 3350 | void ZSafe::saveDocumentAs() |
3283 | { | 3351 | { |
3284 | 3352 | ||
3285 | #ifndef DESKTOP | 3353 | #ifndef DESKTOP |
3354 | #ifndef NO_OPIE | ||
3355 | QMap<QString, QStringList> mimeTypes; | ||
3356 | mimeTypes.insert(tr("All"), QStringList() ); | ||
3357 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | ||
3358 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | ||
3359 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3360 | QString::null, | ||
3361 | mimeTypes, | ||
3362 | this, | ||
3363 | tr ("Save ZSafe document as..")); | ||
3364 | #else | ||
3286 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3365 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3287 | tr ("Save ZSafe document as.."), | 3366 | tr ("Save ZSafe document as.."), |
3288 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3367 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3289 | "*.zsf"); | 3368 | "*.zsf"); |
3369 | #endif | ||
3290 | #else | 3370 | #else |
3291 | // open the file dialog | 3371 | // open the file dialog |
3292 | QString newFile = QFileDialog::getSaveFileName( | 3372 | QString newFile = QFileDialog::getSaveFileName( |
3293 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3373 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3294 | "ZSafe (*.zsf)", | 3374 | "ZSafe (*.zsf)", |
3295 | this, | 3375 | this, |
@@ -3301,12 +3381,13 @@ void ZSafe::saveDocumentAs() | |||
3301 | if (newFile && newFile.length() > 0 ) | 3381 | if (newFile && newFile.length() > 0 ) |
3302 | { | 3382 | { |
3303 | // save the previous opened document | 3383 | // save the previous opened document |
3304 | if (!filename.isEmpty()) | 3384 | if (!filename.isEmpty()) |
3305 | saveDocument(filename, FALSE); | 3385 | saveDocument(filename, FALSE); |
3306 | 3386 | ||
3387 | selectedItem = NULL; | ||
3307 | filename = newFile; | 3388 | filename = newFile; |
3308 | 3389 | ||
3309 | // save the current filename to the config file | 3390 | // save the current filename to the config file |
3310 | conf->writeEntry(APP_KEY+"document", filename); | 3391 | conf->writeEntry(APP_KEY+"document", filename); |
3311 | saveConf(); | 3392 | saveConf(); |
3312 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3393 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |