• 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
  • dialogs
timedialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  timedialog.cpp - K Desktop Planetarium
3  -------------------
4  begin : Sun Feb 11 2001
5  copyright : (C) 2001 by Jason Harris
6  email : jharris@30doradus.org
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 
19 #include "timedialog.h"
20 
21 #include <klocale.h>
22 #include <kpushbutton.h>
23 #include <kdatepicker.h>
24 
25 #include <QFrame>
26 #include <QVBoxLayout>
27 #include <QHBoxLayout>
28 #include <QKeyEvent>
29 #include <QTimeEdit>
30 
31 #include "kstarsdatetime.h"
32 #include "kstarsdata.h"
33 #include "simclock.h"
34 #include "geolocation.h"
35 
36 TimeDialog::TimeDialog( const KStarsDateTime &now, GeoLocation *_geo, QWidget *parent, bool UTCFrame )
37  : KDialog( parent ), geo( _geo )
38 {
39  UTCNow = UTCFrame;
40 
41  QFrame *page = new QFrame(this);
42  setMainWidget( page );
43  if( UTCNow )
44  setCaption( i18nc( "set clock to a new time", "Set UTC Time" ) );
45  else
46  setCaption( i18nc( "set clock to a new time", "Set Time" ) );
47  setButtons( KDialog::Ok|KDialog::Cancel );
48 
49  vlay = new QVBoxLayout( page );
50  vlay->setMargin( 2 );
51  vlay->setSpacing( 2 );
52  hlay = new QHBoxLayout(); //this layout will be added to the VLayout
53  hlay->setSpacing( 2 );
54 
55  dPicker = new KDatePicker( now.date(), page );
56  tEdit = new QTimeEdit( now.time(), page );
57  NowButton = new KPushButton( page );
58  NowButton->setObjectName( "NowButton" );
59  NowButton->setText( UTCNow ? i18n( "UTC Now" ) : i18n( "Now" ) );
60 
61  vlay->addWidget( dPicker, 0, 0 );
62  vlay->addLayout( hlay, 0 );
63 
64  hlay->addWidget( tEdit );
65  hlay->addWidget( NowButton );
66 
67  vlay->activate();
68 
69  QObject::connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ));
70  QObject::connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ));
71  QObject::connect( NowButton, SIGNAL( clicked() ), this, SLOT( setNow() ));
72 }
73 
74 //Add handler for Escape key to close window
75 //Use keyReleaseEvent because keyPressEvents are already consumed
76 //by the KDatePicker.
77 void TimeDialog::keyReleaseEvent( QKeyEvent *kev ) {
78  switch( kev->key() ) {
79  case Qt::Key_Escape:
80  {
81  close();
82  break;
83  }
84 
85  default: { kev->ignore(); break; }
86  }
87 }
88 
89 void TimeDialog::setNow( void )
90 {
91  KStarsDateTime dt( KStarsDateTime::currentDateTime( KDateTime::Spec::UTC() ) );
92  if ( ! UTCNow )
93  dt = geo->UTtoLT( dt );
94 
95  dPicker->setDate( dt.date() );
96  tEdit->setTime( dt.time() );
97 }
98 
99 QTime TimeDialog::selectedTime( void ) {
100  return tEdit->time();
101 }
102 
103 QDate TimeDialog::selectedDate( void ) {
104  return dPicker->date();
105 }
106 
107 KStarsDateTime TimeDialog::selectedDateTime( void ) {
108  return KStarsDateTime( selectedDate(), selectedTime() );
109 }
110 
111 #include "timedialog.moc"
timedialog.h
QWidget
KDialog
TimeDialog::selectedDate
QDate selectedDate(void)
Definition: timedialog.cpp:103
geolocation.h
TimeDialog::selectedTime
QTime selectedTime(void)
Definition: timedialog.cpp:99
TimeDialog::setNow
void setNow(void)
When the "Now" button is pressed, read the time and date from the system clock.
Definition: timedialog.cpp:89
GeoLocation
Contains all relevant information for specifying a location on Earth: City Name, State/Province name...
Definition: geolocation.h:39
KStarsDateTime::currentDateTime
static KStarsDateTime currentDateTime(KDateTime::Spec ts=KDateTime::Spec::ClockTime())
Definition: kstarsdatetime.cpp:67
i18nc
i18nc("string from libindi, used in the config dialog","100x")
KStarsDateTime
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
Definition: kstarsdatetime.h:45
simclock.h
TimeDialog::selectedDateTime
KStarsDateTime selectedDateTime(void)
Definition: timedialog.cpp:107
TimeDialog::keyReleaseEvent
void keyReleaseEvent(QKeyEvent *)
Definition: timedialog.cpp:77
kstarsdatetime.h
GeoLocation::UTtoLT
KStarsDateTime UTtoLT(const KStarsDateTime &ut) const
Definition: geolocation.h:233
kstarsdata.h
TimeDialog::TimeDialog
TimeDialog(const KStarsDateTime &now, GeoLocation *_geo, QWidget *parent, bool UTCFrame=false)
Constructor.
Definition: timedialog.cpp:36
QFrame
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