mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-24 19:02:51 +00:00
33 lines
2 KiB
Text
33 lines
2 KiB
Text
|
|
This example application shows various ways of using the EntityTreeModel.
|
|
|
|
Each tab shows a different widget which might form part of an application. You will need to
|
|
read the code to understand how things work. Generally, things are clicked together by
|
|
creating specific proxy models to achieve a particular goal. To make collections checkable, for example,
|
|
the CheckableItemProxyModel is used. See tab6widget and checkable2.
|
|
|
|
Most tabs use an EntityTreeWidget. This widget is purely for code sharing between the widgets,
|
|
and for providing UI to users to configure the EntityTreeModel wrapped inside it. The EntityTreeWidget
|
|
has an init method which is called after construction and which calls virtual methods. Each tab has a
|
|
subclass of it for specialization, which practically means creating and configuring proxy models on
|
|
a tab specific basis. Read the code for more.
|
|
|
|
It is important to note that the EntityTreeWidget enables code sharing and test orientated ui such as
|
|
changing the fetched mimetypes. It is not something that should be used in applications though. It might
|
|
reduce clarity about how things fit together until you read the code of it. tab6widget and checkable2 do the
|
|
same thing, but checkable2 does not use the EntityTreeWidget. checkable2 is more readable if you want to see
|
|
how to connect the multiple proxies together with setSourceModel. Read the code and compare them to figure out
|
|
how to use the ideas implemented in the other widgets.
|
|
|
|
Note also that a proxy might not normally be visible but can be put into a view at any time to see its
|
|
contents. A debugging technique is to create a QTreeView on the heap without a parent and show it. It
|
|
will then be a 'toplevel' window showing the contents.
|
|
|
|
QTreeView *debugView = new QTreeView(); // No parent!
|
|
debugView->setModel(modelIWanToSee);
|
|
debugView->show();
|
|
|
|
This technique can be used to debug any kde pim application.
|
|
|
|
Anyone who wants an excuse to read and understand this stuff is encouraged to rename the files from
|
|
tab<number>widget to something more descriptive.
|