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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • eclipses
EclipsesBrowserDialog.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2012 Rene Kuettner <rene@bitkanal.net>
9 //
10 
11 #include "EclipsesBrowserDialog.h"
12 
13 #include "MarbleModel.h"
14 #include "MarbleClock.h"
15 #include "MarbleDebug.h"
16 
17 #include "EclipsesModel.h"
18 #include "EclipsesItem.h"
19 
20 #include "ui_EclipsesBrowserDialog.h"
21 
22 namespace Marble {
23 
24 EclipsesBrowserDialog::EclipsesBrowserDialog( const MarbleModel *model,
25  QWidget *parent )
26  : QDialog( parent ),
27  m_marbleModel( model )
28 {
29  initialize();
30 }
31 
32 EclipsesBrowserDialog::~EclipsesBrowserDialog()
33 {
34  delete m_eclModel;
35 }
36 
37 void EclipsesBrowserDialog::setYear( int year )
38 {
39  m_browserWidget->spinBoxYear->setValue( year );
40 }
41 
42 int EclipsesBrowserDialog::year() const
43 {
44  return m_browserWidget->spinBoxYear->value();
45 }
46 
47 void EclipsesBrowserDialog::setWithLunarEclipses( const bool enable )
48 {
49  if( m_eclModel->withLunarEclipses() != enable ) {
50  m_eclModel->setWithLunarEclipses( enable );
51  m_eclModel->update();
52  }
53 }
54 
55 bool EclipsesBrowserDialog::withLunarEclipses() const
56 {
57  return m_eclModel->withLunarEclipses();
58 }
59 
60 void EclipsesBrowserDialog::accept()
61 {
62  QItemSelectionModel *s = m_browserWidget->treeView->selectionModel();
63  QModelIndex selected = s->currentIndex();
64 
65  if( selected.isValid() ) {
66  EclipsesItem *item = static_cast<EclipsesItem*>( selected.internalPointer() );
67  emit buttonShowClicked( m_eclModel->year(), item->index() );
68  }
69 
70  QDialog::accept();
71 }
72 
73 void EclipsesBrowserDialog::updateEclipsesForYear( int year )
74 {
75  m_eclModel->setYear( year );
76  updateButtonStates();
77 }
78 
79 void EclipsesBrowserDialog::updateButtonStates()
80 {
81  QItemSelectionModel *s = m_browserWidget->treeView->selectionModel();
82  m_browserWidget->buttonShow->setEnabled( s->hasSelection() );
83 }
84 
85 void EclipsesBrowserDialog::initialize()
86 {
87  m_browserWidget = new Ui::EclipsesBrowserDialog();
88  m_browserWidget->setupUi( this );
89 
90  m_browserWidget->treeView->setExpandsOnDoubleClick( false );
91 
92  m_eclModel = new EclipsesModel( m_marbleModel );
93  m_browserWidget->treeView->setModel( m_eclModel );
94 
95  connect( m_browserWidget->buttonShow, SIGNAL(clicked()),
96  this, SLOT(accept()) );
97  connect( m_browserWidget->buttonClose, SIGNAL(clicked()),
98  this, SLOT(reject()) );
99  connect( m_browserWidget->spinBoxYear, SIGNAL(valueChanged(int)),
100  this, SLOT(updateEclipsesForYear(int)) );
101  connect( m_browserWidget->treeView->selectionModel(),
102  SIGNAL(selectionChanged(const QItemSelection&,
103  const QItemSelection&)),
104  this, SLOT(updateButtonStates()) );
105  connect( m_browserWidget->buttonSettings, SIGNAL(clicked()),
106  SIGNAL(buttonSettingsClicked()) );
107 
108  setYear( m_marbleModel->clock()->dateTime().date().year() );
109 
110  update();
111 
112  m_browserWidget->treeView->resizeColumnToContents(2);
113  m_browserWidget->treeView->resizeColumnToContents(3);
114 }
115 
116 } // namespace Marble
117 
118 #include "EclipsesBrowserDialog.moc"
119 
QModelIndex
QWidget
Marble::EclipsesBrowserDialog::updateEclipsesForYear
void updateEclipsesForYear(int year)
Update the list of eclipses for the given year.
Definition: EclipsesBrowserDialog.cpp:73
QDialog::reject
virtual void reject()
QItemSelectionModel::currentIndex
QModelIndex currentIndex() const
MarbleModel.h
This file contains the headers for MarbleModel.
Marble::EclipsesBrowserDialog::setYear
void setYear(int year)
Set the year.
Definition: EclipsesBrowserDialog.cpp:37
Marble::MarbleModel::clock
MarbleClock * clock()
Definition: MarbleModel.cpp:537
EclipsesBrowserDialog.h
MarbleDebug.h
Marble::EclipsesModel::setYear
void setYear(int year)
Set the year.
Definition: EclipsesModel.cpp:58
QWidget::update
void update()
Marble::MarbleClock::dateTime
QDateTime dateTime() const
Returns the internal date and time.
Definition: MarbleClock.cpp:100
EclipsesModel.h
QModelIndex::isValid
bool isValid() const
Marble::EclipsesBrowserDialog::buttonShowClicked
void buttonShowClicked(int year, int index)
This signal is emitted when the use clicks the "show" button.
Marble::EclipsesItem::index
int index() const
The index of the eclipse event.
Definition: EclipsesItem.cpp:43
Marble::EclipsesModel::setWithLunarEclipses
void setWithLunarEclipses(const bool enable)
Set if lunar eclipses are enbled.
Definition: EclipsesModel.cpp:75
QItemSelectionModel::hasSelection
bool hasSelection() const
QModelIndex::internalPointer
void * internalPointer() const
QDate::year
int year() const
Marble::EclipsesModel::year
int year() const
Return the year.
Definition: EclipsesModel.cpp:70
Marble::EclipsesBrowserDialog::EclipsesBrowserDialog
EclipsesBrowserDialog(const MarbleModel *model, QWidget *parent=0)
Definition: EclipsesBrowserDialog.cpp:24
QDialog::accept
virtual void accept()
Marble::EclipsesBrowserDialog::~EclipsesBrowserDialog
~EclipsesBrowserDialog()
Definition: EclipsesBrowserDialog.cpp:32
MarbleClock.h
Marble::EclipsesModel::withLunarEclipses
bool withLunarEclipses() const
Return whether or not lunar eclipses are enabled.
Definition: EclipsesModel.cpp:84
QItemSelection
Marble::MarbleModel
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition: MarbleModel.h:97
EclipsesItem.h
Marble::EclipsesBrowserDialog::accept
void accept()
Accept the dialog.
Definition: EclipsesBrowserDialog.cpp:60
QDateTime::date
QDate date() const
Marble::EclipsesBrowserDialog::withLunarEclipses
bool withLunarEclipses() const
Returns whether or not lunar eclipses are listed.
Definition: EclipsesBrowserDialog.cpp:55
Marble::EclipsesBrowserDialog::year
int year() const
Return the year the browser is set to.
Definition: EclipsesBrowserDialog.cpp:42
Marble::EclipsesBrowserDialog::buttonSettingsClicked
void buttonSettingsClicked()
This signal is emitted when the 'Settings' button is clicked.
QDialog
Marble::EclipsesBrowserDialog::setWithLunarEclipses
void setWithLunarEclipses(const bool enable)
Set whether or not to list lunar eclipses.
Definition: EclipsesBrowserDialog.cpp:47
Marble::EclipsesModel::update
void update()
Update the list of eclipse items.
Definition: EclipsesModel.cpp:194
Marble::EclipsesBrowserDialog::initialize
void initialize()
Initialize the object.
Definition: EclipsesBrowserDialog.cpp:85
QItemSelectionModel
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Marble::EclipsesBrowserDialog::updateButtonStates
void updateButtonStates()
Update the dialog's button states.
Definition: EclipsesBrowserDialog.cpp:79
Marble::EclipsesItem
The representation of an eclipse event.
Definition: EclipsesItem.h:37
Marble::EclipsesModel
The model for eclipses.
Definition: EclipsesModel.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • 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
  • 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