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