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 * method to format localized floating point numbers without
72 * ever using scientific notation
74 QString formatLocFPNumber(double d);
76 /// colors a widget red if invalid
77 void setValid(QWidget * widget, bool valid);
79 /// Qt5 changed setSectionMode to setSectionResizeMode
80 /// These wrappers work for Qt4 and Qt5
81 void setSectionResizeMode(QHeaderView * view,
82 int logicalIndex, QHeaderView::ResizeMode mode);
83 void setSectionResizeMode(QHeaderView * view,
84 QHeaderView::ResizeMode mode);
86 } // namespace frontend
90 * qt_ - i18nize string and convert to QString
92 * Use this in qt4/ instead of _()
94 QString const qt_(std::string const & str);
95 QString const qt_(QString const & qstr);
99 support::FileName libFileSearch(QString const & dir, QString const & name,
100 QString const & ext = QString(),
101 support::search_mode mode = support::must_exist);
104 support::FileName imageLibFileSearch(QString & dir, QString const & name,
105 QString const & ext = QString(),
106 support::search_mode mode = support::must_exist);
108 /** Wrappers around browseFile which try to provide a filename
111 \param title: title for dialog
113 \param filters: *.ps, etc
115 \param save: whether to save dialog info (current path, etc) for next use.
117 The \param labelN and \param dirN arguments provide for extra buttons
118 in the dialog (e.g., "Templates" and a path to that directory).
120 The difference between the functions concerns when we think we have a
123 In \c browseRelToParent, we return a relative path only if it IS NOT of
124 the form "../../foo.txt".
126 In \c browseRelToSub, we return a relative path only if it IS of the
127 form "../../foo.txt".
129 QString browseRelToParent(QString const & filename,
130 QString const & relpath,
131 QString const & title,
132 QStringList const & filters,
134 QString const & label1 = QString(),
135 QString const & dir1 = QString(),
136 QString const & label2 = QString(),
137 QString const & dir2 = QString());
139 QString browseRelToSub(QString const & filename,
140 QString const & relpath,
141 QString const & title,
142 QStringList const & filters,
144 QString const & label1 = QString(),
145 QString const & dir1 = QString(),
146 QString const & label2 = QString(),
147 QString const & dir2 = QString());
149 /** Build filelists of all availabe bst/cls/sty-files. Done through
150 * kpsewhich and an external script, saved in *Files.lst.
151 * \param arg: cls, sty, bst, or bib, as required by TeXFiles.py.
152 * Can be a list of these, too.
154 void rescanTexStyles(std::string const & arg = empty_string());
156 /** Fill \c contents from one of the three texfiles.
157 * Each entry in the file list is returned as a name_with_path
159 QStringList texFileList(QString const & filename);
161 /// Convert internal line endings to line endings as expected by the OS
162 QString const externalLineEnding(docstring const & str);
164 /// Convert line endings in any formnat to internal line endings
165 docstring const internalLineEnding(QString const & str);
167 // wrapper around the docstring versions
168 QString internalPath(QString const &);
169 QString onlyFileName(QString const & str);
170 QString onlyPath(QString const & str);
171 QStringList fileFilters(QString const & description);
173 QString changeExtension(QString const & oldname, QString const & extension);
175 /// Remove the extension from \p name
176 QString removeExtension(QString const & name);
178 /** Add the extension \p ext to \p name.
179 Use this instead of changeExtension if you know that \p name is without
180 extension, because changeExtension would wrongly interpret \p name if it
183 QString addExtension(QString const & name, QString const & extension);
185 /// Return the extension of the file (not including the .)
186 QString getExtension(QString const & name);
187 QString makeAbsPath(QString const & relpath, QString const & base);
188 QString changeExtension(QString const & oldname, QString const & ext);
190 /// \return the display string associated with given type and buffer
192 QString guiName(std::string const & type, BufferParams const & bp);
196 #endif // QTHELPERS_H