mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Fixed toggling the 'Day' item in the 'Timers' menu, so that it selects the right day of week for timers in the future
This commit is contained in:
parent
969864aacb
commit
c2daf37ed1
2
HISTORY
2
HISTORY
@ -3156,3 +3156,5 @@ Video Disk Recorder Revision History
|
|||||||
- Fixed some typos in the Makefile's 'font' target (thanks to Olaf Titz).
|
- Fixed some typos in the Makefile's 'font' target (thanks to Olaf Titz).
|
||||||
- Fixed handling childTid in cThread to avoid possible race conditions (thanks
|
- Fixed handling childTid in cThread to avoid possible race conditions (thanks
|
||||||
to Stefan Huelswitt for pointing this out).
|
to Stefan Huelswitt for pointing this out).
|
||||||
|
- Fixed toggling the "Day" item in the "Timers" menu, so that it selects the
|
||||||
|
right day of week for timers in the future.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: menuitems.c 1.20 2004/11/14 16:16:21 kls Exp $
|
* $Id: menuitems.c 1.21 2004/11/21 13:24:10 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "menuitems.h"
|
#include "menuitems.h"
|
||||||
@ -554,6 +554,7 @@ cMenuEditDayItem::cMenuEditDayItem(const char *Name, int *Value)
|
|||||||
:cMenuEditIntItem(Name, Value, -INT_MAX, 31)
|
:cMenuEditIntItem(Name, Value, -INT_MAX, 31)
|
||||||
{
|
{
|
||||||
d = -1;
|
d = -1;
|
||||||
|
md = 0;
|
||||||
if (*value < 0) {
|
if (*value < 0) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while (days[n]) {
|
while (days[n]) {
|
||||||
@ -621,12 +622,14 @@ eOSState cMenuEditDayItem::ProcessKey(eKeys Key)
|
|||||||
eOSState result = cMenuEditIntItem::ProcessKey(Key);
|
eOSState result = cMenuEditIntItem::ProcessKey(Key);
|
||||||
if (result == osContinue && Key == k0) {
|
if (result == osContinue && Key == k0) {
|
||||||
if (d >= 0) {
|
if (d >= 0) {
|
||||||
*value = cTimer::GetMDay(time(NULL));
|
*value = md ? md : cTimer::GetMDay(time(NULL));
|
||||||
|
md = 0;
|
||||||
d = -1;
|
d = -1;
|
||||||
Set();
|
Set();
|
||||||
}
|
}
|
||||||
else if (*value == 0 || *value == v) {
|
else if (*value == 0 || *value == v) {
|
||||||
d = cTimer::GetWDay(time(NULL));
|
md = v;
|
||||||
|
d = cTimer::GetWDayFromMDay(v);
|
||||||
*value = days[d];
|
*value = days[d];
|
||||||
Set();
|
Set();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: menuitems.h 1.9 2004/05/16 12:45:14 kls Exp $
|
* $Id: menuitems.h 1.10 2004/11/21 13:23:00 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __MENUITEMS_H
|
#ifndef __MENUITEMS_H
|
||||||
@ -119,9 +119,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class cMenuEditDayItem : public cMenuEditIntItem {
|
class cMenuEditDayItem : public cMenuEditIntItem {
|
||||||
protected:
|
private:
|
||||||
static int days[];
|
static int days[];
|
||||||
int d;
|
int d;
|
||||||
|
int md;
|
||||||
|
protected:
|
||||||
virtual void Set(void);
|
virtual void Set(void);
|
||||||
public:
|
public:
|
||||||
cMenuEditDayItem(const char *Name, int *Value);
|
cMenuEditDayItem(const char *Name, int *Value);
|
||||||
|
14
timers.c
14
timers.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: timers.c 1.17 2004/11/14 16:02:42 kls Exp $
|
* $Id: timers.c 1.18 2004/11/21 13:15:33 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
@ -269,6 +269,18 @@ int cTimer::GetWDay(time_t t)
|
|||||||
return weekday == 0 ? 6 : weekday - 1; // we start with monday==0!
|
return weekday == 0 ? 6 : weekday - 1; // we start with monday==0!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cTimer::GetWDayFromMDay(int MDay)
|
||||||
|
{
|
||||||
|
time_t now = time(NULL);
|
||||||
|
int md = GetMDay(now);
|
||||||
|
for (int i = -1; i <= 28; i++) { // looking 4 weeks into the future should be enough
|
||||||
|
time_t t0 = IncDay(now, i);
|
||||||
|
if (GetMDay(t0) == MDay)
|
||||||
|
return GetWDay(t0);
|
||||||
|
}
|
||||||
|
return GetWDay(now); // just to return something
|
||||||
|
}
|
||||||
|
|
||||||
bool cTimer::DayMatches(time_t t) const
|
bool cTimer::DayMatches(time_t t) const
|
||||||
{
|
{
|
||||||
return IsSingleEvent() ? GetMDay(t) == day : (day & (1 << GetWDay(t))) != 0;
|
return IsSingleEvent() ? GetMDay(t) == day : (day & (1 << GetWDay(t))) != 0;
|
||||||
|
3
timers.h
3
timers.h
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: timers.h 1.11 2004/11/14 16:02:28 kls Exp $
|
* $Id: timers.h 1.12 2004/11/21 12:37:33 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __TIMERS_H
|
#ifndef __TIMERS_H
|
||||||
@ -66,6 +66,7 @@ public:
|
|||||||
bool IsSingleEvent(void) const;
|
bool IsSingleEvent(void) const;
|
||||||
static int GetMDay(time_t t);
|
static int GetMDay(time_t t);
|
||||||
static int GetWDay(time_t t);
|
static int GetWDay(time_t t);
|
||||||
|
static int GetWDayFromMDay(int MDay);
|
||||||
bool DayMatches(time_t t) const;
|
bool DayMatches(time_t t) const;
|
||||||
static time_t IncDay(time_t t, int Days);
|
static time_t IncDay(time_t t, int Days);
|
||||||
static time_t SetTime(time_t t, int SecondsFromMidnight);
|
static time_t SetTime(time_t t, int SecondsFromMidnight);
|
||||||
|
Loading…
Reference in New Issue
Block a user