]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/qt_helpers.h
Use QFontMetrics information for underlines (and friends) width and position
[lyx.git] / src / frontends / qt4 / qt_helpers.h
index dd284a8655099af9de1b77028d41ad0993e43911..fcdcd53102e85a9dfcdd2230e180e9653d9cd44e 100644 (file)
 
 #include "Length.h"
 #include "support/qstring_helpers.h"
+#include "support/filetools.h"
 #include "qt_i18n.h"
 
-#include <QString>
+#include <QHeaderView>
 
 class QComboBox;
 class QLineEdit;
@@ -26,28 +27,32 @@ class QString;
 class QWidget;
 template <class T> class QList;
 
-class LengthCombo;
-
 namespace lyx {
 
 namespace support { class FileName; }
 
 class BufferParams;
-
 namespace frontend {
 
+class LengthCombo;
+
 /// method to get a Length from widgets (LengthCombo)
 std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
 /// method to get a Length from widgets (QComboBox)
 Length widgetsToLength(QLineEdit const * input, QComboBox const * combo);
 
-//FIXME It would be nice if defaultUnit were a default argument
 /// method to set widgets from a Length
+//FIXME Remove default_unit argument for the first form. FIXME Change
+// all the code to remove default_unit argument when equal to the
+// default.
 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
-Length const & len, Length::UNIT default_unit);
+                    Length const & len, 
+                    Length::UNIT default_unit = Length::defaultUnit());
 /// method to set widgets from a string
 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
-std::string const & len, Length::UNIT default_unit);
+                    std::string const & len, 
+                    Length::UNIT default_unit = Length::defaultUnit());
 /// method to set widgets from a docstring
 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
 docstring const & len, Length::UNIT default_unit);
@@ -62,10 +67,22 @@ void doubleToWidget(QLineEdit * input, double const & value,
 /// method to set a (localized) double value in a widget (QLineEdit)
 void doubleToWidget(QLineEdit * input, std::string const & value,
        char f = 'g', int prec = 6);
+/**
+ * method to format localized floating point numbers without
+ * ever using scientific notation
+ */
+QString formatLocFPNumber(double d);
 
 /// colors a widget red if invalid
 void setValid(QWidget * widget, bool valid);
 
+/// Qt5 changed setSectionMode to setSectionResizeMode
+/// These wrappers work for Qt4 and Qt5
+void setSectionResizeMode(QHeaderView * view,
+    int logicalIndex, QHeaderView::ResizeMode mode);
+void setSectionResizeMode(QHeaderView * view,
+       QHeaderView::ResizeMode mode);
+
 } // namespace frontend
 
 
@@ -75,19 +92,42 @@ void setValid(QWidget * widget, bool valid);
  * Use this in qt4/ instead of _()
  */
 QString const qt_(std::string const & str);
+QString const qt_(QString const & qstr);
+
 
 ///
 support::FileName libFileSearch(QString const & dir, QString const & name,
-                               QString const & ext = QString());
+                               QString const & ext = QString(),
+                               support::search_mode mode = support::must_exist);
+
+///
+support::FileName imageLibFileSearch(QString & dir, QString const & name,
+                               QString const & ext = QString(),
+                               support::search_mode mode = support::must_exist);
+
+/** Wrappers around browseFile which try to provide a filename
+       relative to relpath.
 
-/** Wrapper around browseFile which tries to provide a filename
-       relative to relpath.  If the relative path is of the form "foo.txt"
-       or "bar/foo.txt", then it is returned as relative. OTOH, if it is
-       of the form "../baz/foo.txt", an absolute path is returned. This is
-       intended to be useful for insets which encapsulate files/
+\param title: title for dialog
+       
+\param filters: *.ps, etc
+
+\param save: whether to save dialog info (current path, etc) for next use.
+
+The \param labelN and \param dirN arguments provide for extra buttons 
+in the dialog (e.g., "Templates" and a path to that directory).
+
+The difference between the functions concerns when we think we have a 
+relative path. 
+
+In \c browseRelToParent, we return a relative path only if it IS NOT of 
+       the form "../../foo.txt".
+
+In \c browseRelToSub, we return a relative path only if it IS of the
+ form "../../foo.txt".
 */
-QString browseRelFile(QString const & filename,
-       QString const & refpath,
+QString browseRelToParent(QString const & filename,
+       QString const & relpath,
        QString const & title,
        QStringList const & filters,
        bool save = false,
@@ -96,11 +136,22 @@ QString browseRelFile(QString const & filename,
        QString const & label2 = QString(),
        QString const & dir2 = QString());
 
+QString browseRelToSub(QString const & filename,
+       QString const & relpath,
+       QString const & title,
+       QStringList const & filters,
+       bool save = false,
+       QString const & label1 = QString(),
+       QString const & dir1 = QString(),
+       QString const & label2 = QString(),
+       QString const & dir2 = QString());
 
 /** Build filelists of all availabe bst/cls/sty-files. Done through
 *  kpsewhich and an external script, saved in *Files.lst.
+*  \param arg: cls, sty, bst, or bib, as required by TeXFiles.py.
+*         Can be a list of these, too.
 */
-void rescanTexStyles();
+void rescanTexStyles(std::string const & arg = empty_string());
 
 /** Fill \c contents from one of the three texfiles.
  *  Each entry in the file list is returned as a name_with_path
@@ -115,7 +166,7 @@ docstring const internalLineEnding(QString const & str);
 
 // wrapper around the docstring versions
 QString internalPath(QString const &);
-QString onlyFilename(QString const & str);
+QString onlyFileName(QString const & str);
 QString onlyPath(QString const & str);
 QStringList fileFilters(QString const & description);