2 Copyright 2004-2020 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
23 #include "directory.h"
24 #include "recording.h"
28 #include "vrecordingmenu.h"
29 #include "vrecording.h"
31 #include "vvideorec.h"
32 #include "vradiorec.h"
40 #include "vrecordinglistclassic.h"
42 VRecordingListClassic::VRecordingListClassic()
46 if (Video::getInstance()->getFormat() == Video::PAL)
56 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
58 sl.setPosition(10, 30 + 5);
59 sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
63 VRecordingListClassic::~VRecordingListClassic()
67 void VRecordingListClassic::drawData(bool doIndexPop)
69 int saveIndex = sl.getCurrentOption();
70 int saveTop = sl.getTopOption();
78 char timeString[16]; // "dd/mm hh:mm"
81 Directory* currentSubDir;
82 DirectoryList::iterator i;
83 DirectoryList* dirList = recman->getDirectories();
84 for (i = dirList->begin(); i != dirList->end(); i++)
87 std::string dirString = fmt::format("<dir> {}/{}\t \t{}", currentSubDir->getNumNewRecordings(), currentSubDir->getNumRecordings(), currentSubDir->name);
88 currentSubDir->index = sl.addOption(dirString, 0, first);
91 // FIXME convert the whole program to time_t's
93 Recording* currentRec;
94 RecordingList::iterator j;
95 RecordingList* recList = recman->getRecordings();
96 for (j = recList->begin(); j != recList->end(); j++)
99 time_t recStartTime = static_cast<time_t>(currentRec->getStartTime());
100 LOCALTIME_R(&recStartTime, &btime);
101 strftime(timeString, 16, "%d/%m %H:%M", &btime);
102 std::string fileString = fmt::format("{} \t{}\t{}", timeString, (currentRec->getNew() ? '*': ' '), currentRec->getProgName());
103 currentRec->index = sl.addOption(fileString, 0, first);
109 sl.hintSetCurrent(slIndexStack.top());
114 sl.hintSetCurrent(saveIndex);
115 sl.hintSetTop(saveTop);
121 void VRecordingListClassic::draw(bool doIndexPop)
125 if (recman->isSubDir())
128 SNPRINTF(title, 300, tr("Recordings - %s"), recman->getCurDirName());
129 setTitleText(title, 364);
133 setTitleText(tr("Recordings"));
141 drawText(tr("Loading..."), 240, 180, DrawStyle::LIGHTTEXT);
146 int gigFree = recman->getFreeSpace() / 1024;
147 SNPRINTF(freeSpace, 50, tr("%lu%% used, %iGB free"), recman->getUsedPercent(), gigFree);
148 drawTextRJ(freeSpace, 560, 5, DrawStyle::LIGHTTEXT);
153 w.nextSymbol = WSymbol::UP;
154 w.setPosition(20, 385);
156 w.nextSymbol = WSymbol::DOWN;
157 w.setPosition(50, 385);
159 w.nextSymbol = WSymbol::SKIPBACK;
160 w.setPosition(85, 385);
162 w.nextSymbol = WSymbol::SKIPFORWARD;
163 w.setPosition(115, 385);
165 w.nextSymbol = WSymbol::PLAY;
166 w.setPosition(150, 385);
168 drawTextRJ(tr("[ok] = menu"), 560, 385, DrawStyle::LIGHTTEXT);
170 // All static stuff done
171 drawData(doIndexPop);
175 void VRecordingListClassic::doShowingBar()
177 int topOption = sl.getTopOption() + 1;
178 if (sl.getNumOptions() == 0) topOption = 0;
179 #ifndef GRADIENT_DRAWING
180 rectangle(220, 385, 180, 25, DrawStyle::VIEWBACKGROUND);
183 SNPRINTF(showing, 200, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
184 drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
187 void VRecordingListClassic::quickUpdate() { //only quick for plattform that need it!
188 #ifdef GRADIENT_DRAWING