Line data Source code
1 : // Author(s): Rimco Boudewijns 2 : // Copyright: see the accompanying file COPYING or copy at 3 : // https://github.com/mCRL2org/mCRL2/blob/master/COPYING 4 : // 5 : // Distributed under the Boost Software License, Version 1.0. 6 : // (See accompanying file LICENSE_1_0.txt or copy at 7 : // http://www.boost.org/LICENSE_1_0.txt) 8 : // 9 : 10 : #include "mcrl2/gui/persistentfiledialog.h" 11 : 12 : using namespace mcrl2::gui::qt; 13 : 14 0 : PersistentFileDialog::PersistentFileDialog(QString directory, QWidget *parent) 15 : : QObject(parent), 16 0 : m_parent(parent), 17 0 : m_directory(directory) 18 : { 19 0 : if (m_directory.isEmpty()) 20 0 : m_directory = QDir::currentPath(); 21 0 : } 22 : 23 0 : QString PersistentFileDialog::getExistingDirectory(const QString &caption, QFileDialog::Options options) 24 : { 25 0 : QString result = QFileDialog::getExistingDirectory(m_parent, caption, m_directory, options); 26 0 : if (!result.isNull()) 27 : { 28 0 : QFileInfo info(result); 29 0 : m_directory = info.absolutePath(); 30 0 : } 31 0 : return result; 32 0 : } 33 : 34 0 : QString PersistentFileDialog::getOpenFileName(const QString &caption, const QString &filter, QString *selectedFilter, QFileDialog::Options options) 35 : { 36 0 : QString result = QFileDialog::getOpenFileName(m_parent, caption, m_directory, filter, selectedFilter, options); 37 0 : if (!result.isNull()) 38 : { 39 0 : QFileInfo info(result); 40 0 : m_directory = info.absolutePath(); 41 0 : } 42 0 : return result; 43 0 : } 44 : 45 0 : QStringList PersistentFileDialog::getOpenFileNames(const QString &caption, const QString &filter, QString *selectedFilter, QFileDialog::Options options) 46 : { 47 0 : QStringList result = QFileDialog::getOpenFileNames(m_parent, caption, m_directory, filter, selectedFilter, options); 48 0 : if (!result.isEmpty()) 49 : { 50 0 : QFileInfo info(result[0]); 51 0 : m_directory = info.absolutePath(); 52 0 : } 53 0 : return result; 54 0 : } 55 : 56 0 : QString PersistentFileDialog::getSaveFileName(const QString &caption, const QString &filter, QString *selectedFilter, QFileDialog::Options options) 57 : { 58 0 : QString result = QFileDialog::getSaveFileName(m_parent, caption, m_directory, filter, selectedFilter, options); 59 0 : if (!result.isNull()) 60 : { 61 0 : QFileInfo info(result); 62 0 : m_directory = info.absolutePath(); 63 0 : } 64 0 : return result; 65 0 : } 66 :