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 Length with optional "auto" if zero
52 void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo,
53 Length const & len, Length::UNIT defaultUnit);
55 /// colors a widget red if invalid
56 void setValid(QWidget * widget, bool valid);
58 } // namespace frontend
62 * qt_ - i18nize string and convert to QString
64 * Use this in qt4/ instead of _()
66 QString const qt_(std::string const & str);
69 support::FileName libFileSearch(QString const & dir, QString const & name,
70 QString const & ext = QString());
72 /** Wrapper around browseFile which tries to provide a filename
73 relative to relpath. If the relative path is of the form "foo.txt"
74 or "bar/foo.txt", then it is returned as relative. OTOH, if it is
75 of the form "../baz/foo.txt", an absolute path is returned. This is
76 intended to be useful for insets which encapsulate files/
78 QString browseRelFile(QString const & filename,
79 QString const & refpath,
80 QString const & title,
81 QStringList const & filters,
83 QString const & label1 = QString(),
84 QString const & dir1 = QString(),
85 QString const & label2 = QString(),
86 QString const & dir2 = QString());
89 /** Build filelists of all availabe bst/cls/sty-files. Done through
90 * kpsewhich and an external script, saved in *Files.lst.
92 void rescanTexStyles();
94 /** Fill \c contents from one of the three texfiles.
95 * Each entry in the file list is returned as a name_with_path
97 QStringList texFileList(QString const & filename);
99 /// Convert internal line endings to line endings as expected by the OS
100 QString const externalLineEnding(docstring const & str);
102 /// Convert line endings in any formnat to internal line endings
103 docstring const internalLineEnding(QString const & str);
105 // wrapper around the docstring versions
106 QString internalPath(QString const &);
107 QString onlyFilename(QString const & str);
108 QString onlyPath(QString const & str);
109 QStringList fileFilters(QString const & description);
111 QString changeExtension(QString const & oldname, QString const & extension);
113 /// Remove the extension from \p name
114 QString removeExtension(QString const & name);
116 /** Add the extension \p ext to \p name.
117 Use this instead of changeExtension if you know that \p name is without
118 extension, because changeExtension would wrongly interpret \p name if it
121 QString addExtension(QString const & name, QString const & extension);
123 /// Return the extension of the file (not including the .)
124 QString getExtension(QString const & name);
125 QString makeAbsPath(QString const & relpath, QString const & base);
126 QString changeExtension(QString const & oldname, QString const & ext);
128 /// \return the display string associated with given type and buffer
130 QString guiName(std::string const & type, BufferParams const & bp);
134 #endif // QTHELPERS_H