dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
defaulthwsettingswidget.cpp
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  *
27  * Additional note on redistribution: The copyright and license notices above
28  * must be maintained in each individual source file that is a derivative work
29  * of this source file; otherwise redistribution is prohibited.
30  */
32 #include <utils/longlongspinbox.h>
33 #include <QErrorMessage>
34 #include <QDebug>
35 #include <QLineEdit>
36 #include <QComboBox>
37 #include <QSpinBox>
38 #include <QDoubleSpinBox>
39 
46  : ConfigTaskWidget(parent)
47  , defaultHWSettingsWidget(new Ui_DefaultHwSettings)
48 {
49  Q_ASSERT(settingsObj);
50 
51  defaultHWSettingsWidget->setupUi(this);
52 
53  QFormLayout *layout =
54  qobject_cast<QFormLayout *>(defaultHWSettingsWidget->portSettingsFrame->layout());
55  QWidget *wdg;
56  QLabel *lbl;
57 
58  QList<UAVObjectField *> fields = settingsObj->getFields();
59  for (int i = 0; i < fields.size(); i++) {
60  switch (fields[i]->getType()) {
63  wdg = new QComboBox(this);
64  break;
70  QSpinBox *sbx = new QSpinBox(this);
71  if (fields[i]->getUnits().length())
72  sbx->setSuffix(QString(" %1").arg(fields[i]->getUnits()));
73  sbx->setDisplayIntegerBase(fields[i]->getDisplayIntegerBase());
74  sbx->setPrefix(fields[i]->getDisplayPrefix());
75  wdg = sbx;
76  break;
77  }
79  LongLongSpinBox *sbx = new LongLongSpinBox(this);
80  if (fields[i]->getUnits().length())
81  sbx->setSuffix(QString(" %1").arg(fields[i]->getUnits()));
82  sbx->setDisplayIntegerBase(fields[i]->getDisplayIntegerBase());
83  sbx->setPrefix(fields[i]->getDisplayPrefix());
84  wdg = sbx;
85  break;
86  }
88  QDoubleSpinBox *sbx = new QDoubleSpinBox(this);
89  if (fields[i]->getUnits().length())
90  sbx->setSuffix(QString(" %1").arg(fields[i]->getUnits()));
91  wdg = sbx;
92  break;
93  }
95  wdg = new QLineEdit(this);
96  break;
97  default:
98  continue;
99  }
100 
101  QStringList objRelation;
102  objRelation.append(QString("objname:%1").arg(settingsObj->getName()));
103  objRelation.append(QString("fieldname:%1").arg(fields[i]->getName()));
104  objRelation.append(QString("buttongroup:1"));
105  objRelation.append(QString("haslimits:yes"));
106 
107  wdg->setProperty("objrelation", objRelation);
108 
109  lbl = new QLabel(fields[i]->getName(), this);
110  layout->addRow(lbl, wdg);
111  }
112 
113  autoLoadWidgets();
114  loadAllLimits();
115  populateWidgets();
117  enableControls(true);
118 
119  // Have to force the form as clean (unedited by user) since refreshWidgetsValues forces it to
120  // dirty.
122 
124 }
125 
127 {
128  delete defaultHWSettingsWidget;
129 }
void setPrefix(const QString &prefix)
void setDisplayIntegerBase(int base)
DefaultHwSettingsWidget(UAVObject *settingsObj, QWidget *parent=nullptr)
DefaultHwSettingsWidget::DefaultHwSettingsWidget Constructed when either a new board connection is es...
for i
Definition: OPPlots.m:140
void setSuffix(const QString &suffix)
QList< UAVObjectField * > getFields()
Definition: uavobject.cpp:196
virtual void populateWidgets()
QString getName()
Definition: uavobject.cpp:131
virtual void enableControls(bool enable)
virtual void refreshWidgetsValues(UAVObject *obj=NULL)