]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/FileDialog.h
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / FileDialog.h
1 // -*- C++ -*-
2 /**
3  * \file FileDialog.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef FILEDIALOG_H
14 #define FILEDIALOG_H
15
16 #include <QString>
17
18 #include <utility>
19
20 namespace lyx {
21
22 /**
23  * \class FileDialog
24  * \brief GUI-I definition of file dialog interface
25  */
26 class FileDialog
27 {
28 public:
29         /// label, directory path button
30         typedef std::pair<QString, QString> Button;
31
32         /// result type
33         enum ResultType {
34                 Later, /**< modeless chooser, no result */
35                 Chosen /**< string contains filename */
36         };
37
38         /// result return
39         typedef std::pair<FileDialog::ResultType, QString> Result;
40
41         /**
42          * Constructs a file dialog with title \param title.
43          *
44          * Up to two optional extra buttons are allowed for specifying
45          * additional directories in the navigation (an empty
46          * directory is interpreted as FileName::getcwd())
47          */
48         FileDialog(QString const & title);
49
50         ~FileDialog();
51
52         void setButton1(QString const & label, QString const & dir);
53         void setButton2(QString const & label, QString const & dir);
54
55         /// Choose a file for opening, starting in directory \c path.
56         Result open(QString const & path, QStringList const & filters,
57                           QString const & suggested = QString());
58
59         /// Choose a directory, starting in directory \c path.
60         Result opendir(QString const & path = QString(),
61                              QString const & suggested = QString());
62
63         /// Choose a file for saving, starting in directory \c  path.
64         Result save(QString const & path, QStringList const & filters,
65                           QString const & suggested = QString());
66
67         /// Also retrieve the selected filter (selectedFilter can be 0 if
68         /// that output is not needed).
69         Result save(QString const & path, QStringList const & filters,
70                     QString const & suggested, QString *selectedFilter);
71
72 private:
73         class Private;
74         friend class Private;
75         Private * private_;
76
77         /// the dialog title
78         QString title_;
79
80 };
81
82 } // namespace lyx
83
84 #endif // FILEDIALOG_H