summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2001-08-26 14:17:20 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2001-08-26 14:17:20 +0200
commit6f6891082885d6c68f1a7efd80f99a0c907a9a4b (patch)
tree0d1bab65caa4e601bd5c5569452d83ba80b2dedb /menu.c
parent7092907ccd846090da89cedf0cca216ff38c6205 (diff)
downloadvdr-6f6891082885d6c68f1a7efd80f99a0c907a9a4b.tar.gz
vdr-6f6891082885d6c68f1a7efd80f99a0c907a9a4b.tar.bz2
Sorting timers in the 'Timers' menu
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/menu.c b/menu.c
index 4158f75f..6d6eae8e 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c 1.108 2001/08/26 12:13:24 kls Exp $
+ * $Id: menu.c 1.109 2001/08/26 14:03:27 kls Exp $
*/
#include "menu.h"
@@ -957,20 +957,25 @@ eOSState cMenuEditTimer::ProcessKey(eKeys Key)
class cMenuTimerItem : public cOsdItem {
private:
- int index;
cTimer *timer;
public:
- cMenuTimerItem(int Index, cTimer *Timer);
+ cMenuTimerItem(cTimer *Timer);
+ virtual bool operator< (const cListObject &ListObject);
virtual void Set(void);
+ cTimer *Timer(void) { return timer; }
};
-cMenuTimerItem::cMenuTimerItem(int Index, cTimer *Timer)
+cMenuTimerItem::cMenuTimerItem(cTimer *Timer)
{
- index = Index;
timer = Timer;
Set();
}
+bool cMenuTimerItem::operator< (const cListObject &ListObject)
+{
+ return *timer < *((cMenuTimerItem *)&ListObject)->timer;
+}
+
void cMenuTimerItem::Set(void)
{
char *buffer = NULL;
@@ -996,6 +1001,7 @@ private:
eOSState Del(void);
virtual void Move(int From, int To);
eOSState Summary(void);
+ cTimer *CurrentTimer(void);
public:
cMenuTimers(void);
virtual eOSState ProcessKey(eKeys Key);
@@ -1008,15 +1014,23 @@ cMenuTimers::cMenuTimers(void)
cTimer *timer;
while ((timer = Timers.Get(i)) != NULL) {
- Add(new cMenuTimerItem(i, timer));
+ Add(new cMenuTimerItem(timer));
i++;
}
- SetHelp(tr("Edit"), tr("New"), tr("Delete"), tr("Mark"));
+ if (Setup.SortTimers)
+ Sort();
+ SetHelp(tr("Edit"), tr("New"), tr("Delete"), Setup.SortTimers ? NULL : tr("Mark"));
+}
+
+cTimer *cMenuTimers::CurrentTimer(void)
+{
+ cMenuTimerItem *item = (cMenuTimerItem *)Get(Current());
+ return item ? item->Timer() : NULL;
}
eOSState cMenuTimers::Activate(bool On)
{
- cTimer *timer = Timers.Get(Current());
+ cTimer *timer = CurrentTimer();
if (timer && timer->active != On) {
timer->active = On;
RefreshCurrent();
@@ -1031,8 +1045,8 @@ eOSState cMenuTimers::Edit(void)
{
if (HasSubMenu() || Count() == 0)
return osContinue;
- isyslog(LOG_INFO, "editing timer %d", Current() + 1);
- return AddSubMenu(new cMenuEditTimer(Current()));
+ isyslog(LOG_INFO, "editing timer %d", CurrentTimer()->Index() + 1);
+ return AddSubMenu(new cMenuEditTimer(CurrentTimer()->Index()));
}
eOSState cMenuTimers::New(void)
@@ -1041,22 +1055,22 @@ eOSState cMenuTimers::New(void)
return osContinue;
cTimer *timer = new cTimer;
Timers.Add(timer);
- Add(new cMenuTimerItem(timer->Index()/*XXX*/, timer), true);
+ Add(new cMenuTimerItem(timer), true);
Timers.Save();
isyslog(LOG_INFO, "timer %d added", timer->Index() + 1);
- return AddSubMenu(new cMenuEditTimer(Current(), true));
+ return AddSubMenu(new cMenuEditTimer(timer->Index(), true));
}
eOSState cMenuTimers::Del(void)
{
// Check if this timer is active:
- int Index = Current();
- cTimer *ti = Timers.Get(Index);
+ cTimer *ti = CurrentTimer();
if (ti) {
if (!ti->recording) {
if (Interface->Confirm(tr("Delete timer?"))) {
- Timers.Del(Timers.Get(Index));
- cOsdMenu::Del(Index);
+ int Index = ti->Index();
+ Timers.Del(ti);
+ cOsdMenu::Del(Current());
Timers.Save();
Display();
isyslog(LOG_INFO, "timer %d deleted", Index + 1);
@@ -1081,7 +1095,7 @@ eOSState cMenuTimers::Summary(void)
{
if (HasSubMenu() || Count() == 0)
return osContinue;
- cTimer *ti = Timers.Get(Current());
+ cTimer *ti = CurrentTimer();
if (ti && ti->summary && *ti->summary)
return AddSubMenu(new cMenuText(tr("Summary"), ti->summary));
return Edit(); // convenience for people not using the Summary feature ;-)
@@ -1109,7 +1123,9 @@ eOSState cMenuTimers::ProcessKey(eKeys Key)
case kRed: return Edit();
case kGreen: return New();
case kYellow: return Del();
- case kBlue: Mark(); break;
+ case kBlue: if (!Setup.SortTimers)
+ Mark();
+ break;
default: break;
}
}
@@ -1706,6 +1722,7 @@ void cMenuSetup::Set(void)
Add(new cMenuEditIntItem( tr("EPGScanTimeout"), &data.EPGScanTimeout));
Add(new cMenuEditIntItem( tr("EPGBugfixLevel"), &data.EPGBugfixLevel, 0, 3));
Add(new cMenuEditIntItem( tr("SVDRPTimeout"), &data.SVDRPTimeout));
+ Add(new cMenuEditBoolItem(tr("SortTimers"), &data.SortTimers));
Add(new cMenuEditIntItem( tr("PrimaryLimit"), &data.PrimaryLimit, 0, MAXPRIORITY));
Add(new cMenuEditIntItem( tr("DefaultPriority"), &data.DefaultPriority, 0, MAXPRIORITY));
Add(new cMenuEditIntItem( tr("DefaultLifetime"), &data.DefaultLifetime, 0, MAXLIFETIME));