summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2015-05-06 17:57:36 +0200
committerDavid Faure <david.faure@kdab.com>2015-05-07 09:14:18 +0000
commitae8406d82f541f6d9112bdac192e5e4e114d56aa (patch)
treeea8344f5e62950f7e94dc6061db263a9ffb9d560 /src
parent87155a8d651c94872207cf2a1b85a92d5c509073 (diff)
Deprecate ItemIsTristate in favor of ItemIsAutoTristate.
This makes the behavior much more clear. You can get a tristate checkbox just by setting the CheckStateRole to PartiallyChecked, no tristate flag needed. The flag, on the other hand, enables the automatic-tristate behavior in QTreeViews (and only there), hence the new name for it. Change-Id: I18d292a8b8294c863eab806f3874d15dfb72556c Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qnamespace.h5
-rw-r--r--src/corelib/global/qnamespace.qdoc4
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp2
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.h2
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp8
5 files changed, 13 insertions, 8 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 32b2a26992..123e2edf0e 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1458,7 +1458,10 @@ public:
ItemIsDropEnabled = 8,
ItemIsUserCheckable = 16,
ItemIsEnabled = 32,
- ItemIsTristate = 64,
+ ItemIsAutoTristate = 64,
+#if QT_DEPRECATED_SINCE(5, 6)
+ ItemIsTristate = ItemIsAutoTristate,
+#endif
ItemNeverHasChildren = 128,
ItemIsUserTristate = 256
};
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index e22ed24e58..d4d7b631ad 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2642,10 +2642,12 @@
\value ItemIsDropEnabled It can be used as a drop target.
\value ItemIsUserCheckable It can be checked or unchecked by the user.
\value ItemIsEnabled The user can interact with the item.
- \value ItemIsTristate The item can show three separate states.
+ \value ItemIsAutoTristate The item's state depends on the state of its children.
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).
+ \value ItemIsTristate \e{This enum value is deprecated.} Use Qt::ItemIsAutoTristate
+ instead.
\value ItemNeverHasChildren The item never has child items.
\value ItemIsUserTristate The user can cycle through three separate states.
This value has been added in Qt 5.5.
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index ed2479302e..2bd19fb49e 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -1258,7 +1258,7 @@ void QStandardItem::setCheckable(bool checkable)
void QStandardItem::setTristate(bool tristate)
{
Q_D(QStandardItem);
- d->changeFlags(tristate, Qt::ItemIsTristate);
+ d->changeFlags(tristate, Qt::ItemIsAutoTristate);
}
/*!
diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h
index 3dd613f907..d9530ac0bf 100644
--- a/src/gui/itemmodels/qstandarditemmodel.h
+++ b/src/gui/itemmodels/qstandarditemmodel.h
@@ -159,7 +159,7 @@ public:
void setCheckable(bool checkable);
inline bool isTristate() const {
- return (flags() & Qt::ItemIsTristate) != 0;
+ return (flags() & Qt::ItemIsAutoTristate) != 0;
}
void setTristate(bool tristate);
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index bf736bc387..1366a00318 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -1720,12 +1720,12 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value)
}
} break;
case Qt::CheckStateRole:
- if ((itemFlags & Qt::ItemIsTristate) && value != Qt::PartiallyChecked) {
+ if ((itemFlags & Qt::ItemIsAutoTristate) && value != Qt::PartiallyChecked) {
for (int i = 0; i < children.count(); ++i) {
QTreeWidgetItem *child = children.at(i);
if (child->data(column, role).isValid()) {// has a CheckState
Qt::ItemFlags f = itemFlags; // a little hack to avoid multiple dataChanged signals
- itemFlags &= ~Qt::ItemIsTristate;
+ itemFlags &= ~Qt::ItemIsAutoTristate;
child->setData(column, role, value);
itemFlags = f;
}
@@ -1760,7 +1760,7 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value)
model->emitDataChanged(this, column);
if (role == Qt::CheckStateRole) {
QTreeWidgetItem *p;
- for (p = par; p && (p->itemFlags & Qt::ItemIsTristate); p = p->par)
+ for (p = par; p && (p->itemFlags & Qt::ItemIsAutoTristate); p = p->par)
model->emitDataChanged(p, column);
}
}
@@ -1779,7 +1779,7 @@ QVariant QTreeWidgetItem::data(int column, int role) const
break;
case Qt::CheckStateRole:
// special case for check state in tristate
- if (children.count() && (itemFlags & Qt::ItemIsTristate))
+ if (children.count() && (itemFlags & Qt::ItemIsAutoTristate))
return childrenCheckState(column);
// fallthrough intended
default: