]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/FileDialog.C
fix typo that put too many include paths for most people
[lyx.git] / src / frontends / qt2 / FileDialog.C
1 /**
2  * \file qt2/FileDialog.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon
7  */
8
9 #ifdef __GNUG__
10 #pragma implementation
11 #endif
12
13 #include <config.h>
14 #include <gettext.h>
15 #include <utility>
16
17 #include "commandtags.h"
18 #include "LString.h"
19 #include "frontends/FileDialog.h"
20 #include "FileDialog_private.h"
21 #include "debug.h"
22
23 using std::make_pair;
24 using std::pair;
25 using std::endl;
26
27 FileDialog::FileDialog(LyXView *lv, string const &t, kb_action s, Button b1, Button b2)
28         : private_(0), lv_(lv), title_(t), success_(s)
29 {
30         // FIXME
31 }
32
33
34 FileDialog::~FileDialog()
35 {
36 }
37
38
39 FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
40 {
41         string filter = mask;
42         if (mask.empty())
43                 filter = _("*|All files");
44
45         LyXFileDialog * dlg = new LyXFileDialog(lv_, success_, path, filter, title_);
46         lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << endl;
47
48         if (!suggested.empty())
49                 dlg->setSelection(suggested.c_str());
50
51         if (success_ == LFUN_SELECT_FILE_SYNC) {
52                 FileDialog::Result result;
53                 lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
54                 result.first = FileDialog::Chosen;
55                 int res = dlg->exec();
56                 lyxerr[Debug::GUI] << "result " << res << endl;
57                 if (res == QDialog::Accepted)
58                         result.second = string(dlg->selectedFile().data());
59                 delete dlg;
60                 return result;
61         }
62         dlg->show();
63         return make_pair(FileDialog::Later, string());
64 }