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"
27 template <class T> class QList;
33 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 //FIXME It would be nice if defaultUnit were a default argument
45 /// method to set widgets from a Length
46 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
47 Length const & len, Length::UNIT default_unit);
48 /// method to set widgets from a string
49 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
50 std::string const & len, Length::UNIT default_unit);
51 /// method to set widgets from a docstring
52 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
53 docstring const & len, Length::UNIT default_unit);
55 /// method to get a double value from a localized widget (QLineEdit)
56 double widgetToDouble(QLineEdit const * input);
57 /// method to get a double value from a localized widget (QLineEdit)
58 std::string widgetToDoubleStr(QLineEdit const * input);
59 /// method to set a (localized) double value in a widget (QLineEdit)
60 void doubleToWidget(QLineEdit * input, double const & value,
61 char f = 'g', int prec = 6);
62 /// method to set a (localized) double value in a widget (QLineEdit)
63 void doubleToWidget(QLineEdit * input, std::string const & value,
64 char f = 'g', int prec = 6);
66 /// colors a widget red if invalid
67 void setValid(QWidget * widget, bool valid);
69 } // namespace frontend
73 * qt_ - i18nize string and convert to QString
75 * Use this in qt4/ instead of _()
77 QString const qt_(std::string const & str);
80 support::FileName libFileSearch(QString const & dir, QString const & name,
81 QString const & ext = QString());
84 support::FileName imageLibFileSearch(QString & dir, QString const & name,
85 QString const & ext = QString());
87 /** Wrappers around browseFile which try to provide a filename
90 \param title: title for dialog
92 \param filters: *.ps, etc
94 \param save: whether to save dialog info (current path, etc) for next use.
96 The \param labelN and \param dirN arguments provide for extra buttons
97 in the dialog (e.g., "Templates" and a path to that directory).
99 The difference between the functions concerns when we think we have a
102 In \c browseRelToParent, we return a relative path only if it IS NOT of
103 the form "../../foo.txt".
105 In \c browseRelToSub, we return a relative path only if it IS of the
106 form "../../foo.txt".
108 QString browseRelToParent(QString const & filename,
109 QString const & relpath,
110 QString const & title,
111 QStringList const & filters,
113 QString const & label1 = QString(),
114 QString const & dir1 = QString(),
115 QString const & label2 = QString(),
116 QString const & dir2 = QString());
118 QString browseRelToSub(QString const & filename,
119 QString const & relpath,
120 QString const & title,
121 QStringList const & filters,
123 QString const & label1 = QString(),
124 QString const & dir1 = QString(),
125 QString const & label2 = QString(),
126 QString const & dir2 = QString());
128 /** Build filelists of all availabe bst/cls/sty-files. Done through
129 * kpsewhich and an external script, saved in *Files.lst.
130 * \param arg: cls, sty, bst, or bib, as required by TeXFiles.py.
131 * Can be a list of these, too.
133 void rescanTexStyles(std::string const & arg = empty_string());
135 /** Fill \c contents from one of the three texfiles.
136 * Each entry in the file list is returned as a name_with_path
138 QStringList texFileList(QString const & filename);
140 /// Convert internal line endings to line endings as expected by the OS
141 QString const externalLineEnding(docstring const & str);
143 /// Convert line endings in any formnat to internal line endings
144 docstring const internalLineEnding(QString const & str);
146 // wrapper around the docstring versions
147 QString internalPath(QString const &);
148 QString onlyFileName(QString const & str);
149 QString onlyPath(QString const & str);
150 QStringList fileFilters(QString const & description);
152 QString changeExtension(QString const & oldname, QString const & extension);
154 /// Remove the extension from \p name
155 QString removeExtension(QString const & name);
157 /** Add the extension \p ext to \p name.
158 Use this instead of changeExtension if you know that \p name is without
159 extension, because changeExtension would wrongly interpret \p name if it
162 QString addExtension(QString const & name, QString const & extension);
164 /// Return the extension of the file (not including the .)
165 QString getExtension(QString const & name);
166 QString makeAbsPath(QString const & relpath, QString const & base);
167 QString changeExtension(QString const & oldname, QString const & ext);
169 /// \return the display string associated with given type and buffer
171 QString guiName(std::string const & type, BufferParams const & bp);
175 #endif // QTHELPERS_H