]> git.vomp.tv Git - vompclient.git/blob - vrecordinglistadvanced.cc
A couple of files were missing in git now added
[vompclient.git] / vrecordinglistadvanced.cc
1 /*
2     Copyright 2004-2007 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "vrecordinglistadvanced.h"
22
23 #include "recman.h"
24 #include "directory.h"
25 #include "recording.h"
26 #include "recinfo.h"
27 #include "remote.h"
28 #include "wsymbol.h"
29 #include "boxstack.h"
30 #include "vrecordingmenu.h"
31 #include "vrecording.h"
32 #include "vdr.h"
33 #include "vvideorec.h"
34 #include "vradiorec.h"
35 #include "colour.h"
36 #include "video.h"
37 #include "i18n.h"
38 #include "command.h"
39 #include "vinfo.h"
40 #include "log.h"
41 #include "movieinfo.h"
42 #include "seriesinfo.h"
43 #include "staticartwork.h"
44
45 #include <sstream>
46
47
48 VRecordingListAdvanced::VRecordingListAdvanced()
49 {
50         setSize(640, 500); //old   setSize(570, 420);
51         createBuffer();
52
53         setPosition(40, 40);
54
55         setTitleBarOn(1);
56         setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
57     TVMediaInfo *info= new TVMediaInfo();
58     info->setStaticArtwork(sa_recordings);
59     setTitleBarIcon(info);
60
61         sl.setPosition(10, 30 + 5);
62         sl.setSize(area.w*42/100 - 20, area.h - 30 - 15 - 30);
63         sl.setLinesPerOption(2.4f);
64         add(&sl);
65
66         Region slarea=sl.getRegionR();
67
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);
71         add(&epg);
72         epg.setText("");
73         epg.setBackgroundColour(DrawStyle::VIEWBACKGROUND);
74
75         epgTVmedia.setPosition(epg.getRegionR().w-100-10,10);
76         epgTVmedia.setSize(100,150/Osd::getInstance()->getPixelAspect());
77         epg.add(&epgTVmedia);
78
79 }
80
81 VRecordingListAdvanced::~VRecordingListAdvanced()
82 {
83 }
84
85 void VRecordingListAdvanced::drawData(bool doIndexPop)
86 {
87   int saveIndex = sl.getCurrentOption();
88   int saveTop = sl.getTopOption();
89   sl.clear();
90   sl.addColumn(0);
91   sl.addColumn(25 );
92   sl.addColumn(25 + 7);
93   //sl.addColumn(118);
94
95   int first = 1;
96
97   char tempA[300]; // FIXME  this is guesswork!
98   char tempB[300]; // FIXME
99   struct tm* btime;
100
101   Directory* currentSubDir;
102   DirectoryList::iterator i;
103   DirectoryList* dirList = recman->getDirectories();
104   for (i = dirList->begin(); i != dirList->end(); i++)
105   {
106     currentSubDir = *i;
107     SNPRINTF(tempA, 299, tr("\t%s \n \t <dir> %lu/%lu"),  currentSubDir->name, currentSubDir->getNumNewRecordings(), currentSubDir->getNumRecordings());
108
109     TVMediaInfo *info= NULL;
110     if (currentSubDir->recList.begin() != currentSubDir->recList.end())
111     {
112                 info=new TVMediaInfo();
113                 info->setPosterThumb((*currentSubDir->recList.begin())->getFileName());
114     }
115     currentSubDir->index = sl.addOption(tempA, 0, first, info);
116     first = 0;
117
118   }
119   // FIXME convert the whole program to time_t's
120
121   Recording* currentRec;
122   RecordingList::iterator j;
123   RecordingList* recList = recman->getRecordings();
124   for (j = recList->begin(); j != recList->end(); j++)
125   {
126     currentRec = *j;
127     time_t recStartTime = (time_t)currentRec->getStartTime();
128     btime = localtime(&recStartTime);
129 //NMT does not like this too!
130         //#ifndef _MSC_VER
131 //    strftime(tempA, 299, "%0d/%0m %0H:%0M ", btime);
132 //#else
133     strftime(tempA, 299, "%d/%m/%y %H:%M ", btime);
134 //#endif
135     sprintf(tempB, "%c\t%s\n \t%s",  (currentRec->getNew() ? '*': ' '), currentRec->getProgName(),tempA);
136     // New TVMedia stuff
137     TVMediaInfo *info= new TVMediaInfo();
138     info->setPosterThumb(currentRec->getFileName());
139     currentRec->index = sl.addOption(tempB, 0, first, info);
140     first = 0;
141   }
142
143   if (doIndexPop)
144   {
145     sl.hintSetCurrent(slIndexStack.top());
146     slIndexStack.pop();
147   }
148   else
149   {
150     sl.hintSetCurrent(saveIndex);
151     sl.hintSetTop(saveTop);
152   }
153   updateSelection();
154   sl.draw();
155   doShowingBar();
156   epg.draw();
157 }
158
159 void VRecordingListAdvanced::draw(bool doIndexPop)
160 {
161   if (!loading)
162   {
163     if (recman->isSubDir())
164     {
165       char title[300];
166       SNPRINTF(title, 299, tr("Recordings - %s"), recman->getCurDirName());
167       setTitleText(title, 364);
168     }
169     else
170     {
171       setTitleText(tr("Recordings"));
172     }
173   }
174
175   TBBoxx::draw();
176
177   if (loading)
178   {
179     drawText(tr("Loading..."), area.w*22/100-90, 180, DrawStyle::LIGHTTEXT);
180   }
181   else
182   {
183     char freeSpace[50];
184     int gigFree = recman->getFreeSpace() / 1024;
185     SNPRINTF(freeSpace, 49, tr("%lu%% used, %iGB free"), recman->getUsedPercent(), gigFree);
186     drawTextRJ(freeSpace, 560+70, 5, DrawStyle::LIGHTTEXT);
187     // Symbols
188
189     WSymbol w;
190     TEMPADD(&w);
191     w.nextSymbol = WSymbol::UP;
192     w.setPosition(20, area.h-35);
193     w.draw();
194     w.nextSymbol = WSymbol::DOWN;
195     w.setPosition(50, area.h-35);
196     w.draw();
197     w.nextSymbol = WSymbol::SKIPBACK;
198     w.setPosition(85, area.h-35);
199     w.draw();
200     w.nextSymbol = WSymbol::SKIPFORWARD;
201     w.setPosition(115, area.h-35);
202     w.draw();
203     w.nextSymbol = WSymbol::PLAY;
204     w.setPosition(150, area.h-35);
205     w.draw();
206     drawTextRJ(tr("[ok] = menu"), 560+70, 385+80, DrawStyle::LIGHTTEXT);
207
208     // All static stuff done
209     drawData(doIndexPop);
210   }
211 }
212
213 void VRecordingListAdvanced::doShowingBar()
214 { //setSize(640, 500); //old   setSize(570, 420);
215   int topOption = sl.getTopOption() + 1;
216   if (sl.getNumOptions() == 0) topOption = 0;
217 #ifndef GRADIENT_DRAWING
218   rectangle(area.w/2-65, area.h-115, 180, 25, DrawStyle::VIEWBACKGROUND);
219 #endif
220   char showing[200];
221   sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
222   drawText(showing, area.w/2-65, area.h-35, DrawStyle::LIGHTTEXT);
223 }
224
225 void VRecordingListAdvanced::updateSelection()
226 {
227         Recording* toShow = getCurrentOptionRecording();
228         if (toShow)
229         {
230                 toShow->loadRecInfo();
231                 std::stringstream description;
232                 if (toShow->recInfo && strlen(toShow->recInfo->summary)){
233                         description << "\n"<< toShow->recInfo->title  << "\n\n";
234                         description << toShow->recInfo->summary;
235                 }else {
236                         description << "\n" << std::string(toShow->getProgName()) << "\n\n";
237                         description << tr("Summary unavailable");
238
239                 }
240                 TVMedia poster;
241                 poster.height=0;
242                 if (toShow->movieInfo) {
243                         poster=toShow->movieInfo->poster;
244                 }
245                 if (toShow->seriesInfo) {
246                         if (toShow->seriesInfo->seasonposter.height) {
247                                 poster=toShow->seriesInfo->seasonposter;
248                         }
249                         else
250                                 if (toShow->seriesInfo->posters.size()) {
251                                         poster=toShow->seriesInfo->posters[0];
252                                 }
253                 }
254                 if (poster.height) {
255                         epgTVmedia.setTVMedia(poster.info, WTVMedia::ZoomHorizontal);
256                         epgTVmedia.setVisible(true);
257                 } else {
258                         epgTVmedia.setVisible(false);
259                 }
260
261                 epg.setText(description.str().c_str());
262         } else {
263                 Directory* toShowDir = getCurrentOptionDirectory();
264                 if (toShowDir)
265                 {
266                         std::stringstream description;
267                         description << "\n"<< std::string(toShowDir->name) << "\n\n";
268
269                         Directory* currentSubDir;
270                         DirectoryList::iterator i;
271                         DirectoryList & dirList = toShowDir->dirList;
272                         for (i = dirList.begin(); i != dirList.end(); i++)
273                         {
274                                 currentSubDir = *i;
275                                 description << tr("<dir> ") <<  std::string(currentSubDir->name) << " "
276                                                 << currentSubDir->getNumNewRecordings() <<"/"<< currentSubDir->getNumRecordings() <<"\n";
277                         }
278                         Recording* currentRec;
279                         RecordingList::iterator j;
280                         RecordingList & recList = toShowDir->recList;
281                         char tempA[300];
282                         struct tm* btime;
283                         for (j = recList.begin(); j != recList.end(); j++)
284                         {
285                                 currentRec = *j;
286
287                                 time_t recStartTime = (time_t)currentRec->getStartTime();
288                                 btime = localtime(&recStartTime);
289                                 strftime(tempA, 299, "%d/%m/%y %H:%M ", btime);
290
291                                 description<< tempA <<" "<< std::string(currentRec->getProgName()) << "\n";
292
293                         }
294                         epgTVmedia.setVisible(false);
295                         epg.setText(description.str().c_str());
296
297
298                 }
299         }
300
301 }
302
303
304
305 void VRecordingListAdvanced::quickUpdate() { //only quick for plattform that need it!
306         updateSelection();
307 #ifdef GRADIENT_DRAWING
308       draw();
309 #else
310       sl.draw();
311       doShowingBar();
312       epg.draw();
313 #endif
314 }