QAbstractItemView: add isPersistentEditorOpen()
[ChangeLog][QtWidgets][QAbstractItemView/QTreeWidget/QTableWidget/QListWidget] Added isPersistentEditorOpen(). Task-number: QTBUG-61139 Change-Id: I74997d9626812fed83591d32c503680575ec0f7c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
ab420484e7
commit
4088f4ce4d
@ -3138,7 +3138,7 @@ int QAbstractItemView::sizeHintForColumn(int column) const
|
||||
Opens a persistent editor on the item at the given \a index.
|
||||
If no editor exists, the delegate will create a new editor.
|
||||
|
||||
\sa closePersistentEditor()
|
||||
\sa closePersistentEditor(), isPersistentEditorOpen()
|
||||
*/
|
||||
void QAbstractItemView::openPersistentEditor(const QModelIndex &index)
|
||||
{
|
||||
@ -3157,7 +3157,7 @@ void QAbstractItemView::openPersistentEditor(const QModelIndex &index)
|
||||
/*!
|
||||
Closes the persistent editor for the item at the given \a index.
|
||||
|
||||
\sa openPersistentEditor()
|
||||
\sa openPersistentEditor(), isPersistentEditorOpen()
|
||||
*/
|
||||
void QAbstractItemView::closePersistentEditor(const QModelIndex &index)
|
||||
{
|
||||
@ -3171,6 +3171,19 @@ void QAbstractItemView::closePersistentEditor(const QModelIndex &index)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.10
|
||||
|
||||
Returns whether a persistent editor is open for the item at index \a index.
|
||||
|
||||
\sa openPersistentEditor(), closePersistentEditor()
|
||||
*/
|
||||
bool QAbstractItemView::isPersistentEditorOpen(const QModelIndex &index) const
|
||||
{
|
||||
Q_D(const QAbstractItemView);
|
||||
return d->editorForIndex(index).widget;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.1
|
||||
|
||||
|
@ -213,6 +213,7 @@ public:
|
||||
|
||||
void openPersistentEditor(const QModelIndex &index);
|
||||
void closePersistentEditor(const QModelIndex &index);
|
||||
bool isPersistentEditorOpen(const QModelIndex &index) const;
|
||||
|
||||
void setIndexWidget(const QModelIndex &index, QWidget *widget);
|
||||
QWidget *indexWidget(const QModelIndex &index) const;
|
||||
|
@ -1617,7 +1617,7 @@ void QListWidget::editItem(QListWidgetItem *item)
|
||||
Opens an editor for the given \a item. The editor remains open after
|
||||
editing.
|
||||
|
||||
\sa closePersistentEditor()
|
||||
\sa closePersistentEditor(), isPersistentEditorOpen()
|
||||
*/
|
||||
void QListWidget::openPersistentEditor(QListWidgetItem *item)
|
||||
{
|
||||
@ -1629,7 +1629,7 @@ void QListWidget::openPersistentEditor(QListWidgetItem *item)
|
||||
/*!
|
||||
Closes the persistent editor for the given \a item.
|
||||
|
||||
\sa openPersistentEditor()
|
||||
\sa openPersistentEditor(), isPersistentEditorOpen()
|
||||
*/
|
||||
void QListWidget::closePersistentEditor(QListWidgetItem *item)
|
||||
{
|
||||
@ -1638,6 +1638,20 @@ void QListWidget::closePersistentEditor(QListWidgetItem *item)
|
||||
QAbstractItemView::closePersistentEditor(index);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.10
|
||||
|
||||
Returns whether a persistent editor is open for item \a item.
|
||||
|
||||
\sa openPersistentEditor(), closePersistentEditor()
|
||||
*/
|
||||
bool QListWidget::isPersistentEditorOpen(QListWidgetItem *item) const
|
||||
{
|
||||
Q_D(const QListWidget);
|
||||
const QModelIndex index = d->listModel()->index(item);
|
||||
return QAbstractItemView::isPersistentEditorOpen(index);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.1
|
||||
|
||||
|
@ -240,6 +240,8 @@ public:
|
||||
void editItem(QListWidgetItem *item);
|
||||
void openPersistentEditor(QListWidgetItem *item);
|
||||
void closePersistentEditor(QListWidgetItem *item);
|
||||
using QAbstractItemView::isPersistentEditorOpen;
|
||||
bool isPersistentEditorOpen(QListWidgetItem *item) const;
|
||||
|
||||
QWidget *itemWidget(QListWidgetItem *item) const;
|
||||
void setItemWidget(QListWidgetItem *item, QWidget *widget);
|
||||
|
@ -2221,7 +2221,7 @@ void QTableWidget::editItem(QTableWidgetItem *item)
|
||||
/*!
|
||||
Opens an editor for the give \a item. The editor remains open after editing.
|
||||
|
||||
\sa closePersistentEditor()
|
||||
\sa closePersistentEditor(), isPersistentEditorOpen()
|
||||
*/
|
||||
void QTableWidget::openPersistentEditor(QTableWidgetItem *item)
|
||||
{
|
||||
@ -2235,7 +2235,7 @@ void QTableWidget::openPersistentEditor(QTableWidgetItem *item)
|
||||
/*!
|
||||
Closes the persistent editor for \a item.
|
||||
|
||||
\sa openPersistentEditor()
|
||||
\sa openPersistentEditor(), isPersistentEditorOpen()
|
||||
*/
|
||||
void QTableWidget::closePersistentEditor(QTableWidgetItem *item)
|
||||
{
|
||||
@ -2246,6 +2246,20 @@ void QTableWidget::closePersistentEditor(QTableWidgetItem *item)
|
||||
QAbstractItemView::closePersistentEditor(index);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.10
|
||||
|
||||
Returns whether a persistent editor is open for item \a item.
|
||||
|
||||
\sa openPersistentEditor(), closePersistentEditor()
|
||||
*/
|
||||
bool QTableWidget::isPersistentEditorOpen(QTableWidgetItem *item) const
|
||||
{
|
||||
Q_D(const QTableWidget);
|
||||
const QModelIndex index = d->tableModel()->index(item);
|
||||
return QAbstractItemView::isPersistentEditorOpen(index);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.1
|
||||
|
||||
|
@ -263,6 +263,8 @@ public:
|
||||
void editItem(QTableWidgetItem *item);
|
||||
void openPersistentEditor(QTableWidgetItem *item);
|
||||
void closePersistentEditor(QTableWidgetItem *item);
|
||||
using QAbstractItemView::isPersistentEditorOpen;
|
||||
bool isPersistentEditorOpen(QTableWidgetItem *item) const;
|
||||
|
||||
QWidget *cellWidget(int row, int column) const;
|
||||
void setCellWidget(int row, int column, QWidget *widget);
|
||||
|
@ -2907,7 +2907,7 @@ void QTreeWidget::editItem(QTreeWidgetItem *item, int column)
|
||||
/*!
|
||||
Opens a persistent editor for the \a item in the given \a column.
|
||||
|
||||
\sa closePersistentEditor()
|
||||
\sa closePersistentEditor(), isPersistentEditorOpen()
|
||||
*/
|
||||
|
||||
void QTreeWidget::openPersistentEditor(QTreeWidgetItem *item, int column)
|
||||
@ -2922,7 +2922,7 @@ void QTreeWidget::openPersistentEditor(QTreeWidgetItem *item, int column)
|
||||
This function has no effect if no persistent editor is open for this
|
||||
combination of item and column.
|
||||
|
||||
\sa openPersistentEditor()
|
||||
\sa openPersistentEditor(), isPersistentEditorOpen()
|
||||
*/
|
||||
|
||||
void QTreeWidget::closePersistentEditor(QTreeWidgetItem *item, int column)
|
||||
@ -2931,6 +2931,21 @@ void QTreeWidget::closePersistentEditor(QTreeWidgetItem *item, int column)
|
||||
QAbstractItemView::closePersistentEditor(d->index(item, column));
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.10
|
||||
|
||||
Returns whether a persistent editor is open for item \a item in
|
||||
column \a column.
|
||||
|
||||
\sa openPersistentEditor(), closePersistentEditor()
|
||||
*/
|
||||
|
||||
bool QTreeWidget::isPersistentEditorOpen(QTreeWidgetItem *item, int column) const
|
||||
{
|
||||
Q_D(const QTreeWidget);
|
||||
return QAbstractItemView::isPersistentEditorOpen(d->index(item, column));
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.1
|
||||
|
||||
|
@ -300,6 +300,8 @@ public:
|
||||
void editItem(QTreeWidgetItem *item, int column = 0);
|
||||
void openPersistentEditor(QTreeWidgetItem *item, int column = 0);
|
||||
void closePersistentEditor(QTreeWidgetItem *item, int column = 0);
|
||||
using QAbstractItemView::isPersistentEditorOpen;
|
||||
bool isPersistentEditorOpen(QTreeWidgetItem *item, int column = 0) const;
|
||||
|
||||
QWidget *itemWidget(QTreeWidgetItem *item, int column) const;
|
||||
void setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget);
|
||||
|
@ -626,7 +626,9 @@ void tst_QAbstractItemView::rowDelegate()
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||
|
||||
QModelIndex index = model.index(3, 0);
|
||||
QVERIFY(!view.isPersistentEditorOpen(index));
|
||||
view.openPersistentEditor(index);
|
||||
QVERIFY(view.isPersistentEditorOpen(index));
|
||||
QWidget *w = view.indexWidget(index);
|
||||
QVERIFY(w);
|
||||
QCOMPARE(w->metaObject()->className(), "QWidget");
|
||||
@ -646,7 +648,9 @@ void tst_QAbstractItemView::columnDelegate()
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||
|
||||
QModelIndex index = model.index(0, 3);
|
||||
QVERIFY(!view.isPersistentEditorOpen(index));
|
||||
view.openPersistentEditor(index);
|
||||
QVERIFY(view.isPersistentEditorOpen(index));
|
||||
QWidget *w = view.indexWidget(index);
|
||||
QVERIFY(w);
|
||||
QCOMPARE(w->metaObject()->className(), "QWidget");
|
||||
|
Loading…
x
Reference in New Issue
Block a user