Improve LiveDataDock and import widget
ClosedPublic

Authored by croick on Jan 17 2019, 1:58 PM.

Details

Summary
  • settings are only applied to the element selected first in the project explorer
  • add name (editable) and source (read-only) line edit
  • optimize access to MQTT host data (reduce QMap searches)
  • disable/enable reading type options for different source types
  • distinguish MQTT source by host name and port
  • allow different LiveDataSources from the same host
Test Plan
  • create new LiveData sources (Ascii, ROOT, MQTT)
  • select several of them in the project explorer, but edit only one
  • change name in dock widget

Diff Detail

Repository
R262 LabPlot
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
croick created this revision.Jan 17 2019, 1:58 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptJan 17 2019, 1:58 PM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
croick requested review of this revision.Jan 17 2019, 1:58 PM

The dock looks like this:

src/kdefrontend/dockwidgets/LiveDataDock.cpp
1245–1246

Actually I'm not so sure, what m_previousMQTTClient (formerly m_clients[m_previousMQTTClient->clientHostName()]) is supposed to do. Could someone clarify?

asemke added a subscriber: asemke.Jan 18 2019, 7:37 AM
asemke added inline comments.
src/kdefrontend/GuiObserver.cpp
573

why not to simply

auto* client = qobject_cast<MQTTClient*>(selectedAspects.first());
m_mainWindow->m_liveDataDock->setMQTTClient(cleint)

?

sgerlach added inline comments.
src/kdefrontend/GuiObserver.cpp
582–583

why not to simply (see above)

593–594

why not to simply (see above)

609

why not to simply (see above)

sgerlach added inline comments.Jan 19 2019, 11:24 AM
src/kdefrontend/dockwidgets/LiveDataDock.cpp
396

m_mqttClient is only defined if HAVE_MQTT

So would you agree, that qobject_cast is not required, since the class name is checked anyway?
The result of the cast isn't checked anywhere, so one could just use static_cast (and simply take the first element in the list).

src/kdefrontend/dockwidgets/LiveDataDock.cpp
396

Thanks, of course.

croick updated this revision to Diff 50383.Jan 27 2019, 3:00 PM
  • suppose that casting is possible, add ifdef
croick marked 6 inline comments as done.Jan 27 2019, 3:02 PM
asemke added inline comments.Jan 29 2019, 8:21 PM
src/kdefrontend/MainWin.cpp
1923

this piece of code you removed now made sure we don't connect to the same broker twice. Here we also showed an message to the user to make this clear. To me it make sense. We should maybe adapt this logic and extend it to other data sources, too. Was there any reason to remove this logic? You partially moved this logic to LiveDataDock::setMQTTClient(), right?

croick updated this revision to Diff 50544.Jan 30 2019, 9:52 AM
  • re-insert check for existing hosts
croick marked an inline comment as done.Jan 30 2019, 9:53 AM
croick added inline comments.
src/kdefrontend/MainWin.cpp
1923

Initially I removed this, because there was no check for the port, which makes this check exclude more hosts than required, but then I added that logic in the dock widget.
In my opinion it should be up to the user to manage the number of distinct clients. There might be a reason to split them. I would show a warning at most, but let the user decide if it still is what was intended.

On the other hand, that should not be part of this patch. So I will take it back in (including a check for the port number).

asemke accepted this revision.Feb 2 2019, 7:27 AM
asemke added inline comments.
src/kdefrontend/dockwidgets/LiveDataDock.cpp
1245–1246

I asked Ferencz, who contributed this code. The idea here was disconnect from the slot if we are going to connect to a new and different host. But the check seems to be wrong here. Also, we disallow in MainWin::newLiveDataSourceActionTriggered() having multiple mqtt live sources having the same host, if I see it correctly. Let's adrdess this outside of this patch.

This revision is now accepted and ready to land.Feb 2 2019, 7:27 AM
This revision was automatically updated to reflect the committed changes.
croick marked an inline comment as done.