]> git.vomp.tv Git - vompclient.git/blob - vrecordinglistclassic.cc
More compiler warning fixes
[vompclient.git] / vrecordinglistclassic.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 "vrecordinglistclassic.h"
22
23 #include "recman.h"
24 #include "directory.h"
25 #include "recording.h"
26 #include "remote.h"
27 #include "wsymbol.h"
28 #include "boxstack.h"
29 #include "vrecordingmenu.h"
30 #include "vrecording.h"
31 #include "vdr.h"
32 #include "vvideorec.h"
33 #include "vradiorec.h"
34 #include "colour.h"
35 #include "video.h"
36 #include "i18n.h"
37 #include "command.h"
38 #include "vinfo.h"
39 #include "log.h"
40
41 VRecordingListClassic::VRecordingListClassic()
42 {
43   setSize(570, 420);
44   createBuffer();
45   if (Video::getInstance()->getFormat() == Video::PAL)
46   {
47     setPosition(80, 70);
48   }
49   else
50   {
51     setPosition(70, 35);
52   }
53
54   setTitleBarOn(1);
55   setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
56
57   sl.setPosition(10, 30 + 5);
58   sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
59   add(&sl);
60 }
61
62 VRecordingListClassic::~VRecordingListClassic()
63 {
64 }
65
66 void VRecordingListClassic::drawData(bool doIndexPop)
67 {
68   int saveIndex = sl.getCurrentOption();
69   int saveTop = sl.getTopOption();
70   sl.clear();
71   sl.addColumn(0);
72   sl.addColumn(102);
73   sl.addColumn(118);
74
75   int first = 1;
76
77   char tempA[300]; // FIXME  this is guesswork!
78   char tempB[300]; // FIXME
79   struct tm btime;
80
81   Directory* currentSubDir;
82   DirectoryList::iterator i;
83   DirectoryList* dirList = recman->getDirectories();
84   for (i = dirList->begin(); i != dirList->end(); i++)
85   {
86     currentSubDir = *i;
87     SNPRINTF(tempA, 299, tr("<dir> %lu/%lu\t \t%s"), currentSubDir->getNumNewRecordings(), currentSubDir->getNumRecordings(), currentSubDir->name);
88     currentSubDir->index = sl.addOption(tempA, 0, first);
89     first = 0;
90   }
91   // FIXME convert the whole program to time_t's
92
93   Recording* currentRec;
94   RecordingList::iterator j;
95   RecordingList* recList = recman->getRecordings();
96   for (j = recList->begin(); j != recList->end(); j++)
97   {
98     currentRec = *j;
99     time_t recStartTime = (time_t)currentRec->getStartTime();
100     localtime_r(&recStartTime, &btime);
101 //NMT does not like this too!
102         //#ifndef _MSC_VER
103 //    strftime(tempA, 299, "%0d/%0m %0H:%0M ", &btime);
104 //#else
105     strftime(tempA, 299, "%d/%m %H:%M ", &btime);
106 //#endif
107     sprintf(tempB, "%s\t%c\t%s", tempA, (currentRec->getNew() ? '*': ' '), currentRec->getProgName());
108       
109     currentRec->index = sl.addOption(tempB, 0, first);
110     first = 0;
111   }
112
113   if (doIndexPop)
114   {
115     sl.hintSetCurrent(slIndexStack.top());
116     slIndexStack.pop();
117   }
118   else
119   {
120     sl.hintSetCurrent(saveIndex);
121     sl.hintSetTop(saveTop);
122   }
123   sl.draw();
124   doShowingBar();
125 }
126
127 void VRecordingListClassic::draw(bool doIndexPop)
128 {
129   if (!loading)
130   {
131     if (recman->isSubDir())
132     {
133       char title[300];
134       SNPRINTF(title, 299, tr("Recordings - %s"), recman->getCurDirName());
135       setTitleText(title, 364);
136     }
137     else
138     {
139       setTitleText(tr("Recordings"));
140     }
141   }
142
143   TBBoxx::draw();
144
145   if (loading)
146   {
147     drawText(tr("Loading..."), 240, 180, DrawStyle::LIGHTTEXT);
148   }
149   else
150   {
151     char freeSpace[50];
152     int gigFree = recman->getFreeSpace() / 1024;
153     SNPRINTF(freeSpace, 49, tr("%lu%% used, %iGB free"), recman->getUsedPercent(), gigFree);
154     drawTextRJ(freeSpace, 560, 5, DrawStyle::LIGHTTEXT);
155     // Symbols
156
157     WSymbol w;
158     TEMPADD(&w);
159     w.nextSymbol = WSymbol::UP;
160     w.setPosition(20, 385);
161     w.draw();
162     w.nextSymbol = WSymbol::DOWN;
163     w.setPosition(50, 385);
164     w.draw();
165     w.nextSymbol = WSymbol::SKIPBACK;
166     w.setPosition(85, 385);
167     w.draw();
168     w.nextSymbol = WSymbol::SKIPFORWARD;
169     w.setPosition(115, 385);
170     w.draw();
171     w.nextSymbol = WSymbol::PLAY;
172     w.setPosition(150, 385);
173     w.draw();
174     drawTextRJ(tr("[ok] = menu"), 560, 385, DrawStyle::LIGHTTEXT);
175
176     // All static stuff done
177     drawData(doIndexPop);
178   }
179 }
180
181 void VRecordingListClassic::doShowingBar()
182 {
183   int topOption = sl.getTopOption() + 1;
184   if (sl.getNumOptions() == 0) topOption = 0;
185 #ifndef GRADIENT_DRAWING
186   rectangle(220, 385, 180, 25, DrawStyle::VIEWBACKGROUND);
187 #endif
188   char showing[200];
189   sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
190   drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
191 }
192
193 void VRecordingListClassic::quickUpdate() { //only quick for plattform that need it!
194 #ifdef GRADIENT_DRAWING
195       draw();
196 #else
197       sl.draw();
198       doShowingBar();
199 #endif
200 }