]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/qt_helpers.h
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[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 class QComboBox;
21 class QLineEdit;
22 class QCheckBox;
23 class QString;
24 class QWidget;
25 template <class T> class QList;
26
27 class LengthCombo;
28
29 namespace lyx {
30
31 namespace support { class FileFilterList; }
32 namespace support { class FileName; }
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<QString, QString> LanguagePair;
75
76 /** If the caller is the character dialog, add "No change" and "Reset"
77 *  to the vector.
78 */
79 QList<LanguagePair> languageData(bool character_dlg);
80
81 support::FileName libFileSearch(QString const & dir, QString const & name,
82                                 QString const & ext = QString());
83
84 /** Wrapper around browseFile which tries to provide a filename
85         relative to relpath.  If the relative path is of the form "foo.txt"
86         or "bar/foo.txt", then it is returned as relative. OTOH, if it is
87         of the form "../baz/foo.txt", an absolute path is returned. This is
88         intended to be useful for insets which encapsulate files/
89 */
90 QString browseRelFile(QString const & filename,
91         QString const & refpath,
92         QString const & title,
93         support::FileFilterList const & filters,
94         bool save = false,
95         QString const & label1 = QString(),
96         QString const & dir1 = QString(),
97         QString const & label2 = QString(),
98         QString const & dir2 = QString());
99
100
101 /** Build filelists of all availabe bst/cls/sty-files. Done through
102 *  kpsewhich and an external script, saved in *Files.lst.
103 */
104 void rescanTexStyles();
105
106 /** Fill \c contents from one of the three texfiles.
107  *  Each entry in the file list is returned as a name_with_path
108  */
109 QStringList texFileList(QString const & filename);
110
111 // wrapper around the docstring versions
112 QString internalPath(QString const &);
113 QString onlyFilename(QString const & str);
114 QString onlyPath(QString const & str);
115
116 QString changeExtension(QString const & oldname, QString const & extension);
117
118 /// Remove the extension from \p name
119 QString removeExtension(QString const & name);
120
121 /** Add the extension \p ext to \p name.
122  Use this instead of changeExtension if you know that \p name is without
123  extension, because changeExtension would wrongly interpret \p name if it
124  contains a dot.
125  */
126 QString addExtension(QString const & name, QString const & extension);
127
128 /// Return the extension of the file (not including the .)
129 QString getExtension(QString const & name);
130
131 } // namespace lyx
132
133 #endif // QTHELPERS_H