4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
17 #include "support/qstring_helpers.h"
18 #include "support/filetools.h"
21 #include <QHeaderView>
28 template <class T> class QList;
32 namespace support { class FileName; }
40 /// method to get a Length from widgets (LengthCombo)
41 std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
42 /// method to get a Length from widgets (QComboBox)
43 Length widgetsToLength(QLineEdit const * input, QComboBox const * combo);
45 /// method to set widgets from a Length
46 //FIXME Remove default_unit argument for the first form. FIXME Change
47 // all the code to remove default_unit argument when equal to the
49 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
51 Length::UNIT default_unit = Length::defaultUnit());
52 /// method to set widgets from a string
53 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
54 std::string const & len,
55 Length::UNIT default_unit = Length::defaultUnit());
56 /// method to set widgets from a docstring
57 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
58 docstring const & len, Length::UNIT default_unit);
60 /// method to get a double value from a localized widget (QLineEdit)
61 double widgetToDouble(QLineEdit const * input);
62 /// method to get a double value from a localized widget (QLineEdit)
63 std::string widgetToDoubleStr(QLineEdit const * input);
64 /// method to set a (localized) double value in a widget (QLineEdit)
65 void doubleToWidget(QLineEdit * input, double const & value,
66 char f = 'g', int prec = 6);
67 /// method to set a (localized) double value in a widget (QLineEdit)
68 void doubleToWidget(QLineEdit * input, std::string const & value,
69 char f = 'g', int prec = 6);
71 /// colors a widget red if invalid
72 void setValid(QWidget * widget, bool valid);
74 /// Qt5 changed setSectionMode to setSectionResizeMode
75 /// These wrappers work for Qt4 and Qt5
76 void setSectionResizeMode(QHeaderView * view,
77 int logicalIndex, QHeaderView::ResizeMode mode);
78 void setSectionResizeMode(QHeaderView * view,
79 QHeaderView::ResizeMode mode);
81 } // namespace frontend
85 * qt_ - i18nize string and convert to QString
87 * Use this in qt4/ instead of _()
89 QString const qt_(std::string const & str);
90 QString const qt_(QString const & qstr);
94 support::FileName libFileSearch(QString const & dir, QString const & name,
95 QString const & ext = QString(),
96 support::search_mode mode = support::must_exist);
99 support::FileName imageLibFileSearch(QString & dir, QString const & name,
100 QString const & ext = QString(),
101 support::search_mode mode = support::must_exist);
103 /** Wrappers around browseFile which try to provide a filename
106 \param title: title for dialog
108 \param filters: *.ps, etc
110 \param save: whether to save dialog info (current path, etc) for next use.
112 The \param labelN and \param dirN arguments provide for extra buttons
113 in the dialog (e.g., "Templates" and a path to that directory).
115 The difference between the functions concerns when we think we have a
118 In \c browseRelToParent, we return a relative path only if it IS NOT of
119 the form "../../foo.txt".
121 In \c browseRelToSub, we return a relative path only if it IS of the
122 form "../../foo.txt".
124 QString browseRelToParent(QString const & filename,
125 QString const & relpath,
126 QString const & title,
127 QStringList const & filters,
129 QString const & label1 = QString(),
130 QString const & dir1 = QString(),
131 QString const & label2 = QString(),
132 QString const & dir2 = QString());
134 QString browseRelToSub(QString const & filename,
135 QString const & relpath,
136 QString const & title,
137 QStringList const & filters,
139 QString const & label1 = QString(),
140 QString const & dir1 = QString(),
141 QString const & label2 = QString(),
142 QString const & dir2 = QString());
144 /** Build filelists of all availabe bst/cls/sty-files. Done through
145 * kpsewhich and an external script, saved in *Files.lst.
146 * \param arg: cls, sty, bst, or bib, as required by TeXFiles.py.
147 * Can be a list of these, too.
149 void rescanTexStyles(std::string const & arg = empty_string());
151 /** Fill \c contents from one of the three texfiles.
152 * Each entry in the file list is returned as a name_with_path
154 QStringList texFileList(QString const & filename);
156 /// Convert internal line endings to line endings as expected by the OS
157 QString const externalLineEnding(docstring const & str);
159 /// Convert line endings in any formnat to internal line endings
160 docstring const internalLineEnding(QString const & str);
162 // wrapper around the docstring versions
163 QString internalPath(QString const &);
164 QString onlyFileName(QString const & str);
165 QString onlyPath(QString const & str);
166 QStringList fileFilters(QString const & description);
168 QString changeExtension(QString const & oldname, QString const & extension);
170 /// Remove the extension from \p name
171 QString removeExtension(QString const & name);
173 /** Add the extension \p ext to \p name.
174 Use this instead of changeExtension if you know that \p name is without
175 extension, because changeExtension would wrongly interpret \p name if it
178 QString addExtension(QString const & name, QString const & extension);
180 /// Return the extension of the file (not including the .)
181 QString getExtension(QString const & name);
182 QString makeAbsPath(QString const & relpath, QString const & base);
183 QString changeExtension(QString const & oldname, QString const & ext);
185 /// \return the display string associated with given type and buffer
187 QString guiName(std::string const & type, BufferParams const & bp);
191 #endif // QTHELPERS_H