1.1 --- a/file.cpp Thu Jun 14 10:21:41 2007 +0000
1.2 +++ b/file.cpp Mon Oct 22 09:50:03 2007 +0000
1.3 @@ -63,6 +63,55 @@
1.4 return d;
1.5 }
1.6
1.7 +#include <QFileDialog>
1.8 +extern QString vymName;
1.9 +extern QDir lastFileDir;
1.10 +
1.11 +QString browseDirectory (QWidget *parent,const QString &caption)
1.12 +{
1.13 + QFileDialog fd(parent,caption);
1.14 + fd.setMode (QFileDialog::DirectoryOnly);
1.15 + fd.setCaption(vymName+ " - "+caption);
1.16 + fd.setDir (lastFileDir);
1.17 + fd.show();
1.18 +
1.19 + if ( fd.exec() == QDialog::Accepted )
1.20 + return fd.selectedFile();
1.21 + else
1.22 + return "";
1.23 +}
1.24 +
1.25 +
1.26 +
1.27 +bool reallyWriteDirectory(const QString &dir)
1.28 +{
1.29 + QStringList eList = QDir(dir).entryList();
1.30 + if (eList.first() ==".") eList.pop_front(); // remove "."
1.31 + if (eList.first() =="..") eList.pop_front(); // remove "."
1.32 + if (!eList.isEmpty())
1.33 + {
1.34 + QMessageBox mb( vymName,
1.35 + QObject::tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1.36 + QMessageBox::Warning,
1.37 + QMessageBox::Yes ,
1.38 + QMessageBox::Cancel | QMessageBox::Default,
1.39 + QMessageBox::QMessageBox::NoButton );
1.40 +
1.41 + mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") );
1.42 + mb.setButtonText( QMessageBox::No, QObject::tr("Cancel"));
1.43 + switch( mb.exec() )
1.44 + {
1.45 + case QMessageBox::Yes:
1.46 + // save
1.47 + return true;
1.48 + case QMessageBox::Cancel:
1.49 + // do nothing
1.50 + return false;
1.51 + }
1.52 + }
1.53 + return true;
1.54 +}
1.55 +
1.56 QString makeUniqueDir (bool &ok,QString s)
1.57 {
1.58 // Create unique directory e.g. s="/tmp/vym-XXXXXX"