• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • indi
indidevice.cpp
Go to the documentation of this file.
1 /* GUI Device Manager
2  Copyright (C) 2012 Jasem Mutlaq (mutlaqja AT ikarustech DOT com)
3 
4  This application is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  */
10 
11 
12 #include <zlib.h>
13 #include <indicom.h>
14 #include <base64.h>
15 #include <basedevice.h>
16 #include <indiproperty.h>
17 
18 #include <QFrame>
19 #include <QCheckBox>
20 #include <QLabel>
21 #include <QPushButton>
22 #include <QLayout>
23 #include <QButtonGroup>
24 #include <QSocketNotifier>
25 #include <QDateTime>
26 #include <QSplitter>
27 
28 
29 #include <kled.h>
30 #include <klineedit.h>
31 #include <kpushbutton.h>
32 #include <klocale.h>
33 #include <kmessagebox.h>
34 #include <kdebug.h>
35 #include <kcombobox.h>
36 #include <knuminput.h>
37 #include <kstatusbar.h>
38 #include <kmenu.h>
39 #include <kvbox.h>
40 #include <ktabwidget.h>
41 #include <ktextedit.h>
42 
43 #include "kstars.h"
44 #include "skymap.h"
45 #include "skyobjects/skyobject.h"
46 #include "dialogs/timedialog.h"
47 #include "geolocation.h"
48 
49 #include "indiproperty.h"
50 #include "indidevice.h"
51 #include "indigroup.h"
52 #include "indielement.h"
53 
54 const char *libindi_strings_context = "string from libindi, used in the config dialog";
55 
56 INDI_D::INDI_D(GUIManager *in_manager, INDI::BaseDevice *in_dv, ClientManager *in_cm) : KDialog( 0 )
57  {
58 
59  guiManager = in_manager;
60  dv = in_dv;
61  clientManager = in_cm;
62 
63  deviceVBox = new QSplitter();
64  deviceVBox->setOrientation(Qt::Vertical);
65 
66  groupContainer = new KTabWidget();
67 
68  msgST_w = new KTextEdit();
69  msgST_w->setReadOnly(true);
70 
71 
72  deviceVBox->addWidget(groupContainer);
73  deviceVBox->addWidget(msgST_w);
74 
75  //parent->mainTabWidget->addTab(deviceVBox, label);
76 }
77 
78 bool INDI_D::buildProperty(INDI::Property * prop)
79 {
80  QString groupName(prop->getGroupName());
81 
82  if (strcmp(prop->getDeviceName(), dv->getDeviceName()))
83  {
84  // qDebug() << "Ignoring property " << prop->getName() << " for device " << prop->getgetDeviceName() << " because our deviec is "
85  // << dv->getDeviceName() << endl;
86  return false;
87  }
88 
89  // qDebug() << "Received new property " << prop->getName() << " for our device " << dv->getDeviceName() << endl;
90 
91  INDI_G * pg = getGroup(groupName);
92 
93  if (pg == NULL)
94  {
95  pg = new INDI_G(this, groupName);
96  groupsList.append(pg);
97  groupContainer->addTab(pg->getContainer(), i18nc(libindi_strings_context, groupName.toUtf8()));
98  }
99 
100  return pg->addProperty(prop);
101 
102 }
103 
104 bool INDI_D::removeProperty(INDI::Property * prop)
105 {
106  if (prop == NULL)
107  return false;
108 
109  QString groupName(prop->getGroupName());
110 
111  if (strcmp(prop->getDeviceName(), dv->getDeviceName()))
112  {
113  // qDebug() << "Ignoring property " << prop->getName() << " for device " << prop->getgetDeviceName() << " because our deviec is "
114  // << dv->getDeviceName() << endl;
115  return false;
116  }
117 
118  // qDebug() << "Received new property " << prop->getName() << " for our device " << dv->getDeviceName() << endl;
119 
120  INDI_G * pg = getGroup(groupName);
121 
122  if (pg == NULL)
123  return false;
124 
125  bool removeResult = pg->removeProperty(prop->getName());
126 
127  if (pg->size() ==0 && removeResult)
128  {
129  //qDebug() << "Removing tab for group " << pg->getName() << " with an index of " << groupsList.indexOf(pg) << endl;
130  groupContainer->removeTab(groupsList.indexOf(pg));
131  groupsList.removeOne(pg);
132  delete (pg);
133  }
134 
135  return removeResult;
136 
137 }
138 
139 bool INDI_D::updateSwitchGUI(ISwitchVectorProperty *svp)
140 {
141  INDI_P *guiProp = NULL;
142  QString propName(svp->name);
143 
144  if (strcmp(svp->device, dv->getDeviceName()))
145  return false;
146 
147  foreach(INDI_G *pg, groupsList)
148  {
149  if ( (guiProp = pg->getProperty(propName)) != NULL)
150  break;
151  }
152 
153  if (guiProp == NULL)
154  return false;
155 
156  guiProp->updateStateLED();
157 
158  if (guiProp->getGUIType() == PG_MENU)
159  guiProp->updateMenuGUI();
160  else
161  {
162  foreach(INDI_E *lp, guiProp->getElements())
163  lp->syncSwitch();
164  }
165 
166  return true;
167 }
168 
169 bool INDI_D::updateTextGUI(ITextVectorProperty *tvp)
170 {
171  INDI_P *guiProp = NULL;
172  QString propName(tvp->name);
173 
174  if (strcmp(tvp->device, dv->getDeviceName()))
175  return false;
176 
177  foreach(INDI_G *pg, groupsList)
178  {
179  if ( (guiProp = pg->getProperty(propName)) != NULL)
180  break;
181  }
182 
183  if (guiProp == NULL)
184  return false;
185 
186  guiProp->updateStateLED();
187 
188  foreach(INDI_E *lp, guiProp->getElements())
189  lp->syncText();
190 
191  return true;
192 }
193 
194 bool INDI_D::updateNumberGUI (INumberVectorProperty *nvp)
195 {
196  INDI_P *guiProp = NULL;
197  QString propName(nvp->name);
198 
199  if (strcmp(nvp->device, dv->getDeviceName()))
200  return false;
201 
202  foreach(INDI_G *pg, groupsList)
203  {
204  if ( (guiProp = pg->getProperty(propName)) != NULL)
205  break;
206  }
207 
208  if (guiProp == NULL)
209  return false;
210 
211  guiProp->updateStateLED();
212 
213  foreach(INDI_E *lp, guiProp->getElements())
214  lp->syncNumber();
215 
216  return true;
217 
218 }
219 
220 bool INDI_D::updateLightGUI (ILightVectorProperty *lvp)
221 {
222  INDI_P *guiProp = NULL;
223  QString propName(lvp->name);
224 
225  if (strcmp(lvp->device, dv->getDeviceName()))
226  return false;
227 
228  foreach(INDI_G *pg, groupsList)
229  {
230  if ( (guiProp = pg->getProperty(propName)) != NULL)
231  break;
232  }
233 
234  if (guiProp == NULL)
235  return false;
236 
237  guiProp->updateStateLED();
238 
239  foreach(INDI_E *lp, guiProp->getElements())
240  lp->syncLight();
241 
242  return true;
243 
244 }
245 
246 bool INDI_D::updateBLOBGUI (IBLOB *bp)
247 {
248  INDI_P *guiProp = NULL;
249  QString propName(bp->bvp->name);
250 
251  if (strcmp(bp->bvp->device, dv->getDeviceName()))
252  return false;
253 
254  foreach(INDI_G *pg, groupsList)
255  {
256  if ( (guiProp = pg->getProperty(propName)) != NULL)
257  break;
258  }
259 
260  if (guiProp == NULL)
261  return false;
262 
263  guiProp->updateStateLED();
264 
265  return true;
266 
267 }
268 
269 void INDI_D::updateMessageLog(INDI::BaseDevice *idv, int messageID)
270 {
271  if (idv != dv)
272  return;
273 
274  msgST_w->ensureCursorVisible();
275  msgST_w->insertPlainText(dv->messageQueue(messageID) + QString("\n"));
276  QTextCursor c = msgST_w->textCursor();
277  c.movePosition(QTextCursor::Start);
278  msgST_w->setTextCursor(c);
279 }
280 
281 INDI_D::~INDI_D()
282 {
283  /* while ( ! gl.isEmpty() ) delete gl.takeFirst();
284 
285  delete(deviceVBox);
286  delete (stdDev);
287  free (dataBuffer);
288  dataBuffer = NULL;
289  deviceVBox = NULL;
290  stdDev = NULL;
291  */
292 }
293 
294 INDI_G * INDI_D::getGroup (const QString & groupName)
295 {
296  foreach(INDI_G *pg, groupsList)
297  {
298  if (pg->getName() == groupName )
299  return pg;
300  }
301 
302  return NULL;
303 
304 
305 }
306 
307 void INDI_D::clearMessageLog()
308 {
309  msgST_w->clear();
310 }
311 
312 
313 #include "indidevice.moc"
INDI_G::addProperty
bool addProperty(INDI::Property *prob)
Definition: indigroup.cpp:55
INDI_D::removeProperty
bool removeProperty(INDI::Property *prop)
Definition: indidevice.cpp:104
INDI_P
Definition: indiproperty.h:38
INDI_D::updateLightGUI
bool updateLightGUI(ILightVectorProperty *lvp)
Definition: indidevice.cpp:220
INDI_D::buildProperty
bool buildProperty(INDI::Property *prop)
Definition: indidevice.cpp:78
libindi_strings_context
const char * libindi_strings_context
Definition: indidevice.cpp:54
INDI_D::~INDI_D
~INDI_D()
Definition: indidevice.cpp:281
INDI_E::syncText
void syncText()
Definition: indielement.cpp:249
INDI_D::clearMessageLog
void clearMessageLog()
Definition: indidevice.cpp:307
INDI_D::INDI_D
INDI_D(GUIManager *in_manager, INDI::BaseDevice *in_idv, ClientManager *in_cm)
Definition: indidevice.cpp:56
timedialog.h
skyobject.h
INDI_D::updateMessageLog
void updateMessageLog(INDI::BaseDevice *idv, int messageID)
Definition: indidevice.cpp:269
INDI_E::syncLight
void syncLight()
Definition: indielement.cpp:461
INDI_D::getGroup
INDI_G * getGroup(const QString &groupName)
Definition: indidevice.cpp:294
PG_MENU
Definition: indicommon.h:47
INDI_E
Definition: indielement.h:44
INDI_P::updateMenuGUI
void updateMenuGUI()
Definition: indiproperty.cpp:560
KDialog
indidevice.h
INDI_P::getElements
QList< INDI_E * > getElements()
Definition: indiproperty.h:89
INDI_E::syncSwitch
void syncSwitch()
Definition: indielement.cpp:213
INDI_E::syncNumber
void syncNumber()
Definition: indielement.cpp:259
geolocation.h
INDI_P::updateStateLED
void updateStateLED()
Definition: indiproperty.cpp:81
skymap.h
INDI_G
Definition: indigroup.h:31
INDI_G::getName
const QString & getName()
Definition: indigroup.h:44
i18nc
i18nc("string from libindi, used in the config dialog","100x")
INDI_D::updateTextGUI
bool updateTextGUI(ITextVectorProperty *tvp)
Definition: indidevice.cpp:169
INDI_G::getContainer
QFrame * getContainer()
Definition: indigroup.h:43
INDI_G::removeProperty
bool removeProperty(const QString &propName)
Definition: indigroup.cpp:74
ClientManager
Definition: clientmanager.h:22
INDI_D::updateNumberGUI
bool updateNumberGUI(INumberVectorProperty *nvp)
Definition: indidevice.cpp:194
INDI_D::updateSwitchGUI
bool updateSwitchGUI(ISwitchVectorProperty *svp)
Definition: indidevice.cpp:139
INDI_G::getProperty
INDI_P * getProperty(const QString &propName)
Definition: indigroup.cpp:94
indiproperty.h
indigroup.h
kstars.h
INDI_G::size
int size()
Definition: indigroup.h:50
GUIManager
Definition: guimanager.h:46
indielement.h
INDI_P::getGUIType
PGui getGUIType()
Definition: indiproperty.h:71
KTextEdit
INDI_D::updateBLOBGUI
bool updateBLOBGUI(IBLOB *bp)
Definition: indidevice.cpp:246
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal