File indexing completed on 2024-05-12 05:21:22
0001 /* 0002 This file is part of KOrganizer. 0003 0004 SPDX-FileCopyrightText: 2002 Adriaan de Groot <groot@kde.org> 0005 SPDX-FileCopyrightText: 2004 Cornelius Schumacher <schumacher@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0008 */ 0009 0010 #pragma once 0011 0012 #include <QDate> 0013 #include <QObject> 0014 0015 class QTimer; 0016 0017 class DateChecker : public QObject 0018 { 0019 Q_OBJECT 0020 public: 0021 explicit DateChecker(QObject *parent = nullptr); 0022 ~DateChecker() override; 0023 0024 /** 0025 The DateChecker automatically checks for 0026 the passage of midnight. If rollover type is 0027 set to None, no signals are emitted and no 0028 processing is done. With rollover set to 0029 FollowDay, the day highlighter changes at 0030 midnight and dayPassed() is emitted. 0031 With FollowMonth, it has the same effect 0032 as FollowDay but also adjusts the month that is 0033 visible and emits monthPassed() when the month changes. 0034 */ 0035 enum RolloverType { None, FollowDay, FollowMonth }; 0036 void enableRollover(RolloverType); 0037 0038 Q_SIGNALS: 0039 // Signals emitted at midnight carrying the new date. 0040 void dayPassed(const QDate &); 0041 void monthPassed(const QDate &); 0042 0043 protected Q_SLOTS: 0044 /** 0045 Called regularly to see if we need to update the view 0046 wrt. the today box and the month box. Only important 0047 if you leave KOrganizer idle for long periods of time. 0048 0049 Until we have a reliable way of setting QTimers to go 0050 off at a particular wall-clock time, we need this, 0051 which calls passedMidnight() at the right moments. 0052 */ 0053 void possiblyPastMidnight(); 0054 0055 /** 0056 Handles updating the view when midnight has come by due to idle time. 0057 */ 0058 void passedMidnight(); 0059 0060 private: 0061 QTimer *mUpdateTimer = nullptr; 0062 QDate mLastDayChecked; 0063 RolloverType mUpdateRollover; 0064 };