diff options
author | David Faure <david.faure@kdab.com> | 2015-05-06 20:45:17 +0200 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2015-05-07 09:50:59 +0000 |
commit | cd90182e6761f4becec01f4baea4e2cf70a9982e (patch) | |
tree | ccb2bc63e3891eb557fb79a0f5d4172b405c52f1 /src/gui/itemmodels | |
parent | ae8406d82f541f6d9112bdac192e5e4e114d56aa (diff) | |
download | qtbase-cd90182e6761f4becec01f4baea4e2cf70a9982e.tar.gz |
QStandardItem: add user-tristate and auto-tristate getters/setters
and deprecate isTristate()/setTristate() which isn't specific enough.
This matches the changes to the flags themselves.
Change-Id: I0ba592af340cb81fc9f4d483569844fe8d7510c3
Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'src/gui/itemmodels')
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel.cpp | 75 | ||||
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel.h | 14 |
2 files changed, 76 insertions, 13 deletions
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 2bd19fb49e..7dc42544eb 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -1224,7 +1224,7 @@ void QStandardItem::setSelectable(bool selectable) The item delegate will render a checkable item with a check box next to the item's text. - \sa isCheckable(), setCheckState(), setTristate() + \sa isCheckable(), setCheckState(), setUserTristate(), setAutoTristate() */ void QStandardItem::setCheckable(bool checkable) { @@ -1244,34 +1244,87 @@ void QStandardItem::setCheckable(bool checkable) The default value is false. - \sa setCheckable(), checkState(), isTristate() + \sa setCheckable(), checkState(), isUserTristate(), isAutoTristate() */ /*! - Sets whether the item is tristate. If \a tristate is true, the - item is checkable with three separate states; otherwise, the item - is checkable with two states. (Note that this also requires that - the item is checkable; see isCheckable().) + \fn void QStandardItem::setTristate(bool tristate) + \obsolete - \sa isTristate(), setCheckable(), setCheckState() + Use QStandardItem::setAutoTristate(bool tristate) instead. + For a tristate checkbox that the user can change between all three + states, use QStandardItem::setUserTristate(bool tristate) instead. */ -void QStandardItem::setTristate(bool tristate) + +/*! + \fn void QStandardItem::isTristate() const + \obsolete + + Use QStandardItem::isAutoTristate() instead. + For a tristate checkbox that the user can change between all three + states, use QStandardItem::isUserTristate() instead. +*/ + +/*! + Sets whether the item is tristate and controlled by QTreeWidget. + This enables automatic management of the state of parent items in QTreeWidget + (checked if all children are checked, unchecked if all children are unchecked, + or partially checked if only some children are checked). + + \since 5.6 + \sa isAutoTristate(), setCheckable(), setCheckState() +*/ +void QStandardItem::setAutoTristate(bool tristate) { Q_D(QStandardItem); d->changeFlags(tristate, Qt::ItemIsAutoTristate); } /*! - \fn bool QStandardItem::isTristate() const + \fn bool QStandardItem::isAutoTristate() const + + Returns whether the item is tristate and is controlled by QTreeWidget. + + The default value is false. + + \since 5.6 + \sa setAutoTristate(), isCheckable(), checkState() +*/ + +/*! + Sets whether the item is tristate and controlled by the user. + If \a tristate is true, the user can cycle through three separate states; + otherwise, the item is checkable with two states. + (Note that this also requires that the item is checkable; see isCheckable().) + + \since 5.6 + \sa isUserTristate(), setCheckable(), setCheckState() +*/ +void QStandardItem::setUserTristate(bool tristate) +{ + Q_D(QStandardItem); + d->changeFlags(tristate, Qt::ItemIsUserTristate); +} + +/*! + \fn bool QStandardItem::isUserTristate() const + \since 5.6 Returns whether the item is tristate; that is, if it's checkable with three - separate states. + separate states and the user can cycle through all three states. The default value is false. - \sa setTristate(), isCheckable(), checkState() + \sa setUserTristate(), isCheckable(), checkState() */ +#if QT_DEPRECATED_SINCE(5, 6) +void QStandardItem::setTristate(bool tristate) +{ + setAutoTristate(tristate); +} +#endif + #ifndef QT_NO_DRAGANDDROP /*! diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h index d9530ac0bf..44156d1907 100644 --- a/src/gui/itemmodels/qstandarditemmodel.h +++ b/src/gui/itemmodels/qstandarditemmodel.h @@ -158,10 +158,20 @@ public: } void setCheckable(bool checkable); - inline bool isTristate() const { + inline bool isAutoTristate() const { return (flags() & Qt::ItemIsAutoTristate) != 0; } - void setTristate(bool tristate); + void setAutoTristate(bool tristate); + + inline bool isUserTristate() const { + return (flags() & Qt::ItemIsUserTristate) != 0; + } + void setUserTristate(bool tristate); + +#if QT_DEPRECATED_SINCE(5, 6) + QT_DEPRECATED bool isTristate() const { return isAutoTristate(); } + QT_DEPRECATED void setTristate(bool tristate); +#endif #ifndef QT_NO_DRAGANDDROP inline bool isDragEnabled() const { |