]> git.lyx.org Git - lyx.git/blob - src/frontends/kde/FileDialog.C
implement getLabelList
[lyx.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 - to get the icon menu working sensibly we need MVCise the operations
35         // so we can get told which icons to use ...
36 }
37
38
39 FileDialog::~FileDialog()
40 {
41 }
42
43
44 FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
45 {
46         string filter = mask;
47  
48         if (mask.empty())
49                 filter = _("*|All files");
50  
51         LyXKFileDialog * dlg = new LyXKFileDialog(lv_, success_, path, filter, title_);
52
53         lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << endl;
54
55         if (!suggested.empty())
56                 dlg->setSelection(suggested.c_str());
57  
58         if (success_ == LFUN_SELECT_FILE_SYNC) {
59                 FileDialog::Result result;
60
61                 lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
62
63                 result.first = FileDialog::Chosen;
64
65                 int res = dlg->exec();
66
67                 lyxerr[Debug::GUI] << "result " << res << endl;
68         
69                 if (res == QDialog::Accepted)
70                         result.second = string(dlg->selectedFile().data());
71
72                 delete dlg;
73  
74                 return result;
75         }
76
77         dlg->show();
78
79         return make_pair(FileDialog::Later, string());
80 }