/*
Copyright 2004-2007 Chris Tallon
This file is part of VOMP.
VOMP is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
VOMP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VOMP; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "vrecordinglistclassic.h"
#include "recman.h"
#include "directory.h"
#include "recording.h"
#include "remote.h"
#include "wsymbol.h"
#include "boxstack.h"
#include "vrecordingmenu.h"
#include "vrecording.h"
#include "vdr.h"
#include "vvideorec.h"
#include "vradiorec.h"
#include "colour.h"
#include "video.h"
#include "i18n.h"
#include "command.h"
#include "vinfo.h"
#include "log.h"
VRecordingListClassic::VRecordingListClassic()
{
setSize(570, 420);
createBuffer();
if (Video::getInstance()->getFormat() == Video::PAL)
{
setPosition(80, 70);
}
else
{
setPosition(70, 35);
}
setTitleBarOn(1);
setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
sl.setPosition(10, 30 + 5);
sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
add(&sl);
}
VRecordingListClassic::~VRecordingListClassic()
{
}
void VRecordingListClassic::drawData(bool doIndexPop)
{
int saveIndex = sl.getCurrentOption();
int saveTop = sl.getTopOption();
sl.clear();
sl.addColumn(0);
sl.addColumn(102);
sl.addColumn(118);
int first = 1;
char tempA[300]; // FIXME this is guesswork!
char tempB[300]; // FIXME
struct tm btime;
Directory* currentSubDir;
DirectoryList::iterator i;
DirectoryList* dirList = recman->getDirectories();
for (i = dirList->begin(); i != dirList->end(); i++)
{
currentSubDir = *i;
SNPRINTF(tempA, 299, tr("
%lu/%lu\t \t%s"), currentSubDir->getNumNewRecordings(), currentSubDir->getNumRecordings(), currentSubDir->name);
currentSubDir->index = sl.addOption(tempA, 0, first);
first = 0;
}
// FIXME convert the whole program to time_t's
Recording* currentRec;
RecordingList::iterator j;
RecordingList* recList = recman->getRecordings();
for (j = recList->begin(); j != recList->end(); j++)
{
currentRec = *j;
time_t recStartTime = (time_t)currentRec->getStartTime();
LOCALTIME_R(&recStartTime, &btime);
//NMT does not like this too!
//#ifndef _MSC_VER
// strftime(tempA, 299, "%0d/%0m %0H:%0M ", &btime);
//#else
strftime(tempA, 299, "%d/%m %H:%M ", &btime);
//#endif
sprintf(tempB, "%s\t%c\t%s", tempA, (currentRec->getNew() ? '*': ' '), currentRec->getProgName());
currentRec->index = sl.addOption(tempB, 0, first);
first = 0;
}
if (doIndexPop)
{
sl.hintSetCurrent(slIndexStack.top());
slIndexStack.pop();
}
else
{
sl.hintSetCurrent(saveIndex);
sl.hintSetTop(saveTop);
}
sl.draw();
doShowingBar();
}
void VRecordingListClassic::draw(bool doIndexPop)
{
if (!loading)
{
if (recman->isSubDir())
{
char title[300];
SNPRINTF(title, 299, tr("Recordings - %s"), recman->getCurDirName());
setTitleText(title, 364);
}
else
{
setTitleText(tr("Recordings"));
}
}
TBBoxx::draw();
if (loading)
{
drawText(tr("Loading..."), 240, 180, DrawStyle::LIGHTTEXT);
}
else
{
char freeSpace[50];
int gigFree = recman->getFreeSpace() / 1024;
SNPRINTF(freeSpace, 49, tr("%lu%% used, %iGB free"), recman->getUsedPercent(), gigFree);
drawTextRJ(freeSpace, 560, 5, DrawStyle::LIGHTTEXT);
// Symbols
WSymbol w;
TEMPADD(&w);
w.nextSymbol = WSymbol::UP;
w.setPosition(20, 385);
w.draw();
w.nextSymbol = WSymbol::DOWN;
w.setPosition(50, 385);
w.draw();
w.nextSymbol = WSymbol::SKIPBACK;
w.setPosition(85, 385);
w.draw();
w.nextSymbol = WSymbol::SKIPFORWARD;
w.setPosition(115, 385);
w.draw();
w.nextSymbol = WSymbol::PLAY;
w.setPosition(150, 385);
w.draw();
drawTextRJ(tr("[ok] = menu"), 560, 385, DrawStyle::LIGHTTEXT);
// All static stuff done
drawData(doIndexPop);
}
}
void VRecordingListClassic::doShowingBar()
{
int topOption = sl.getTopOption() + 1;
if (sl.getNumOptions() == 0) topOption = 0;
#ifndef GRADIENT_DRAWING
rectangle(220, 385, 180, 25, DrawStyle::VIEWBACKGROUND);
#endif
char showing[200];
sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
}
void VRecordingListClassic::quickUpdate() { //only quick for plattform that need it!
#ifdef GRADIENT_DRAWING
draw();
#else
sl.draw();
doShowingBar();
#endif
}