1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/* * statistic_item.h: The actual menu implementations
*
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id:
*/
#include "zaphistoryosd.h"
#include "zaphistory.h"
#include "zaplist.h"
#include "setup-zaphistory.h"
#include "statistic_item.h"
#include "epg_item.h"
#include <vdr/channels.h>
#include <vdr/menu.h>
#include <vdr/interface.h>
cZapHistoryChannelItem::cZapHistoryChannelItem(cZapHistoryChannel *Channel):cZapHistoryOsdItem(Channel)
{
if (Channel->GetChannel()->GroupSep())
SetSelectable(false);
Set();
}
void cZapHistoryChannelItem::Set(void)
{
char *buffer = NULL;
char *timeBuffer = NULL;
char *zapCountBuffer = NULL;
int hours = zapChannel->GetWatchTime() / 3600;
int minutes = (int) ( (zapChannel->GetWatchTime() % 3600) / 60 );
// build watch time string: e.g. --42:17
if (hours >= 1000)
asprintf( &timeBuffer, "%d:%02d" , hours, minutes );
else if (hours >= 100)
asprintf( &timeBuffer, "-%d:%02d" , hours, minutes );
else if (hours >= 10)
asprintf( &timeBuffer, "--%d:%02d" , hours, minutes );
else
asprintf( &timeBuffer, "---%d:%02d" , hours, minutes );
// build counter string: e.g. --58
if (zapChannel->GetZapCount() >= 1000)
asprintf( &zapCountBuffer, "%ld", zapChannel->GetZapCount() );
else if (zapChannel->GetZapCount() >= 100)
asprintf( &zapCountBuffer, "-%ld", zapChannel->GetZapCount() );
else if (zapChannel->GetZapCount() >= 10)
asprintf( &zapCountBuffer, "--%ld", zapChannel->GetZapCount() );
else
asprintf( &zapCountBuffer, "---%ld", zapChannel->GetZapCount() );
// build all data into one string
asprintf(&buffer, "%s\t %s\t %s", zapChannel->GetChannel()->Name(), zapCountBuffer, timeBuffer );
SetText(buffer, false);
}
|