26 #include <basedevice.h>
29 #include <klineedit.h>
32 #include <kcombobox.h>
33 #include <kpushbutton.h>
34 #include <knuminput.h>
36 #include <kmessagebox.h>
38 #include <QButtonGroup>
43 #include <QDataStream>
45 #include <QHBoxLayout>
46 #include <QVBoxLayout>
47 #include <QAbstractButton>
64 name = QString(prop->getName());
66 PHBox =
new QHBoxLayout();
68 PHBox->setSpacing(KDialog::spacingHint());
69 PVBox =
new QVBoxLayout();
71 PVBox->setSpacing(KDialog::spacingHint());
85 switch (dataProp->getState())
88 ledStatus->setColor(Qt::gray);
92 ledStatus->setColor(Qt::green);
96 ledStatus->setColor(Qt::yellow);
100 ledStatus->setColor(Qt::red);
117 if (label ==
"(I18N_EMPTY_MESSAGE)")
118 label = dataProp->getLabel();
123 ledStatus->setMaximumSize(16,16);
124 ledStatus->setLook(KLed::Sunken);
129 PHBox->addWidget(ledStatus);
134 if (label ==
"(I18N_EMPTY_MESSAGE)")
135 label = name.toUtf8();
142 labelW->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
143 labelW->setFrameShape( QFrame::StyledPanel );
146 labelW->setTextFormat( Qt::RichText );
147 labelW->setAlignment(Qt::AlignVCenter | Qt::AlignLeft );
148 labelW->setWordWrap(
true);
150 PHBox->addWidget(labelW);
156 PHBox->addLayout(PVBox);
158 switch (dataProp->getType())
161 if (dataProp->getSwitch()->r == ISR_NOFMANY)
163 else if (dataProp->getSwitch()->nsp > 4)
198 ISwitchVectorProperty *svp = dataProp->getSwitch();
203 groupB =
new QButtonGroup(0);
206 groupB->setExclusive(
true);
208 groupB->setExclusive(
false);
210 QObject::connect(groupB, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(
newSwitch(QAbstractButton *)));
212 for (
int i=0; i < svp->nsp; i++)
214 ISwitch *sp = &(svp->sp[i]);
215 lp =
new INDI_E(
this, dataProp);
219 elementList.append(lp);
222 horSpacer =
new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
224 PHBox->addItem(horSpacer);
231 ITextVectorProperty *tvp = dataProp->getText();
236 for (
int i=0; i < tvp->ntp; i++)
238 IText *tp = &(tvp->tp[i]);
239 lp =
new INDI_E(
this, dataProp);
243 elementList.append(lp);
247 horSpacer =
new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
249 PHBox->addItem(horSpacer);
256 if (name ==
"TIME_UTC")
267 INumberVectorProperty *nvp = dataProp->getNumber();
272 for (
int i=0; i < nvp->nnp; i++)
274 INumber *np = &(nvp->np[i]);
275 lp =
new INDI_E(
this, dataProp);
279 elementList.append(lp);
283 horSpacer =
new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
285 PHBox->addItem(horSpacer);
299 ILightVectorProperty *lvp = dataProp->getLight();
304 for (
int i=0; i < lvp->nlp; i++)
306 ILight *lp = &(lvp->lp[i]);
307 ep =
new INDI_E(
this, dataProp);
311 elementList.append(ep);
315 horSpacer =
new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
317 PHBox->addItem(horSpacer);
323 IBLOBVectorProperty *bvp = dataProp->getBLOB();
328 for (
int i=0; i < bvp->nbp; i++)
330 IBLOB *bp = &(bvp->bp[i]);
331 lp =
new INDI_E(
this, dataProp);
335 elementList.append(lp);
339 horSpacer =
new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
341 PHBox->addItem(horSpacer);
343 enableBLOBC =
new QCheckBox();
344 enableBLOBC->setIcon(KIcon(
"modem"));
345 enableBLOBC->setChecked(
true);
346 enableBLOBC->setToolTip(i18n(
"Enable binary data transfer from this property to KStars and vice-versa."));
348 PHBox->addWidget(enableBLOBC);
350 connect(enableBLOBC, SIGNAL(stateChanged(
int)),
this, SLOT(
setBLOBOption(
int)));
352 if (dataProp->getPermission() != IP_RO)
359 if (state == Qt::Checked)
368 ISwitchVectorProperty *svp = dataProp->getSwitch();
369 QString buttonText = button->text();
374 buttonText.remove(
"&");
376 foreach(
INDI_E *el, elementList)
387 ISwitchVectorProperty *svp = dataProp->getSwitch();
392 if (index >= svp->nsp)
395 ISwitch *sp = &(svp->sp[index]);
406 ISwitchVectorProperty *svp = dataProp->getSwitch();
411 ISwitch *sp = IUFindSwitch(svp, name.toLatin1().constData());
416 if (svp->r == ISR_1OFMANY)
422 sp->s = (sp->s == ISS_ON) ? ISS_OFF : ISS_ON;
431 ISwitchVectorProperty *svp = dataProp->getSwitch();
437 foreach(
INDI_E *el, elementList)
449 ITextVectorProperty *tvp = NULL;
450 INumberVectorProperty *nvp = NULL;
452 switch (dataProp->getType())
455 tvp = dataProp->getText();
461 foreach(
INDI_E *el, elementList)
469 nvp = dataProp->getNumber();
475 foreach(
INDI_E *el, elementList)
492 QStringList menuOptions;
496 ISwitchVectorProperty *svp = dataProp->getSwitch();
503 QObject::connect(menuC, SIGNAL(activated(
int)),
this, SLOT(
newSwitch(
int)));
505 for (
int i=0; i < svp->nsp; i++)
507 ISwitch *tp = &(svp->sp[i]);
512 lp =
new INDI_E(
this, dataProp);
518 if (oneOption ==
"(I18N_EMPTY_MESSAGE)")
519 oneOption = lp->
getLabel().toUtf8();
521 menuOptions.append(oneOption);
523 elementList.append(lp);
526 menuC->addItems(menuOptions);
527 menuC->setCurrentIndex(onItem);
529 horSpacer =
new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
532 PHBox->addWidget(menuC);
533 PHBox->addItem(horSpacer);
541 setB->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
547 PHBox->addWidget(setB);
557 PVBox->addLayout(layout);
562 ISwitchVectorProperty *svp = dataProp->getSwitch();
566 int currentIndex = IUFindOnSwitchIndex(svp);
567 menuC->setCurrentIndex(currentIndex);
572 switch (dataProp->getType())
575 if (!strcmp(dataProp->getName(),
"TIME_UTC"))
599 bool openingTag=
false;
600 IBLOBVectorProperty *bvp = dataProp->getBLOB();
608 foreach(
INDI_E *ep, elementList)
613 if (openingTag ==
false)
619 IBLOB *bp = &(bvp->bp[index]);
646 if (!timeEle || !offsetEle)
return;
650 if ( timedialog.exec() == QDialog::Accepted )
655 timeEle->
setText(QString(
"%1-%2-%3T%4:%5:%6")
656 .arg(newDate.year()).arg(newDate.month())
657 .arg(newDate.day()).arg(
newTime.hour())
671 foreach(
INDI_E *ep, elementList)
673 if (ep->
getName() == elementName)
683 while ( ! elementList.isEmpty() )
delete elementList.takeFirst();
693 #include "indiproperty.moc"
#define PROPERTY_LABEL_WIDTH
INDI_E * getElement(const QString &elementName)
void setupSetButton(const QString &caption)
static KStars * Instance()
void addLayout(QHBoxLayout *layout)
const QString & getName()
const QString & getLabel()
void buildText(IText *itp)
INDI_P(INDI_G *ipg, INDI::Property *prop)
void buildLight(ILight *ilp)
void buildNumber(INumber *inp)
i18nc("string from libindi, used in the config dialog","100x")
void buildMenuItem(ISwitch *sw)
void newSwitch(QAbstractButton *button)
const char * libindi_strings_context
void setText(const QString &newText)
ClientManager * getClientManager()
void addWidget(QWidget *w)
void buildBLOB(IBLOB *ibp)
void setBLOBDirty(bool isDirty)
void buildSwitch(QButtonGroup *groupB, ISwitch *sw)
void setBLOBOption(int state)