[Interest] MVC question (using QNetworkConfiguration/QNetworkSession)
Christian Gagneraud
chgans at gna.org
Fri Jul 19 00:38:48 CEST 2013
Hi there,
I'm building a simple GUI for evaluating QNetworkConfigurationManager,
QNetworkConfiguration and QNetworkSession.
The goal is to evaluate the usability of these 3 classes and the
performance/reactivity of the underlying network manager (connman on
GNU/Linux desktop and embedded device)
I'm running XUbuntu 13.04, later migrated to KDE.
I first used Qt-4.8.4/connman-1.10 shipped with Ubunutu, but as it
didn't work very well, I ended up using manually built Qt-5.1+ and
connman 1.16+ (I got rid of any network manager using apt-get remove).
Later I will have to run this on an embedded device (same techno as the
BeagleBone Black), ideally using the Yocto project [1] (ex OpenEmbedded).
My GUI is really simple and looks like this:
+---------------------------------------+
| manager details |
| [update] |
+-----------+---------------------------+
| | configuration details |
| conf list | |
| | [create session] |
+-----------+---------------------------+
| | session details |
| session | |
| list |[open] [close] [stop] [del]|
+-----------+---------------------------+
| |
| Logger view |
| |
+---------------------------------------+
For now, the 2 lists are bare QListView, the XXX details are views
implemented as "specialised" widgets (QFrame) and they all have a
setModel() method: managerView->setModel(manager),
configurationView->setModel(configuration), ...
And I have implemented a ConfigurationListModel to go with the list view
(SessionListModel will come later on)
I have connected
configurationListView->selectionModel()->selectionChanged() signal to do
a configurationView->setModel(), this works fine.
Now I have to deal with the fact that configurations can change their
properties, this is indicated by the manager emiting the
configurationChanged() signal. (QNetworkConfiguration are lightweight
object and don't have propertyChanged() signals)
So basically i have to do a configurationView()->setModel() when the
currently selected configuration has changed somehow.
My question is not about how to do this - this is obviously doable -,
but rather: In this kind of scenario, what is the Best Way (tm) to do
this kind of things?
Should I make my ConfigurationListModel aware of which model is selected
and emit a "ready to use" signal when the selection has changed and when
the currently selected configuration has changed? Is it a good practice
to make a ListModel aware of which model is currently selected in an
associated ListView, eg by doing view->setModel() and model->setView()?
This is a really simple app, but I would like to grab the opportunity to
learn more about Qt MVC implementation and best practices that go with it.
Thanks,
Chris
[1] https://www.yoctoproject.org/
More information about the Interest
mailing list