void CGUIDialogPVRTimerSettings::DaysOptionsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { if (setting == NULL || data == NULL) return; CGUIDialogPVRTimerSettings *dialog = static_cast<CGUIDialogPVRTimerSettings*>(data); if (dialog == NULL) return; const CPVRTimerInfoTag *tag = dialog->m_timerItem->GetPVRTimerInfoTag(); if (tag == NULL) return; if (setting->GetId() == SETTING_TMR_DAY) { for (unsigned int iDayPtr = 19086; iDayPtr <= 19096; iDayPtr++) list.push_back(std::make_pair(g_localizeStrings.Get(iDayPtr), list.size())); } else if (setting->GetId() == SETTING_TMR_FIRST_DAY) list.push_back(std::make_pair(g_localizeStrings.Get(19030), 0)); CDateTime time = CDateTime::GetCurrentDateTime(); for (int i = 1; i < 365; ++i) { std::string string = time.GetAsLocalizedDate(); list.push_back(std::make_pair(time.GetAsLocalizedDate(), list.size())); time += CDateTimeSpan(1, 0, 0, 0); } }
CStdString CGUIDialogMediaFilter::RangeAsDate(float valueLower, float valueUpper, float minimum) { CDateTime from = (time_t)valueLower; CDateTime to = (time_t)valueUpper; CStdString text; if (valueLower != valueUpper) text.Format(g_localizeStrings.Get(21469).c_str(), from.GetAsLocalizedDate(), to.GetAsLocalizedDate()); else text.Format("%s", from.GetAsLocalizedDate()); return text; }
void CLangInfo::SettingOptionsLongDateFormatsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t, void *data) { bool match = false; const std::string& longDateFormatSetting = static_cast<const CSettingString*>(setting)->GetValue(); CDateTime now = CDateTime::GetCurrentDateTime(); list.push_back(std::make_pair(StringUtils::Format(g_localizeStrings.Get(20035).c_str(), now.GetAsLocalizedDate(g_langInfo.m_currentRegion->m_strDateFormatLong).c_str()), SETTING_REGIONAL_DEFAULT)); if (longDateFormatSetting == SETTING_REGIONAL_DEFAULT) { match = true; current = SETTING_REGIONAL_DEFAULT; } for (size_t i = 0; i < LONG_DATE_FORMATS_SIZE; i++) { const std::string& longDateFormat = longDateFormats[i]; list.push_back(std::make_pair(now.GetAsLocalizedDate(longDateFormat), longDateFormat)); if (!match && longDateFormatSetting == longDateFormat) { match = true; current = longDateFormat; } } if (!match && !list.empty()) current = list[0].second; }
void CProfile::setDate() { const CDateTime now = CDateTime::GetCurrentDateTime(); std::string strDate = now.GetAsLocalizedDate(false); std::string strTime = now.GetAsLocalizedTime(TIME_FORMAT_GUESS); if (strDate.empty() || strTime.empty()) setDate("-"); else setDate(strDate+" - "+strTime); }
void CGUIDialogPVRTimerSettings::DaysFiller( const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) { list.clear(); current = 0; // Data range: "today" until "yesterday next year" const CDateTime now(CDateTime::GetCurrentDateTime()); CDateTime time(now.GetYear(), now.GetMonth(), now.GetDay(), 0, 0, 0); const CDateTime yesterdayPlusOneYear( time.GetYear() + 1, time.GetMonth(), time.GetDay() - 1, time.GetHour(), time.GetMinute(), time.GetSecond()); CDateTime oldCDateTime; if (setting->GetId() == SETTING_TMR_FIRST_DAY) oldCDateTime = pThis->m_timerInfoTag->FirstDayAsLocalTime(); else if (setting->GetId() == SETTING_TMR_START_DAY) oldCDateTime = pThis->m_timerInfoTag->StartAsLocalTime(); else oldCDateTime = pThis->m_timerInfoTag->EndAsLocalTime(); const CDateTime oldCDate(oldCDateTime.GetYear(), oldCDateTime.GetMonth(), oldCDateTime.GetDay(), 0, 0, 0); if ((oldCDate < time) || (oldCDate > yesterdayPlusOneYear)) list.push_back(std::make_pair(oldCDate.GetAsLocalizedDate(true /*long date*/), GetDateAsIndex(oldCDate))); while (time <= yesterdayPlusOneYear) { list.push_back(std::make_pair(time.GetAsLocalizedDate(true /*long date*/), GetDateAsIndex(time))); time += CDateTimeSpan(1, 0, 0, 0); } if (setting->GetId() == SETTING_TMR_FIRST_DAY) current = GetDateAsIndex(pThis->m_firstDayLocalTime); else if (setting->GetId() == SETTING_TMR_START_DAY) current = GetDateAsIndex(pThis->m_startLocalTime); else current = GetDateAsIndex(pThis->m_endLocalTime); } else CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::DaysFiller - No dialog"); }
void CGUIEPGGridContainerModel::Initialize(const std::unique_ptr<CFileItemList> &items, const CDateTime &gridStart, const CDateTime &gridEnd, int iRulerUnit, int iBlocksPerPage, float fBlockSize) { if (!m_channelItems.empty()) { CLog::LogF(LOGERROR, "Already initialized!"); return; } //////////////////////////////////////////////////////////////////////// // Create programme & channel items m_programmeItems.reserve(items->Size()); CFileItemPtr fileItem; int iLastChannelID = -1; ItemsPtr itemsPointer; itemsPointer.start = 0; CPVRChannelPtr channel; int j = 0; for (int i = 0; i < items->Size(); ++i) { fileItem = items->Get(i); if (!fileItem->HasEPGInfoTag() || !fileItem->GetEPGInfoTag()->HasChannel()) continue; m_programmeItems.emplace_back(fileItem); channel = fileItem->GetEPGInfoTag()->Channel(); if (!channel) continue; int iCurrentChannelID = channel->ChannelID(); if (iCurrentChannelID != iLastChannelID) { if (j > 0) { itemsPointer.stop = j - 1; m_epgItemsPtr.emplace_back(itemsPointer); itemsPointer.start = j; } iLastChannelID = iCurrentChannelID; m_channelItems.emplace_back(CFileItemPtr(new CFileItem(channel))); } ++j; } if (!m_programmeItems.empty()) { itemsPointer.stop = m_programmeItems.size() - 1; m_epgItemsPtr.emplace_back(itemsPointer); } /* check for invalid start and end time */ if (gridStart >= gridEnd) { // default to start "now minus GRID_START_PADDING minutes" and end "start plus one page". m_gridStart = CDateTime::GetUTCDateTime() - CDateTimeSpan(0, 0, GetGridStartPadding(), 0); m_gridEnd = m_gridStart + CDateTimeSpan(0, 0, iBlocksPerPage * MINSPERBLOCK, 0); } else if (gridStart > (CDateTime::GetUTCDateTime() - CDateTimeSpan(0, 0, GetGridStartPadding(), 0))) { // adjust to start "now minus GRID_START_PADDING minutes". m_gridStart = CDateTime::GetUTCDateTime() - CDateTimeSpan(0, 0, GetGridStartPadding(), 0); m_gridEnd = gridEnd; } else { m_gridStart = gridStart; m_gridEnd = gridEnd; } // roundup m_gridStart = CDateTime(m_gridStart.GetYear(), m_gridStart.GetMonth(), m_gridStart.GetDay(), m_gridStart.GetHour(), m_gridStart.GetMinute() >= 30 ? 30 : 0, 0); m_gridEnd = CDateTime(m_gridEnd.GetYear(), m_gridEnd.GetMonth(), m_gridEnd.GetDay(), m_gridEnd.GetHour(), m_gridEnd.GetMinute() >= 30 ? 30 : 0, 0); //////////////////////////////////////////////////////////////////////// // Create ruler items CDateTime ruler; ruler.SetFromUTCDateTime(m_gridStart); CDateTime rulerEnd; rulerEnd.SetFromUTCDateTime(m_gridEnd); CFileItemPtr rulerItem(new CFileItem(ruler.GetAsLocalizedDate(true))); rulerItem->SetProperty("DateLabel", true); m_rulerItems.emplace_back(rulerItem); const CDateTimeSpan unit(0, 0, iRulerUnit * MINSPERBLOCK, 0); for (; ruler < rulerEnd; ruler += unit) { rulerItem.reset(new CFileItem(ruler.GetAsLocalizedTime("", false))); rulerItem->SetLabel2(ruler.GetAsLocalizedDate(true)); m_rulerItems.emplace_back(rulerItem); } FreeItemsMemory(); //////////////////////////////////////////////////////////////////////// // Create epg grid const CDateTimeSpan blockDuration(0, 0, MINSPERBLOCK, 0); const CDateTimeSpan gridDuration(m_gridEnd - m_gridStart); m_blocks = (gridDuration.GetDays() * 24 * 60 + gridDuration.GetHours() * 60 + gridDuration.GetMinutes()) / MINSPERBLOCK; if (m_blocks >= MAXBLOCKS) m_blocks = MAXBLOCKS; else if (m_blocks < iBlocksPerPage) m_blocks = iBlocksPerPage; m_gridIndex.reserve(m_channelItems.size()); const std::vector<GridItem> blocks(m_blocks); for (size_t channel = 0; channel < m_channelItems.size(); ++channel) { m_gridIndex.emplace_back(blocks); CDateTime gridCursor(m_gridStart); //reset cursor for new channel unsigned long progIdx = m_epgItemsPtr[channel].start; unsigned long lastIdx = m_epgItemsPtr[channel].stop; int iEpgId = m_programmeItems[progIdx]->GetEPGInfoTag()->EpgID(); int itemSize = 1; // size of the programme in blocks int savedBlock = 0; CFileItemPtr item; CPVREpgInfoTagPtr tag; for (int block = 0; block < m_blocks; ++block) { while (progIdx <= lastIdx) { item = m_programmeItems[progIdx]; tag = item->GetEPGInfoTag(); // Note: Start block of an event is start-time-based calculated block + 1, // unless start times matches exactly the begin of a block. if (tag->EpgID() != iEpgId || gridCursor < tag->StartAsUTC() || m_gridEnd <= tag->StartAsUTC()) break; if (gridCursor < tag->EndAsUTC()) { m_gridIndex[channel][block].item = item; m_gridIndex[channel][block].progIndex = progIdx; break; } progIdx++; } gridCursor += blockDuration; if (block == 0) continue; const CFileItemPtr prevItem(m_gridIndex[channel][block - 1].item); const CFileItemPtr currItem(m_gridIndex[channel][block].item); if (block == m_blocks - 1 || prevItem != currItem) { // special handling for last block. int blockDelta = -1; int sizeDelta = 0; if (block == m_blocks - 1 && prevItem == currItem) { itemSize++; blockDelta = 0; sizeDelta = 1; } if (prevItem) { m_gridIndex[channel][savedBlock].item->SetProperty("GenreType", prevItem->GetEPGInfoTag()->GenreType()); } else { CPVREpgInfoTagPtr gapTag(CPVREpgInfoTag::CreateDefaultTag()); gapTag->SetChannel(m_channelItems[channel]->GetPVRChannelInfoTag()); CFileItemPtr gapItem(new CFileItem(gapTag)); for (int i = block + blockDelta; i >= block - itemSize + sizeDelta; --i) { m_gridIndex[channel][i].item = gapItem; } } float fItemWidth = itemSize * fBlockSize; m_gridIndex[channel][savedBlock].originWidth = fItemWidth; m_gridIndex[channel][savedBlock].width = fItemWidth; itemSize = 1; savedBlock = block; // special handling for last block. if (block == m_blocks - 1 && prevItem != currItem) { if (currItem) { m_gridIndex[channel][savedBlock].item->SetProperty("GenreType", currItem->GetEPGInfoTag()->GenreType()); } else { CPVREpgInfoTagPtr gapTag(CPVREpgInfoTag::CreateDefaultTag()); gapTag->SetChannel(m_channelItems[channel]->GetPVRChannelInfoTag()); CFileItemPtr gapItem(new CFileItem(gapTag)); m_gridIndex[channel][block].item = gapItem; } m_gridIndex[channel][savedBlock].originWidth = fBlockSize; // size always 1 block here m_gridIndex[channel][savedBlock].width = fBlockSize; } } else { itemSize++; } } } }
void CGUIControlRangeSetting::Update(bool updateDisplayOnly /* = false */) { if (m_pSlider == NULL || m_pSetting->GetType() != SettingTypeList) return; CGUIControlBaseSetting::Update(); CSettingList *settingList = static_cast<CSettingList*>(m_pSetting); const SettingPtrList &settingListValues = settingList->GetValue(); if (settingListValues.size() != 2) return; const CSetting *listDefintion = settingList->GetDefinition(); const CSettingControlRange *controlRange = static_cast<const CSettingControlRange*>(m_pSetting->GetControl()); const std::string &controlFormat = controlRange->GetFormat(); std::string strText; std::string strTextLower, strTextUpper; std::string formatString = g_localizeStrings.Get(controlRange->GetFormatLabel() > -1 ? controlRange->GetFormatLabel() : 21469); std::string valueFormat = controlRange->GetValueFormat(); if (controlRange->GetValueFormatLabel() > -1) valueFormat = g_localizeStrings.Get(controlRange->GetValueFormatLabel()); switch (listDefintion->GetType()) { case SettingTypeInteger: { int valueLower, valueUpper; if (updateDisplayOnly) { valueLower = m_pSlider->GetIntValue(CGUISliderControl::RangeSelectorLower); valueUpper = m_pSlider->GetIntValue(CGUISliderControl::RangeSelectorUpper); } else { valueLower = static_cast<CSettingInt*>(settingListValues[0].get())->GetValue(); valueUpper = static_cast<CSettingInt*>(settingListValues[1].get())->GetValue(); m_pSlider->SetIntValue(valueLower, CGUISliderControl::RangeSelectorLower); m_pSlider->SetIntValue(valueUpper, CGUISliderControl::RangeSelectorUpper); } if (controlFormat == "date" || controlFormat == "time") { CDateTime dateLower = (time_t)valueLower; CDateTime dateUpper = (time_t)valueUpper; if (controlFormat == "date") { if (valueFormat.empty()) { strTextLower = dateLower.GetAsLocalizedDate(); strTextUpper = dateUpper.GetAsLocalizedDate(); } else { strTextLower = dateLower.GetAsLocalizedDate(valueFormat); strTextUpper = dateUpper.GetAsLocalizedDate(valueFormat); } } else { if (valueFormat.empty()) valueFormat = "mm:ss"; strTextLower = dateLower.GetAsLocalizedTime(valueFormat); strTextUpper = dateUpper.GetAsLocalizedTime(valueFormat); } } else { strTextLower = StringUtils::Format(valueFormat.c_str(), valueLower); strTextUpper = StringUtils::Format(valueFormat.c_str(), valueUpper); } if (valueLower != valueUpper) strText = StringUtils::Format(formatString.c_str(), strTextLower.c_str(), strTextUpper.c_str()); else strText = strTextLower; break; } case SettingTypeNumber: { double valueLower, valueUpper; if (updateDisplayOnly) { valueLower = static_cast<double>(m_pSlider->GetFloatValue(CGUISliderControl::RangeSelectorLower)); valueUpper = static_cast<double>(m_pSlider->GetFloatValue(CGUISliderControl::RangeSelectorUpper)); } else { valueLower = static_cast<CSettingNumber*>(settingListValues[0].get())->GetValue(); valueUpper = static_cast<CSettingNumber*>(settingListValues[1].get())->GetValue(); m_pSlider->SetFloatValue((float)valueLower, CGUISliderControl::RangeSelectorLower); m_pSlider->SetFloatValue((float)valueUpper, CGUISliderControl::RangeSelectorUpper); } strTextLower = StringUtils::Format(valueFormat.c_str(), valueLower); if (valueLower != valueUpper) { strTextUpper = StringUtils::Format(valueFormat.c_str(), valueUpper); strText = StringUtils::Format(formatString.c_str(), strTextLower.c_str(), strTextUpper.c_str()); } else strText = strTextLower; break; } default: strText.clear(); break; } if (!strText.empty()) m_pSlider->SetTextValue(strText); }
void CGUIDialogPVRTimerSettings::CreateSettings() { CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag(); // clear out any old settings m_settings.clear(); // create our settings controls m_bTimerActive = tag->IsActive(); AddBool(CONTROL_TMR_ACTIVE, 19074, &m_bTimerActive); AddButton(CONTROL_TMR_NAME, 19075, &tag->m_strTitle, true); if (tag->SupportsFolders()) AddButton(CONTROL_TMR_DIR, 19076, &tag->m_strDirectory, true); AddBool(CONTROL_TMR_RADIO, 19077, &tag->m_bIsRadio); /// Channel names { // For TV CFileItemList channelslist_tv; SETTINGSTRINGS channelstrings_tv; AddChannelNames(channelslist_tv, channelstrings_tv, false); // For Radio CFileItemList channelslist_radio; SETTINGSTRINGS channelstrings_radio; AddChannelNames(channelslist_radio, channelstrings_radio, true); } /// Day { SETTINGSTRINGS daystrings; tm time_cur; tm time_tmr; for (unsigned int iDayPtr = 19086; iDayPtr <= 19096; iDayPtr++) daystrings.push_back(g_localizeStrings.Get(iDayPtr)); CDateTime time = CDateTime::GetCurrentDateTime(); CDateTime timestart = tag->StartAsLocalTime(); /* get diffence of timer in days between today and timer start date */ time.GetAsTm(time_cur); timestart.GetAsTm(time_tmr); m_tmp_day += time_tmr.tm_yday - time_cur.tm_yday; if (time_tmr.tm_yday - time_cur.tm_yday < 0) m_tmp_day += 365; for (int i = 1; i < 365; ++i) { CStdString string = time.GetAsLocalizedDate(); daystrings.push_back(string); time += CDateTimeSpan(1, 0, 0, 0); } SetWeekdaySettingFromTimer(*tag); AddSpin(CONTROL_TMR_DAY, 19079, &m_tmp_day, daystrings.size(), daystrings); } AddButton(CONTROL_TMR_BEGIN, 19080, &timerStartTimeStr, true); AddButton(CONTROL_TMR_END, 19081, &timerEndTimeStr, true); AddSpin(CONTROL_TMR_PRIORITY, 19082, &tag->m_iPriority, 0, 99); AddSpin(CONTROL_TMR_LIFETIME, 19083, &tag->m_iLifetime, 0, 365); /// First day { SETTINGSTRINGS daystrings; tm time_cur; tm time_tmr; CDateTime time = CDateTime::GetCurrentDateTime(); CDateTime timestart = tag->FirstDayAsLocalTime(); /* get diffence of timer in days between today and timer start date */ if (time < timestart) { time.GetAsTm(time_cur); timestart.GetAsTm(time_tmr); m_tmp_iFirstDay += time_tmr.tm_yday - time_cur.tm_yday + 1; if (time_tmr.tm_yday - time_cur.tm_yday < 0) m_tmp_iFirstDay += 365; } daystrings.push_back(g_localizeStrings.Get(19030)); for (int i = 1; i < 365; ++i) { CStdString string = time.GetAsLocalizedDate(); daystrings.push_back(string); time += CDateTimeSpan(1, 0, 0, 0); } AddSpin(CONTROL_TMR_FIRST_DAY, 19084, &m_tmp_iFirstDay, daystrings.size(), daystrings); if (tag->m_bIsRepeating) EnableSettings(CONTROL_TMR_FIRST_DAY, true); else EnableSettings(CONTROL_TMR_FIRST_DAY, false); } }
void CGUIDialogPVRTimerSettings::CreateSettings() { CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag(); // clear out any old settings m_settings.clear(); // create our settings controls AddBool(CONTROL_TMR_ACTIVE, 19074, &tag->m_bIsActive); AddButton(CONTROL_TMR_NAME, 19075, &tag->m_strTitle, true); AddBool(CONTROL_TMR_RADIO, 19077, &tag->m_bIsRadio); /// Channel names { // For TV CFileItemList channelslist_tv; SETTINGSTRINGS channelstrings_tv; CPVRManager::GetChannelGroups()->GetGroupAll(false)->GetMembers(&channelslist_tv); channelstrings_tv.push_back("0 dummy"); for (int i = 0; i < channelslist_tv.Size(); i++) { CStdString string; CFileItemPtr item = channelslist_tv[i]; string.Format("%i %s", item->GetPVRChannelInfoTag()->ChannelNumber(), item->GetPVRChannelInfoTag()->ChannelName().c_str()); channelstrings_tv.push_back(string); } AddSpin(CONTROL_TMR_CHNAME_TV, 19078, &tag->m_iChannelNumber, channelstrings_tv.size(), channelstrings_tv); EnableSettings(CONTROL_TMR_CHNAME_TV, !tag->m_bIsRadio); // For Radio CFileItemList channelslist_radio; SETTINGSTRINGS channelstrings_radio; CPVRManager::GetChannelGroups()->GetGroupAll(true)->GetMembers(&channelslist_radio); channelstrings_radio.push_back("0 dummy"); for (int i = 0; i < channelslist_radio.Size(); i++) { CStdString string; CFileItemPtr item = channelslist_radio[i]; string.Format("%i %s", item->GetPVRChannelInfoTag()->ChannelNumber(), item->GetPVRChannelInfoTag()->ChannelName().c_str()); channelstrings_radio.push_back(string); } AddSpin(CONTROL_TMR_CHNAME_RADIO, 19078, &tag->m_iChannelNumber, channelstrings_radio.size(), channelstrings_radio); EnableSettings(CONTROL_TMR_CHNAME_RADIO, tag->m_bIsRadio); } /// Day { SETTINGSTRINGS daystrings; tm time_cur; tm time_tmr; daystrings.push_back(g_localizeStrings.Get(19086)); daystrings.push_back(g_localizeStrings.Get(19087)); daystrings.push_back(g_localizeStrings.Get(19088)); daystrings.push_back(g_localizeStrings.Get(19089)); daystrings.push_back(g_localizeStrings.Get(19090)); daystrings.push_back(g_localizeStrings.Get(19091)); daystrings.push_back(g_localizeStrings.Get(19092)); daystrings.push_back(g_localizeStrings.Get(19093)); daystrings.push_back(g_localizeStrings.Get(19094)); daystrings.push_back(g_localizeStrings.Get(19095)); daystrings.push_back(g_localizeStrings.Get(19096)); CDateTime time = CDateTime::GetCurrentDateTime(); CDateTime timestart = tag->StartAsLocalTime(); /* get diffence of timer in days between today and timer start date */ time.GetAsTm(time_cur); timestart.GetAsTm(time_tmr); if (time_tmr.tm_yday - time_cur.tm_yday >= 0) m_tmp_day += time_tmr.tm_yday - time_cur.tm_yday; else m_tmp_day += time_tmr.tm_yday - time_cur.tm_yday + 365; for (int i = 1; i < 365; ++i) { CStdString string = time.GetAsLocalizedDate(); daystrings.push_back(string); time += CDateTimeSpan(1, 0, 0, 0); } if (tag->m_bIsRepeating) { if (tag->m_iWeekdays == 0x01) m_tmp_day = 0; else if (tag->m_iWeekdays == 0x02) m_tmp_day = 1; else if (tag->m_iWeekdays == 0x04) m_tmp_day = 2; else if (tag->m_iWeekdays == 0x08) m_tmp_day = 3; else if (tag->m_iWeekdays == 0x10) m_tmp_day = 4; else if (tag->m_iWeekdays == 0x20) m_tmp_day = 5; else if (tag->m_iWeekdays == 0x40) m_tmp_day = 6; else if (tag->m_iWeekdays == 0x1F) m_tmp_day = 7; else if (tag->m_iWeekdays == 0x3F) m_tmp_day = 8; else if (tag->m_iWeekdays == 0x7F) m_tmp_day = 9; else if (tag->m_iWeekdays == 0x60) m_tmp_day = 10; } AddSpin(CONTROL_TMR_DAY, 19079, &m_tmp_day, daystrings.size(), daystrings); } AddButton(CONTROL_TMR_BEGIN, 19080, &timerStartTimeStr, true); AddButton(CONTROL_TMR_END, 19081, &timerEndTimeStr, true); AddSpin(CONTROL_TMR_PRIORITY, 19082, &tag->m_iPriority, 0, 99); AddSpin(CONTROL_TMR_LIFETIME, 19083, &tag->m_iLifetime, 0, 365); /// First day { SETTINGSTRINGS daystrings; tm time_cur; tm time_tmr; CDateTime time = CDateTime::GetCurrentDateTime(); CDateTime timestart = tag->FirstDayAsLocalTime(); /* get diffence of timer in days between today and timer start date */ if (time < timestart) { time.GetAsTm(time_cur); timestart.GetAsTm(time_tmr); if (time_tmr.tm_yday - time_cur.tm_yday >= 0) { m_tmp_iFirstDay += time_tmr.tm_yday - time_cur.tm_yday + 1; } else { m_tmp_iFirstDay += time_tmr.tm_yday - time_cur.tm_yday + 365 + 1; } } daystrings.push_back(g_localizeStrings.Get(19030)); for (int i = 1; i < 365; ++i) { CStdString string = time.GetAsLocalizedDate(); daystrings.push_back(string); time += CDateTimeSpan(1, 0, 0, 0); } AddSpin(CONTROL_TMR_FIRST_DAY, 19084, &m_tmp_iFirstDay, daystrings.size(), daystrings); if (tag->m_bIsRepeating) EnableSettings(CONTROL_TMR_FIRST_DAY, true); else EnableSettings(CONTROL_TMR_FIRST_DAY, false); } }
bool CMusicGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const { if (info.GetData1() && info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST) return GetPlaylistInfo(value, info); const CMusicInfoTag* tag = item->GetMusicInfoTag(); if (tag) { switch (info.m_info) { ///////////////////////////////////////////////////////////////////////////////////////////// // PLAYER_* / MUSICPLAYER_* / LISTITEM_* ///////////////////////////////////////////////////////////////////////////////////////////// case PLAYER_PATH: case PLAYER_FILENAME: case PLAYER_FILEPATH: value = tag->GetURL(); if (value.empty()) value = item->GetPath(); value = GUIINFO::GetFileInfoLabelValueFromPath(info.m_info, value); return true; case PLAYER_TITLE: value = tag->GetTitle(); return !value.empty(); case MUSICPLAYER_TITLE: value = tag->GetTitle(); if (value.empty()) value = item->GetLabel(); if (value.empty()) value = CUtil::GetTitleFromPath(item->GetPath()); return true; case LISTITEM_TITLE: value = tag->GetTitle(); return true; case MUSICPLAYER_PLAYCOUNT: case LISTITEM_PLAYCOUNT: if (tag->GetPlayCount() > 0) { value = StringUtils::Format("%i", tag->GetPlayCount()); return true; } break; case MUSICPLAYER_LASTPLAYED: case LISTITEM_LASTPLAYED: { const CDateTime dateTime = tag->GetLastPlayed(); if (dateTime.IsValid()) { value = dateTime.GetAsLocalizedDate(); return true; } break; } case MUSICPLAYER_TRACK_NUMBER: case LISTITEM_TRACKNUMBER: if (tag->Loaded() && tag->GetTrackNumber() > 0) { value = StringUtils::Format("%02i", tag->GetTrackNumber()); return true; } break; case MUSICPLAYER_DISC_NUMBER: case LISTITEM_DISC_NUMBER: if (tag->GetDiscNumber() > 0) { value = StringUtils::Format("%i", tag->GetDiscNumber()); return true; } break; case MUSICPLAYER_ARTIST: case LISTITEM_ARTIST: value = tag->GetArtistString(); return true; case MUSICPLAYER_ALBUM_ARTIST: case LISTITEM_ALBUM_ARTIST: value = tag->GetAlbumArtistString(); return true; case MUSICPLAYER_CONTRIBUTORS: case LISTITEM_CONTRIBUTORS: if (tag->HasContributors()) { value = tag->GetContributorsText(); return true; } break; case MUSICPLAYER_CONTRIBUTOR_AND_ROLE: case LISTITEM_CONTRIBUTOR_AND_ROLE: if (tag->HasContributors()) { value = tag->GetContributorsAndRolesText(); return true; } break; case MUSICPLAYER_ALBUM: case LISTITEM_ALBUM: value = tag->GetAlbum(); return true; case MUSICPLAYER_YEAR: case LISTITEM_YEAR: value = tag->GetYearString(); return true; case MUSICPLAYER_GENRE: case LISTITEM_GENRE: value = StringUtils::Join(tag->GetGenre(), CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_musicItemSeparator); return true; case MUSICPLAYER_LYRICS: value = tag->GetLyrics(); return true; case MUSICPLAYER_RATING: case LISTITEM_RATING: { float rating = tag->GetRating(); if (rating > 0.f) { value = StringUtils::FormatNumber(rating); return true; } break; } case MUSICPLAYER_RATING_AND_VOTES: case LISTITEM_RATING_AND_VOTES: { float rating = tag->GetRating(); if (rating > 0.f) { int votes = tag->GetVotes(); if (votes <= 0) value = StringUtils::FormatNumber(rating); else value = StringUtils::Format(g_localizeStrings.Get(20350).c_str(), StringUtils::FormatNumber(rating).c_str(), StringUtils::FormatNumber(votes).c_str()); return true; } break; } case MUSICPLAYER_USER_RATING: case LISTITEM_USER_RATING: if (tag->GetUserrating() > 0) { value = StringUtils::Format("%i", tag->GetUserrating()); return true; } break; case MUSICPLAYER_COMMENT: case LISTITEM_COMMENT: value = tag->GetComment(); return true; case MUSICPLAYER_MOOD: case LISTITEM_MOOD: value = tag->GetMood(); return true; case LISTITEM_DBTYPE: value = tag->GetType(); return true; case MUSICPLAYER_DBID: case LISTITEM_DBID: { int dbId = tag->GetDatabaseId(); if (dbId > -1) { value = StringUtils::Format("%i", dbId); return true; } break; } case PLAYER_DURATION: if (!g_application.GetAppPlayer().IsPlayingAudio()) break; // fall-thru is intended. case MUSICPLAYER_DURATION: case LISTITEM_DURATION: { int iDuration = tag->GetDuration(); if (iDuration > 0) { value = StringUtils::SecondsToTimeString(iDuration, static_cast<TIME_FORMAT>(info.GetData4())); return true; } break; } ///////////////////////////////////////////////////////////////////////////////////////////// // LISTITEM_* ///////////////////////////////////////////////////////////////////////////////////////////// case LISTITEM_PROPERTY: if (StringUtils::StartsWithNoCase(info.GetData3(), "Role.")) { // "Role.xxxx" properties are held in music tag std::string property = info.GetData3(); property.erase(0, 5); //Remove Role. value = tag->GetArtistStringForRole(property); return true; } break; case LISTITEM_VOTES: value = StringUtils::FormatNumber(tag->GetVotes()); return true; case LISTITEM_FILENAME: case LISTITEM_FILE_EXTENSION: if (item->IsMusicDb()) value = URIUtils::GetFileName(tag->GetURL()); else if (item->HasVideoInfoTag()) // special handling for music videos, which have both a videotag and a musictag break; else value = URIUtils::GetFileName(item->GetPath()); if (info.m_info == LISTITEM_FILE_EXTENSION) { std::string strExtension = URIUtils::GetExtension(value); value = StringUtils::TrimLeft(strExtension, "."); } return true; case LISTITEM_FOLDERNAME: case LISTITEM_PATH: if (item->IsMusicDb()) value = URIUtils::GetDirectory(tag->GetURL()); else if (item->HasVideoInfoTag()) // special handling for music videos, which have both a videotag and a musictag break; else URIUtils::GetParentPath(item->GetPath(), value); value = CURL(value).GetWithoutUserDetails(); if (info.m_info == LISTITEM_FOLDERNAME) { URIUtils::RemoveSlashAtEnd(value); value = URIUtils::GetFileName(value); } return true; case LISTITEM_FILENAME_AND_PATH: if (item->IsMusicDb()) value = tag->GetURL(); else if (item->HasVideoInfoTag()) // special handling for music videos, which have both a videotag and a musictag break; else value = item->GetPath(); value = CURL(value).GetWithoutUserDetails(); return true; } } switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // MUSICPLAYER_* /////////////////////////////////////////////////////////////////////////////////////////////// case MUSICPLAYER_PROPERTY: value = item->GetProperty(info.GetData3()).asString(); return true; case MUSICPLAYER_PLAYLISTLEN: if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_MUSIC) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_LENGTH); return true; } break; case MUSICPLAYER_PLAYLISTPOS: if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_MUSIC) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_POSITION); return true; } break; case MUSICPLAYER_COVER: if (g_application.GetAppPlayer().IsPlayingAudio()) { if (fallback) *fallback = "DefaultAlbumCover.png"; value = item->HasArt("thumb") ? item->GetArt("thumb") : "DefaultAlbumCover.png"; return true; } break; case MUSICPLAYER_BITRATE: { int iBitrate = m_audioInfo.bitrate; if (iBitrate > 0) { value = StringUtils::Format("%li", std::lrint(static_cast<double>(iBitrate) / 1000.0)); return true; } break; } case MUSICPLAYER_CHANNELS: { int iChannels = m_audioInfo.channels; if (iChannels > 0) { value = StringUtils::Format("%i", iChannels); return true; } break; } case MUSICPLAYER_BITSPERSAMPLE: { int iBPS = m_audioInfo.bitspersample; if (iBPS > 0) { value = StringUtils::Format("%i", iBPS); return true; } break; } case MUSICPLAYER_SAMPLERATE: { int iSamplerate = m_audioInfo.samplerate; if (iSamplerate > 0) { value = StringUtils::Format("%.5g", static_cast<double>(iSamplerate) / 1000.0); return true; } break; } case MUSICPLAYER_CODEC: value = StringUtils::Format("%s", m_audioInfo.codecName.c_str()); return true; } /////////////////////////////////////////////////////////////////////////////////////////////// // MUSICPM_* /////////////////////////////////////////////////////////////////////////////////////////////// if (GetPartyModeLabel(value, info)) return true; return false; }