summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-07-17 13:58:47 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-07-29 11:10:26 +0000
commit08a732b69e951b8f1ca53d2e047c432407f42d67 (patch)
treee3d12a42efc35171acfd70179d1e5c87197f1a41
parentac1af7d6acdb4bad85cc7a3a42a5a1cb4d407875 (diff)
Qt Property Browser solution: Split toolTip into valueToolTip and descriptionToolTip.
Make it possible to have different tool tips for the property name and value. Add comments pointing out the changes to be ported back to the solution. Task-number: QTBUG-45442 Change-Id: I31571d3f502be20b7c0bb2c91cbd999e80ee49aa Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
-rw-r--r--src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp7
-rw-r--r--src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp7
-rw-r--r--src/shared/qtpropertybrowser/qtpropertybrowser.cpp64
-rw-r--r--src/shared/qtpropertybrowser/qtpropertybrowser.h8
-rw-r--r--src/shared/qtpropertybrowser/qttreepropertybrowser.cpp15
5 files changed, 75 insertions, 26 deletions
diff --git a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp
index 0e9d22396..9f1f177bd 100644
--- a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp
+++ b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp
@@ -453,7 +453,7 @@ void QtButtonPropertyBrowserPrivate::updateItem(WidgetItem *item)
font.setUnderline(property->isModified());
item->button->setFont(font);
item->button->setText(property->propertyName());
- item->button->setToolTip(property->toolTip());
+ item->button->setToolTip(property->descriptionToolTip());
item->button->setStatusTip(property->statusTip());
item->button->setWhatsThis(property->whatsThis());
item->button->setEnabled(property->isEnabled());
@@ -463,7 +463,7 @@ void QtButtonPropertyBrowserPrivate::updateItem(WidgetItem *item)
font.setUnderline(property->isModified());
item->label->setFont(font);
item->label->setText(property->propertyName());
- item->label->setToolTip(property->toolTip());
+ item->label->setToolTip(property->descriptionToolTip());
item->label->setStatusTip(property->statusTip());
item->label->setWhatsThis(property->whatsThis());
item->label->setEnabled(property->isEnabled());
@@ -481,7 +481,8 @@ void QtButtonPropertyBrowserPrivate::updateItem(WidgetItem *item)
font.setUnderline(false);
item->widget->setFont(font);
item->widget->setEnabled(property->isEnabled());
- item->widget->setToolTip(property->valueText());
+ const QString valueToolTip = property->valueToolTip();
+ item->widget->setToolTip(valueToolTip.isEmpty() ? property->valueText() : valueToolTip);
}
}
diff --git a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp
index d32f6e5a7..ec0a61712 100644
--- a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp
+++ b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp
@@ -398,7 +398,7 @@ void QtGroupBoxPropertyBrowserPrivate::updateItem(WidgetItem *item)
font.setUnderline(property->isModified());
item->groupBox->setFont(font);
item->groupBox->setTitle(property->propertyName());
- item->groupBox->setToolTip(property->toolTip());
+ item->groupBox->setToolTip(property->descriptionToolTip());
item->groupBox->setStatusTip(property->statusTip());
item->groupBox->setWhatsThis(property->whatsThis());
item->groupBox->setEnabled(property->isEnabled());
@@ -408,7 +408,7 @@ void QtGroupBoxPropertyBrowserPrivate::updateItem(WidgetItem *item)
font.setUnderline(property->isModified());
item->label->setFont(font);
item->label->setText(property->propertyName());
- item->label->setToolTip(property->toolTip());
+ item->label->setToolTip(property->descriptionToolTip());
item->label->setStatusTip(property->statusTip());
item->label->setWhatsThis(property->whatsThis());
item->label->setEnabled(property->isEnabled());
@@ -425,7 +425,8 @@ void QtGroupBoxPropertyBrowserPrivate::updateItem(WidgetItem *item)
font.setUnderline(false);
item->widget->setFont(font);
item->widget->setEnabled(property->isEnabled());
- item->widget->setToolTip(property->valueText());
+ const QString valueToolTip = property->valueToolTip();
+ item->widget->setToolTip(valueToolTip.isEmpty() ? property->valueText() : valueToolTip);
}
//item->setIcon(1, property->valueIcon());
}
diff --git a/src/shared/qtpropertybrowser/qtpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtpropertybrowser.cpp
index aac4c086a..3c8443338 100644
--- a/src/shared/qtpropertybrowser/qtpropertybrowser.cpp
+++ b/src/shared/qtpropertybrowser/qtpropertybrowser.cpp
@@ -51,7 +51,8 @@ public:
QSet<QtProperty *> m_parentItems;
QList<QtProperty *> m_subItems;
- QString m_toolTip;
+ QString m_valueToolTip;
+ QString m_descriptionToolTip;
QString m_statusTip;
QString m_whatsThis;
QString m_name;
@@ -100,7 +101,11 @@ public:
\row
\li statusTip() \li setStatusTip()
\row
- \li toolTip() \li setToolTip()
+ \li descriptionToolTip() \li setDescriptionToolTip()
+ \row
+ \li valueToolTip() \li setValueToolTip()
+ \row
+ \li toolTip() \deprecated in 5.6 \li setToolTip() \deprecated in 5.6
\row
\li whatsThis() \li setWhatsThis()
\row
@@ -192,14 +197,35 @@ QtAbstractPropertyManager *QtProperty::propertyManager() const
return d_ptr->m_manager;
}
+/* Note: As of 17.7.2015 for Qt 5.6, the existing 'toolTip' of the Property
+ * Browser solution was split into valueToolTip() and descriptionToolTip()
+ * to be able to implement custom tool tip for QTBUG-45442. This could
+ * be back-ported to the solution. */
+
+/*!
+ Returns the property value's tool tip.
+
+ This is suitable for tool tips over the value (item delegate).
+
+ \since 5.6
+ \sa setValueToolTip()
+*/
+QString QtProperty::valueToolTip() const
+{
+ return d_ptr->m_valueToolTip;
+}
+
/*!
- Returns the property's tool tip.
+ Returns the property description's tool tip.
- \sa setToolTip()
+ This is suitable for tool tips over the description (label).
+
+ \since 5.6
+ \sa setDescriptionToolTip()
*/
-QString QtProperty::toolTip() const
+QString QtProperty::descriptionToolTip() const
{
- return d_ptr->m_toolTip;
+ return d_ptr->m_descriptionToolTip;
}
/*!
@@ -289,16 +315,32 @@ QString QtProperty::valueText() const
}
/*!
- Sets the property's tool tip to the given \a text.
+ Sets the property value's tool tip to the given \a text.
+
+ \since 5.6
+ \sa valueToolTip()
+*/
+void QtProperty::setValueToolTip(const QString &text)
+{
+ if (d_ptr->m_valueToolTip == text)
+ return;
+
+ d_ptr->m_valueToolTip = text;
+ propertyChanged();
+}
+
+/*!
+ Sets the property description's tool tip to the given \a text.
- \sa toolTip()
+ \since 5.6
+ \sa descriptionToolTip()
*/
-void QtProperty::setToolTip(const QString &text)
+void QtProperty::setDescriptionToolTip(const QString &text)
{
- if (d_ptr->m_toolTip == text)
+ if (d_ptr->m_descriptionToolTip == text)
return;
- d_ptr->m_toolTip = text;
+ d_ptr->m_descriptionToolTip = text;
propertyChanged();
}
diff --git a/src/shared/qtpropertybrowser/qtpropertybrowser.h b/src/shared/qtpropertybrowser/qtpropertybrowser.h
index 357834d4a..7b73009b9 100644
--- a/src/shared/qtpropertybrowser/qtpropertybrowser.h
+++ b/src/shared/qtpropertybrowser/qtpropertybrowser.h
@@ -51,7 +51,9 @@ public:
QtAbstractPropertyManager *propertyManager() const;
- QString toolTip() const;
+ QString toolTip() const { return valueToolTip(); } // Compatibility
+ QString valueToolTip() const;
+ QString descriptionToolTip() const;
QString statusTip() const;
QString whatsThis() const;
QString propertyName() const;
@@ -62,7 +64,9 @@ public:
QIcon valueIcon() const;
QString valueText() const;
- void setToolTip(const QString &text);
+ void setToolTip(const QString &text) { setValueToolTip(text); } // Compatibility
+ void setValueToolTip(const QString &text);
+ void setDescriptionToolTip(const QString &text);
void setStatusTip(const QString &text);
void setWhatsThis(const QString &text);
void setPropertyName(const QString &text);
diff --git a/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp b/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp
index abb883e49..40271a553 100644
--- a/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp
+++ b/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp
@@ -577,21 +577,22 @@ void QtTreePropertyBrowserPrivate::updateItem(QTreeWidgetItem *item)
QtProperty *property = m_itemToIndex[item]->property();
QIcon expandIcon;
if (property->hasValue()) {
- QString toolTip = property->toolTip();
- if (toolTip.isEmpty())
- toolTip = property->valueText();
- item->setToolTip(1, toolTip);
+ const QString valueToolTip = property->valueToolTip();
+ const QString valueText = property->valueText();
+ item->setToolTip(1, valueToolTip.isEmpty() ? valueText : valueToolTip);
item->setIcon(1, property->valueIcon());
- item->setText(1, property->valueText());
+ item->setText(1, valueText);
} else if (markPropertiesWithoutValue() && !m_treeWidget->rootIsDecorated()) {
expandIcon = m_expandIcon;
}
item->setIcon(0, expandIcon);
item->setFirstColumnSpanned(!property->hasValue());
- item->setToolTip(0, property->propertyName());
+ const QString descriptionToolTip = property->descriptionToolTip();
+ const QString propertyName = property->propertyName();
+ item->setToolTip(0, descriptionToolTip.isEmpty() ? propertyName : descriptionToolTip);
item->setStatusTip(0, property->statusTip());
item->setWhatsThis(0, property->whatsThis());
- item->setText(0, property->propertyName());
+ item->setText(0, propertyName);
bool wasEnabled = item->flags() & Qt::ItemIsEnabled;
bool isEnabled = wasEnabled;
if (property->isEnabled()) {