QTreeWidget: mark (is|set)Item(Selected|Hidden|Expanded) as deprecated
QTreeWidget::(is|set)Item(Selected|Hidden|Expanded)() are deprecated for a long time but not marked as such. Therefore explicitly mark them as deprecated so they can get removed with Qt6. Change-Id: Ie4971350de61326811e0788df0d359ed3c442869 Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
7a4ebf1b71
commit
76bb804405
@ -154,14 +154,14 @@ void MainWindow::findItems()
|
||||
QTreeWidgetItem *item;
|
||||
//! [6]
|
||||
foreach (item, treeWidget->selectedItems())
|
||||
treeWidget->setItemSelected(item, false);
|
||||
item->setSelected(false);
|
||||
|
||||
//! [7]
|
||||
QList<QTreeWidgetItem *> found = treeWidget->findItems(
|
||||
itemText, Qt::MatchWildcard);
|
||||
|
||||
foreach (item, found) {
|
||||
treeWidget->setItemSelected(item, true);
|
||||
item->setSelected(true);
|
||||
// Show the item->text(0) for each item.
|
||||
}
|
||||
//! [7]
|
||||
|
@ -1009,8 +1009,18 @@ void QTreeModel::timerEvent(QTimerEvent *ev)
|
||||
Sets the selected state of the item to \a select.
|
||||
|
||||
\sa isSelected()
|
||||
|
||||
*/
|
||||
void QTreeWidgetItem::setSelected(bool select)
|
||||
{
|
||||
const QTreeModel *model = treeModel();
|
||||
if (!model || !view->selectionModel())
|
||||
return;
|
||||
const QModelIndex index = model->index(this, 0);
|
||||
view->selectionModel()->select(index, (select ? QItemSelectionModel::Select
|
||||
: QItemSelectionModel::Deselect)
|
||||
| QItemSelectionModel::Rows);
|
||||
d->selected = select;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QTreeWidgetItem::isSelected() const
|
||||
@ -1020,6 +1030,10 @@ void QTreeModel::timerEvent(QTimerEvent *ev)
|
||||
|
||||
\sa setSelected()
|
||||
*/
|
||||
bool QTreeWidgetItem::isSelected() const
|
||||
{
|
||||
return d->selected;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QTreeWidgetItem::setHidden(bool hide)
|
||||
@ -1033,12 +1047,18 @@ void QTreeModel::timerEvent(QTimerEvent *ev)
|
||||
\sa isHidden()
|
||||
*/
|
||||
|
||||
void QTreeWidgetItem::setHidden(bool ahide)
|
||||
void QTreeWidgetItem::setHidden(bool hide)
|
||||
{
|
||||
if (view) {
|
||||
view->setItemHidden(this, ahide);
|
||||
d->hidden = ahide;
|
||||
const QTreeModel *model = treeModel();
|
||||
if (!model)
|
||||
return;
|
||||
if (this == model->headerItem) {
|
||||
view->header()->setHidden(hide);
|
||||
} else {
|
||||
const QModelIndex index = view->d_func()->index(this);
|
||||
view->setRowHidden(index.row(), index.parent(), hide);
|
||||
}
|
||||
d->hidden = hide;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1052,7 +1072,15 @@ void QTreeWidgetItem::setHidden(bool ahide)
|
||||
|
||||
bool QTreeWidgetItem::isHidden() const
|
||||
{
|
||||
return (view ? d->hidden : false);
|
||||
const QTreeModel *model = treeModel();
|
||||
if (!model)
|
||||
return false;
|
||||
if (this == model->headerItem)
|
||||
return view->header()->isHidden();
|
||||
if (view->d_func()->hiddenIndexes.isEmpty())
|
||||
return false;
|
||||
QTreeModel::SkipSorting skipSorting(model);
|
||||
return view->d_func()->isRowHidden(view->d_func()->index(this));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1064,6 +1092,14 @@ bool QTreeWidgetItem::isHidden() const
|
||||
|
||||
\sa isExpanded()
|
||||
*/
|
||||
void QTreeWidgetItem::setExpanded(bool expand)
|
||||
{
|
||||
const QTreeModel *model = treeModel();
|
||||
if (!model)
|
||||
return;
|
||||
QTreeModel::SkipSorting skipSorting(model);
|
||||
view->setExpanded(view->d_func()->index(this), expand);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QTreeWidgetItem::isExpanded() const
|
||||
@ -1073,6 +1109,14 @@ bool QTreeWidgetItem::isHidden() const
|
||||
|
||||
\sa setExpanded()
|
||||
*/
|
||||
bool QTreeWidgetItem::isExpanded() const
|
||||
{
|
||||
const QTreeModel *model = treeModel();
|
||||
if (!model)
|
||||
return false;
|
||||
QTreeModel::SkipSorting skipSorting(model);
|
||||
return view->isExpanded(view->d_func()->index(this));
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QTreeWidgetItem::setFirstColumnSpanned(bool span)
|
||||
@ -3058,6 +3102,7 @@ void QTreeWidget::setItemWidget(QTreeWidgetItem *item, int column, QWidget *widg
|
||||
QAbstractItemView::setIndexWidget(d->index(item, column), widget);
|
||||
}
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
/*!
|
||||
Returns \c true if the \a item is selected; otherwise returns \c false.
|
||||
|
||||
@ -3069,9 +3114,7 @@ void QTreeWidget::setItemWidget(QTreeWidgetItem *item, int column, QWidget *widg
|
||||
*/
|
||||
bool QTreeWidget::isItemSelected(const QTreeWidgetItem *item) const
|
||||
{
|
||||
if (!item)
|
||||
return false;
|
||||
return item->d->selected;
|
||||
return ((item && item->treeWidget() == this) ? item->isSelected() : false);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3086,16 +3129,10 @@ bool QTreeWidget::isItemSelected(const QTreeWidgetItem *item) const
|
||||
*/
|
||||
void QTreeWidget::setItemSelected(const QTreeWidgetItem *item, bool select)
|
||||
{
|
||||
Q_D(QTreeWidget);
|
||||
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
selectionModel()->select(d->index(item), (select ? QItemSelectionModel::Select
|
||||
: QItemSelectionModel::Deselect)
|
||||
|QItemSelectionModel::Rows);
|
||||
item->d->selected = select;
|
||||
if (item && item->treeWidget() == this)
|
||||
const_cast<QTreeWidgetItem*>(item)->setSelected(select);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Returns a list of all selected non-hidden items.
|
||||
@ -3112,7 +3149,7 @@ QList<QTreeWidgetItem*> QTreeWidget::selectedItems() const
|
||||
seen.reserve(indexes.count());
|
||||
for (const auto &index : indexes) {
|
||||
QTreeWidgetItem *item = d->item(index);
|
||||
if (isItemHidden(item) || seen.contains(item))
|
||||
if (item->isHidden() || seen.contains(item))
|
||||
continue;
|
||||
seen.insert(item);
|
||||
items.append(item);
|
||||
@ -3136,6 +3173,7 @@ QList<QTreeWidgetItem*> QTreeWidget::findItems(const QString &text, Qt::MatchFla
|
||||
return items;
|
||||
}
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
/*!
|
||||
Returns \c true if the \a item is explicitly hidden, otherwise returns \c false.
|
||||
|
||||
@ -3145,13 +3183,7 @@ QList<QTreeWidgetItem*> QTreeWidget::findItems(const QString &text, Qt::MatchFla
|
||||
*/
|
||||
bool QTreeWidget::isItemHidden(const QTreeWidgetItem *item) const
|
||||
{
|
||||
Q_D(const QTreeWidget);
|
||||
if (item == d->treeModel()->headerItem)
|
||||
return header()->isHidden();
|
||||
if (d->hiddenIndexes.isEmpty())
|
||||
return false;
|
||||
QTreeModel::SkipSorting skipSorting(d->treeModel());
|
||||
return d->isRowHidden(d->index(item));
|
||||
return ((item && item->treeWidget() == this) ? item->isHidden() : false);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3165,16 +3197,8 @@ bool QTreeWidget::isItemHidden(const QTreeWidgetItem *item) const
|
||||
*/
|
||||
void QTreeWidget::setItemHidden(const QTreeWidgetItem *item, bool hide)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
Q_D(QTreeWidget);
|
||||
if (item == d->treeModel()->headerItem) {
|
||||
header()->setHidden(hide);
|
||||
} else {
|
||||
const QModelIndex index = d->index(item);
|
||||
setRowHidden(index.row(), index.parent(), hide);
|
||||
}
|
||||
item->d->hidden = hide;
|
||||
if (item && item->treeWidget() == this)
|
||||
const_cast<QTreeWidgetItem*>(item)->setHidden(hide);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3188,9 +3212,7 @@ void QTreeWidget::setItemHidden(const QTreeWidgetItem *item, bool hide)
|
||||
*/
|
||||
bool QTreeWidget::isItemExpanded(const QTreeWidgetItem *item) const
|
||||
{
|
||||
Q_D(const QTreeWidget);
|
||||
QTreeModel::SkipSorting skipSorting(d->treeModel());
|
||||
return isExpanded(d->index(item));
|
||||
return ((item && item->treeWidget() == this) ? item->isExpanded() : false);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3205,10 +3227,10 @@ bool QTreeWidget::isItemExpanded(const QTreeWidgetItem *item) const
|
||||
*/
|
||||
void QTreeWidget::setItemExpanded(const QTreeWidgetItem *item, bool expand)
|
||||
{
|
||||
Q_D(QTreeWidget);
|
||||
QTreeModel::SkipSorting skipSorting(d->treeModel());
|
||||
setExpanded(d->index(item), expand);
|
||||
if (item && item->treeWidget() == this)
|
||||
const_cast<QTreeWidgetItem*>(item)->setExpanded(expand);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\since 4.3
|
||||
|
@ -79,14 +79,14 @@ public:
|
||||
|
||||
inline QTreeWidget *treeWidget() const { return view; }
|
||||
|
||||
inline void setSelected(bool select);
|
||||
inline bool isSelected() const;
|
||||
void setSelected(bool select);
|
||||
bool isSelected() const;
|
||||
|
||||
void setHidden(bool hide);
|
||||
bool isHidden() const;
|
||||
|
||||
inline void setExpanded(bool expand);
|
||||
inline bool isExpanded() const;
|
||||
void setExpanded(bool expand);
|
||||
bool isExpanded() const;
|
||||
|
||||
inline void setFirstColumnSpanned(bool span);
|
||||
inline bool isFirstColumnSpanned() const;
|
||||
@ -315,17 +315,27 @@ public:
|
||||
void setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget);
|
||||
inline void removeItemWidget(QTreeWidgetItem *item, int column);
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
QT_DEPRECATED_X ("Use QTreeWidgetItem::isSelected() instead")
|
||||
bool isItemSelected(const QTreeWidgetItem *item) const;
|
||||
QT_DEPRECATED_X ("Use QTreeWidgetItem::setSelected() instead")
|
||||
void setItemSelected(const QTreeWidgetItem *item, bool select);
|
||||
#endif
|
||||
QList<QTreeWidgetItem*> selectedItems() const;
|
||||
QList<QTreeWidgetItem*> findItems(const QString &text, Qt::MatchFlags flags,
|
||||
int column = 0) const;
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
QT_DEPRECATED_X ("Use QTreeWidgetItem::isHidden() instead")
|
||||
bool isItemHidden(const QTreeWidgetItem *item) const;
|
||||
QT_DEPRECATED_X ("Use QTreeWidgetItem::setHidden() instead")
|
||||
void setItemHidden(const QTreeWidgetItem *item, bool hide);
|
||||
|
||||
QT_DEPRECATED_X ("Use QTreeWidgetItem::isExpanded() instead")
|
||||
bool isItemExpanded(const QTreeWidgetItem *item) const;
|
||||
QT_DEPRECATED_X ("Use QTreeWidgetItem::setExpanded() instead")
|
||||
void setItemExpanded(const QTreeWidgetItem *item, bool expand);
|
||||
#endif
|
||||
|
||||
bool isFirstItemColumnSpanned(const QTreeWidgetItem *item) const;
|
||||
void setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span);
|
||||
@ -413,18 +423,6 @@ inline QTreeWidgetItem *QTreeWidget::itemAt(int ax, int ay) const
|
||||
inline void QTreeWidget::setHeaderLabel(const QString &alabel)
|
||||
{ setHeaderLabels(QStringList(alabel)); }
|
||||
|
||||
inline void QTreeWidgetItem::setSelected(bool aselect)
|
||||
{ if (view) view->setItemSelected(this, aselect); }
|
||||
|
||||
inline bool QTreeWidgetItem::isSelected() const
|
||||
{ return (view ? view->isItemSelected(this) : false); }
|
||||
|
||||
inline void QTreeWidgetItem::setExpanded(bool aexpand)
|
||||
{ if (view) view->setItemExpanded(this, aexpand); }
|
||||
|
||||
inline bool QTreeWidgetItem::isExpanded() const
|
||||
{ return (view ? view->isItemExpanded(this) : false); }
|
||||
|
||||
inline void QTreeWidgetItem::setFirstColumnSpanned(bool aspan)
|
||||
{ if (view) view->setFirstItemColumnSpanned(this, aspan); }
|
||||
|
||||
|
@ -79,7 +79,7 @@ void tst_QAbstractItemModelTester::treeWidgetModel()
|
||||
root->removeChild(remove);
|
||||
QTreeWidgetItem *parent = new QTreeWidgetItem(&widget, QStringList("parent"));
|
||||
new QTreeWidgetItem(parent, QStringList("child"));
|
||||
widget.setItemHidden(parent, true);
|
||||
parent->setHidden(true);
|
||||
|
||||
widget.sortByColumn(0, Qt::AscendingOrder);
|
||||
}
|
||||
|
@ -608,31 +608,31 @@ void tst_QTreeWidget::setItemHidden()
|
||||
QVERIFY(testWidget->visualItemRect(child).isValid()
|
||||
&& testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child)));
|
||||
|
||||
QVERIFY(!testWidget->isItemHidden(parent));
|
||||
QVERIFY(!testWidget->isItemHidden(child));
|
||||
QVERIFY(!parent->isHidden());
|
||||
QVERIFY(!child->isHidden());
|
||||
|
||||
testWidget->setItemHidden(parent, true);
|
||||
parent->setHidden(true);
|
||||
|
||||
QVERIFY(!(testWidget->visualItemRect(parent).isValid()
|
||||
&& testWidget->viewport()->rect().intersects(testWidget->visualItemRect(parent))));
|
||||
QVERIFY(!(testWidget->visualItemRect(child).isValid()
|
||||
&& testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child))));
|
||||
|
||||
QVERIFY(testWidget->isItemHidden(parent));
|
||||
QVERIFY(!testWidget->isItemHidden(child));
|
||||
QVERIFY(parent->isHidden());
|
||||
QVERIFY(!child->isHidden());
|
||||
|
||||
// From task 78670 (This caused an core dump)
|
||||
// Check if we can set an item visible if it already is visible.
|
||||
testWidget->setItemHidden(parent, false);
|
||||
testWidget->setItemHidden(parent, false);
|
||||
QVERIFY(!testWidget->isItemHidden(parent));
|
||||
parent->setHidden(false);
|
||||
parent->setHidden(false);
|
||||
QVERIFY(!parent->isHidden());
|
||||
|
||||
|
||||
// hide, hide and then unhide.
|
||||
testWidget->setItemHidden(parent, true);
|
||||
testWidget->setItemHidden(parent, true);
|
||||
testWidget->setItemHidden(parent, false);
|
||||
QVERIFY(!testWidget->isItemHidden(parent));
|
||||
parent->setHidden(true);
|
||||
parent->setHidden(true);
|
||||
parent->setHidden(false);
|
||||
QVERIFY(!parent->isHidden());
|
||||
|
||||
|
||||
}
|
||||
@ -658,7 +658,7 @@ void tst_QTreeWidget::setItemHidden2()
|
||||
|
||||
if (testWidget->topLevelItemCount() > 0) {
|
||||
top = testWidget->topLevelItem(0);
|
||||
testWidget->setItemExpanded(top, true);
|
||||
top->setExpanded(true);
|
||||
}
|
||||
|
||||
if (testWidget->topLevelItemCount() > 0) {
|
||||
@ -666,8 +666,8 @@ void tst_QTreeWidget::setItemHidden2()
|
||||
for (int i = 0; i < top->childCount(); i++) {
|
||||
leaf = top->child(i);
|
||||
if (leaf->text(0).toInt() % 2 == 0) {
|
||||
if (!testWidget->isItemHidden(leaf)) {
|
||||
testWidget->setItemHidden(leaf, true);
|
||||
if (!leaf->isHidden()) {
|
||||
leaf->setHidden(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -821,7 +821,7 @@ void tst_QTreeWidget::selectedItems()
|
||||
else
|
||||
item = item->child(index);
|
||||
}
|
||||
testWidget->setItemSelected(item, true);
|
||||
item->setSelected(true);
|
||||
}
|
||||
|
||||
// hide rows
|
||||
@ -833,7 +833,7 @@ void tst_QTreeWidget::selectedItems()
|
||||
else
|
||||
item = item->child(index);
|
||||
}
|
||||
testWidget->setItemHidden(item, true);
|
||||
item->setHidden(true);
|
||||
}
|
||||
|
||||
// open/close toplevel
|
||||
@ -862,18 +862,20 @@ void tst_QTreeWidget::selectedItems()
|
||||
// compare isSelected
|
||||
for (int t=0; t<testWidget->topLevelItemCount(); ++t) {
|
||||
QTreeWidgetItem *top = testWidget->topLevelItem(t);
|
||||
if (testWidget->isItemSelected(top) && !testWidget->isItemHidden(top))
|
||||
if (top->isSelected() && !top->isHidden())
|
||||
QVERIFY(sel.contains(top));
|
||||
for (int c=0; c<top->childCount(); ++c) {
|
||||
QTreeWidgetItem *child = top->child(c);
|
||||
if (testWidget->isItemSelected(child) && !testWidget->isItemHidden(child))
|
||||
if (child->isSelected() && !child->isHidden())
|
||||
QVERIFY(sel.contains(child));
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
// Possible to select null without crashing?
|
||||
testWidget->setItemSelected(0, true);
|
||||
QVERIFY(!testWidget->isItemSelected(0));
|
||||
#endif
|
||||
|
||||
// unselect
|
||||
foreach (IntList itemPath, selectedItems) {
|
||||
@ -884,7 +886,7 @@ void tst_QTreeWidget::selectedItems()
|
||||
else
|
||||
item = item->child(index);
|
||||
}
|
||||
testWidget->setItemSelected(item, false);
|
||||
item->setSelected(false);
|
||||
}
|
||||
QCOMPARE(testWidget->selectedItems().count(), 0);
|
||||
}
|
||||
@ -1010,21 +1012,21 @@ void tst_QTreeWidget::expand()
|
||||
QTreeWidgetItem *topLevelItem = testWidget->topLevelItem(topLevelIndex);
|
||||
QTreeWidgetItem *childItem = topLevelItem->child(childIndex);
|
||||
|
||||
QVERIFY(!testWidget->isItemExpanded(topLevelItem));
|
||||
testWidget->setItemExpanded(topLevelItem, true);
|
||||
QVERIFY(testWidget->isItemExpanded(topLevelItem));
|
||||
QVERIFY(!topLevelItem->isExpanded());
|
||||
topLevelItem->setExpanded(true);
|
||||
QVERIFY(topLevelItem->isExpanded());
|
||||
|
||||
QVERIFY(!testWidget->isItemExpanded(childItem));
|
||||
testWidget->setItemExpanded(childItem, true);
|
||||
QVERIFY(testWidget->isItemExpanded(childItem));
|
||||
QVERIFY(!childItem->isExpanded());
|
||||
childItem->setExpanded(true);
|
||||
QVERIFY(childItem->isExpanded());
|
||||
|
||||
QVERIFY(testWidget->isItemExpanded(topLevelItem));
|
||||
testWidget->setItemExpanded(topLevelItem, false);
|
||||
QVERIFY(!testWidget->isItemExpanded(topLevelItem));
|
||||
QVERIFY(topLevelItem->isExpanded());
|
||||
topLevelItem->setExpanded(false);
|
||||
QVERIFY(!topLevelItem->isExpanded());
|
||||
|
||||
QVERIFY(testWidget->isItemExpanded(childItem));
|
||||
testWidget->setItemExpanded(childItem, false);
|
||||
QVERIFY(!testWidget->isItemExpanded(childItem));
|
||||
QVERIFY(childItem->isExpanded());
|
||||
childItem->setExpanded(false);
|
||||
QVERIFY(!childItem->isExpanded());
|
||||
}
|
||||
|
||||
void tst_QTreeWidget::checkState_data()
|
||||
@ -1525,7 +1527,7 @@ void tst_QTreeWidget::keyboardNavigation()
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
if (testWidget->isItemExpanded(item)) {
|
||||
if (item->isExpanded()) {
|
||||
row = 0;
|
||||
item = item->child(row);
|
||||
} else {
|
||||
@ -1538,7 +1540,7 @@ void tst_QTreeWidget::keyboardNavigation()
|
||||
break;
|
||||
case Qt::Key_Left:
|
||||
if (checkScroll) {
|
||||
QVERIFY(testWidget->isItemExpanded(item));
|
||||
QVERIFY(item->isExpanded());
|
||||
QCOMPARE(scrollBar->value(), valueBeforeClick - scrollBar->singleStep());
|
||||
}
|
||||
// windows style right will walk to the parent
|
||||
@ -1597,9 +1599,9 @@ void tst_QTreeWidget::scrollToItem()
|
||||
QCOMPARE(search->text(0), QLatin1String("111"));
|
||||
|
||||
QTreeWidgetItem *par = search->parent();
|
||||
QVERIFY(testWidget->isItemExpanded(par));
|
||||
QVERIFY(par->isExpanded());
|
||||
par = par->parent();
|
||||
QVERIFY(testWidget->isItemExpanded(par));
|
||||
QVERIFY(par->isExpanded());
|
||||
}
|
||||
|
||||
// From task #85413
|
||||
@ -2917,14 +2919,14 @@ void tst_QTreeWidget::randomExpand()
|
||||
QTreeWidgetItem *newItem1 = 0;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
newItem1 = new QTreeWidgetItem(&tree, item1);
|
||||
tree.setItemExpanded(newItem1, true);
|
||||
QCOMPARE(tree.isItemExpanded(newItem1), true);
|
||||
newItem1->setExpanded(true);
|
||||
QCOMPARE(newItem1->isExpanded(), true);
|
||||
|
||||
QTreeWidgetItem *x = new QTreeWidgetItem();
|
||||
QCOMPARE(tree.isItemExpanded(newItem1), true);
|
||||
QCOMPARE(newItem1->isExpanded(), true);
|
||||
newItem1->addChild(x);
|
||||
|
||||
QCOMPARE(tree.isItemExpanded(newItem1), true);
|
||||
QCOMPARE(newItem1->isExpanded(), true);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2937,19 +2939,19 @@ void tst_QTreeWidget::crashTest()
|
||||
|
||||
QTreeWidgetItem *item1 = new QTreeWidgetItem(tree);
|
||||
item1->setText(0, "item1");
|
||||
tree->setItemExpanded(item1, true);
|
||||
item1->setExpanded(true);
|
||||
QTreeWidgetItem *item2 = new QTreeWidgetItem(item1);
|
||||
item2->setText(0, "item2");
|
||||
|
||||
QTreeWidgetItem *item3 = new QTreeWidgetItem(tree, item1);
|
||||
item3->setText(0, "item3");
|
||||
tree->setItemExpanded(item3, true);
|
||||
item3->setExpanded(true);
|
||||
QTreeWidgetItem *item4 = new QTreeWidgetItem(item3);
|
||||
item4->setText(0, "item4");
|
||||
|
||||
QTreeWidgetItem *item5 = new QTreeWidgetItem(tree, item3);
|
||||
item5->setText(0, "item5");
|
||||
tree->setItemExpanded(item5, true);
|
||||
item5->setExpanded(true);
|
||||
QTreeWidgetItem *item6 = new QTreeWidgetItem(item5);
|
||||
item6->setText(0, "item6");
|
||||
|
||||
|
@ -95,11 +95,11 @@ void tst_QTreeWidgetItemIterator::initTestCase()
|
||||
const QString topS = QLatin1String("top") + QString::number(i);
|
||||
top->setText(0, topS);
|
||||
switch (i) {
|
||||
case 0: testWidget->setItemHidden(top, true);break;
|
||||
case 1: testWidget->setItemHidden(top, false);break;
|
||||
case 0: top->setHidden(true);break;
|
||||
case 1: top->setHidden(false);break;
|
||||
|
||||
case 2: testWidget->setItemSelected(top, true);break;
|
||||
case 3: testWidget->setItemSelected(top, false);break;
|
||||
case 2: top->setSelected(true);break;
|
||||
case 3: top->setSelected(false);break;
|
||||
|
||||
case 4: top->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);break;
|
||||
case 5: top->setFlags(Qt::ItemIsEnabled);break;
|
||||
@ -126,11 +126,11 @@ void tst_QTreeWidgetItemIterator::initTestCase()
|
||||
QTreeWidgetItem *child = new QTreeWidgetItem(top);
|
||||
child->setText(0, topS + QLatin1String(",child") + QString::number(j));
|
||||
switch (j) {
|
||||
case 0: testWidget->setItemHidden(child, true);break;
|
||||
case 1: testWidget->setItemHidden(child, false);break;
|
||||
case 0: child->setHidden(true);break;
|
||||
case 1: child->setHidden(false);break;
|
||||
|
||||
case 2: testWidget->setItemSelected(child, true);break;
|
||||
case 3: testWidget->setItemSelected(child, false);break;
|
||||
case 2: child->setSelected(true);break;
|
||||
case 3: child->setSelected(false);break;
|
||||
|
||||
case 4: child->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);break;
|
||||
case 5: child->setFlags(Qt::ItemIsEnabled);break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user