]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/qt_helpers.h
merge helper files;
[lyx.git] / src / frontends / qt4 / qt_helpers.h
1 // -*- C++ -*-
2 /**
3  * \file qt_helpers.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Dekel Tsur
8  * \author Richard Heck
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef QTHELPERS_H
14 #define QTHELPERS_H
15
16 #include "Length.h"
17 #include "support/qstring_helpers.h"
18 #include "support/strfwd.h"
19
20 #include <vector>
21
22 class QComboBox;
23 class QLineEdit;
24 class QCheckBox;
25 class QString;
26 class QWidget;
27
28 class LengthCombo;
29
30 namespace lyx {
31
32 namespace support { class FileFilterList; }
33
34 namespace frontend {
35
36 /// method to get a Length from widgets (LengthCombo)
37 std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
38 /// method to get a Length from widgets (QComboBox)
39 Length widgetsToLength(QLineEdit const * input, QComboBox const * combo);
40
41 //FIXME It would be nice if defaultUnit were a default argument
42 /// method to set widgets from a Length
43 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
44 Length const & len, Length::UNIT default_unit);
45 /// method to set widgets from a string
46 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
47 std::string const & len, Length::UNIT default_unit);
48 /// method to set widgets from a Length with optional "auto" if zero
49 void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo,
50 Length const & len, Length::UNIT defaultUnit);
51
52 /// colors a widget red if invalid
53 void setValid(QWidget * widget, bool valid);
54
55 } // namespace frontend
56
57
58 /**
59 * qt_ - i18nize string and convert to QString
60  *
61  * Use this in qt4/ instead of _()
62  */
63 QString const qt_(char const * str, const char * comment = 0);
64
65
66 /**
67  * qt_ - i18nize string and convert to QString
68  *
69  * Use this in qt4/ instead of _()
70  */
71 QString const qt_(std::string const & str);
72
73 ///
74 typedef std::pair<docstring, std::string> LanguagePair;
75
76 /** If the caller is the character dialog, add "No change" and "Reset"
77 *  to the vector.
78 */
79 std::vector<LanguagePair> const getLanguageData(bool character_dlg);
80
81 /** Launch a file dialog and return the chosen file.
82         filename: a suggested filename.
83         title: the title of the dialog.
84         pattern: *.ps etc.
85         dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
86 */
87 docstring browseFile(docstring const & filename,
88         docstring const & title,
89         support::FileFilterList const & filters,
90         bool save = false,
91         docstring const & label1 = docstring(),
92         docstring const & dir1 = docstring(),
93         docstring const & label2 = docstring(),
94         docstring const & dir2 = docstring());
95
96
97 /** Wrapper around browseFile which tries to provide a filename
98         relative to relpath.  If the relative path is of the form "foo.txt"
99         or "bar/foo.txt", then it is returned as relative. OTOH, if it is
100         of the form "../baz/foo.txt", an absolute path is returned. This is
101         intended to be useful for insets which encapsulate files/
102 */
103 docstring browseRelFile(docstring const & filename,
104         docstring const & refpath,
105         docstring const & title,
106         support::FileFilterList const & filters,
107         bool save = false,
108         docstring const & label1 = docstring(),
109         docstring const & dir1 = docstring(),
110         docstring const & label2 = docstring(),
111         docstring const & dir2 = docstring());
112
113
114 /** Wrapper around browseFile which tries to provide a filename
115 *  relative to the user or system directory. The dir, name and ext
116 *  parameters have the same meaning as in the
117 *  support::LibFileSearch function.
118 */
119 docstring browseLibFile(docstring const & dir,
120         docstring const & name,
121         docstring const & ext,
122         docstring const & title,
123         support::FileFilterList const & filters);
124
125
126 /** Launch a file dialog and return the chosen directory.
127         pathname: a suggested pathname.
128         title: the title of the dialog.
129         dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
130 */
131 docstring browseDir(docstring const & pathname,
132         docstring const & title,
133         docstring const & label1 = docstring(),
134         docstring const & dir1 = docstring(),
135         docstring const & label2 = docstring(),
136         docstring const & dir2 = docstring());
137
138
139 /** Build filelists of all availabe bst/cls/sty-files. Done through
140 *  kpsewhich and an external script, saved in *Files.lst.
141 */
142 void rescanTexStyles();
143
144 /** Fill \c contents from one of the three texfiles.
145  *  Each entry in the file list is returned as a name_with_path
146  */
147 void getTexFileList(std::string const & filename, std::vector<std::string> & contents);
148
149 } // namespace lyx
150
151 #endif // QTHELPERS_H