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