[Interest] MVC question (using QNetworkConfiguration/QNetworkSession)

Christian Gagneraud chgans at gna.org
Tue Jul 23 03:31:24 CEST 2013


On 22/07/13 12:50, Aaron McCarthy wrote:
> Hi,
>
> On Fri, 19 Jul 2013 10:38:48 AM Christian Gagneraud wrote:
>> 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?
>
> Your ConfigurationListModel should update in repose to the
> configuration changed signals from QNetworkConfigurationManager. You
> should not need to change the model assigned to the
> configurationView. Instead in response to the signals:
>
> configurationAdded() add a new row to your model
> (beginInsertRows()/endInsertRows())
>
> configurationRemoved() remove a row from your model
> (beginRemoveRows()/endRemoveRows())
>
> configurationChanged() update row and emit dataChanged() signal.

Thanks Aaron, I was missing this one.

Chris

>
> Cheers,
>
> --
>
> Aaron McCarthy
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>




More information about the Interest mailing list