• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • tools
  • whatsinteresting
wiequipsettings.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  wiequipsettings.cpp - K Desktop Planetarium
3  -------------------
4  begin : 2013/09/01
5  copyright : (C) 2013 by Samikshan Bairagya
6  email : samikshan@gmail.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include <QListWidget>
19 #include <QLineEdit>
20 #include <QDoubleSpinBox>
21 #include <QComboBox>
22 #include "wiequipsettings.h"
23 #include "kstars.h"
24 #include "kstarsdata.h"
25 #include "Options.h"
26 
27 WIEquipSettings::WIEquipSettings(KStars* ks): QFrame(ks), m_Ks(ks)
28 {
29  setupUi(this);
30  populateScopeListWidget();
31  kcfg_ScopeListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
32  binoDetailsFrame->setEnabled(kcfg_BinocularsCheck->isChecked());
33  scopeFrame->setEnabled(kcfg_TelescopeCheck->isChecked());
34 
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()));
41 }
42 
43 void WIEquipSettings::populateScopeListWidget()
44 {
45  kcfg_ScopeListWidget->clear();
47  KStars::Instance()->data()->userdb()->GetAllScopes(m_ScopeList);
48  foreach(OAL::Scope *scope, m_ScopeList)
49  {
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());
57 
58  kcfg_ScopeListWidget->addItem(scopeItem);
59  }
60  if (kcfg_ScopeListWidget->count() == 0) return;
61 
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"));
65  kcfg_ScopeListWidget->setCurrentItem(kcfg_ScopeListWidget->item(Options::scopeListWidget()));
66 }
67 
68 void WIEquipSettings::slotTelescopeCheck(bool on)
69 {
70  if (on)
71  kcfg_NoEquipCheck->setEnabled(false);
72  else
73  {
74  if (!kcfg_BinocularsCheck->isChecked())
75  kcfg_NoEquipCheck->setEnabled(true);
76  }
77  scopeFrame->setEnabled(on);
78 }
79 
80 void WIEquipSettings::slotBinocularsCheck(bool on)
81 {
82  if (on)
83  kcfg_NoEquipCheck->setEnabled(false);
84  else
85  {
86  if (!kcfg_TelescopeCheck->isChecked())
87  kcfg_NoEquipCheck->setEnabled(true);
88  }
89  binoDetailsFrame->setEnabled(on);
90 }
91 
92 void WIEquipSettings::slotNoEquipCheck(bool on)
93 {
94  if (on)
95  {
96  kcfg_TelescopeCheck->setEnabled(false);
97  kcfg_BinocularsCheck->setEnabled(false);
98  }
99  else
100  {
101  kcfg_TelescopeCheck->setEnabled(true);
102  kcfg_BinocularsCheck->setEnabled(true);
103  }
104 }
105 
106 void WIEquipSettings::slotScopeSelected(QListWidgetItem* scopeItem)
107 {
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"));
112 
113  if (scopeItem->data(Type).toString() == "Reflector")
114  m_TelType = ObsConditions::Reflector;
115  else if (scopeItem->data(Type).toString() == "Reflector")
116  m_TelType = ObsConditions::Refractor;
117 }
118 
119 void WIEquipSettings::slotSaveNewScope()
120 {
121  KStars::Instance()->data()->userdb()->AddScope(modelLineEdit->text(), vendorLineEdit->text(), driverComboBox->currentText(),
122  typeComboBox->currentText(), focalLenSpinBox->value(), apertureSpinBox->value());
123  populateScopeListWidget(); //Reload scope list widget
124 }
125 
126 void WIEquipSettings::setAperture()
127 {
128  if (kcfg_ScopeListWidget->count() == 0)
129  {
130  if (Options::binocularsCheck())
131  {
132  m_Aperture = kcfg_BinocularsAperture->value();
133  return;
134  }
135  else
136  {
137  m_Aperture = INVALID_APERTURE;
138  return;
139  }
140  }
141 
142  if (!Options::telescopeCheck() && !Options::binocularsCheck())
143  {
144  m_Aperture = INVALID_APERTURE;
145  }
146  else if (!Options::telescopeCheck()) //No telescope available, but binoculars available
147  {
148  m_Aperture = kcfg_BinocularsAperture->value();
149  }
150  else if (!Options::binocularsCheck()) //No binoculars available, but telescope available
151  {
152  if (kcfg_ScopeListWidget->count() == 0)
153  {
154  m_Aperture = INVALID_APERTURE;
155  return;
156  }
157  else
158  m_Aperture = kcfg_ScopeListWidget->currentItem()->data(Aperture).toDouble();
159  }
160  else //Both Telescope and Binoculars available
161  {
162  if (kcfg_ScopeListWidget->count() == 0)
163  {
164  m_Aperture = kcfg_BinocularsAperture->value();
165  return;
166  }
167  //If both Binoculars and Telescope available then select bigger aperture
168  double telAperture = kcfg_ScopeListWidget->currentItem()->data(Aperture).toDouble();
169  double binoAperture = kcfg_BinocularsAperture->value();
170  m_Aperture = telAperture > binoAperture ? telAperture : binoAperture;
171  }
172 }
KSUserDB::AddScope
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.
Definition: ksuserdb.cpp:353
OAL::Scope
Definition: scope.h:25
INVALID_APERTURE
#define INVALID_APERTURE
Definition: wiequipsettings.h:21
ObsConditions::Refractor
Definition: obsconditions.h:44
KStars::Instance
static KStars * Instance()
Definition: kstars.h:125
KStars
This is the main window for KStars.
Definition: kstars.h:94
KSUserDB::GetAllScopes
void GetAllScopes(QList< OAL::Scope * > &m_scopeList)
updates the scope list with all scopes from database List is cleared and then filled with content...
Definition: ksuserdb.cpp:399
Options::scopeListWidget
static uint scopeListWidget()
Get Index of selected scope from list of scopes.
Definition: Options.h:4559
OAL::Scope::aperture
double aperture() const
Definition: scope.h:35
wiequipsettings.h
WIEquipSettings::setAperture
void setAperture()
Set aperture to use.
Definition: wiequipsettings.cpp:126
OAL::Scope::focalLength
double focalLength() const
Definition: scope.h:34
OAL::Scope::type
QString type() const
Definition: scope.h:31
Options.h
ObsConditions::Reflector
Definition: obsconditions.h:44
WIEquipSettings::populateScopeListWidget
void populateScopeListWidget()
Populates scope list widget in UI with list of telescopes from KStars userdb.
Definition: wiequipsettings.cpp:43
KStars::data
KStarsData * data() const
Definition: kstars.h:131
Options::binocularsCheck
static bool binocularsCheck()
Get Availability of binoculars.
Definition: Options.h:4502
kstarsdata.h
KStarsData::userdb
KSUserDB * userdb()
Definition: kstarsdata.h:152
OAL::Scope::model
QString model() const
Definition: scope.h:29
QFrame
kstars.h
OAL::Scope::vendor
QString vendor() const
Definition: scope.h:30
Options::telescopeCheck
static bool telescopeCheck()
Get Availability of telescope.
Definition: Options.h:4483
WIEquipSettings::WIEquipSettings
WIEquipSettings(KStars *ks)
Constructor.
Definition: wiequipsettings.cpp:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal