2 * \file qt2/FileDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
12 #pragma implementation
17 #include "commandtags.h"
19 #include "frontends/FileDialog.h"
20 #include "FileDialog_private.h"
22 #include "qt_helpers.h"
25 #include <qapplication.h>
34 struct FileDialog::Private {
40 FileDialog::FileDialog(LyXView * lv, string const & t,
41 kb_action s, Button b1, Button b2)
42 : private_(new FileDialog::Private), lv_(lv), title_(t), success_(s)
49 FileDialog::~FileDialog()
55 FileDialog::Result const FileDialog::save(string const & path,
57 string const & suggested)
61 filter = _("All files (*)");
63 LyXFileDialog dlg(path, filter, title_, private_->b1, private_->b2);
64 lyxerr[Debug::GUI] << "Select with path \"" << path
65 << "\", mask \"" << filter
66 << "\", suggested \"" << suggested << endl;
68 dlg.setMode(QFileDialog::AnyFile);
70 if (!suggested.empty())
71 dlg.setSelection(toqstr(suggested));
73 FileDialog::Result result;
74 lyxerr[Debug::GUI] << "Synchronous FileDialog: " << endl;
75 result.first = FileDialog::Chosen;
77 lyxerr[Debug::GUI] << "result " << res << endl;
78 if (res == QDialog::Accepted)
79 result.second = string(dlg.selectedFile().data());
85 FileDialog::Result const FileDialog::open(string const & path,
87 string const & suggested)
91 filter = _("All files (*)");
93 LyXFileDialog dlg(path, filter, title_, private_->b1, private_->b2);
94 lyxerr[Debug::GUI] << "Select with path \"" << path
95 << "\", mask \"" << filter
96 << "\", suggested \"" << suggested << endl;
98 if (!suggested.empty())
99 dlg.setSelection(toqstr(suggested));
101 FileDialog::Result result;
102 lyxerr[Debug::GUI] << "Synchronous FileDialog: " << endl;
103 result.first = FileDialog::Chosen;
104 int res = dlg.exec();
105 lyxerr[Debug::GUI] << "result " << res << endl;
106 if (res == QDialog::Accepted)
107 result.second = string(dlg.selectedFile().data());
113 FileDialog::Result const FileDialog::opendir(string const & path,
114 string const & suggested)
116 string filter = _("Directories");
118 LyXFileDialog dlg(path, filter, title_, private_->b1, private_->b2);
119 lyxerr[Debug::GUI] << "Select with path \"" << path
120 << "\", suggested \"" << suggested << endl;
122 dlg.setMode(QFileDialog::DirectoryOnly);
124 if (!suggested.empty())
125 dlg.setSelection(toqstr(suggested));
127 FileDialog::Result result;
128 lyxerr[Debug::GUI] << "Synchronous FileDialog: " << endl;
129 result.first = FileDialog::Chosen;
130 int res = dlg.exec();
131 lyxerr[Debug::GUI] << "result " << res << endl;
132 if (res == QDialog::Accepted)
133 result.second = string(dlg.selectedFile().data());