]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/qt_helpers.h
compile fix
[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 "qt_i18n.h"
19
20 #include <QString>
21
22 class QComboBox;
23 class QLineEdit;
24 class QCheckBox;
25 class QString;
26 class QWidget;
27 template <class T> class QList;
28
29 class LengthCombo;
30
31 namespace lyx {
32
33 namespace support { class FileName; }
34
35 class LyXErr;
36
37 LyXErr & operator<<(LyXErr &, QString const &);
38
39 namespace frontend {
40
41 /// method to get a Length from widgets (LengthCombo)
42 std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
43 /// method to get a Length from widgets (QComboBox)
44 Length widgetsToLength(QLineEdit const * input, QComboBox const * combo);
45
46 //FIXME It would be nice if defaultUnit were a default argument
47 /// method to set widgets from a Length
48 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
49 Length const & len, Length::UNIT default_unit);
50 /// method to set widgets from a string
51 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
52 std::string const & len, Length::UNIT default_unit);
53 /// method to set widgets from a Length with optional "auto" if zero
54 void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo,
55 Length const & len, Length::UNIT defaultUnit);
56
57 /// colors a widget red if invalid
58 void setValid(QWidget * widget, bool valid);
59
60 } // namespace frontend
61
62
63 /**
64  * qt_ - i18nize string and convert to QString
65  *
66  * Use this in qt4/ instead of _()
67  */
68 QString const qt_(std::string const & str);
69
70 ///
71 struct LanguagePair { QString first; QString second; };
72
73 /** If the caller is the character dialog, add "No change" and "Reset"
74 *  to the vector.
75 */
76 QList<LanguagePair> languageData(bool character_dlg);
77
78 support::FileName libFileSearch(QString const & dir, QString const & name,
79                                 QString const & ext = QString());
80
81 /** Wrapper around browseFile which tries to provide a filename
82         relative to relpath.  If the relative path is of the form "foo.txt"
83         or "bar/foo.txt", then it is returned as relative. OTOH, if it is
84         of the form "../baz/foo.txt", an absolute path is returned. This is
85         intended to be useful for insets which encapsulate files/
86 */
87 QString browseRelFile(QString const & filename,
88         QString const & refpath,
89         QString const & title,
90         QStringList const & filters,
91         bool save = false,
92         QString const & label1 = QString(),
93         QString const & dir1 = QString(),
94         QString const & label2 = QString(),
95         QString const & dir2 = QString());
96
97
98 /** Build filelists of all availabe bst/cls/sty-files. Done through
99 *  kpsewhich and an external script, saved in *Files.lst.
100 */
101 void rescanTexStyles();
102
103 /** Fill \c contents from one of the three texfiles.
104  *  Each entry in the file list is returned as a name_with_path
105  */
106 QStringList texFileList(QString const & filename);
107
108 // wrapper around the docstring versions
109 QString internalPath(QString const &);
110 QString onlyFilename(QString const & str);
111 QString onlyPath(QString const & str);
112 QStringList fileFilters(QString const & description);
113
114 QString changeExtension(QString const & oldname, QString const & extension);
115
116 /// Remove the extension from \p name
117 QString removeExtension(QString const & name);
118
119 /** Add the extension \p ext to \p name.
120  Use this instead of changeExtension if you know that \p name is without
121  extension, because changeExtension would wrongly interpret \p name if it
122  contains a dot.
123  */
124 QString addExtension(QString const & name, QString const & extension);
125
126 /// Return the extension of the file (not including the .)
127 QString getExtension(QString const & name);
128 QString makeAbsPath(QString const & relpath, QString const & base);
129
130 } // namespace lyx
131
132 #endif // QTHELPERS_H