Kstars

wiequipsettings.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Samikshan Bairagya <samikshan@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "wiequipsettings.h"
8#include "oal/equipmentwriter.h"
9#include "kstars.h"
10#include "Options.h"
11
12#include <QListWidgetItem>
13
14WIEquipSettings::WIEquipSettings() : QFrame(KStars::Instance())
15{
16 setupUi(this);
17
19 binoDetailsFrame->setEnabled(kcfg_BinocularsCheck->isChecked());
20 scopeFrame->setEnabled(kcfg_TelescopeCheck->isChecked());
21
22 connect(kcfg_TelescopeCheck, SIGNAL(toggled(bool)), this, SLOT(slotTelescopeCheck(bool)));
23 connect(kcfg_BinocularsCheck, SIGNAL(toggled(bool)), this, SLOT(slotBinocularsCheck(bool)));
24 connect(ScopeListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(slotScopeSelected(int)));
25 connect(saveNewScopeButton, SIGNAL(clicked()), this, SLOT(slotAddNewScope()));
26
27 populateScopeListWidget();
28}
29
31{
32 ScopeListWidget->clear();
33 ///Get telescope list from KStars user database.
34 KStars::Instance()->data()->userdb()->GetAllScopes(m_ScopeList);
35 foreach (OAL::Scope *scope, m_ScopeList)
36 {
38 scopeItem->setText(scope->vendor());
39 scopeItem->setData(Vendor, scope->vendor());
40 scopeItem->setData(Model, scope->model());
41 scopeItem->setData(Aperture, scope->aperture());
42 scopeItem->setData(FocalLength, scope->focalLength());
43 scopeItem->setData(Type, scope->type());
44
45 ScopeListWidget->addItem(scopeItem);
46 }
47 if (ScopeListWidget->count() == 0)
48 return;
49
50 vendorText->setText(ScopeListWidget->item(0)->data(Vendor).toString());
51 modelText->setText(ScopeListWidget->item(0)->data(Model).toString());
52 apertureText->setText(ScopeListWidget->item(0)->data(Aperture).toString().append(" mm"));
53
54 ScopeListWidget->setCurrentRow(Options::scopeListIndex());
55}
56
57void WIEquipSettings::slotTelescopeCheck(bool on)
58{
59 scopeFrame->setEnabled(on);
60 Options::setTelescopeCheck(on);
61}
62
63void WIEquipSettings::slotBinocularsCheck(bool on)
64{
65 binoDetailsFrame->setEnabled(on);
66 Options::setBinocularsCheck(on);
67}
68
69void WIEquipSettings::slotScopeSelected(int row)
70{
71 if (row == -1)
72 return;
73
74 QListWidgetItem *item = ScopeListWidget->item(row);
75
76 if (item == nullptr)
77 return;
78
79 vendorText->setText(item->data(Vendor).toString());
80 modelText->setText(item->data(Model).toString());
81 apertureText->setText(item->data(Aperture).toString().append(" mm"));
82
83 if (item->data(Type).toString() == "Reflector")
84 m_TelType = ObsConditions::Reflector;
85 else if (item->data(Type).toString() == "Refractor")
86 m_TelType = ObsConditions::Refractor;
87
88 Options::setScopeListIndex(row);
89}
90
91void WIEquipSettings::slotAddNewScope()
92{
93 EquipmentWriter equipmentdlg;
94 equipmentdlg.loadEquipment();
95 equipmentdlg.exec();
96
97 populateScopeListWidget(); //Reload scope list widget
98}
99
101{
102 double telAperture = INVALID_APERTURE;
103 double binoAperture = INVALID_APERTURE;
104
105 if (kcfg_TelescopeCheck->isChecked() && ScopeListWidget->selectedItems().isEmpty() == false)
106 telAperture = ScopeListWidget->currentItem()->data(Aperture).toDouble();
107 if (kcfg_BinocularsCheck->isChecked())
110
111 // JM 2016-05-11: This is way over-complicated
112 /*
113 if (ScopeListWidget->count() == 0)
114 {
115 if (Options::binocularsCheck()z)
116 {
117 m_Aperture = kcfg_BinocularsAperture->value();
118 return;
119 }
120 else
121 {
122 m_Aperture = INVALID_APERTURE;
123 return;
124 }
125 }
126
127 if (!Options::telescopeCheck() && !Options::binocularsCheck())
128 {
129 m_Aperture = INVALID_APERTURE;
130 }
131 else if (!Options::telescopeCheck()) //No telescope available, but binoculars available
132 {
133 m_Aperture = kcfg_BinocularsAperture->value();
134 }
135 else if (!Options::binocularsCheck()) //No binoculars available, but telescope available
136 {
137 if (ScopeListWidget->count() == 0)
138 {
139 m_Aperture = INVALID_APERTURE;
140 return;
141 }
142 else
143 m_Aperture = ScopeListWidget->currentItem()->data(Aperture).toDouble();
144 }
145 else //Both Telescope and Binoculars available
146 {
147 if (ScopeListWidget->count() == 0)
148 {
149 m_Aperture = kcfg_BinocularsAperture->value();
150 return;
151 }
152 //If both Binoculars and Telescope available then select bigger aperture
153 double telAperture = ScopeListWidget->currentItem()->data(Aperture).toDouble();
154 double binoAperture = kcfg_BinocularsAperture->value();
155 m_Aperture = telAperture > binoAperture ? telAperture : binoAperture;
156 }*/
157}
This is the main window for KStars.
Definition kstars.h:91
static KStars * Instance()
Definition kstars.h:123
Information on telescope used in observation.
Definition scope.h:18
void populateScopeListWidget()
Populates scope list widget in UI with list of telescopes from KStars userdb.
void setAperture()
Set aperture to use.
virtual QVariant data(int role) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:45:36 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.