#include "ColorSet.h"
#include "Length.h"
-#include "support/lstrings.h"
#include "support/qstring_helpers.h"
#include "support/filetools.h"
#include "qt_i18n.h"
class LengthCombo;
-struct ColorSorter {
- bool operator()(ColorCode lhs, ColorCode rhs) const {
- return support::compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0;
- }
-};
-
/// 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)
/// 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);
+
+/// Method to sort colors by GUI name in combo widgets
+bool ColorSorter(ColorCode lhs, ColorCode rhs);
/// colors a widget red if invalid
void setValid(QWidget * widget, bool valid);
+// set focus and highlight the current item if there is no selection already
+void focusAndHighlight(QAbstractItemView * w);
+
/// Qt5 changed setSectionMode to setSectionResizeMode
/// These wrappers work for Qt4 and Qt5
void setSectionResizeMode(QHeaderView * view,
QString makeAbsPath(QString const & relpath, QString const & base);
QString changeExtension(QString const & oldname, QString const & ext);
-/// \return the display string associated with given type and buffer
-/// parameter.
-QString guiName(std::string const & type, BufferParams const & bp);
+/// Format \param text for display as a ToolTip, breaking at lines of \param
+/// width ems. Note: this function is expensive. Better call it in a delayed
+/// manner, i.e. not to fill in a model (see for instance the function
+/// ToolTipFormatter::eventFilter).
+///
+/// When is it called automatically? Whenever the tooltip is not already rich
+/// text beginning with <html>, and is defined by the following functions:
+/// - QWidget::setToolTip(),
+/// - QAbstractItemModel::setData(..., Qt::ToolTipRole),
+/// - Inset::toolTip()
+///
+/// In other words, tooltips can use Qt html, and the tooltip will still be
+/// correctly broken. Moreover, it is possible to specify an entirely custom
+/// tooltip (not subject to automatic formatting) by giving it in its entirety,
+/// i.e. starting with <html>.
+QString formatToolTip(QString text, int width = 30);
+
+
+#if QT_VERSION < 0x050300
+// Very partial implementation of QSignalBlocker for archaic qt versions.
+class QSignalBlocker {
+public:
+ explicit QSignalBlocker(QObject * o)
+ : obj(o), init_state(obj && obj->blockSignals(true)) {}
+
+ ~QSignalBlocker() {
+ if (obj)
+ obj->blockSignals(init_state);
+ }
+private:
+ QObject * obj;
+ bool init_state;
+};
+#endif
+
+
+// Check if qstr is understood as rich text (Qt HTML) and if so, produce a
+// rendering in plain text.
+QString qtHtmlToPlainText(QString const & qstr);
+
} // namespace lyx