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