QTreeWidget: mark is/setFirstItemColumnSpanned() as deprecated
Deprecate the QTreeWidget functions is/setFirstItemColumnSpanned() to stay in sync with the other deprecated functions (selected/expanded/hidden) so they can get removed in Qt6. Also add a small unit test for them. Change-Id: Ie1cb5d7163c2d56d653c21e841ccaf7d38569787 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
f56ca2c4f6
commit
e56c79dc9d
@ -1127,6 +1127,14 @@ bool QTreeWidgetItem::isExpanded() const
|
|||||||
|
|
||||||
\sa isFirstColumnSpanned()
|
\sa isFirstColumnSpanned()
|
||||||
*/
|
*/
|
||||||
|
void QTreeWidgetItem::setFirstColumnSpanned(bool span)
|
||||||
|
{
|
||||||
|
const QTreeModel *model = treeModel();
|
||||||
|
if (!model || this == model->headerItem)
|
||||||
|
return; // We can't set the header items to spanning
|
||||||
|
const QModelIndex index = model->index(this, 0);
|
||||||
|
view->setFirstColumnSpanned(index.row(), index.parent(), span);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn bool QTreeWidgetItem::isFirstColumnSpanned() const
|
\fn bool QTreeWidgetItem::isFirstColumnSpanned() const
|
||||||
@ -1136,6 +1144,14 @@ bool QTreeWidgetItem::isExpanded() const
|
|||||||
|
|
||||||
\sa setFirstColumnSpanned()
|
\sa setFirstColumnSpanned()
|
||||||
*/
|
*/
|
||||||
|
bool QTreeWidgetItem::isFirstColumnSpanned() const
|
||||||
|
{
|
||||||
|
const QTreeModel *model = treeModel();
|
||||||
|
if (!model || this == model->headerItem)
|
||||||
|
return false;
|
||||||
|
const QModelIndex index = model->index(this, 0);
|
||||||
|
return view->isFirstColumnSpanned(index.row(), index.parent());
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QString QTreeWidgetItem::text(int column) const
|
\fn QString QTreeWidgetItem::text(int column) const
|
||||||
@ -3230,7 +3246,6 @@ void QTreeWidget::setItemExpanded(const QTreeWidgetItem *item, bool expand)
|
|||||||
if (item && item->treeWidget() == this)
|
if (item && item->treeWidget() == this)
|
||||||
const_cast<QTreeWidgetItem*>(item)->setExpanded(expand);
|
const_cast<QTreeWidgetItem*>(item)->setExpanded(expand);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.3
|
\since 4.3
|
||||||
@ -3239,14 +3254,14 @@ void QTreeWidget::setItemExpanded(const QTreeWidgetItem *item, bool expand)
|
|||||||
otherwise returns \c false.
|
otherwise returns \c false.
|
||||||
|
|
||||||
\sa setFirstItemColumnSpanned()
|
\sa setFirstItemColumnSpanned()
|
||||||
|
|
||||||
|
\obsolete
|
||||||
|
|
||||||
|
This function is deprecated. Use \l{QTreeWidgetItem::isFirstColumnSpanned()} instead.
|
||||||
*/
|
*/
|
||||||
bool QTreeWidget::isFirstItemColumnSpanned(const QTreeWidgetItem *item) const
|
bool QTreeWidget::isFirstItemColumnSpanned(const QTreeWidgetItem *item) const
|
||||||
{
|
{
|
||||||
Q_D(const QTreeWidget);
|
return ((item && item->treeWidget() == this) ? item->isFirstColumnSpanned() : false);
|
||||||
if (item == d->treeModel()->headerItem)
|
|
||||||
return false; // We can't set the header items to spanning
|
|
||||||
const QModelIndex index = d->index(item);
|
|
||||||
return isFirstColumnSpanned(index.row(), index.parent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -3256,15 +3271,17 @@ bool QTreeWidget::isFirstItemColumnSpanned(const QTreeWidgetItem *item) const
|
|||||||
otherwise the item will show one section per column.
|
otherwise the item will show one section per column.
|
||||||
|
|
||||||
\sa isFirstItemColumnSpanned()
|
\sa isFirstItemColumnSpanned()
|
||||||
|
|
||||||
|
\obsolete
|
||||||
|
|
||||||
|
This function is deprecated. Use \l{QTreeWidgetItem::setFirstColumnSpanned()} instead.
|
||||||
*/
|
*/
|
||||||
void QTreeWidget::setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span)
|
void QTreeWidget::setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span)
|
||||||
{
|
{
|
||||||
Q_D(QTreeWidget);
|
if (item && item->treeWidget() == this)
|
||||||
if (item == d->treeModel()->headerItem)
|
const_cast<QTreeWidgetItem*>(item)->setFirstColumnSpanned(span);
|
||||||
return; // We can't set header items to spanning
|
|
||||||
const QModelIndex index = d->index(item);
|
|
||||||
setFirstColumnSpanned(index.row(), index.parent(), span);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.3
|
\since 4.3
|
||||||
|
@ -88,8 +88,8 @@ public:
|
|||||||
void setExpanded(bool expand);
|
void setExpanded(bool expand);
|
||||||
bool isExpanded() const;
|
bool isExpanded() const;
|
||||||
|
|
||||||
inline void setFirstColumnSpanned(bool span);
|
void setFirstColumnSpanned(bool span);
|
||||||
inline bool isFirstColumnSpanned() const;
|
bool isFirstColumnSpanned() const;
|
||||||
|
|
||||||
inline void setDisabled(bool disabled);
|
inline void setDisabled(bool disabled);
|
||||||
inline bool isDisabled() const;
|
inline bool isDisabled() const;
|
||||||
@ -335,10 +335,12 @@ public:
|
|||||||
bool isItemExpanded(const QTreeWidgetItem *item) const;
|
bool isItemExpanded(const QTreeWidgetItem *item) const;
|
||||||
QT_DEPRECATED_X ("Use QTreeWidgetItem::setExpanded() instead")
|
QT_DEPRECATED_X ("Use QTreeWidgetItem::setExpanded() instead")
|
||||||
void setItemExpanded(const QTreeWidgetItem *item, bool expand);
|
void setItemExpanded(const QTreeWidgetItem *item, bool expand);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
QT_DEPRECATED_X ("Use QTreeWidgetItem::isFirstColumnSpanned() instead")
|
||||||
bool isFirstItemColumnSpanned(const QTreeWidgetItem *item) const;
|
bool isFirstItemColumnSpanned(const QTreeWidgetItem *item) const;
|
||||||
|
QT_DEPRECATED_X ("Use QTreeWidgetItem::setFirstColumnSpanned() instead")
|
||||||
void setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span);
|
void setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span);
|
||||||
|
#endif
|
||||||
|
|
||||||
QTreeWidgetItem *itemAbove(const QTreeWidgetItem *item) const;
|
QTreeWidgetItem *itemAbove(const QTreeWidgetItem *item) const;
|
||||||
QTreeWidgetItem *itemBelow(const QTreeWidgetItem *item) const;
|
QTreeWidgetItem *itemBelow(const QTreeWidgetItem *item) const;
|
||||||
@ -423,12 +425,6 @@ inline QTreeWidgetItem *QTreeWidget::itemAt(int ax, int ay) const
|
|||||||
inline void QTreeWidget::setHeaderLabel(const QString &alabel)
|
inline void QTreeWidget::setHeaderLabel(const QString &alabel)
|
||||||
{ setHeaderLabels(QStringList(alabel)); }
|
{ setHeaderLabels(QStringList(alabel)); }
|
||||||
|
|
||||||
inline void QTreeWidgetItem::setFirstColumnSpanned(bool aspan)
|
|
||||||
{ if (view) view->setFirstItemColumnSpanned(this, aspan); }
|
|
||||||
|
|
||||||
inline bool QTreeWidgetItem::isFirstColumnSpanned() const
|
|
||||||
{ return (view ? view->isFirstItemColumnSpanned(this) : false); }
|
|
||||||
|
|
||||||
inline void QTreeWidgetItem::setDisabled(bool disabled)
|
inline void QTreeWidgetItem::setDisabled(bool disabled)
|
||||||
{ setFlags(disabled ? (flags() & ~Qt::ItemIsEnabled) : flags() | Qt::ItemIsEnabled); }
|
{ setFlags(disabled ? (flags() & ~Qt::ItemIsEnabled) : flags() | Qt::ItemIsEnabled); }
|
||||||
|
|
||||||
|
@ -140,6 +140,7 @@ private slots:
|
|||||||
void expandAndCallapse();
|
void expandAndCallapse();
|
||||||
void itemData();
|
void itemData();
|
||||||
void setDisabled();
|
void setDisabled();
|
||||||
|
void setSpanned();
|
||||||
void removeSelectedItem();
|
void removeSelectedItem();
|
||||||
void removeCurrentItem();
|
void removeCurrentItem();
|
||||||
void removeCurrentItem_task186451();
|
void removeCurrentItem_task186451();
|
||||||
@ -2818,6 +2819,28 @@ void tst_QTreeWidget::setDisabled()
|
|||||||
QCOMPARE(takenChildren.items[1]->isDisabled(), false);
|
QCOMPARE(takenChildren.items[1]->isDisabled(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QTreeWidget::setSpanned()
|
||||||
|
{
|
||||||
|
QTreeWidget w;
|
||||||
|
QTreeWidgetItem *i1 = new QTreeWidgetItem();
|
||||||
|
QScopedPointer<QTreeWidgetItem> i2(new QTreeWidgetItem());
|
||||||
|
|
||||||
|
QTreeWidgetItem *top = new QTreeWidgetItem(&w);
|
||||||
|
top->addChild(i1);
|
||||||
|
|
||||||
|
top->setFirstColumnSpanned(true);
|
||||||
|
QCOMPARE(top->isFirstColumnSpanned(), true);
|
||||||
|
QCOMPARE(i1->isFirstColumnSpanned(), false);
|
||||||
|
QCOMPARE(i2->isFirstColumnSpanned(), false);
|
||||||
|
|
||||||
|
top->setFirstColumnSpanned(false);
|
||||||
|
i1->setFirstColumnSpanned(true);
|
||||||
|
i2->setFirstColumnSpanned(true);
|
||||||
|
QCOMPARE(top->isFirstColumnSpanned(), false);
|
||||||
|
QCOMPARE(i1->isFirstColumnSpanned(), true);
|
||||||
|
QCOMPARE(i2->isFirstColumnSpanned(), false);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QTreeWidget::removeSelectedItem()
|
void tst_QTreeWidget::removeSelectedItem()
|
||||||
{
|
{
|
||||||
const QScopedPointer <QTreeWidget> w(new QTreeWidget);
|
const QScopedPointer <QTreeWidget> w(new QTreeWidget);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user