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/>.
25 #include "directory.h"
26 #include "recording.h"
31 #include "vrecordingmenu.h"
32 #include "vrecording.h"
34 #include "vvideorec.h"
35 #include "vradiorec.h"
42 #include "movieinfo.h"
43 #include "seriesinfo.h"
44 #include "staticartwork.h"
46 #include "imageloader.h"
49 #include "vrecordinglistadvanced.h"
52 VRecordingListAdvanced::VRecordingListAdvanced()
60 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
62 Image icon = ImageLoader::getInstance()->createStatic(sa_recordings);
63 setTitleBarIcon(icon);
65 sl.setPosition(10, 30 + 5);
66 sl.setSize(area.w*42/100 - 20, area.h - 30 - 15 - 30);
67 sl.setLinesPerOption(2.4f);
70 Region slarea = sl.getRegionR();
72 epg.setParaMode(true);
73 epg.setPosition(slarea.x +slarea.w+10 ,30+5);
74 epg.setSize(area.w -slarea.x -slarea.w -10, area.h - 30 - 15 - 30);
77 epg.setBackgroundColour(DrawStyle::VIEWBACKGROUND);
79 epgTVmedia.setPosition(epg.getRegionR().w-100-10,10);
80 epgTVmedia.setSize(100, static_cast<u4>(150/Osd::getInstance()->getPixelAspect()));
84 VRecordingListAdvanced::~VRecordingListAdvanced()
88 void VRecordingListAdvanced::drawData(bool doIndexPop)
90 int saveIndex = sl.getCurrentOption();
91 int saveTop = sl.getTopOption();
100 char timeString[16]; // "dd/mm/yy hh:mm"
103 Directory* currentSubDir;
104 DirectoryList::iterator i;
105 DirectoryList* dirList = recman->getDirectories();
106 for (i = dirList->begin(); i != dirList->end(); i++)
109 std::string dirString = fmt::format("\t{} \n \t <dir> {}/{}", currentSubDir->name, currentSubDir->getNumNewRecordings(), currentSubDir->getNumRecordings());
112 if (currentSubDir->recList.begin() != currentSubDir->recList.end())
114 icon = ImageLoader::getInstance()->createRecFolder((*currentSubDir->recList.begin())->getFileName());
116 currentSubDir->index = sl.addOption(dirString, 0, first, icon);
120 // FIXME convert the whole program to time_t's
122 Recording* currentRec;
123 RecordingList::iterator j;
124 RecordingList* recList = recman->getRecordings();
125 for (j = recList->begin(); j != recList->end(); j++)
128 time_t recStartTime = static_cast<time_t>(currentRec->getStartTime());
129 LOCALTIME_R(&recStartTime, &btime);
130 strftime(timeString, 16, "%d/%m/%y %H:%M", &btime);
131 std::string fileString = fmt::format("{}\t{}\n \t{}", (currentRec->getNew() ? '*': ' '), currentRec->getProgName(), timeString);
133 Image icon = ImageLoader::getInstance()->createRecThumb(currentRec->getFileName());
134 currentRec->index = sl.addOption(fileString, 0, first, icon);
140 sl.hintSetCurrent(slIndexStack.top());
145 sl.hintSetCurrent(saveIndex);
146 sl.hintSetTop(saveTop);
151 void VRecordingListAdvanced::draw(bool doIndexPop)
155 if (recman->isSubDir())
158 SNPRINTF(title, 300, tr("Recordings - %s"), recman->getCurDirName());
159 setTitleText(title, 364);
163 setTitleText(tr("Recordings"));
165 drawData(doIndexPop);
172 drawText(tr("Loading..."), area.w*22/100-90, 180, DrawStyle::LIGHTTEXT);
177 int gigFree = recman->getFreeSpace() / 1024;
178 SNPRINTF(freeSpace, 50, tr("%lu%% used, %iGB free"), recman->getUsedPercent(), gigFree);
179 drawTextRJ(freeSpace, 560+70, 5, DrawStyle::LIGHTTEXT);
184 w.nextSymbol = WSymbol::UP;
185 w.setPosition(20, area.h-35);
187 w.nextSymbol = WSymbol::DOWN;
188 w.setPosition(50, area.h-35);
190 w.nextSymbol = WSymbol::SKIPBACK;
191 w.setPosition(85, area.h-35);
193 w.nextSymbol = WSymbol::SKIPFORWARD;
194 w.setPosition(115, area.h-35);
196 w.nextSymbol = WSymbol::PLAY;
197 w.setPosition(150, area.h-35);
199 drawTextRJ(tr("[ok] = menu"), 560+70, 385+80, DrawStyle::LIGHTTEXT);
201 // All static stuff done
206 void VRecordingListAdvanced::doShowingBar()
207 { //setSize(640, 500); //old setSize(570, 420);
208 int topOption = sl.getTopOption() + 1;
209 if (sl.getNumOptions() == 0) topOption = 0;
210 #ifndef GRADIENT_DRAWING
211 rectangle(area.w/2-65, area.h-115, 180, 25, DrawStyle::VIEWBACKGROUND);
214 SNPRINTF(showing, 200, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
215 drawText(showing, area.w/2-65, area.h-35, DrawStyle::LIGHTTEXT);
218 void VRecordingListAdvanced::updateSelection()
220 Recording* toShow = getCurrentOptionRecording();
223 toShow->loadRecInfo();
224 std::stringstream description;
225 if (toShow->recInfo && strlen(toShow->recInfo->summary)){
226 description << "\n"<< toShow->recInfo->title << "\n\n";
227 description << toShow->recInfo->summary;
229 description << "\n" << std::string(toShow->getProgName()) << "\n\n";
230 description << tr("Summary unavailable");
233 TVMediaStruct poster;
235 if (toShow->movieInfo) {
236 poster=toShow->movieInfo->poster;
238 if (toShow->seriesInfo) {
239 if (toShow->seriesInfo->seasonposter.height) {
240 poster=toShow->seriesInfo->seasonposter;
243 if (toShow->seriesInfo->posters.size()) {
244 poster=toShow->seriesInfo->posters[0];
248 epgTVmedia.setImage(poster.image, WTVMedia::ZoomHorizontal);
249 epgTVmedia.setVisible(true);
251 epgTVmedia.setVisible(false);
254 epg.setText(description.str().c_str());
256 Directory* toShowDir = getCurrentOptionDirectory();
259 std::stringstream description;
260 description << "\n"<< std::string(toShowDir->name) << "\n\n";
262 Directory* currentSubDir;
263 DirectoryList::iterator i;
264 DirectoryList & dirList = toShowDir->dirList;
265 for (i = dirList.begin(); i != dirList.end(); i++)
268 description << tr("<dir> ") << std::string(currentSubDir->name) << " "
269 << currentSubDir->getNumNewRecordings() <<"/"<< currentSubDir->getNumRecordings() <<"\n";
271 Recording* currentRec;
272 RecordingList::iterator j;
273 RecordingList & recList = toShowDir->recList;
276 for (j = recList.begin(); j != recList.end(); j++)
280 time_t recStartTime = static_cast<time_t>(currentRec->getStartTime());
281 LOCALTIME_R(&recStartTime, &btime);
282 strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime);
284 description<< tempA <<" "<< std::string(currentRec->getProgName()) << "\n";
287 epgTVmedia.setVisible(false);
288 epg.setText(description.str().c_str());
298 void VRecordingListAdvanced::quickUpdate() { //only quick for plattform that need it!
300 #ifdef GRADIENT_DRAWING