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/>.
24 #include "directory.h"
25 #include "recording.h"
30 #include "vrecordingmenu.h"
31 #include "vrecording.h"
33 #include "vvideorec.h"
34 #include "vradiorec.h"
41 #include "movieinfo.h"
42 #include "seriesinfo.h"
43 #include "staticartwork.h"
45 #include "vrecordinglistadvanced.h"
48 VRecordingListAdvanced::VRecordingListAdvanced()
56 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
57 TVMediaInfo* info = new TVMediaInfo();
58 info->setStaticArtwork(sa_recordings);
59 setTitleBarIcon(info);
61 sl.setPosition(10, 30 + 5);
62 sl.setSize(area.w*42/100 - 20, area.h - 30 - 15 - 30);
63 sl.setLinesPerOption(2.4f);
66 Region slarea = sl.getRegionR();
68 epg.setParaMode(true);
69 epg.setPosition(slarea.x +slarea.w+10 ,30+5);
70 epg.setSize(area.w -slarea.x -slarea.w -10, area.h - 30 - 15 - 30);
73 epg.setBackgroundColour(DrawStyle::VIEWBACKGROUND);
75 epgTVmedia.setPosition(epg.getRegionR().w-100-10,10);
76 epgTVmedia.setSize(100, static_cast<UINT>(150/Osd::getInstance()->getPixelAspect()));
80 VRecordingListAdvanced::~VRecordingListAdvanced()
84 void VRecordingListAdvanced::drawData(bool doIndexPop)
86 int saveIndex = sl.getCurrentOption();
87 int saveTop = sl.getTopOption();
96 char tempA[300]; // FIXME this is guesswork!
97 char tempB[300]; // FIXME
100 Directory* currentSubDir;
101 DirectoryList::iterator i;
102 DirectoryList* dirList = recman->getDirectories();
103 for (i = dirList->begin(); i != dirList->end(); i++)
106 SNPRINTF(tempA, 300, tr("\t%s \n \t <dir> %lu/%lu"), 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(tempA, 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(tempA, 299, "%d/%m/%y %H:%M ", &btime);
131 int check = SNPRINTF(tempB, 300, "%c\t%s\n \t%s", (currentRec->getNew() ? '*': ' '), currentRec->getProgName(), tempA);
132 if ((check < 0) || (check > 299)) Log::getInstance()->log("VRecordingsListAdvanced", Log::ERR, "String too big");
135 TVMediaInfo *info= new TVMediaInfo();
136 info->setPosterThumb(currentRec->getFileName());
137 info->setStaticFallback(sa_recording);
138 currentRec->index = sl.addOption(tempB, 0, first, info);
144 sl.hintSetCurrent(slIndexStack.top());
149 sl.hintSetCurrent(saveIndex);
150 sl.hintSetTop(saveTop);
155 void VRecordingListAdvanced::draw(bool doIndexPop)
159 if (recman->isSubDir())
162 SNPRINTF(title, 300, tr("Recordings - %s"), recman->getCurDirName());
163 setTitleText(title, 364);
167 setTitleText(tr("Recordings"));
169 drawData(doIndexPop);
176 drawText(tr("Loading..."), area.w*22/100-90, 180, DrawStyle::LIGHTTEXT);
181 int gigFree = recman->getFreeSpace() / 1024;
182 SNPRINTF(freeSpace, 50, tr("%lu%% used, %iGB free"), recman->getUsedPercent(), gigFree);
183 drawTextRJ(freeSpace, 560+70, 5, DrawStyle::LIGHTTEXT);
188 w.nextSymbol = WSymbol::UP;
189 w.setPosition(20, area.h-35);
191 w.nextSymbol = WSymbol::DOWN;
192 w.setPosition(50, area.h-35);
194 w.nextSymbol = WSymbol::SKIPBACK;
195 w.setPosition(85, area.h-35);
197 w.nextSymbol = WSymbol::SKIPFORWARD;
198 w.setPosition(115, area.h-35);
200 w.nextSymbol = WSymbol::PLAY;
201 w.setPosition(150, area.h-35);
203 drawTextRJ(tr("[ok] = menu"), 560+70, 385+80, DrawStyle::LIGHTTEXT);
205 // All static stuff done
210 void VRecordingListAdvanced::doShowingBar()
211 { //setSize(640, 500); //old setSize(570, 420);
212 int topOption = sl.getTopOption() + 1;
213 if (sl.getNumOptions() == 0) topOption = 0;
214 #ifndef GRADIENT_DRAWING
215 rectangle(area.w/2-65, area.h-115, 180, 25, DrawStyle::VIEWBACKGROUND);
218 SNPRINTF(showing, 200, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
219 drawText(showing, area.w/2-65, area.h-35, DrawStyle::LIGHTTEXT);
222 void VRecordingListAdvanced::updateSelection()
224 Recording* toShow = getCurrentOptionRecording();
227 toShow->loadRecInfo();
228 std::stringstream description;
229 if (toShow->recInfo && strlen(toShow->recInfo->summary)){
230 description << "\n"<< toShow->recInfo->title << "\n\n";
231 description << toShow->recInfo->summary;
233 description << "\n" << std::string(toShow->getProgName()) << "\n\n";
234 description << tr("Summary unavailable");
239 if (toShow->movieInfo) {
240 poster=toShow->movieInfo->poster;
242 if (toShow->seriesInfo) {
243 if (toShow->seriesInfo->seasonposter.height) {
244 poster=toShow->seriesInfo->seasonposter;
247 if (toShow->seriesInfo->posters.size()) {
248 poster=toShow->seriesInfo->posters[0];
252 epgTVmedia.setTVMedia(poster.info, WTVMedia::ZoomHorizontal);
253 epgTVmedia.setVisible(true);
255 epgTVmedia.setVisible(false);
258 epg.setText(description.str().c_str());
260 Directory* toShowDir = getCurrentOptionDirectory();
263 std::stringstream description;
264 description << "\n"<< std::string(toShowDir->name) << "\n\n";
266 Directory* currentSubDir;
267 DirectoryList::iterator i;
268 DirectoryList & dirList = toShowDir->dirList;
269 for (i = dirList.begin(); i != dirList.end(); i++)
272 description << tr("<dir> ") << std::string(currentSubDir->name) << " "
273 << currentSubDir->getNumNewRecordings() <<"/"<< currentSubDir->getNumRecordings() <<"\n";
275 Recording* currentRec;
276 RecordingList::iterator j;
277 RecordingList & recList = toShowDir->recList;
280 for (j = recList.begin(); j != recList.end(); j++)
284 time_t recStartTime = static_cast<time_t>(currentRec->getStartTime());
285 LOCALTIME_R(&recStartTime, &btime);
286 strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime);
288 description<< tempA <<" "<< std::string(currentRec->getProgName()) << "\n";
291 epgTVmedia.setVisible(false);
292 epg.setText(description.str().c_str());
302 void VRecordingListAdvanced::quickUpdate() { //only quick for plattform that need it!
304 #ifdef GRADIENT_DRAWING