Skip to content

Conversation

Znurre
Copy link
Contributor

@Znurre Znurre commented Feb 20, 2018

This commit adds support for getting/setting itemDelegate for ListView and TreeView

@Znurre Znurre force-pushed the ListViewDelegate branch from 7663a23 to d181cfe Compare March 23, 2018 17:55
@0x6e 0x6e requested review from krake-kdab and 0x6e March 26, 2018 09:53
Copy link
Contributor

@krake-kdab krake-kdab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general an interesting change, however without any delegate to instantiate I am wondering a bit what the use case is that you have in mind


public:
explicit DeclarativeTreeViewExtension(QObject *parent = 0);
explicit DeclarativeTreeViewExtension(QObject *parent = Q_NULLPTR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general a valid change, but not related to support for delegates.
Such a cleanup should be in a separate commit and probably across classes.

#include <QToolBar>
#include <QToolButton>
#include <QTreeView>
#include <QAbstractItemDelegate>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think includes are usually in alphabetical order

// uncreatable core
qmlRegisterType<QAbstractItemModel>();
qmlRegisterType<QItemSelectionModel>();
qmlRegisterType<QAbstractItemDelegate>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QAbstractItemDelegate can not be constructed in C++, since it is abstract.
So this would need to be registered with qmlRegisterUncreatableType()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I beg to differ. It's using the qmlRegisterType overload without parameters, only to make the type known to QML.
Same thing can be seen 2 lines above for QAbstractItemModel.
Should this really be handled with qmlRegisterUncreatableType?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good point.
I guess we should change that to uncreatable type registration, in a future clean up commit, and for the other uncreatables as well

@Znurre
Copy link
Contributor Author

Znurre commented Mar 26, 2018

My use case for this is simply instantiating a custom delegate in QML and assigning it to a ListView/TreeView as delegate.

@krake-kdab
Copy link
Contributor

My use case for this is simply instantiating a custom delegate in QML and assigning it to a ListView/TreeView as delegate

A cool. We should probably add an example like that :-)

@krake-kdab krake-kdab merged commit 4c3be84 into KDABLabs:master Mar 26, 2018
Znurre added a commit to Znurre/DeclarativeWidgets that referenced this pull request Mar 29, 2018
* Add support for accessing ListView/TreeView itemDelegate
@Znurre Znurre deleted the ListViewDelegate branch March 29, 2018 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants