9 #include <basedevice.h>
14 #include <QPushButton>
16 #include <QButtonGroup>
17 #include <QSocketNotifier>
29 #include <KLocalizedString>
30 #include <KMessageBox>
35 #include "skyobjects/skyobject.h"
36 #include "dialogs/timedialog.h"
37 #include "geolocation.h"
39 #include "indiproperty.h"
40 #include "indidevice.h"
41 #include "indigroup.h"
42 #include "indielement.h"
44 #include <indi_debug.h>
46 const char *libindi_strings_context =
"string from libindi, used in the config dialog";
54 m_ClientManager = in_cm;
56 m_Name = m_BaseDevice->getDeviceName();
65 msgST_w->setReadOnly(
true);
68 deviceVBox->addWidget(groupContainer);
69 deviceVBox->addWidget(msgST_w);
70 deviceVBox->setStretchFactor(0, 2);
75 bool INDI_D::buildProperty(INDI::Property prop)
80 QString groupName(prop.getGroupName());
82 if (prop.getDeviceName() != m_Name)
85 INDI_G *pg = getGroup(groupName);
89 pg =
new INDI_G(
this, groupName);
90 groupsList.append(pg);
91 groupContainer->addTab(pg,
i18nc(libindi_strings_context, groupName.toUtf8()));
94 return pg->addProperty(prop);
98 bool INDI_D::removeProperty(INDI::Property prop)
103 QString groupName(prop->getGroupName());
105 if (strcmp(prop->getDeviceName(), m_BaseDevice->getDeviceName()))
114 INDI_G *pg = getGroup(groupName);
119 bool removeResult = pg->removeProperty(prop->getName());
121 if (pg->size() == 0 && removeResult)
124 groupContainer->removeTab(groupsList.indexOf(pg));
125 groupsList.removeOne(pg);
133 bool INDI_D::removeProperty(
const QString &device,
const QString &name)
135 if (device != m_Name)
138 for (
auto &oneGroup : groupsList)
140 for (
auto &oneProperty : oneGroup->getProperties())
142 if (name == oneProperty->getName())
144 bool rc = oneGroup->removeProperty(name);
145 if (oneGroup->size() == 0)
147 int index = groupsList.indexOf(oneGroup);
148 groupContainer->removeTab(index);
149 delete groupsList.takeAt(index);
159 bool INDI_D::updateSwitchGUI(ISwitchVectorProperty *svp)
161 INDI_P *guiProp =
nullptr;
164 if (m_Name != svp->device)
167 for (
const auto &pg : groupsList)
169 if ((guiProp = pg->getProperty(propName)) !=
nullptr)
173 if (guiProp ==
nullptr || guiProp->isRegistered() ==
false)
176 guiProp->updateStateLED();
178 if (guiProp->getGUIType() == PG_MENU)
179 guiProp->updateMenuGUI();
182 for (
const auto &lp : guiProp->getElements())
189 bool INDI_D::updateTextGUI(ITextVectorProperty *tvp)
191 INDI_P *guiProp =
nullptr;
194 if (m_Name != tvp->device)
197 for (
const auto &pg : groupsList)
199 INDI_P *
const p = pg->getProperty(propName);
207 if (guiProp ==
nullptr)
210 guiProp->updateStateLED();
212 for (
const auto &lp : guiProp->getElements())
218 bool INDI_D::updateNumberGUI(INumberVectorProperty *nvp)
220 INDI_P *guiProp =
nullptr;
223 if (m_Name != nvp->device)
226 for (
const auto &pg : groupsList)
228 INDI_P *
const p = pg->getProperty(propName);
236 if (guiProp ==
nullptr)
239 guiProp->updateStateLED();
241 for (
const auto &lp : guiProp->getElements())
247 bool INDI_D::updateLightGUI(ILightVectorProperty *lvp)
249 INDI_P *guiProp =
nullptr;
252 if (m_Name != lvp->device)
255 for (
const auto &pg : groupsList)
257 INDI_P *
const p = pg->getProperty(propName);
265 if (guiProp ==
nullptr)
268 guiProp->updateStateLED();
270 for (
const auto &lp : guiProp->getElements())
276 bool INDI_D::updateBLOBGUI(IBLOB *bp)
278 INDI_P *guiProp =
nullptr;
279 QString propName(bp->bvp->name);
281 if (m_Name != bp->bvp->device)
284 for (
const auto &pg : groupsList)
286 INDI_P *
const p = pg->getProperty(propName);
294 if (guiProp ==
nullptr)
297 guiProp->updateStateLED();
302 void INDI_D::updateMessageLog(INDI::BaseDevice *idv,
int messageID)
304 if (idv != m_BaseDevice)
318 qCDebug(KSTARS_INDI) << idv->getDeviceName() <<
":" <<
message.
mid(21);
322 if (Options::showINDIMessages())
325 msgST_w->ensureCursorVisible();
326 msgST_w->insertHtml(
i18nc(
"Message shown in INDI control panel",
"%1", formatted));
327 msgST_w->insertPlainText(
"\n");
330 msgST_w->setTextCursor(c);
332 qCInfo(KSTARS_INDI) << idv->getDeviceName() <<
": " <<
message.
mid(21);
343 for (
const auto &pg : groupsList)
345 if (pg->getName() == groupName)
352 void INDI_D::clearMessageLog()