diff -r f3465a5f0dc4 -r 95f1af9b525a file.cpp --- a/file.cpp Thu Jun 14 10:21:41 2007 +0000 +++ b/file.cpp Thu Aug 09 18:34:08 2007 +0000 @@ -63,6 +63,55 @@ return d; } +#include +extern QString vymName; +extern QDir lastFileDir; + +QString browseDirectory (QWidget *parent,const QString &caption) +{ + QFileDialog fd(parent,caption); + fd.setMode (QFileDialog::DirectoryOnly); + fd.setCaption(vymName+ " - "+caption); + fd.setDir (lastFileDir); + fd.show(); + + if ( fd.exec() == QDialog::Accepted ) + return fd.selectedFile(); + else + return ""; +} + + + +bool reallyWriteDirectory(const QString &dir) +{ + QStringList eList = QDir(dir).entryList(); + if (eList.first() ==".") eList.pop_front(); // remove "." + if (eList.first() =="..") eList.pop_front(); // remove "." + if (!eList.isEmpty()) + { + QMessageBox mb( vymName, + QObject::tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir), + QMessageBox::Warning, + QMessageBox::Yes , + QMessageBox::Cancel | QMessageBox::Default, + QMessageBox::QMessageBox::NoButton ); + + mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") ); + mb.setButtonText( QMessageBox::No, QObject::tr("Cancel")); + switch( mb.exec() ) + { + case QMessageBox::Yes: + // save + return true; + case QMessageBox::Cancel: + // do nothing + return false; + } + } + return true; +} + QString makeUniqueDir (bool &ok,QString s) { // Create unique directory e.g. s="/tmp/vym-XXXXXX"