summaryrefslogtreecommitdiff
path: root/setup-zaphistory.c
blob: b34c3f8544f8c6284fae4400b3db29cc2dc0c461 (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * ZapHistory Player plugin for VDR
 *
 * This code is distributed under the terms and conditions of the
 * GNU GENERAL PUBLIC LICENSE. Read the file COPYING for details.
 */

#include "zaphistory.h"
#include "setup-zaphistory.h"
#ifdef __QNXNTO__
#include <strings.h>
#include <vdr/channels.h>

#endif

cZapHistorySetup ZapHistorySetup;

// --- cZapHistorySetup -----------------------------------------------------------
cZapHistorySetup::cZapHistorySetup(void)
{
    // set default values
    HideMainMenu  = 0;
    DefaultView = historyView;
    DefaultSort = historySort;
    EntryCount = 10;
    
    ProgressView = 0;
}

void cZapHistorySetup::IntToEnum() {
    // Convert int-dummy values to enum
    switch (DummyDefaultView) {
	    case 0: DefaultView = historyView; break;
	    case 1: DefaultView = statisticView; break;
    }

    switch (DummyDefaultSort) {
	    case 0: DefaultSort = historySort; break;
	    case 1: DefaultSort = zapcountSort; break;
	    case 2: DefaultSort = watchtimeSort; break;
    }
}

bool cZapHistorySetup::SetupParse(const char *Name, const char *Value)
{
    // Parse your own setup parameters and store their values.
    if (!strcasecmp(Name, "HideMainMenu"))  HideMainMenu  = atoi(Value);
    else if (!strcasecmp(Name, "EntryCount"))  EntryCount  = atoi(Value);
    else if (!strcasecmp(Name, "DefaultView"))  { DummyDefaultView = atoi(Value); IntToEnum(); }
    else if (!strcasecmp(Name, "DefaultSort")) { DummyDefaultSort = atoi(Value); IntToEnum(); }
    else if (!strcasecmp(Name, "ProgressView")) { ProgressView = atoi(Value); }
    else
	    return false;
    return true;
}

// --- cMenuSetupZapHistory --------------------------------------------------------

cMenuSetupZapHistory::cMenuSetupZapHistory(void)
{
    // init sort option strings
    sortStrs[0] = tr("Latest view");
    sortStrs[1] = tr("Zap count");
    sortStrs[2] = tr("View time");

    // init view option strings
    viewStrs[0] = tr("Button$Schedule");
    viewStrs[1] = tr("Button$Statistic");

    ProgressViewtStrs[0] = tr("old text bar");
    ProgressViewtStrs[1] = tr("VDRSymbols");
    ProgressViewtStrs[2] = tr("Percent");
    
    // add menu items
    SetSection(tr("Zaphistory"));
#if APIVERSNUM >= 20301
    LOCK_CHANNELS_READ;
    Add(new cMenuEditIntItem(tr("Number of entries"),  &ZapHistorySetup.EntryCount, 0, Channels->Count() ));
#else
    Add(new cMenuEditIntItem(tr("Number of entries"),  &ZapHistorySetup.EntryCount, 0, Channels.Count() ));
#endif
    Add(new cMenuEditBoolItem(tr("Hide mainmenu entry"), &ZapHistorySetup.HideMainMenu));
    Add(new cMenuEditStraItem(tr("Default view"), &ZapHistorySetup.DummyDefaultView, 2, viewStrs));
    Add(new cMenuEditStraItem(tr("Default sort"), &ZapHistorySetup.DummyDefaultSort, 3, sortStrs));    
    Add(new cMenuEditStraItem(tr("Progress view"), &ZapHistorySetup.ProgressView, 3, ProgressViewtStrs));    
}

void cMenuSetupZapHistory::Store(void)
{
    // store setup
    ZapHistorySetup.IntToEnum();

    SetupStore("HideMainMenu",  ZapHistorySetup.HideMainMenu  );
    SetupStore("EntryCount",  ZapHistorySetup.EntryCount  );
    SetupStore("DefaultView",  ZapHistorySetup.DummyDefaultView  );
    SetupStore("DefaultSort",  ZapHistorySetup.DummyDefaultSort  );
    SetupStore("ProgressView",  ZapHistorySetup.ProgressView  );
}