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

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
TimeControlWidget.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 2010 Harshit Jain <hjain.itbhu@gmail.com>
9 //
10 
11 // Own
12 #include "TimeControlWidget.h"
13 #include "ui_TimeControlWidget.h"
14 
15 // Qt
16 #include <QShowEvent>
17 
18 // Marble
19 #include "MarbleClock.h"
20 #include "MarbleDebug.h"
21 
22 using namespace Marble;
23 /* TRANSLATOR Marble::TimeControlWidget */
24 
25 TimeControlWidget::TimeControlWidget( MarbleClock* clock, QWidget* parent )
26  : QDialog( parent ),
27  m_uiWidget( new Ui::TimeControlWidget ),
28  m_clock( clock ),
29  m_lastDateTime()
30 {
31  m_uiWidget->setupUi( this );
32 
33  connect( m_uiWidget->speedSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSpeedLabel(int)) );
34  connect( m_uiWidget->nowToolButton, SIGNAL(clicked()), this, SLOT(nowClicked()) );
35  connect( m_uiWidget->applyButton, SIGNAL(clicked()), this, SLOT(apply()) );
36  connect( m_uiWidget->cancelButton, SIGNAL(clicked()), this, SLOT(reject()) );
37  connect( m_uiWidget->okButton, SIGNAL(clicked()), this, SLOT(apply()) );
38  connect( m_uiWidget->okButton, SIGNAL(clicked()), this, SLOT(accept()) );
39  connect( m_clock, SIGNAL(timeChanged()), this, SLOT(updateDateTime()) );
40  connect( m_clock, SIGNAL(updateIntervalChanged(int)), this, SLOT(updateRefreshRate(int)) );
41 
42  setModal( false );
43 
44 }
45 
46 TimeControlWidget::~TimeControlWidget()
47 {
48  delete m_uiWidget;
49 }
50 
51 void TimeControlWidget::updateSpeedLabel( int speed )
52 {
53  m_uiWidget->speedLabel->setText( QString( "%1x" ).arg( speed ) );
54 }
55 
56 void TimeControlWidget::updateRefreshRate( int seconds )
57 {
58  m_uiWidget->refreshIntervalSpinBox->setValue( seconds );
59 }
60 
61 void TimeControlWidget::updateDateTime()
62 {
63  m_uiWidget->currentDateTimeEdit->setDateTime( m_clock->dateTime().addSecs( m_clock->timezone() ) );
64 }
65 
66 void TimeControlWidget::nowClicked()
67 {
68  m_uiWidget->newDateTimeEdit->setDateTime( QDateTime::currentDateTime().toUTC().addSecs( m_clock->timezone() ) );
69 }
70 
71 void TimeControlWidget::apply()
72 {
73  if( m_lastDateTime != m_uiWidget->newDateTimeEdit->dateTime() )
74  {
75  m_lastDateTime = m_uiWidget->newDateTimeEdit->dateTime();
76  m_clock->setDateTime( m_lastDateTime.toUTC() );
77  }
78  m_clock->setUpdateInterval( m_uiWidget->refreshIntervalSpinBox->value() );
79  m_clock->setSpeed( m_uiWidget->speedSlider->value() );
80 }
81 
82 void TimeControlWidget::showEvent(QShowEvent* event)
83 {
84  if( !event->spontaneous() )
85  {
86  // Loading all options
87  m_uiWidget->refreshIntervalSpinBox->setValue( m_clock->updateInterval() );
88  m_uiWidget->speedSlider->setValue( m_clock->speed() );
89  m_uiWidget->speedLabel->setText( QString( "%1x" ).arg( m_clock->speed() ) );
90  updateDateTime();
91  m_lastDateTime = m_clock->dateTime();
92  m_uiWidget->newDateTimeEdit->setDateTime( m_lastDateTime.addSecs( m_clock->timezone() ) );
93  }
94 }
95 
96 #include "TimeControlWidget.moc"
Marble::TimeControlWidget
Definition: TimeControlWidget.h:31
QDialog
Marble::MarbleClock::setDateTime
void setDateTime(const QDateTime &datetime)
Sets the internal date and time a custom one.
Definition: MarbleClock.cpp:104
Marble::MarbleClock::setUpdateInterval
void setUpdateInterval(int seconds)
Set the interval at which dateTime() is updated and timeChanged() is emitted.
Definition: MarbleClock.cpp:115
Marble::MarbleClock::timezone
int timezone() const
Returns the timezone of the clock.
Definition: MarbleClock.cpp:137
QWidget
Marble::MarbleClock::updateInterval
int updateInterval()
Returns the interval at which dateTime() is updated and timeChanged() is emitted, The default is 60 s...
Definition: MarbleClock.cpp:121
MarbleDebug.h
Marble::TimeControlWidget::m_uiWidget
Ui::TimeControlWidget * m_uiWidget
Definition: TimeControlWidget.h:70
Marble::MarbleClock::dateTime
QDateTime dateTime() const
Returns the internal date and time.
Definition: MarbleClock.cpp:110
Marble::TimeControlWidget::TimeControlWidget
TimeControlWidget(MarbleClock *clock, QWidget *parent=0)
Definition: TimeControlWidget.cpp:25
Marble::TimeControlWidget::showEvent
void showEvent(QShowEvent *event)
Definition: TimeControlWidget.cpp:82
Marble::TimeControlWidget::~TimeControlWidget
virtual ~TimeControlWidget()
Definition: TimeControlWidget.cpp:46
Marble::TimeControlWidget::m_clock
MarbleClock * m_clock
Definition: TimeControlWidget.h:72
TimeControlWidget.h
MarbleClock.h
Marble::MarbleClock::setSpeed
void setSpeed(int speed)
Sets the speed of the timer which is how fast the marble clock can run relative to actual speed of ti...
Definition: MarbleClock.cpp:131
Marble::TimeControlWidget::m_lastDateTime
QDateTime m_lastDateTime
Definition: TimeControlWidget.h:73
Marble::MarbleClock::speed
int speed() const
Returns the speed of the timer.
Definition: MarbleClock.cpp:126
Marble::MarbleClock
Definition: MarbleClock.h:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:53 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
  • 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