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 "vrecordinglistadvanced.h"
49 VRecordingListAdvanced::VRecordingListAdvanced()
57 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
58 TVMediaInfo* info = new TVMediaInfo();
59 info->setStaticArtwork(sa_recordings);
60 setTitleBarIcon(info);
62 sl.setPosition(10, 30 + 5);
63 sl.setSize(area.w*42/100 - 20, area.h - 30 - 15 - 30);
64 sl.setLinesPerOption(2.4f);
67 Region slarea = sl.getRegionR();
69 epg.setParaMode(true);
70 epg.setPosition(slarea.x +slarea.w+10 ,30+5);
71 epg.setSize(area.w -slarea.x -slarea.w -10, area.h - 30 - 15 - 30);
74 epg.setBackgroundColour(DrawStyle::VIEWBACKGROUND);
76 epgTVmedia.setPosition(epg.getRegionR().w-100-10,10);
77 epgTVmedia.setSize(100, static_cast<UINT>(150/Osd::getInstance()->getPixelAspect()));
81 VRecordingListAdvanced::~VRecordingListAdvanced()
85 void VRecordingListAdvanced::drawData(bool doIndexPop)
87 int saveIndex = sl.getCurrentOption();
88 int saveTop = sl.getTopOption();
97 char timeString[16]; // "dd/mm/yy hh:mm"
100 Directory* currentSubDir;
101 DirectoryList::iterator i;
102 DirectoryList* dirList = recman->getDirectories();
103 for (i = dirList->begin(); i != dirList->end(); i++)
106 std::string dirString = fmt::format("\t{} \n \t <dir> {}/{}", currentSubDir->name, currentSubDir->getNumNewRecordings(), currentSubDir->getNumRecordings());
108 TVMediaInfo *info=new TVMediaInfo();
109 if (currentSubDir->recList.begin() != currentSubDir->recList.end())
111 info->setPosterThumb((*currentSubDir->recList.begin())->getFileName());
112 info->setStaticFallback(sa_recfolder);
114 info->setStaticArtwork(sa_recfolder);
116 currentSubDir->index = sl.addOption(dirString, 0, first, info);
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);
134 TVMediaInfo *info= new TVMediaInfo();
135 info->setPosterThumb(currentRec->getFileName());
136 info->setStaticFallback(sa_recording);
137 currentRec->index = sl.addOption(fileString, 0, first, info);
143 sl.hintSetCurrent(slIndexStack.top());
148 sl.hintSetCurrent(saveIndex);
149 sl.hintSetTop(saveTop);
154 void VRecordingListAdvanced::draw(bool doIndexPop)
158 if (recman->isSubDir())
161 SNPRINTF(title, 300, tr("Recordings - %s"), recman->getCurDirName());
162 setTitleText(title, 364);
166 setTitleText(tr("Recordings"));
168 drawData(doIndexPop);
175 drawText(tr("Loading..."), area.w*22/100-90, 180, DrawStyle::LIGHTTEXT);
180 int gigFree = recman->getFreeSpace() / 1024;
181 SNPRINTF(freeSpace, 50, tr("%lu%% used, %iGB free"), recman->getUsedPercent(), gigFree);
182 drawTextRJ(freeSpace, 560+70, 5, DrawStyle::LIGHTTEXT);
187 w.nextSymbol = WSymbol::UP;
188 w.setPosition(20, area.h-35);
190 w.nextSymbol = WSymbol::DOWN;
191 w.setPosition(50, area.h-35);
193 w.nextSymbol = WSymbol::SKIPBACK;
194 w.setPosition(85, area.h-35);
196 w.nextSymbol = WSymbol::SKIPFORWARD;
197 w.setPosition(115, area.h-35);
199 w.nextSymbol = WSymbol::PLAY;
200 w.setPosition(150, area.h-35);
202 drawTextRJ(tr("[ok] = menu"), 560+70, 385+80, DrawStyle::LIGHTTEXT);
204 // All static stuff done
209 void VRecordingListAdvanced::doShowingBar()
210 { //setSize(640, 500); //old setSize(570, 420);
211 int topOption = sl.getTopOption() + 1;
212 if (sl.getNumOptions() == 0) topOption = 0;
213 #ifndef GRADIENT_DRAWING
214 rectangle(area.w/2-65, area.h-115, 180, 25, DrawStyle::VIEWBACKGROUND);
217 SNPRINTF(showing, 200, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
218 drawText(showing, area.w/2-65, area.h-35, DrawStyle::LIGHTTEXT);
221 void VRecordingListAdvanced::updateSelection()
223 Recording* toShow = getCurrentOptionRecording();
226 toShow->loadRecInfo();
227 std::stringstream description;
228 if (toShow->recInfo && strlen(toShow->recInfo->summary)){
229 description << "\n"<< toShow->recInfo->title << "\n\n";
230 description << toShow->recInfo->summary;
232 description << "\n" << std::string(toShow->getProgName()) << "\n\n";
233 description << tr("Summary unavailable");
238 if (toShow->movieInfo) {
239 poster=toShow->movieInfo->poster;
241 if (toShow->seriesInfo) {
242 if (toShow->seriesInfo->seasonposter.height) {
243 poster=toShow->seriesInfo->seasonposter;
246 if (toShow->seriesInfo->posters.size()) {
247 poster=toShow->seriesInfo->posters[0];
251 epgTVmedia.setTVMedia(poster.info, WTVMedia::ZoomHorizontal);
252 epgTVmedia.setVisible(true);
254 epgTVmedia.setVisible(false);
257 epg.setText(description.str().c_str());
259 Directory* toShowDir = getCurrentOptionDirectory();
262 std::stringstream description;
263 description << "\n"<< std::string(toShowDir->name) << "\n\n";
265 Directory* currentSubDir;
266 DirectoryList::iterator i;
267 DirectoryList & dirList = toShowDir->dirList;
268 for (i = dirList.begin(); i != dirList.end(); i++)
271 description << tr("<dir> ") << std::string(currentSubDir->name) << " "
272 << currentSubDir->getNumNewRecordings() <<"/"<< currentSubDir->getNumRecordings() <<"\n";
274 Recording* currentRec;
275 RecordingList::iterator j;
276 RecordingList & recList = toShowDir->recList;
279 for (j = recList.begin(); j != recList.end(); j++)
283 time_t recStartTime = static_cast<time_t>(currentRec->getStartTime());
284 LOCALTIME_R(&recStartTime, &btime);
285 strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime);
287 description<< tempA <<" "<< std::string(currentRec->getProgName()) << "\n";
290 epgTVmedia.setVisible(false);
291 epg.setText(description.str().c_str());
301 void VRecordingListAdvanced::quickUpdate() { //only quick for plattform that need it!
303 #ifdef GRADIENT_DRAWING