diff --git a/qtpropertybrowser/src/qtpropertybrowser.cpp b/qtpropertybrowser/src/qtpropertybrowser.cpp index 738bfbf..84421a3 100644 --- a/qtpropertybrowser/src/qtpropertybrowser.cpp +++ b/qtpropertybrowser/src/qtpropertybrowser.cpp @@ -59,6 +59,7 @@ class QtPropertyPrivate QtPropertyPrivate(QtAbstractPropertyManager *manager) : m_enabled(true), m_modified(false), + m_bold(false), m_manager(manager) {} QtProperty *q_ptr; @@ -71,6 +72,7 @@ class QtPropertyPrivate QString m_name; bool m_enabled; bool m_modified; + bool m_bold; QtAbstractPropertyManager * const m_manager; }; @@ -264,6 +266,16 @@ bool QtProperty::isModified() const return d_ptr->m_modified; } +/*! + Returns whether the property is bold. + + \sa setBold() +*/ +bool QtProperty::isBold() const +{ + return d_ptr->m_bold; +} + /*! Returns whether the property has a value. @@ -399,6 +411,20 @@ void QtProperty::setModified(bool modified) propertyChanged(); } +/*! + Sets the property's bold state according to the passed \a bold value. + + \sa isBold() +*/ +void QtProperty::setBold(bool bold) +{ + if (d_ptr->m_bold == bold) + return; + + d_ptr->m_bold = bold; + propertyChanged(); +} + /*! Appends the given \a property to this property's subproperties. diff --git a/qtpropertybrowser/src/qtpropertybrowser.h b/qtpropertybrowser/src/qtpropertybrowser.h index 6b734f0..648d1f7 100644 --- a/qtpropertybrowser/src/qtpropertybrowser.h +++ b/qtpropertybrowser/src/qtpropertybrowser.h @@ -86,6 +86,7 @@ class QT_QTPROPERTYBROWSER_EXPORT QtProperty QString propertyName() const; bool isEnabled() const; bool isModified() const; + bool isBold() const; bool hasValue() const; QIcon valueIcon() const; @@ -98,6 +99,7 @@ class QT_QTPROPERTYBROWSER_EXPORT QtProperty void setPropertyName(const QString &text); void setEnabled(bool enable); void setModified(bool modified); + void setBold(bool bold); void addSubProperty(QtProperty *property); void insertSubProperty(QtProperty *property, QtProperty *afterProperty); diff --git a/qtpropertybrowser/src/qtpropertymanager.cpp b/qtpropertybrowser/src/qtpropertymanager.cpp index 4da2ef8..6c30358 100644 --- a/qtpropertybrowser/src/qtpropertymanager.cpp +++ b/qtpropertybrowser/src/qtpropertymanager.cpp @@ -508,7 +508,7 @@ QtMetaEnumProvider::QtMetaEnumProvider() QtMetaEnumWrapper::staticMetaObject.propertyOffset() + 0); m_policyEnum = p.enumerator(); const int keyCount = m_policyEnum.keyCount(); - for (int i = 0; i < keyCount; i++) + for (int i = 0; i < keyCount; ++i) m_policyEnumNames << QLatin1String(m_policyEnum.key(i)); initLocale(); @@ -522,7 +522,7 @@ QSizePolicy::Policy QtMetaEnumProvider::indexToSizePolicy(int index) const int QtMetaEnumProvider::sizePolicyToIndex(QSizePolicy::Policy policy) const { const int keyCount = m_policyEnum.keyCount(); - for (int i = 0; i < keyCount; i++) + for (int i = 0; i < keyCount; ++i) if (indexToSizePolicy(i) == policy) return i; return -1; @@ -891,7 +891,7 @@ void QtIntPropertyManager::setSingleStep(QtProperty *property, int step) /*! Sets read-only status of the property. - \sa QtIntPropertyManager::setReadOnly + \sa QtIntPropertyManager::isReadOnly */ void QtIntPropertyManager::setReadOnly(QtProperty *property, bool readOnly) { @@ -1165,7 +1165,7 @@ void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step) /*! Sets read-only status of the property. - \sa QtDoublePropertyManager::setReadOnly + \sa QtDoublePropertyManager::isReadOnly */ void QtDoublePropertyManager::setReadOnly(QtProperty *property, bool readOnly) { @@ -1526,7 +1526,7 @@ void QtStringPropertyManager::setEchoMode(QtProperty *property, EchoMode echoMod /*! Sets read-only status of the property. - \sa QtStringPropertyManager::setReadOnly + \sa QtStringPropertyManager::isReadOnly */ void QtStringPropertyManager::setReadOnly(QtProperty *property, bool readOnly) { @@ -1543,7 +1543,7 @@ void QtStringPropertyManager::setReadOnly(QtProperty *property, bool readOnly) it.value() = data; emit propertyChanged(property); - emit readOnlyChanged(property, data.readOnly); + emit readOnlyChanged(property, data.echoMode); } /*! @@ -4821,6 +4821,7 @@ class QtEnumPropertyManagerPrivate { Data() : val(-1) {} int val; + bool readOnly; QStringList enumNames; QMap enumIcons; }; @@ -5062,6 +5063,41 @@ void QtEnumPropertyManager::setEnumIcons(QtProperty *property, const QMap(d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::readOnly, property, false); +} + +/*! + Sets read-only status of the property. + + \sa QtEnumPropertyManager::isReadOnly +*/ +void QtEnumPropertyManager::setReadOnly(QtProperty *property, bool readOnly) +{ + const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; + + QtEnumPropertyManagerPrivate::Data data = it.value(); + + if (data.readOnly == readOnly) + return; + + data.readOnly = readOnly; + it.value() = data; + + emit propertyChanged(property); + emit readOnlyChanged(property, data.readOnly); +} + /*! \reimp */ diff --git a/qtpropertybrowser/src/qtpropertymanager.h b/qtpropertybrowser/src/qtpropertymanager.h index d6b94cc..af3ae7f 100644 --- a/qtpropertybrowser/src/qtpropertymanager.h +++ b/qtpropertybrowser/src/qtpropertymanager.h @@ -198,7 +198,7 @@ public Q_SLOTS: void valueChanged(QtProperty *property, const QString &val); void regExpChanged(QtProperty *property, const QRegExp ®Exp); void echoModeChanged(QtProperty *property, const int); - void readOnlyChanged(QtProperty *property, bool); + void readOnlyChanged(QtProperty *property, bool readOnly); protected: QString valueText(const QtProperty *property) const; @@ -585,15 +585,18 @@ class QT_QTPROPERTYBROWSER_EXPORT QtEnumPropertyManager : public QtAbstractPrope int value(const QtProperty *property) const; QStringList enumNames(const QtProperty *property) const; QMap enumIcons(const QtProperty *property) const; + bool isReadOnly(const QtProperty *property) const; public Q_SLOTS: void setValue(QtProperty *property, int val); void setEnumNames(QtProperty *property, const QStringList &names); void setEnumIcons(QtProperty *property, const QMap &icons); + void setReadOnly(QtProperty *property, bool readOnly); Q_SIGNALS: void valueChanged(QtProperty *property, int val); void enumNamesChanged(QtProperty *property, const QStringList &names); void enumIconsChanged(QtProperty *property, const QMap &icons); + void readOnlyChanged(QtProperty *property, bool readOnly); protected: QString valueText(const QtProperty *property) const; QIcon valueIcon(const QtProperty *property) const; diff --git a/qtpropertybrowser/src/qttreepropertybrowser.cpp b/qtpropertybrowser/src/qttreepropertybrowser.cpp index 97818e1..321a7b9 100644 --- a/qtpropertybrowser/src/qttreepropertybrowser.cpp +++ b/qtpropertybrowser/src/qttreepropertybrowser.cpp @@ -1071,6 +1071,17 @@ void QtTreePropertyBrowser::editItem(QtBrowserItem *item) d_ptr->editItem(item); } +/*! +Ensure that the column width fits the current content size. Useful to ensure that +as much as possible is visible for the user based on the current content, while still +allowing for the overall resize mode to be QHeaderView::Interactive for the +user to adjust individually as needed. +*/ +void QtTreePropertyBrowser::resizeToContent() const +{ + d_ptr->m_treeWidget->header()->resizeSections(QHeaderView::ResizeToContents); +} + #if QT_VERSION >= 0x040400 QT_END_NAMESPACE #endif diff --git a/qtpropertybrowser/src/qttreepropertybrowser.h b/qtpropertybrowser/src/qttreepropertybrowser.h index 7a3057f..6d95ccd 100644 --- a/qtpropertybrowser/src/qttreepropertybrowser.h +++ b/qtpropertybrowser/src/qttreepropertybrowser.h @@ -108,6 +108,8 @@ class QT_QTPROPERTYBROWSER_EXPORT QtTreePropertyBrowser : public QtAbstractPrope void editItem(QtBrowserItem *item); + void resizeToContent() const; + Q_SIGNALS: void collapsed(QtBrowserItem *item);