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

korganizer

  • sources
  • kde-4.14
  • kdepim
  • korganizer
datechecker.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2002 Adriaan de Groot <groot@kde.org>
5  Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 #include "datechecker.h"
27 
28 #include <QTimer>
29 
30 DateChecker::DateChecker( QObject *parent ) : QObject( parent ), mUpdateTimer( 0 )
31 {
32  enableRollover( FollowMonth );
33 }
34 
35 DateChecker::~DateChecker()
36 {
37 }
38 
39 void DateChecker::enableRollover( RolloverType r )
40 {
41  switch( r ) {
42  case None:
43  if ( mUpdateTimer ) {
44  mUpdateTimer->stop();
45  delete mUpdateTimer;
46  mUpdateTimer = 0;
47  }
48  break;
49  case FollowDay:
50  case FollowMonth:
51  if ( !mUpdateTimer ) {
52  mUpdateTimer = new QTimer( this );
53  connect( mUpdateTimer, SIGNAL(timeout()),
54  SLOT(possiblyPastMidnight()) );
55  }
56  mUpdateTimer->setSingleShot( true );
57  mUpdateTimer->start( 0 );
58  mLastDayChecked = QDate::currentDate();
59  }
60  mUpdateRollover = r;
61 }
62 
63 void DateChecker::passedMidnight()
64 {
65  QDate today = QDate::currentDate();
66 
67  if ( today.month() != mLastDayChecked.month() ) {
68  if ( mUpdateRollover == FollowMonth ) {
69  emit monthPassed( today );
70  }
71  }
72  emit dayPassed( today );
73 }
74 
75 void DateChecker::possiblyPastMidnight()
76 {
77  if ( mLastDayChecked != QDate::currentDate() ) {
78  passedMidnight();
79  mLastDayChecked = QDate::currentDate();
80  }
81  // Set the timer to go off 1 second after midnight
82  // or after 8 minutes, whichever comes first.
83  if ( mUpdateTimer ) {
84  QTime now = QTime::currentTime();
85  QTime midnight = QTime( 23, 59, 59 );
86  int msecsWait = qMin( 480000, now.msecsTo( midnight ) + 2000 );
87 
88  mUpdateTimer->stop();
89  mUpdateTimer->start( msecsWait );
90  }
91 }
92 
DateChecker::passedMidnight
void passedMidnight()
Handles updating the view when midnight has come by due to idle time.
Definition: datechecker.cpp:63
datechecker.h
DateChecker::FollowMonth
Definition: datechecker.h:55
DateChecker::None
Definition: datechecker.h:53
QTime::msecsTo
int msecsTo(const QTime &t) const
QDate::month
int month() const
QTime
QTimer
QObject
DateChecker::FollowDay
Definition: datechecker.h:54
QDate
DateChecker::~DateChecker
~DateChecker()
Definition: datechecker.cpp:35
QTimer::stop
void stop()
QTime::currentTime
QTime currentTime()
DateChecker::dayPassed
void dayPassed(const QDate &)
DateChecker::monthPassed
void monthPassed(const QDate &)
DateChecker::enableRollover
void enableRollover(RolloverType)
Definition: datechecker.cpp:39
QDate::currentDate
QDate currentDate()
QTimer::start
void start(int msec)
DateChecker::DateChecker
DateChecker(QObject *parent=0)
Definition: datechecker.cpp:30
DateChecker::possiblyPastMidnight
void possiblyPastMidnight()
Called regularly to see if we need to update the view wrt.
Definition: datechecker.cpp:75
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QTimer::setSingleShot
void setSingleShot(bool singleShot)
DateChecker::RolloverType
RolloverType
The DateChecker automatically checks for the passage of midnight.
Definition: datechecker.h:52
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

korganizer

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

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