Implemented 'summary' feature

This commit is contained in:
Klaus Schmidinger
2000-07-24 16:43:04 +02:00
parent 6602eb5c90
commit 07d92eaee7
7 changed files with 175 additions and 23 deletions

78
menu.c
View File

@@ -4,10 +4,11 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: menu.c 1.19 2000/07/16 14:52:48 kls Exp $
* $Id: menu.c 1.20 2000/07/24 16:25:53 kls Exp $
*/
#include "menu.h"
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
@@ -707,6 +708,51 @@ eOSState cMenuChannels::ProcessKey(eKeys Key)
return state;
}
// --- cMenuSummary --------------------------------------------------------
class cMenuSummary : public cOsdMenu {
public:
cMenuSummary(const char *Text);
virtual eOSState ProcessKey(eKeys Key);
};
cMenuSummary::cMenuSummary(const char *Text)
:cOsdMenu("Summary")
{
while (*Text) {
char line[MenuColumns + 1];
char *p = line;
const char *b = NULL;
*p++ = ' ';
while (*Text && p - line < MenuColumns - 2) {
if (isspace(*Text))
b = Text; // remember the blank
if (*Text == '\n')
break;
*p++ = *Text++;
}
if (*Text) {
if (b && Text - b > 0) {
p -= Text - b;
Text = b + 1;
}
else
Text++;
}
*p = 0;
Add(new cOsdItem(line, osBack));
}
}
eOSState cMenuSummary::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown)
state = osContinue;
return state;
}
// --- cMenuEditTimer --------------------------------------------------------
class cMenuEditTimer : public cOsdMenu {
@@ -799,6 +845,7 @@ private:
eOSState New(void);
eOSState Del(void);
virtual void Move(int From, int To);
eOSState Summary(void);
public:
cMenuTimers(void);
virtual eOSState ProcessKey(eKeys Key);
@@ -880,6 +927,16 @@ void cMenuTimers::Move(int From, int To)
isyslog(LOG_INFO, "timer %d moved to %d", From + 1, To + 1);
}
eOSState cMenuTimers::Summary(void)
{
if (HasSubMenu() || Count() == 0)
return osContinue;
cTimer *ti = Timers.Get(Current());
if (ti && ti->summary && *ti->summary)
return AddSubMenu(new cMenuSummary(ti->summary));
return Edit(); // convenience for people not using the Summary feature ;-)
}
eOSState cMenuTimers::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
@@ -888,7 +945,7 @@ eOSState cMenuTimers::ProcessKey(eKeys Key)
switch (Key) {
case kLeft:
case kRight: return Activate(Key == kRight);
case kOk:
case kOk: return Summary();
case kRed: return Edit();
case kGreen: return New();
case kYellow: return Del();
@@ -926,6 +983,7 @@ private:
cRecordings Recordings;
eOSState Play(void);
eOSState Del(void);
eOSState Summary(void);
public:
cMenuRecordings(void);
virtual eOSState ProcessKey(eKeys Key);
@@ -941,7 +999,7 @@ cMenuRecordings::cMenuRecordings(void)
recording = Recordings.Next(recording);
}
}
SetHelp("Play", NULL/*XXX"Resume"*/, "Delete");
SetHelp("Play", NULL/*XXX"Resume"*/, "Delete", "Summary");
}
eOSState cMenuRecordings::Play(void)
@@ -975,6 +1033,16 @@ eOSState cMenuRecordings::Del(void)
return osContinue;
}
eOSState cMenuRecordings::Summary(void)
{
if (HasSubMenu() || Count() == 0)
return osContinue;
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
if (ri && ri->recording->Summary() && *ri->recording->Summary())
return AddSubMenu(new cMenuSummary(ri->recording->Summary()));
return osContinue;
}
eOSState cMenuRecordings::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
@@ -984,6 +1052,7 @@ eOSState cMenuRecordings::ProcessKey(eKeys Key)
case kOk:
case kRed: return Play();
case kYellow: return Del();
case kBlue: return Summary();
default: break;
}
}
@@ -1061,7 +1130,8 @@ cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer)
timer->SetRecording(true);
cChannel::SwitchTo(timer->channel - 1, dvbApi);
cRecording Recording(timer);
dvbApi->StartRecord(Recording.FileName());
if (dvbApi->StartRecord(Recording.FileName()))
Recording.WriteSummary();
Interface.DisplayRecording(dvbApi->Index(), true);
}