TDuration::TDuration(const Fraction& _f) { Fraction f(_f.reduced()); _dots = 0; if (f.numerator() == 0) { _val = V_ZERO; _dots = 0; return; } switch(f.denominator()) { case 1: _val = V_WHOLE; break; case 2: _val = V_HALF; break; case 4: _val = V_QUARTER; break; case 8: _val = V_EIGHT; break; case 16: _val = V_16TH; break; case 32: _val = V_32ND; break; case 64: _val = V_64TH; break; case 128: _val = V_128TH; break; case 256: _val = V_256TH; break; case 512: _val = V_512TH; break; case 1024: _val = V_1024TH; break; default: _val = V_INVALID; break; } if (f.denominator() != 0) { int v = f.numerator() / f.denominator(); if(v == 4) { _val = V_LONG; return; } else if (v == 2) { _val = V_BREVE; return; } } if (f.numerator() != 1) { switch(f.numerator()) { case 3: _val = DurationType(_val - 1); _dots = 1; break; case 7: _val = DurationType(_val - 2); _dots = 2; break; default: qDebug("TDuration(%d/%d): not implemented", f.numerator(), f.denominator()); // abort(); _val = V_INVALID; _dots = 0; break; } } }
TDuration TDuration::shift(int v) const { if (_val == DurationType::V_MEASURE || _val == DurationType::V_INVALID || _val == DurationType::V_ZERO) return TDuration(); int newValue = int(_val) + v; if ((newValue < int(DurationType::V_LONG)) || (newValue > int(DurationType::V_256TH))) return TDuration(); return TDuration(DurationType(newValue)); }
TDuration TDuration::shift(int v) const { if (_val == V_MEASURE || _val == V_INVALID || _val == V_ZERO) return TDuration(); int newValue = _val + v; if ((newValue < 0) || (newValue > V_256TH)) return TDuration(); return TDuration(DurationType(newValue)); }
void TDuration::setVal(int ticks) { if (ticks == 0) _val = V_MEASURE; else { TDuration dt; for (int i = 0; i < TDuration::V_ZERO; ++i) { dt.setType(TDuration::DurationType(i)); int t = dt.ticks(); if (ticks / t) { int remain = ticks % t; if ((t - remain) < (t/4)) { _val = DurationType(i - 1); return; } _val = DurationType(i); getDots(t, remain, &_dots); return; } } qDebug("2: no duration type for ticks %d", ticks); _val = V_QUARTER; // fallback default value } }
GLCD::cType cGraphLCDSkinConfig::GetToken(const GLCD::tSkinToken & Token) { if (Token.Id > tokPrivateChannelStart && Token.Id < tokPrivateChannelEnd) { tChannel channel = mState->GetChannelInfo(); switch (Token.Id) { case tokChannelNumber: return channel.number; case tokChannelName: return channel.name; case tokChannelShortName: return channel.shortName; case tokChannelProvider: return channel.provider; case tokChannelPortal: return channel.portal; case tokChannelSource: return channel.source; case tokChannelID: return (GLCD::cType) (const char *) channel.id.ToString(); case tokHasTeletext: case tokChannelHasTeletext: return channel.hasTeletext; case tokHasMultilang: case tokChannelHasMultilang: return channel.hasMultiLanguage; case tokHasDolby: case tokChannelHasDolby: return channel.hasDolby; case tokIsEncrypted: case tokChannelIsEncrypted: return channel.isEncrypted; case tokIsRadio: case tokChannelIsRadio: return channel.isRadio; case tokChannelAlias: { char tmp[64]; std::string alias; sprintf(tmp, "%d-%d-%d", channel.id.Nid(), channel.id.Tid(), channel.id.Sid()); alias = mAliasList.GetAlias(tmp); return alias; } default: break; } } else if (Token.Id > tokPrivateRecordingStart && Token.Id < tokPrivateRecordingEnd) { switch (Token.Id) { case tokIsRecording: { if (Token.Attrib.Type == GLCD::aNumber) return mState->IsRecording(Token.Attrib.Number); return mState->IsRecording(-1); } case tokRecordings: { if (Token.Attrib.Type == GLCD::aNumber) return mState->Recordings(Token.Attrib.Number); return mState->Recordings(-1); } default: break; } } else if (Token.Id > tokPrivatePresentStart && Token.Id < tokPrivatePresentEnd) { tEvent event = mState->GetPresentEvent(); switch (Token.Id) { case tokPresentValid: return event.valid; case tokPresentStartDateTime: return TimeType(event.startTime, Token.Attrib.Text); case tokPresentVpsDateTime: return TimeType(event.vpsTime, Token.Attrib.Text); case tokPresentEndDateTime: return TimeType(event.startTime + event.duration, Token.Attrib.Text); case tokPresentDuration: return DurationType(event.duration * FRAMESPERSEC, Token.Attrib.Text); case tokPresentProgress: return DurationType((time(NULL) - event.startTime) * FRAMESPERSEC, Token.Attrib.Text); case tokPresentRemaining: if ((time(NULL) - event.startTime) < event.duration) { return DurationType((event.duration - (time(NULL) - event.startTime)) * FRAMESPERSEC, Token.Attrib.Text); } return false; case tokPresentTitle: return event.title; case tokPresentShortText: return event.shortText; case tokPresentDescription: return event.description; default: break; } } else if (Token.Id > tokPrivateFollowingStart && Token.Id < tokPrivateFollowingEnd) { tEvent event = mState->GetFollowingEvent(); switch (Token.Id) { case tokFollowingValid: return event.valid; case tokFollowingStartDateTime: return TimeType(event.startTime, Token.Attrib.Text); case tokFollowingVpsDateTime: return TimeType(event.vpsTime, Token.Attrib.Text); case tokFollowingEndDateTime: return TimeType(event.startTime + event.duration, Token.Attrib.Text); case tokFollowingDuration: return DurationType(event.duration * FRAMESPERSEC, Token.Attrib.Text); case tokFollowingTitle: return event.title; case tokFollowingShortText: return event.shortText; case tokFollowingDescription: return event.description; default: break; } } else if (Token.Id > tokPrivateVolumeStart && Token.Id < tokPrivateVolumeEnd) { tVolumeState volume = mState->GetVolumeState(); switch (Token.Id) { case tokVolumeCurrent: return volume.value; case tokVolumeTotal: return 255; case tokIsMute: case tokVolumeIsMute: return volume.value == 0; default: break; } } else if (Token.Id > tokPrivateReplayStart && Token.Id < tokPrivateReplayEnd) { tReplayState replay = mState->GetReplayState(); switch (Token.Id) { case tokReplayTitle: return replay.name; case tokReplayPositionIndex: return DurationType(replay.current, Token.Attrib.Text); case tokReplayDurationIndex: return DurationType(replay.total, Token.Attrib.Text); case tokReplayPosition: return replay.current; case tokReplayDuration: return replay.total; case tokReplayRemaining: return DurationType(replay.total - replay.current, Token.Attrib.Text); case tokIsPlaying: case tokReplayIsPlaying: return replay.play && replay.speed == -1; case tokIsPausing: case tokReplayIsPausing: return !replay.play && replay.speed == -1; case tokIsFastForward: case tokReplayIsFastForward: if (replay.play && replay.forward && replay.speed != -1) { return Token.Attrib.Type == GLCD::aNumber ? (GLCD::cType) (replay.speed == Token.Attrib.Number) : (GLCD::cType) true; } return false; case tokIsFastRewind: case tokReplayIsFastRewind: if (replay.play && !replay.forward && replay.speed != -1) { return Token.Attrib.Type == GLCD::aNumber ? (GLCD::cType) (replay.speed == Token.Attrib.Number) : (GLCD::cType) true; } return false; case tokIsSlowForward: case tokReplayIsSlowForward: if (!replay.play && replay.forward && replay.speed != -1) { return Token.Attrib.Type == GLCD::aNumber ? (GLCD::cType) (replay.speed == Token.Attrib.Number) : (GLCD::cType) true; } return false; case tokIsSlowRewind: case tokReplayIsSlowRewind: if (!replay.play && !replay.forward && replay.speed != -1) { return Token.Attrib.Type == GLCD::aNumber ? (GLCD::cType) (replay.speed == Token.Attrib.Number) : (GLCD::cType) true; } return false; case tokReplayMode: switch (replay.mode) { case eReplayAudioCD: return "cd"; case eReplayDVD: return "dvd"; case eReplayFile: return "file"; case eReplayImage: return "image"; case eReplayMusic: return "music"; default: return "vdr"; } case tokReplayIsShuffle: case tokReplayIsLoop: default: break; } } else if (Token.Id > tokPrivateOsdStart && Token.Id < tokPrivateOsdEnd) { tOsdState osd = mState->GetOsdState(); switch (Token.Id) { case tokMessage: return osd.message; case tokMenuTitle: return osd.title; case tokMenuItem: case tokMenuCurrent: case tokIsMenuCurrent: { if (osd.items.size() == 0 || osd.currentItemIndex == -1) { return false; } int maxItems = Token.MaxItems; if (maxItems > (int) osd.items.size()) maxItems = osd.items.size(); int currentIndex = maxItems / 2; if (osd.currentItemIndex < currentIndex) currentIndex = osd.currentItemIndex; int topIndex = osd.currentItemIndex - currentIndex; if ((topIndex + maxItems) > (int) osd.items.size()) { currentIndex += (topIndex + maxItems) - osd.items.size(); topIndex = osd.currentItemIndex - currentIndex; } if (Token.Id == tokMenuItem) { if (Token.Index < maxItems && Token.Index != currentIndex) return osd.items[topIndex + Token.Index]; } else if (Token.Id == tokMenuCurrent) { if (Token.Index < maxItems && Token.Index == currentIndex) return osd.items[topIndex + Token.Index]; } else if (Token.Id == tokIsMenuCurrent) { if (Token.Index < maxItems && Token.Index == currentIndex) return true; } return false; } case tokButtonRed: return osd.redButton; case tokButtonGreen: return osd.greenButton; case tokButtonYellow: return osd.yellowButton; case tokButtonBlue: return osd.blueButton; default: break; } } else if (Token.Id > tokPrivateSettingStart && Token.Id < tokPrivateSettingEnd) { switch (Token.Id) { case tokSettingShowChannelLogo: if (GraphLCDSetup.ShowChannelLogo) return true; return false; case tokSettingShowReplayLogo: if (GraphLCDSetup.ShowReplayLogo) return true; return false; case tokSettingShowSymbols: if (GraphLCDSetup.ShowSymbols) return true; return false; case tokSettingShowTimebar: if (GraphLCDSetup.ShowTimebar) return true; return false; default: break; } } else { switch (Token.Id) { case tokDateTime: return TimeType(time(NULL), Token.Attrib.Text); case tokConfigPath: return mConfigPath; case tokSkinPath: return mSkinPath; case tokScreenWidth: { const GLCD::cBitmap * bitmap = mDisplay->GetScreen(); return bitmap->Width(); } case tokScreenHeight: { const GLCD::cBitmap * bitmap = mDisplay->GetScreen(); return bitmap->Height(); } default: break; } } return ""; }