mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 15:58:31 +00:00
added device info in displaychannel
This commit is contained in:
@@ -17,6 +17,7 @@ cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplVi
|
||||
lastAudioChannel = -1;
|
||||
lastTracDesc = "";
|
||||
lastTrackLang = "";
|
||||
InitDevices();
|
||||
DeleteOsdOnExit();
|
||||
SetFadeTime(tmplView->GetNumericParameter(ptFadeTime));
|
||||
}
|
||||
@@ -109,7 +110,8 @@ void cDisplayChannelView::DrawProgressBar(cString &start, cString &stop, int Cur
|
||||
intTokens.insert(pair<string, int>("duration", Total));
|
||||
intTokens.insert(pair<string, int>("elapsed", Current));
|
||||
intTokens.insert(pair<string, int>("remaining", Total - Current));
|
||||
|
||||
|
||||
ClearProgressBar();
|
||||
DrawViewElement(veProgressBar, &stringTokens, &intTokens);
|
||||
}
|
||||
|
||||
@@ -399,6 +401,29 @@ void cDisplayChannelView::ClearSignalBackground(void) {
|
||||
ClearViewElement(veSignalQualityBack);
|
||||
}
|
||||
|
||||
void cDisplayChannelView::DrawDevices(bool initial) {
|
||||
if (!ViewElementImplemented(veDevices)) {
|
||||
return;
|
||||
}
|
||||
map < string, string > stringTokens;
|
||||
map < string, int > intTokens;
|
||||
map < string, vector< map< string, string > > > deviceLoopTokens;
|
||||
vector< map< string, string > > devices;
|
||||
|
||||
bool changed = SetDevices(initial, &intTokens, &devices);
|
||||
if (!changed)
|
||||
return;
|
||||
|
||||
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
|
||||
|
||||
ClearViewElement(veDevices);
|
||||
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
|
||||
}
|
||||
|
||||
void cDisplayChannelView::ClearDevices(void) {
|
||||
ClearViewElement(veDevices);
|
||||
}
|
||||
|
||||
void cDisplayChannelView::DrawChannelGroups(const cChannel *Channel, cString ChannelName) {
|
||||
if (!ViewElementImplemented(veChannelGroup)) {
|
||||
return;
|
||||
|
@@ -3,8 +3,9 @@
|
||||
|
||||
#include "../libtemplate/template.h"
|
||||
#include "view.h"
|
||||
#include "viewhelpers.h"
|
||||
|
||||
class cDisplayChannelView : public cView {
|
||||
class cDisplayChannelView : public cView, public cViewHelpers {
|
||||
private:
|
||||
cString lastDate;
|
||||
int lastScreenWidth;
|
||||
@@ -44,6 +45,8 @@ public:
|
||||
void DrawSignalBackground(void);
|
||||
void ClearSignal(void);
|
||||
void ClearSignalBackground(void);
|
||||
void DrawDevices(bool initial);
|
||||
void ClearDevices(void);
|
||||
void DrawChannelGroups(const cChannel *Channel, cString ChannelName);
|
||||
void ClearChannelGroups(void);
|
||||
void DisplayMessage(eMessageType Type, const char *Text);
|
||||
|
@@ -223,9 +223,6 @@ cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuIni
|
||||
cDisplayMenuMainView::~cDisplayMenuMainView() {
|
||||
CancelSave();
|
||||
FadeOut();
|
||||
delete[] lastSignalStrength;
|
||||
delete[] lastSignalQuality;
|
||||
delete[] recDevices;
|
||||
}
|
||||
|
||||
void cDisplayMenuMainView::DrawStaticViewElements(void) {
|
||||
@@ -360,18 +357,6 @@ void cDisplayMenuMainView::DrawDiscUsage(void) {
|
||||
DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
|
||||
}
|
||||
|
||||
void cDisplayMenuMainView::InitDevices(void) {
|
||||
int numDevices = cDevice::NumDevices();
|
||||
lastSignalStrength = new int[numDevices];
|
||||
lastSignalQuality = new int[numDevices];
|
||||
recDevices = new bool[numDevices];
|
||||
for (int i=0; i<numDevices; i++) {
|
||||
lastSignalStrength[i] = 0;
|
||||
lastSignalQuality[i] = 0;
|
||||
recDevices[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool cDisplayMenuMainView::DrawLoad(void) {
|
||||
if (!ViewElementImplemented(veSystemLoad)) {
|
||||
return false;
|
||||
@@ -400,120 +385,22 @@ bool cDisplayMenuMainView::DrawDevices(void) {
|
||||
if (!ViewElementImplemented(veDevices)) {
|
||||
return false;
|
||||
}
|
||||
int numDevices = cDevice::NumDevices();
|
||||
if (!initial) {
|
||||
//check if drawing is necessary
|
||||
bool changed = false;
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
const cDevice *device = cDevice::GetDevice(i);
|
||||
if (!device || !device->NumProvidedSystems()) {
|
||||
continue;
|
||||
}
|
||||
if ((device->SignalStrength() != lastSignalStrength[i]) || (device->SignalQuality() != lastSignalQuality[i])) {
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!changed) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
map < string, string > stringTokens;
|
||||
map < string, int > intTokens;
|
||||
|
||||
map < string, vector< map< string, string > > > deviceLoopTokens;
|
||||
vector< map< string, string > > devices;
|
||||
|
||||
//check device which currently displays live tv
|
||||
int deviceLiveTV = -1;
|
||||
cDevice *primaryDevice = cDevice::PrimaryDevice();
|
||||
if (primaryDevice) {
|
||||
if (!primaryDevice->Replaying() || primaryDevice->Transferring())
|
||||
deviceLiveTV = cDevice::ActualDevice()->DeviceNumber();
|
||||
else
|
||||
deviceLiveTV = primaryDevice->DeviceNumber();
|
||||
}
|
||||
bool changed = SetDevices(initial, &intTokens, &devices);
|
||||
if (!changed)
|
||||
return false;
|
||||
|
||||
//check currently recording devices
|
||||
for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
|
||||
if (!timer->Recording()) {
|
||||
continue;
|
||||
}
|
||||
if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) {
|
||||
const cDevice *recDevice = RecordControl->Device();
|
||||
if (recDevice) {
|
||||
recDevices[recDevice->DeviceNumber()] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
int actualNumDevices = 0;
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
const cDevice *device = cDevice::GetDevice(i);
|
||||
if (!device || !device->NumProvidedSystems()) {
|
||||
continue;
|
||||
}
|
||||
actualNumDevices++;
|
||||
map< string, string > deviceVals;
|
||||
stringstream strNum;
|
||||
strNum << actualNumDevices;
|
||||
deviceVals.insert(pair< string, string >("devices[num]", strNum.str()));
|
||||
deviceVals.insert(pair< string, string >("devices[type]", *(device->DeviceType())));
|
||||
cCamSlot *camSlot = device->CamSlot();
|
||||
int camNumber = -1;
|
||||
if (camSlot) {
|
||||
camNumber = camSlot->SlotNumber();
|
||||
deviceVals.insert(pair< string, string >("devices[hascam]", "1"));
|
||||
} else {
|
||||
deviceVals.insert(pair< string, string >("devices[hascam]", "0"));
|
||||
}
|
||||
int signalStrength = device->SignalStrength();
|
||||
int signalQuality = device->SignalQuality();
|
||||
stringstream strCamNumber;
|
||||
strCamNumber << camNumber;
|
||||
deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str()));
|
||||
stringstream strStrength;
|
||||
strStrength << signalStrength;
|
||||
deviceVals.insert(pair< string, string >("devices[signalstrength]", strStrength.str()));
|
||||
stringstream strQuality;
|
||||
strQuality << signalQuality;
|
||||
deviceVals.insert(pair< string, string >("devices[signalquality]", strQuality.str()));
|
||||
|
||||
deviceVals.insert(pair< string, string >("devices[livetv]", i == deviceLiveTV ? "1" : "0"));
|
||||
deviceVals.insert(pair< string, string >("devices[recording]", recDevices[i] ? "1" : "0"));
|
||||
|
||||
const cChannel *channel = device->GetCurrentlyTunedTransponder();
|
||||
const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL;
|
||||
if (channel && channel->Number() > 0) {
|
||||
stringstream strChanNum;
|
||||
strChanNum << channel->Number();
|
||||
deviceVals.insert(pair< string, string >("devices[channelnumber]", strChanNum.str()));
|
||||
deviceVals.insert(pair< string, string >("devices[channelname]", channel->Name()));
|
||||
deviceVals.insert(pair< string, string >("devices[channelid]", *(channel->GetChannelID().ToString())));
|
||||
deviceVals.insert(pair< string, string >("devices[istuned]", "1"));
|
||||
} else {
|
||||
deviceVals.insert(pair< string, string >("devices[channelnumber]", "0"));
|
||||
deviceVals.insert(pair< string, string >("devices[channelname]", ""));
|
||||
deviceVals.insert(pair< string, string >("devices[channelid]", ""));
|
||||
deviceVals.insert(pair< string, string >("devices[istuned]", "0"));
|
||||
}
|
||||
|
||||
deviceVals.insert(pair< string, string >("devices[source]", source ? source->Description() : ""));
|
||||
|
||||
devices.push_back(deviceVals);
|
||||
|
||||
lastSignalStrength[i] = signalStrength;
|
||||
lastSignalQuality[i] = signalQuality;
|
||||
}
|
||||
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
|
||||
|
||||
intTokens.insert(pair<string, int>("numdevices", actualNumDevices));
|
||||
|
||||
ClearViewElement(veDevices);
|
||||
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
|
||||
return true;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* cDisplayMenuSchedulesView
|
||||
************************************************************************/
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#define __DISPLAYMENUVIEW_H
|
||||
|
||||
#include "../libtemplate/template.h"
|
||||
#include "viewhelpers.h"
|
||||
#include "displaymenulistview.h"
|
||||
|
||||
class cDisplayMenuView : public cView {
|
||||
@@ -28,17 +29,13 @@ public:
|
||||
bool BackgroundImplemented(void);
|
||||
};
|
||||
|
||||
class cDisplayMenuMainView : public cDisplayMenuView {
|
||||
class cDisplayMenuMainView : public cDisplayMenuView, public cViewHelpers {
|
||||
private:
|
||||
bool initial;
|
||||
int* lastSignalStrength;
|
||||
int* lastSignalQuality;
|
||||
double lastSystemLoad;
|
||||
bool* recDevices;
|
||||
void DrawTimers(void);
|
||||
void DrawDiscUsage(void);
|
||||
bool DrawLoad(void);
|
||||
void InitDevices(void);
|
||||
bool DrawDevices(void);
|
||||
public:
|
||||
cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit);
|
||||
|
133
views/viewhelpers.c
Normal file
133
views/viewhelpers.c
Normal file
@@ -0,0 +1,133 @@
|
||||
#include <vdr/menu.h>
|
||||
#include "../config.h"
|
||||
#include "viewhelpers.h"
|
||||
|
||||
cViewHelpers::cViewHelpers(void) {
|
||||
devicesInit = false;
|
||||
}
|
||||
|
||||
cViewHelpers::~cViewHelpers() {
|
||||
if (devicesInit) {
|
||||
delete[] lastSignalStrength;
|
||||
delete[] lastSignalQuality;
|
||||
delete[] recDevices;
|
||||
}
|
||||
}
|
||||
|
||||
void cViewHelpers::InitDevices(void) {
|
||||
int numDevices = cDevice::NumDevices();
|
||||
lastSignalStrength = new int[numDevices];
|
||||
lastSignalQuality = new int[numDevices];
|
||||
recDevices = new bool[numDevices];
|
||||
for (int i=0; i<numDevices; i++) {
|
||||
lastSignalStrength[i] = 0;
|
||||
lastSignalQuality[i] = 0;
|
||||
recDevices[i] = false;
|
||||
}
|
||||
devicesInit = true;
|
||||
}
|
||||
|
||||
bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices) {
|
||||
int numDevices = cDevice::NumDevices();
|
||||
if (!initial) {
|
||||
//check if drawing is necessary
|
||||
bool changed = false;
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
const cDevice *device = cDevice::GetDevice(i);
|
||||
if (!device || !device->NumProvidedSystems()) {
|
||||
continue;
|
||||
}
|
||||
if ((device->SignalStrength() != lastSignalStrength[i]) || (device->SignalQuality() != lastSignalQuality[i])) {
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!changed) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//check device which currently displays live tv
|
||||
int deviceLiveTV = -1;
|
||||
cDevice *primaryDevice = cDevice::PrimaryDevice();
|
||||
if (primaryDevice) {
|
||||
if (!primaryDevice->Replaying() || primaryDevice->Transferring())
|
||||
deviceLiveTV = cDevice::ActualDevice()->DeviceNumber();
|
||||
else
|
||||
deviceLiveTV = primaryDevice->DeviceNumber();
|
||||
}
|
||||
|
||||
//check currently recording devices
|
||||
for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
|
||||
if (!timer->Recording()) {
|
||||
continue;
|
||||
}
|
||||
if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) {
|
||||
const cDevice *recDevice = RecordControl->Device();
|
||||
if (recDevice) {
|
||||
recDevices[recDevice->DeviceNumber()] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
int actualNumDevices = 0;
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
const cDevice *device = cDevice::GetDevice(i);
|
||||
if (!device || !device->NumProvidedSystems()) {
|
||||
continue;
|
||||
}
|
||||
actualNumDevices++;
|
||||
map< string, string > deviceVals;
|
||||
stringstream strNum;
|
||||
strNum << actualNumDevices;
|
||||
deviceVals.insert(pair< string, string >("devices[num]", strNum.str()));
|
||||
deviceVals.insert(pair< string, string >("devices[type]", *(device->DeviceType())));
|
||||
cCamSlot *camSlot = device->CamSlot();
|
||||
int camNumber = -1;
|
||||
if (camSlot) {
|
||||
camNumber = camSlot->SlotNumber();
|
||||
deviceVals.insert(pair< string, string >("devices[hascam]", "1"));
|
||||
} else {
|
||||
deviceVals.insert(pair< string, string >("devices[hascam]", "0"));
|
||||
}
|
||||
int signalStrength = device->SignalStrength();
|
||||
int signalQuality = device->SignalQuality();
|
||||
stringstream strCamNumber;
|
||||
strCamNumber << camNumber;
|
||||
deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str()));
|
||||
stringstream strStrength;
|
||||
strStrength << signalStrength;
|
||||
deviceVals.insert(pair< string, string >("devices[signalstrength]", strStrength.str()));
|
||||
stringstream strQuality;
|
||||
strQuality << signalQuality;
|
||||
deviceVals.insert(pair< string, string >("devices[signalquality]", strQuality.str()));
|
||||
|
||||
deviceVals.insert(pair< string, string >("devices[livetv]", i == deviceLiveTV ? "1" : "0"));
|
||||
deviceVals.insert(pair< string, string >("devices[recording]", recDevices[i] ? "1" : "0"));
|
||||
|
||||
const cChannel *channel = device->GetCurrentlyTunedTransponder();
|
||||
const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL;
|
||||
if (channel && channel->Number() > 0) {
|
||||
stringstream strChanNum;
|
||||
strChanNum << channel->Number();
|
||||
deviceVals.insert(pair< string, string >("devices[channelnumber]", strChanNum.str()));
|
||||
deviceVals.insert(pair< string, string >("devices[channelname]", channel->Name()));
|
||||
deviceVals.insert(pair< string, string >("devices[channelid]", *(channel->GetChannelID().ToString())));
|
||||
deviceVals.insert(pair< string, string >("devices[istuned]", "1"));
|
||||
} else {
|
||||
deviceVals.insert(pair< string, string >("devices[channelnumber]", "0"));
|
||||
deviceVals.insert(pair< string, string >("devices[channelname]", ""));
|
||||
deviceVals.insert(pair< string, string >("devices[channelid]", ""));
|
||||
deviceVals.insert(pair< string, string >("devices[istuned]", "0"));
|
||||
}
|
||||
|
||||
deviceVals.insert(pair< string, string >("devices[source]", source ? source->Description() : ""));
|
||||
|
||||
devices->push_back(deviceVals);
|
||||
|
||||
lastSignalStrength[i] = signalStrength;
|
||||
lastSignalQuality[i] = signalQuality;
|
||||
}
|
||||
|
||||
intTokens->insert(pair<string, int>("numdevices", actualNumDevices));
|
||||
|
||||
return true;
|
||||
}
|
18
views/viewhelpers.h
Normal file
18
views/viewhelpers.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef __VIEWHELPERS_H
|
||||
#define __VIEWHELPERS_H
|
||||
|
||||
class cViewHelpers {
|
||||
private:
|
||||
bool devicesInit;
|
||||
int* lastSignalStrength;
|
||||
int* lastSignalQuality;
|
||||
bool* recDevices;
|
||||
protected:
|
||||
public:
|
||||
cViewHelpers(void);
|
||||
virtual ~cViewHelpers(void);
|
||||
void InitDevices(void);
|
||||
bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices);
|
||||
};
|
||||
|
||||
#endif //__VIEWHELPERS_H
|
Reference in New Issue
Block a user