]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/FileDialog.C
small cleanup and removal of warnings
[lyx.git] / src / frontends / qt2 / FileDialog.C
1 /**
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.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include <config.h>
16
17 #include "commandtags.h"
18 #include "LString.h"
19 #include "frontends/FileDialog.h"
20 #include "FileDialog_private.h"
21 #include "debug.h"
22 #include "gettext.h"
23
24 #include <qapplication.h>
25
26 #include <utility>
27
28 using std::make_pair;
29 using std::pair;
30 using std::endl;
31
32 struct FileDialog::Private {
33         Button b1;
34         Button b2;
35 };
36
37 FileDialog::FileDialog(LyXView *lv, string const & t, kb_action s, Button b1, Button b2)
38         : private_(new FileDialog::Private), lv_(lv), title_(t), success_(s)
39 {
40         private_->b1 = b1;
41         private_->b2 = b2;
42 }
43
44
45 FileDialog::~FileDialog()
46 {
47         delete private_;
48 }
49
50
51 FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
52 {
53         string filter = mask;
54         if (mask.empty())
55                 filter = _("*|All files");
56
57         LyXFileDialog dlg(path, filter, title_, private_->b1, private_->b2);
58         lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << endl;
59
60         dlg.setMode(QFileDialog::AnyFile);
61
62         if (!suggested.empty())
63                 dlg.setSelection(suggested.c_str());
64
65         // This code relies on DestructiveClose which is broken
66         // in Qt < 3.0.5. So we just don't allow it for now.
67         //if (success_ == LFUN_SELECT_FILE_SYNC) {
68
69         FileDialog::Result result;
70         lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
71         result.first = FileDialog::Chosen;
72         int res = dlg.exec();
73         lyxerr[Debug::GUI] << "result " << res << endl;
74         if (res == QDialog::Accepted)
75                 result.second = string(dlg.selectedFile().data());
76         dlg.hide();
77         return result;
78 #if 0
79         dlg->show();
80         return make_pair(FileDialog::Later, string());
81 #endif
82 }