]> git.lyx.org Git - features.git/blob - src/frontends/kde/FileDialog.C
83bf5cea4fc1ba0396504c96384bf25a683c0f09
[features.git] / src / frontends / kde / FileDialog.C
1 /**
2  * \file 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  
19 #include "LString.h"
20
21 #include "frontends/FileDialog.h"
22
23 #include "FileDialog_private.h" 
24
25 #include "debug.h"
26
27 using std::make_pair;
28 using std::pair;
29 using std::endl;
30
31 FileDialog::FileDialog(LyXView *lv, string const &t, kb_action s, Button b1, Button b2)
32         : private_(0), lv_(lv), title_(t), success_(s)
33 {
34         // FIXME
35 }
36
37
38 FileDialog::~FileDialog()
39 {
40 }
41
42
43 FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
44 {
45         string filter = mask;
46  
47         if (mask.empty())
48                 filter = _("*|All files");
49  
50         LyXKFileDialog * dlg = new LyXKFileDialog(lv_, success_, path, filter, title_);
51
52         lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << endl;
53
54         if (!suggested.empty())
55                 dlg->setSelection(suggested.c_str());
56  
57         if (success_ == LFUN_SELECT_FILE_SYNC) {
58                 FileDialog::Result result;
59
60                 lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
61
62                 result.first = FileDialog::Chosen;
63
64                 int res = dlg->exec();
65
66                 lyxerr[Debug::GUI] << "result " << res << endl;
67         
68                 if (res == QDialog::Accepted)
69                         result.second = string(dlg->selectedFile().data());
70
71                 delete dlg;
72  
73                 return result;
74         }
75
76         dlg->show();
77
78         return make_pair(FileDialog::Later, string());
79 }