Kstars

indiproperty.h
1 /*
2  SPDX-FileCopyrightText: 2003 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 
6 
7 */
8 
9 #pragma once
10 
11 #include "indicommon.h"
12 #include <indiproperty.h>
13 
14 #include <QWidget>
15 
16 #include <memory>
17 
18 namespace INDI
19 {
20 class Property;
21 }
22 
23 class INDI_G;
24 class INDI_E;
25 
26 class QAbstractButton;
27 class QButtonGroup;
28 class QCheckBox;
29 class QComboBox;
30 class QHBoxLayout;
31 class QPushButton;
32 class QSpacerItem;
33 class QVBoxLayout;
34 
35 class KLed;
36 class KSqueezedTextLabel;
37 
38 /**
39  * @class INDI_P
40  * INDI_P represents a single INDI property (Switch, Text, Number, Light, or BLOB). It handles building the GUI and updating the property status and/or value as new data
41  * arrive from INDI Serve. It also sends any changes in the property value back to INDI server via the ClientManager.
42  *
43  * @author Jasem Mutlaq
44  */
45 class INDI_P : public QWidget
46 {
47  Q_OBJECT
48  public:
49  INDI_P(INDI_G *ipg, INDI::Property prop);
50 
51  /* Draw state LED */
52  void updateStateLED();
53 
54  /* Update menu gui */
55  void updateMenuGUI();
56 
57  void initGUI();
58 
59  void buildSwitchGUI();
60  void buildMenuGUI();
61  void buildTextGUI();
62  void buildNumberGUI();
63  void buildLightGUI();
64  void buildBLOBGUI();
65 
66  /** Setup the 'set' button in the property */
67  void setupSetButton(const QString &caption);
68 
69  /**
70  * @brief newTime Display dialog to set UTC date and time to the driver.
71  */
72  void newTime();
73 
74  PGui getGUIType() const
75  {
76  return guiType;
77  }
78 
79  INDI_G *getGroup() const
80  {
81  return pg;
82  }
83 
84  const QString &getName() const
85  {
86  return name;
87  }
88 
89  void addWidget(QWidget *w);
90  void addLayout(QHBoxLayout *layout);
91 
92  INDI_E *getElement(const QString &elementName) const;
93 
94  QList<INDI_E *> getElements() const
95  {
96  return elementList;
97  }
98  bool isRegistered() const;
99  const INDI::Property getProperty() const
100  {
101  return dataProp;
102  }
103 
104  public slots:
105  void processSetButton();
106  void newSwitch(QAbstractButton *button);
107  void newSwitch(int index);
108  void newSwitch(const QString &name);
109  void resetSwitch();
110 
111  void sendBlob();
112  void sendSwitch();
113  void sendText();
114 
115  void setBLOBOption(int state);
116 
117  private:
118  /// Parent group
119  INDI_G *pg { nullptr };
120  INDI::Property dataProp;
121  QCheckBox *enableBLOBC { nullptr };
122  /// Label widget
123  KSqueezedTextLabel* labelW { nullptr };
124  /// Set button
125  QPushButton* setB { nullptr };
126  /// Status LED
127  KLed* ledStatus { nullptr };
128  /// GUI type
129  PGui guiType;
130  /// Horizontal spacer
131  QSpacerItem *horSpacer { nullptr };
132  /// Horizontal container
133  QHBoxLayout *PHBox { nullptr };
134  /// Vertical container
135  QVBoxLayout *PVBox { nullptr };
136  /// Group button for radio and check boxes (Elements)
137  QButtonGroup *groupB { nullptr };
138  /// Combo box for menu
139  QComboBox* menuC { nullptr };
140  QString name;
141  /// List of elements
142  QList<INDI_E *> elementList;
143 };
Q_OBJECTQ_OBJECT
QLayout * layout() const const
void newTime()
newTime Display dialog to set UTC date and time to the driver.
QString caption()
Property
void setupSetButton(const QString &caption)
Setup the 'set' button in the property.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 30 2023 04:02:43 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.