18 #include <QListWidget>
20 #include <QDoubleSpinBox>
31 kcfg_ScopeListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
32 binoDetailsFrame->setEnabled(kcfg_BinocularsCheck->isChecked());
33 scopeFrame->setEnabled(kcfg_TelescopeCheck->isChecked());
35 connect(kcfg_TelescopeCheck, SIGNAL(toggled(
bool)),
this, SLOT(slotTelescopeCheck(
bool)));
36 connect(kcfg_BinocularsCheck, SIGNAL(toggled(
bool)),
this, SLOT(slotBinocularsCheck(
bool)));
37 connect(kcfg_NoEquipCheck, SIGNAL(toggled(
bool)),
this, SLOT(slotNoEquipCheck(
bool)));
38 connect(kcfg_ScopeListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this,
39 SLOT(slotScopeSelected(QListWidgetItem *)));
40 connect(saveNewScopeButton, SIGNAL(clicked()),
this, SLOT(slotSaveNewScope()));
45 kcfg_ScopeListWidget->clear();
50 QListWidgetItem *scopeItem =
new QListWidgetItem;
51 scopeItem->setText(scope->
vendor());
52 scopeItem->setData(Vendor, scope->
vendor());
53 scopeItem->setData(Model, scope->
model());
54 scopeItem->setData(Aperture, scope->
aperture());
55 scopeItem->setData(FocalLength, scope->
focalLength());
56 scopeItem->setData(Type, scope->
type());
58 kcfg_ScopeListWidget->addItem(scopeItem);
60 if (kcfg_ScopeListWidget->count() == 0)
return;
62 vendorText->setText(kcfg_ScopeListWidget->item(0)->data(Vendor).toString());
63 modelText->setText(kcfg_ScopeListWidget->item(0)->data(Model).toString());
64 apertureText->setText(kcfg_ScopeListWidget->item(0)->data(Aperture).toString().append(
" mm"));
68 void WIEquipSettings::slotTelescopeCheck(
bool on)
71 kcfg_NoEquipCheck->setEnabled(
false);
74 if (!kcfg_BinocularsCheck->isChecked())
75 kcfg_NoEquipCheck->setEnabled(
true);
77 scopeFrame->setEnabled(on);
80 void WIEquipSettings::slotBinocularsCheck(
bool on)
83 kcfg_NoEquipCheck->setEnabled(
false);
86 if (!kcfg_TelescopeCheck->isChecked())
87 kcfg_NoEquipCheck->setEnabled(
true);
89 binoDetailsFrame->setEnabled(on);
92 void WIEquipSettings::slotNoEquipCheck(
bool on)
96 kcfg_TelescopeCheck->setEnabled(
false);
97 kcfg_BinocularsCheck->setEnabled(
false);
101 kcfg_TelescopeCheck->setEnabled(
true);
102 kcfg_BinocularsCheck->setEnabled(
true);
106 void WIEquipSettings::slotScopeSelected(QListWidgetItem* scopeItem)
108 if (!scopeItem)
return;
109 vendorText->setText(scopeItem->data(Vendor).toString());
110 modelText->setText(scopeItem->data(Model).toString());
111 apertureText->setText(scopeItem->data(Aperture).toString().append(
" mm"));
113 if (scopeItem->data(Type).toString() ==
"Reflector")
115 else if (scopeItem->data(Type).toString() ==
"Reflector")
119 void WIEquipSettings::slotSaveNewScope()
122 typeComboBox->currentText(), focalLenSpinBox->value(), apertureSpinBox->value());
123 populateScopeListWidget();
128 if (kcfg_ScopeListWidget->count() == 0)
132 m_Aperture = kcfg_BinocularsAperture->value();
148 m_Aperture = kcfg_BinocularsAperture->value();
152 if (kcfg_ScopeListWidget->count() == 0)
158 m_Aperture = kcfg_ScopeListWidget->currentItem()->data(Aperture).toDouble();
162 if (kcfg_ScopeListWidget->count() == 0)
164 m_Aperture = kcfg_BinocularsAperture->value();
168 double telAperture = kcfg_ScopeListWidget->currentItem()->data(Aperture).toDouble();
169 double binoAperture = kcfg_BinocularsAperture->value();
170 m_Aperture = telAperture > binoAperture ? telAperture : binoAperture;
void AddScope(const QString &model, const QString &vendor, const QString &driver, const QString &type, const double &focalLength, const double &aperture)
Appends the scope with given details in the database.
static KStars * Instance()
This is the main window for KStars.
void GetAllScopes(QList< OAL::Scope * > &m_scopeList)
updates the scope list with all scopes from database List is cleared and then filled with content...
static uint scopeListWidget()
Get Index of selected scope from list of scopes.
void setAperture()
Set aperture to use.
double focalLength() const
void populateScopeListWidget()
Populates scope list widget in UI with list of telescopes from KStars userdb.
KStarsData * data() const
static bool binocularsCheck()
Get Availability of binoculars.
static bool telescopeCheck()
Get Availability of telescope.
WIEquipSettings(KStars *ks)
Constructor.