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"
20 #include <QHeaderView>
27 template <class T> class QList;
31 namespace support { class FileName; }
39 /// method to get a Length from widgets (LengthCombo)
40 std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
41 /// method to get a Length from widgets (QComboBox)
42 Length widgetsToLength(QLineEdit const * input, QComboBox const * combo);
44 /// method to set widgets from a Length
45 //FIXME Remove default_unit argument for the first form. FIXME Change
46 // all the code to remove default_unit argument when equal to the
48 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
50 Length::UNIT default_unit = Length::defaultUnit());
51 /// method to set widgets from a string
52 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
53 std::string const & len,
54 Length::UNIT default_unit = Length::defaultUnit());
55 /// method to set widgets from a docstring
56 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
57 docstring const & len, Length::UNIT default_unit);
59 /// method to get a double value from a localized widget (QLineEdit)
60 double widgetToDouble(QLineEdit const * input);
61 /// method to get a double value from a localized widget (QLineEdit)
62 std::string widgetToDoubleStr(QLineEdit const * input);
63 /// method to set a (localized) double value in a widget (QLineEdit)
64 void doubleToWidget(QLineEdit * input, double const & value,
65 char f = 'g', int prec = 6);
66 /// method to set a (localized) double value in a widget (QLineEdit)
67 void doubleToWidget(QLineEdit * input, std::string const & value,
68 char f = 'g', int prec = 6);
70 /// colors a widget red if invalid
71 void setValid(QWidget * widget, bool valid);
73 /// Qt5 changed setSectionMode to setSectionResizeMode
74 /// These wrappers work for Qt4 and Qt5
75 void setSectionResizeMode(QHeaderView * view,
76 int logicalIndex, QHeaderView::ResizeMode mode);
77 void setSectionResizeMode(QHeaderView * view,
78 QHeaderView::ResizeMode mode);
80 } // namespace frontend
84 * qt_ - i18nize string and convert to QString
86 * Use this in qt4/ instead of _()
88 QString const qt_(std::string const & str);
89 QString const qt_(QString const & qstr);
93 support::FileName libFileSearch(QString const & dir, QString const & name,
94 QString const & ext = QString());
97 support::FileName imageLibFileSearch(QString & dir, QString const & name,
98 QString const & ext = QString());
100 /** Wrappers around browseFile which try to provide a filename
103 \param title: title for dialog
105 \param filters: *.ps, etc
107 \param save: whether to save dialog info (current path, etc) for next use.
109 The \param labelN and \param dirN arguments provide for extra buttons
110 in the dialog (e.g., "Templates" and a path to that directory).
112 The difference between the functions concerns when we think we have a
115 In \c browseRelToParent, we return a relative path only if it IS NOT of
116 the form "../../foo.txt".
118 In \c browseRelToSub, we return a relative path only if it IS of the
119 form "../../foo.txt".
121 QString browseRelToParent(QString const & filename,
122 QString const & relpath,
123 QString const & title,
124 QStringList const & filters,
126 QString const & label1 = QString(),
127 QString const & dir1 = QString(),
128 QString const & label2 = QString(),
129 QString const & dir2 = QString());
131 QString browseRelToSub(QString const & filename,
132 QString const & relpath,
133 QString const & title,
134 QStringList const & filters,
136 QString const & label1 = QString(),
137 QString const & dir1 = QString(),
138 QString const & label2 = QString(),
139 QString const & dir2 = QString());
141 /** Build filelists of all availabe bst/cls/sty-files. Done through
142 * kpsewhich and an external script, saved in *Files.lst.
143 * \param arg: cls, sty, bst, or bib, as required by TeXFiles.py.
144 * Can be a list of these, too.
146 void rescanTexStyles(std::string const & arg = empty_string());
148 /** Fill \c contents from one of the three texfiles.
149 * Each entry in the file list is returned as a name_with_path
151 QStringList texFileList(QString const & filename);
153 /// Convert internal line endings to line endings as expected by the OS
154 QString const externalLineEnding(docstring const & str);
156 /// Convert line endings in any formnat to internal line endings
157 docstring const internalLineEnding(QString const & str);
159 // wrapper around the docstring versions
160 QString internalPath(QString const &);
161 QString onlyFileName(QString const & str);
162 QString onlyPath(QString const & str);
163 QStringList fileFilters(QString const & description);
165 QString changeExtension(QString const & oldname, QString const & extension);
167 /// Remove the extension from \p name
168 QString removeExtension(QString const & name);
170 /** Add the extension \p ext to \p name.
171 Use this instead of changeExtension if you know that \p name is without
172 extension, because changeExtension would wrongly interpret \p name if it
175 QString addExtension(QString const & name, QString const & extension);
177 /// Return the extension of the file (not including the .)
178 QString getExtension(QString const & name);
179 QString makeAbsPath(QString const & relpath, QString const & base);
180 QString changeExtension(QString const & oldname, QString const & ext);
182 /// \return the display string associated with given type and buffer
184 QString guiName(std::string const & type, BufferParams const & bp);
188 #endif // QTHELPERS_H