void ProgFinder::updateTimesList() { InfoMap infoMap; m_timesList->Reset(); if (m_showData.size() > 0) { QString itemText; QDateTime starttime; for (uint i = 0; i < m_showData.size(); ++i) { starttime = m_showData[i]->GetScheduledStartTime(); itemText = MythDateTimeToString(starttime, kDateTimeFull | kSimplify); MythUIButtonListItem *item = new MythUIButtonListItem(m_timesList, ""); m_showData[i]->ToMap(infoMap); item->SetTextFromMap(infoMap); QString state = toUIState(m_showData[i]->GetRecordingStatus()); item->SetText(itemText, "buttontext", state); item->DisplayState(state, "status"); } } }
void NetSearch::PopulateResultList(ResultItem::resultList list) { for (ResultItem::resultList::iterator i = list.begin(); i != list.end(); ++i) { QString title = (*i)->GetTitle(); MythUIButtonListItem *item = new MythUIButtonListItem(m_searchResultList, title, qVariantFromValue(*i)); InfoMap metadataMap; (*i)->toMap(metadataMap); item->SetTextFromMap(metadataMap); if (!(*i)->GetThumbnail().isEmpty()) { QString dlfile = (*i)->GetThumbnail(); if (dlfile.contains("%SHAREDIR%")) { dlfile.replace("%SHAREDIR%", GetShareDir()); item->SetImage(dlfile); } else { uint pos = m_searchResultList->GetItemPos(item); m_imageDownload->addThumb((*i)->GetTitle(), (*i)->GetThumbnail(), qVariantFromValue<uint>(pos)); } } } }
void StreamView::updateStreamList(void) { m_streamList->Reset(); bool foundActiveStream = false; for (int x = 0; x < gPlayer->getPlaylist()->getSongs().count(); x++) { Metadata *mdata = gPlayer->getPlaylist()->getSongs().at(x); MythUIButtonListItem *item = new MythUIButtonListItem(m_streamList, "", qVariantFromValue(mdata)); MetadataMap metadataMap; if (mdata) mdata->toMap(metadataMap); item->SetTextFromMap(metadataMap); item->SetText("", "imageloaded"); item->SetFontState("normal"); item->DisplayState("default", "playstate"); // if this is the current radio stream update its play state to match the player if (gPlayer->getCurrentMetadata() && mdata->ID() == gPlayer->getCurrentMetadata()->ID()) { if (gPlayer->isPlaying()) { item->SetFontState("running"); item->DisplayState("playing", "playstate"); } else if (gPlayer->isPaused()) { item->SetFontState("idle"); item->DisplayState("paused", "playstate"); } else { item->SetFontState("normal"); item->DisplayState("stopped", "playstate"); } m_streamList->SetItemCurrent(item); foundActiveStream = true; } } if (m_streamList->GetCount() > 0 && !foundActiveStream) { m_streamList->SetItemCurrent(0); gPlayer->stop(true); } if (m_noStreams) m_noStreams->SetVisible((m_streamList->GetCount() == 0)); if (m_streamList->GetCount() == 0) LOG(VB_GENERAL, LOG_ERR, "StreamView hasn't found any streams!"); }
MythUIButtonListItem *MythGenericTree::CreateListButton(MythUIButtonList *list) { MythUIButtonListItem *item = new MythUIButtonListItem(list, getString()); item->SetData(qVariantFromValue(this)); item->SetTextFromMap(m_strings); item->SetImageFromMap(m_imageFilenames); if (visibleChildCount() > 0) item->setDrawArrow(true); return item; }
void BackendSelection::AddItem(DeviceLocation *dev) { if (!dev) return; QString USN = dev->m_sUSN; m_mutex.lock(); // The devices' USN should be unique. Don't add if it is already there: if (m_devices.find(USN) == m_devices.end()) { dev->AddRef(); m_devices.insert(USN, dev); m_mutex.unlock(); InfoMap infomap; dev->GetDeviceDetail(infomap, true); // We only want the version number, not the library version info infomap["version"] = infomap["modelnumber"].section('.', 0, 1); MythUIButtonListItem *item; item = new MythUIButtonListItem(m_backendList, infomap["modelname"], qVariantFromValue(dev)); item->SetTextFromMap(infomap); bool protoMatch = (infomap["protocolversion"] == MYTH_PROTO_VERSION); QString status = "good"; if (!protoMatch) status = "protocolmismatch"; // TODO: Not foolproof but if we can't get device details then it's // probably because we could not connect to port 6544 - firewall? // Maybe we can replace this with a more specific check if (infomap["modelname"].isEmpty()) status = "blocked"; item->DisplayState(status, "connection"); bool needPin = dev->NeedSecurityPin(); item->DisplayState(needPin ? "yes" : "no", "securitypin"); } else m_mutex.unlock(); dev->Release(); }
void ChannelRecPriority::updateList() { m_channelList->Reset(); QMap<QString, ChannelInfo*>::Iterator it; for (it = m_sortedChannel.begin(); it != m_sortedChannel.end(); ++it) { ChannelInfo *chanInfo = *it; MythUIButtonListItem *item = new MythUIButtonListItem(m_channelList, "", qVariantFromValue(chanInfo)); QString fontState = "default"; item->SetText(chanInfo->GetFormatted(ChannelInfo::kChannelLong), fontState); InfoMap infomap; chanInfo->ToMap(infomap); item->SetTextFromMap(infomap, fontState); item->DisplayState("normal", "status"); if (!chanInfo->icon.isEmpty()) { QString iconUrl = gCoreContext->GetMasterHostPrefix("ChannelIcons", chanInfo->icon); item->SetImage(iconUrl, "icon"); item->SetImage(iconUrl); } item->SetText(QString::number(chanInfo->recpriority), "priority", fontState); if (m_currentItem == chanInfo) m_channelList->SetItemCurrent(item); } // this textarea name is depreciated use 'nochannels_warning' instead MythUIText *noChannelsText = dynamic_cast<MythUIText*>(GetChild("norecordings_info")); if (!noChannelsText) noChannelsText = dynamic_cast<MythUIText*>(GetChild("nochannels_warning")); if (noChannelsText) noChannelsText->SetVisible(m_channelData.isEmpty()); }
void ChannelRecPriority::updateList() { m_channelList->Reset(); QMap<QString, ChannelInfo*>::Iterator it; MythUIButtonListItem *item; for (it = m_sortedChannel.begin(); it != m_sortedChannel.end(); ++it) { ChannelInfo *chanInfo = *it; item = new MythUIButtonListItem(m_channelList, "", qVariantFromValue(chanInfo)); QString fontState = "default"; if (!m_visMap[chanInfo->chanid]) fontState = "disabled"; item->SetText(chanInfo->GetFormatted(ChannelInfo::kChannelLong), fontState); InfoMap infomap; chanInfo->ToMap(infomap); item->SetTextFromMap(infomap, fontState); if (m_visMap[chanInfo->chanid]) item->DisplayState("normal", "status"); else item->DisplayState("disabled", "status"); item->SetImage(chanInfo->iconpath, "icon"); item->SetImage(chanInfo->iconpath); item->SetText(chanInfo->recpriority, "priority", fontState); if (m_currentItem == chanInfo) m_channelList->SetItemCurrent(item); } MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_channelData.isEmpty()); }
void ViewScheduleDiff::updateUIList(void) { for (uint i = 0; i < m_recList.size(); i++) { class ProgramStruct s = m_recList[i]; class ProgramInfo *pginfo = s.after; if (!pginfo) pginfo = s.before; MythUIButtonListItem *item = new MythUIButtonListItem( m_conflictList, "", qVariantFromValue(pginfo)); InfoMap infoMap; pginfo->ToMap(infoMap); QString state = toUIState(pginfo->GetRecordingStatus()); item->DisplayState(state, "status"); item->SetTextFromMap(infoMap, state); if (s.before) item->SetText(toString(s.before->GetRecordingStatus(), s.before->GetCardID()), "statusbefore", state); else item->SetText("-", "statusbefore"); if (s.after) item->SetText(toString(s.after->GetRecordingStatus(), s.after->GetCardID()), "statusafter", state); else item->SetText("-", "statusafter"); } if (m_noChangesText) { if (m_recList.empty()) m_noChangesText->Show(); else m_noChangesText->Hide(); } }
void ProgLister::UpdateButtonList(void) { ProgramList::const_iterator it = m_itemList.begin(); for (; it != m_itemList.end(); ++it) { MythUIButtonListItem *item = new MythUIButtonListItem( m_progList, "", qVariantFromValue(*it)); InfoMap infoMap; (**it).ToMap(infoMap); QString state = toUIState((**it).GetRecordingStatus()); if ((state == "warning") && (plPreviouslyRecorded == m_type)) state = "disabled"; item->SetTextFromMap(infoMap, state); if (m_type == plTitle) { QString tempSubTitle = (**it).GetSubtitle(); if (tempSubTitle.trimmed().isEmpty()) tempSubTitle = (**it).GetTitle(); item->SetText(tempSubTitle, "titlesubtitle", state); } item->DisplayState( QString::number((**it).GetStars(10)), "ratingstate"); item->DisplayState(state, "status"); } if (m_positionText) { m_positionText->SetText( tr("%1 of %2", "Current position in list where %1 is the " "position, %2 is the total count") .arg(m_progList->GetCurrentPos()) .arg(m_progList->GetCount())); } }
void SearchStream::updateStreams(void) { m_streamList->Reset(); QString station = m_stationList->GetValue(); QString genre = m_genreList->GetValue(); QString channel = m_channelEdit->GetText(); bool searchStation = (station != tr("<All Stations>")); bool searchGenre = (genre != tr("<All Genres>")); bool searchChannel = !channel.isEmpty(); QMap<QString, Metadata>::iterator it; for (it = m_streams.begin(); it != m_streams.end(); ++it) { Metadata *mdata = &(*it); if (searchStation && station != mdata->Station()) continue; if (searchGenre && !mdata->Genre().contains(genre, Qt::CaseInsensitive)) continue; if (searchChannel && !mdata->Channel().contains(channel, Qt::CaseInsensitive)) continue; // if we got here we must have a match so add it to the list MythUIButtonListItem *item = new MythUIButtonListItem(m_streamList, "", qVariantFromValue(mdata)); MetadataMap metadataMap; mdata->toMap(metadataMap); item->SetTextFromMap(metadataMap); item->SetText(" ", "dummy"); } m_matchesText->SetText(QString("%1").arg(m_streamList->GetCount())); }
/** \fn GalleryWidget::ShowFileDetails() * \brief Shows the available details of the current image file. The details will only be shown if the file is an image. * \return void */ void GalleryWidget::ShowFileDetails() { ImageMetadata *im = m_fileDataList->at(m_index); if (!im) { delete im; return; } if (im->m_type != kImageFile) { delete im; return; } // First remove all entries m_infoList->Reset(); // This map holds all the exif tag values QMap<QString, QString> infoList; // Get all the available exif header information from the file // and create a data structure that can be displayed nicely QByteArray ba = m_fh->GetExifValues(im); if (ba.count() > 0) { bool readTagValues = false; QString key, value; QXmlStreamReader xml(ba); while (!xml.atEnd()) { xml.readNext(); // Read the general information if (xml.isStartElement() && (xml.name() == "Count" || xml.name() == "File" || xml.name() == "Path" || xml.name() == "Size" || xml.name() == "Extension")) infoList.insert(xml.name().toString(), xml.readElementText()); if (xml.isStartElement() && xml.name() == "ImageMetadataInfo") readTagValues = true; if (readTagValues) { if (xml.isStartElement() && xml.name() == "Label") key = xml.readElementText(); if (xml.isStartElement() && xml.name() == "Value") value = xml.readElementText(); } if (xml.isEndElement() && xml.name() == "ImageMetadataInfo") { readTagValues = false; infoList.insert(key, value); } } } // Now go through the info list and create a map for the mythui buttonlist QMap<QString, QString>::const_iterator i = infoList.constBegin(); while (i != infoList.constEnd()) { MythUIButtonListItem *item = new MythUIButtonListItem(m_infoList, ""); InfoMap infoMap; infoMap.insert("name", i.key()); QString value = tr("Not defined"); if (!i.value().isEmpty()) value = i.value(); infoMap.insert("value", value); item->SetTextFromMap(infoMap); ++i; } m_infoList->SetVisible(true); // All widgets are visible, remember this m_infoVisible = true; SetFocusWidget(m_infoList); delete im; }
void ViewScheduled::FillList() { m_schedulesList->Reset(); MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_recList.empty()); if (m_recList.empty()) return; ProgramList plist; if (!m_recgroupList.contains(m_currentGroup)) m_currentGroup = m_defaultGroup; plist = m_recgroupList[m_currentGroup]; ProgramList::iterator pit = plist.begin(); while (pit != plist.end()) { ProgramInfo *pginfo = *pit; if (!pginfo) { ++pit; continue; } QString state; const RecStatus::Type recstatus = pginfo->GetRecordingStatus(); if (recstatus == RecStatus::Recording || recstatus == RecStatus::Tuning) state = "running"; else if (recstatus == RecStatus::Conflict || recstatus == RecStatus::Offline || recstatus == RecStatus::TunerBusy || recstatus == RecStatus::Failed || recstatus == RecStatus::Failing || recstatus == RecStatus::Aborted || recstatus == RecStatus::Missed) state = "error"; else if (recstatus == RecStatus::WillRecord || recstatus == RecStatus::Pending) { if (m_curinput == 0 || pginfo->GetInputID() == m_curinput) { if (pginfo->GetRecordingPriority2() < 0) state = "warning"; else state = "normal"; } } else if (recstatus == RecStatus::Repeat || recstatus == RecStatus::NeverRecord || recstatus == RecStatus::DontRecord || (recstatus != RecStatus::DontRecord && recstatus <= RecStatus::EarlierShowing)) state = "disabled"; else state = "warning"; MythUIButtonListItem *item = new MythUIButtonListItem(m_schedulesList,"", qVariantFromValue(pginfo)); InfoMap infoMap; pginfo->ToMap(infoMap); item->SetTextFromMap(infoMap, state); QString rating = QString::number(pginfo->GetStars(10)); item->DisplayState(rating, "ratingstate"); item->DisplayState(state, "status"); ++pit; } MythUIText *statusText = dynamic_cast<MythUIText*>(GetChild("status")); if (statusText) { if (m_conflictBool) { // Find first conflict and store in m_conflictDate field ProgramList::const_iterator it = plist.begin(); for (; it != plist.end(); ++it) { ProgramInfo &p = **it; if (p.GetRecordingStatus() == RecStatus::Conflict) { m_conflictDate = p.GetRecordingStartTime() .toLocalTime().date(); break; } } // TODO: This can be templated instead of hardcoding // Conflict/No Conflict QString cstring = tr("Conflict %1") .arg(MythDate::toString(m_conflictDate, MythDate::kDateFull | MythDate::kSimplify)); statusText->SetText(cstring); } else statusText->SetText(tr("No Conflicts")); } MythUIText *filterText = dynamic_cast<MythUIText*>(GetChild("filter")); if (filterText) { if (m_showAll) filterText->SetText(tr("All")); else filterText->SetText(tr("Important")); } }
void ThemeChooser::Init(void) { QString curTheme = gCoreContext->GetSetting("Theme"); ThemeInfo *themeinfo = NULL; ThemeInfo *curThemeInfo = NULL; MythUIButtonListItem *item = NULL; m_themes->Reset(); for( QFileInfoList::iterator it = m_infoList.begin(); it != m_infoList.end(); ++it ) { QFileInfo &theme = *it; if (!m_themeFileNameInfos.contains(theme.filePath())) continue; themeinfo = m_themeFileNameInfos[theme.filePath()]; if (!themeinfo) continue; QString buttonText = QString("%1 %2.%3") .arg(themeinfo->GetName()) .arg(themeinfo->GetMajorVersion()) .arg(themeinfo->GetMinorVersion()); item = new MythUIButtonListItem(m_themes, buttonText); if (item) { if (themeinfo->GetDownloadURL().isEmpty()) item->DisplayState("local", "themelocation"); else item->DisplayState("remote", "themelocation"); item->DisplayState(themeinfo->GetAspect(), "aspectstate"); item->DisplayState(m_themeStatuses[themeinfo->GetName()], "themestatus"); QHash<QString, QString> infomap; themeinfo->ToMap(infomap); item->SetTextFromMap(infomap); item->SetData(qVariantFromValue(themeinfo)); QString thumbnail = themeinfo->GetPreviewPath(); QFileInfo fInfo(thumbnail); // Downloadable themeinfos have thumbnail copies of their preview images if (!themeinfo->GetDownloadURL().isEmpty()) thumbnail = thumbnail.append(".thumb.jpg"); item->SetImage(thumbnail); if (curTheme == themeinfo->GetDirectoryName()) curThemeInfo = themeinfo; } else delete item; } SetFocusWidget(m_themes); if (curThemeInfo) m_themes->SetValueByData(qVariantFromValue(curThemeInfo)); MythUIButtonListItem *current = m_themes->GetItemCurrent(); if (current) itemChanged(current); }
void StreamView::customEvent(QEvent *event) { bool handled = true; if (event->type() == MusicPlayerEvent::PlayedTracksChangedEvent) { if (gPlayer->getPlayedTracksList().count()) updateTrackInfo(gPlayer->getCurrentMetadata()); // add the new track to the list if (m_playedTracksList && gPlayer->getPlayedTracksList().count()) { Metadata *mdata = gPlayer->getPlayedTracksList().last(); MythUIButtonListItem *item = new MythUIButtonListItem(m_playedTracksList, "", qVariantFromValue(mdata), 0); MetadataMap metadataMap; mdata->toMap(metadataMap); item->SetTextFromMap(metadataMap); item->SetFontState("normal"); item->DisplayState("default", "playstate"); item->SetImage(mdata->getAlbumArtFile()); m_playedTracksList->SetItemCurrent(item); } } else if (event->type() == MusicPlayerEvent::TrackChangeEvent) { MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event); if (!mpe) return; int trackNo = mpe->TrackID; if (m_streamList) { if (m_currentTrack >= 0 && m_currentTrack < m_streamList->GetCount()) { MythUIButtonListItem *item = m_streamList->GetItemAt(m_currentTrack); if (item) { item->SetFontState("normal"); item->DisplayState("default", "playstate"); } } if (trackNo >= 0 && trackNo < m_streamList->GetCount()) { if (m_currentTrack == m_streamList->GetCurrentPos()) m_streamList->SetItemCurrent(trackNo); MythUIButtonListItem *item = m_streamList->GetItemAt(trackNo); if (item) { item->SetFontState("running"); item->DisplayState("playing", "playstate"); } } } m_currentTrack = trackNo; updateTrackInfo(gPlayer->getCurrentMetadata()); } else if (event->type() == OutputEvent::Playing) { if (gPlayer->isPlaying()) { if (m_streamList) { MythUIButtonListItem *item = m_streamList->GetItemAt(m_currentTrack); if (item) { item->SetFontState("running"); item->DisplayState("playing", "playstate"); } } } // pass it on to the default handler in MusicCommon handled = false; } else if (event->type() == OutputEvent::Stopped) { if (m_streamList) { MythUIButtonListItem *item = m_streamList->GetItemAt(m_currentTrack); if (item) { item->SetFontState("normal"); item->DisplayState("stopped", "playstate"); } } // pass it on to the default handler in MusicCommon handled = false; } else if (event->type() == OutputEvent::Buffering) { } else if (event->type() == MythEvent::MythEventMessage) { MythEvent *me = (MythEvent *)event; QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts); if (tokens.isEmpty()) return; if (tokens[0] == "DOWNLOAD_FILE") { QStringList args = me->ExtraDataList(); if (tokens[1] == "UPDATE") { } else if (tokens[1] == "FINISHED") { QString url = args[0]; int fileSize = args[2].toInt(); int errorCode = args[4].toInt(); QString filename = args[1]; if ((errorCode != 0) || (fileSize == 0)) LOG(VB_GENERAL, LOG_ERR, QString("StreamView: failed to download radio icon from '%1'").arg(url)); else { for (int x = 0; x < m_streamList->GetCount(); x++) { MythUIButtonListItem *item = m_streamList->GetItemAt(x); Metadata *mdata = qVariantValue<Metadata*> (item->GetData()); if (mdata && mdata->LogoUrl() == url) item->SetImage(filename); } } } } } else if (event->type() == DecoderHandlerEvent::OperationStart) { DecoderHandlerEvent *dhe = dynamic_cast<DecoderHandlerEvent*>(event); if (!dhe) return; if (dhe->getMessage() && m_bufferStatus) { m_bufferStatus->SetText(*dhe->getMessage()); } } else if (event->type() == DecoderHandlerEvent::BufferStatus) { DecoderHandlerEvent *dhe = dynamic_cast<DecoderHandlerEvent*>(event); if (!dhe) return; int available, maxSize; dhe->getBufferStatus(&available, &maxSize); if (m_bufferStatus) { QString status = QString("%1%").arg((int)(100.0 / ((double)maxSize / (double)available))); m_bufferStatus->SetText(status); } if (m_bufferProgress) { m_bufferProgress->SetTotal(maxSize); m_bufferProgress->SetUsed(available); } } else if (event->type() == DecoderHandlerEvent::OperationStop) { if (m_bufferStatus) m_bufferStatus->SetText(""); } else if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = static_cast<DialogCompletionEvent*>(event); // make sure the user didn't ESCAPE out of the menu if (dce->GetResult() < 0) return; QString resultid = dce->GetId(); QString resulttext = dce->GetResultText(); if (resultid == "streammenu") { if (resulttext == tr("Add Stream")) { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); MythScreenType *screen = new EditStreamMetadata(mainStack, this, NULL); if (screen->Create()) mainStack->AddScreen(screen); else delete screen; } else if (resulttext == tr("Remove Stream")) { removeStream(); } else if (resulttext == tr("Edit Stream")) { editStream(); } } else handled = false; } else handled = false; if (!handled) MusicCommon::customEvent(event); }
void ProgramRecPriority::UpdateList() { if (!m_currentItem && !m_programList->IsEmpty()) m_currentItem = m_programList->GetItemCurrent()->GetData() .value<ProgramRecPriorityInfo*>(); m_programList->Reset(); vector<ProgramRecPriorityInfo*>::iterator it; MythUIButtonListItem *item; for (it = m_sortedProgram.begin(); it != m_sortedProgram.end(); ++it) { ProgramRecPriorityInfo *progInfo = *it; item = new MythUIButtonListItem(m_programList, "", qVariantFromValue(progInfo)); int progRecPriority = progInfo->GetRecordingPriority(); if ((progInfo->rectype == kSingleRecord || progInfo->rectype == kOverrideRecord || progInfo->rectype == kDontRecord) && !(progInfo->GetSubtitle()).trimmed().isEmpty()) { QString rating = QString::number(progInfo->GetStars(10)); item->DisplayState(rating, "ratingstate"); } else progInfo->subtitle.clear(); QString state; if (progInfo->recType == kDontRecord || (progInfo->recType != kTemplateRecord && progInfo->recstatus == RecStatus::Inactive)) state = "disabled"; else if (m_conMatch[progInfo->GetRecordingRuleID()] > 0) state = "error"; else if (m_recMatch[progInfo->GetRecordingRuleID()] > 0 || progInfo->recType == kTemplateRecord) state = "normal"; else if (m_nowMatch[progInfo->GetRecordingRuleID()] > 0) state = "running"; else state = "warning"; InfoMap infoMap; progInfo->ToMap(infoMap); item->SetTextFromMap(infoMap, state); QString subtitle; if (progInfo->subtitle != "(null)" && (progInfo->rectype == kSingleRecord || progInfo->rectype == kOverrideRecord || progInfo->rectype == kDontRecord)) { subtitle = progInfo->subtitle; } QString matchInfo; if (progInfo->GetRecordingStatus() == RecStatus::Inactive) { matchInfo = QString("%1 %2") .arg(m_listMatch[progInfo->GetRecordingRuleID()]) .arg(RecStatus::toString(progInfo->GetRecordingStatus(), progInfo->GetRecordingRuleType())); } else matchInfo = tr("Recording %1 of %2") .arg(m_recMatch[progInfo->GetRecordingRuleID()]) .arg(m_listMatch[progInfo->GetRecordingRuleID()]); subtitle = QString("(%1) %2").arg(matchInfo).arg(subtitle); item->SetText(subtitle, "scheduleinfo", state); item->SetText(QString::number(progRecPriority), "progpriority", state); item->SetText(QString::number(progRecPriority), "finalpriority", state); item->SetText(QString::number(progRecPriority), "recpriority", state); item->SetText(QString::number(progRecPriority), "recpriorityB", state); QString tempDateTime = MythDate::toString(progInfo->last_record, MythDate::kDateTimeFull | MythDate::kSimplify | MythDate::kAddYear); item->SetText(tempDateTime, "lastrecorded", state); QString tempDate = MythDate::toString(progInfo->last_record, MythDate::kDateFull | MythDate::kSimplify | MythDate::kAddYear); item->SetText(tempDate, "lastrecordeddate", state); QString tempTime = MythDate::toString( progInfo->last_record, MythDate::kTime); item->SetText(tempTime, "lastrecordedtime", state); QString channame = progInfo->channame; QString channum = progInfo->chanstr; QString callsign = progInfo->chansign; if (progInfo->recType != kSingleRecord && progInfo->recType != kOverrideRecord && progInfo->recType != kDontRecord && !(progInfo->GetRecordingRule()->m_filter & 1024) && progInfo->GetRecordingRule()->m_searchType != kManualSearch) { channame = tr("Any"); channum = tr("Any"); callsign = tr("Any"); } item->SetText(channame, "channel", state); item->SetText(channum, "channum", state); item->SetText(callsign, "callsign", state); QString profile = progInfo->profile; if ((profile == "Default") || (profile == "Live TV") || (profile == "High Quality") || (profile == "Low Quality")) profile = tr(profile.toUtf8().constData()); item->SetText(profile, "recordingprofile", state); item->DisplayState(state, "status"); if (m_currentItem == progInfo) m_programList->SetItemCurrent(item); } m_currentItem = NULL; MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_programData.isEmpty()); }
void IdleScreen::UpdateScreen(void) { if (m_currentRecordings) { m_currentRecordings->Reset(); m_currentRecordings->SetCanTakeFocus(false); } if (m_nextRecordings) { m_nextRecordings->Reset(); m_nextRecordings->SetCanTakeFocus(false); } if (m_conflictingRecordings) { m_conflictingRecordings->Reset(); m_conflictingRecordings->SetCanTakeFocus(false); } if (m_conflictWarning) m_conflictWarning->SetVisible(m_hasConflicts); // update scheduled if (!m_scheduledList.empty()) { ProgramList::iterator pit = m_scheduledList.begin(); MythUIButtonListItem *item; while (pit != m_scheduledList.end()) { ProgramInfo *progInfo = *pit; if (progInfo) { MythUIButtonList *list = nullptr; const RecStatus::Type recstatus = progInfo->GetRecordingStatus(); switch(recstatus) { case RecStatus::Recording: case RecStatus::Tuning: case RecStatus::Failing: list = m_currentRecordings; break; case RecStatus::WillRecord: case RecStatus::Pending: list = m_nextRecordings; break; case RecStatus::Conflict: list = m_conflictingRecordings; break; default: list = nullptr; break; } if (list != nullptr) { item = new MythUIButtonListItem(list,"", qVariantFromValue(progInfo)); InfoMap infoMap; progInfo->ToMap(infoMap); item->SetTextFromMap(infoMap, ""); } } ++pit; } } UpdateStatus(); }
void GrabberSettings::Init(void) { for (QList<MetaGrabberScript*>::const_iterator it = m_movieGrabberList.begin(); it != m_movieGrabberList.end(); ++it) { QString commandline = QString("metadata/Movie/%1") .arg((*it)->GetCommand()); InfoMap map; (*it)->toMap(map); MythUIButtonListItem *item = new MythUIButtonListItem(m_movieGrabberButtonList, (*it)->GetName()); item->SetData(commandline); item->SetTextFromMap(map); } m_movieGrabberList.clear(); for (QList<MetaGrabberScript*>::const_iterator it = m_tvGrabberList.begin(); it != m_tvGrabberList.end(); ++it) { QString commandline = QString("metadata/Television/%1") .arg((*it)->GetCommand()); InfoMap map; (*it)->toMap(map); MythUIButtonListItem *item = new MythUIButtonListItem(m_tvGrabberButtonList, (*it)->GetName()); item->SetData(commandline); item->SetTextFromMap(map); } m_tvGrabberList.clear(); for (QList<MetaGrabberScript*>::const_iterator it = m_gameGrabberList.begin(); it != m_gameGrabberList.end(); ++it) { QString commandline = QString("metadata/Game/%1") .arg((*it)->GetCommand()); InfoMap map; (*it)->toMap(map); MythUIButtonListItem *item = new MythUIButtonListItem(m_gameGrabberButtonList, (*it)->GetName()); item->SetData(commandline); item->SetTextFromMap(map); } m_gameGrabberList.clear(); QString currentTVGrabber = gCoreContext->GetSetting("TelevisionGrabber", "metadata/Television/ttvdb.py"); QString currentMovieGrabber = gCoreContext->GetSetting("MovieGrabber", "metadata/Movie/tmdb3.py"); QString currentGameGrabber = gCoreContext->GetSetting("mythgame.MetadataGrabber", "metadata/Game/giantbomb.py"); m_movieGrabberButtonList->SetValueByData(qVariantFromValue(currentMovieGrabber)); m_tvGrabberButtonList->SetValueByData(qVariantFromValue(currentTVGrabber)); m_gameGrabberButtonList->SetValueByData(qVariantFromValue(currentGameGrabber)); int updates = gCoreContext->GetNumSetting("DailyArtworkUpdates", 0); if (updates == 1) m_dailyUpdatesCheck->SetCheckState(MythUIStateType::Full); }
bool MetadataResultsDialog::Create() { if (!LoadWindowFromXML("base.xml", "MythMetadataResults", this)) return false; bool err = false; UIUtilE::Assign(this, m_resultsList, "results", &err); if (err) { LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythMetadataResults'"); return false; } for (int i = 0; i != m_results.count(); ++i) { MythUIButtonListItem *button = new MythUIButtonListItem(m_resultsList, m_results[i]->GetTitle()); InfoMap metadataMap; m_results[i]->toMap(metadataMap); QString coverartfile; ArtworkList art = m_results[i]->GetArtwork(kArtworkCoverart); if (art.count() > 0) coverartfile = art.takeFirst().thumbnail; if (coverartfile.isEmpty()) { art = m_results[i]->GetArtwork(kArtworkBanner); if (art.count() > 0) coverartfile = art.takeFirst().thumbnail; } if (coverartfile.isEmpty()) { art = m_results[i]->GetArtwork(kArtworkScreenshot); if (art.count() > 0) coverartfile = art.takeFirst().thumbnail; } QString dlfile = getDownloadFilename(m_results[i]->GetTitle(), coverartfile); if (!coverartfile.isEmpty()) { int pos = m_resultsList->GetItemPos(button); if (QFile::exists(dlfile)) button->SetImage(dlfile); else m_imageDownload->addThumb(m_results[i]->GetTitle(), coverartfile, qVariantFromValue<uint>(pos)); } button->SetTextFromMap(metadataMap); button->SetData(qVariantFromValue<uint>(i)); } connect(m_resultsList, SIGNAL(itemClicked(MythUIButtonListItem *)), SLOT(sendResult(MythUIButtonListItem *))); BuildFocusList(); return true; }
void SearchView::customEvent(QEvent *event) { bool handled = false; if (event->type() == MusicPlayerEvent::TrackRemovedEvent || event->type() == MusicPlayerEvent::TrackAddedEvent) { MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event); if (!mpe) return; int trackID = mpe->TrackID; for (int x = 0; x < m_tracksList->GetCount(); x++) { MythUIButtonListItem *item = m_tracksList->GetItemAt(x); MusicMetadata *mdata = qVariantValue<MusicMetadata*> (item->GetData()); if (mdata && (mdata->ID() == (MusicMetadata::IdType) trackID || trackID == -1)) { if (gPlayer->getCurrentPlaylist() && gPlayer->getCurrentPlaylist()->checkTrack(mdata->ID())) item->DisplayState("on", "selectedstate"); else item->DisplayState("off", "selectedstate"); } } // call the default handler in MusicCommon so the playlist and UI is updated MusicCommon::customEvent(event); handled = true; if (m_playTrack) { m_playTrack = false; if (event->type() == MusicPlayerEvent::TrackAddedEvent) { // make the added track current and play it m_currentPlaylist->SetItemCurrent(m_currentPlaylist->GetCount() - 1); playlistItemClicked(m_currentPlaylist->GetItemCurrent()); } } } else if (event->type() == MusicPlayerEvent::AllTracksRemovedEvent) { for (int x = 0; x < m_tracksList->GetCount(); x++) { MythUIButtonListItem *item = m_tracksList->GetItemAt(x); if (item) item->DisplayState("off", "selectedstate"); } } else if (event->type() == MusicPlayerEvent::MetadataChangedEvent) { MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event); if (!mpe) return; uint trackID = mpe->TrackID; for (int x = 0; x < m_tracksList->GetCount(); x++) { MythUIButtonListItem *item = m_tracksList->GetItemAt(x); MusicMetadata *mdata = qVariantValue<MusicMetadata*> (item->GetData()); if (mdata && mdata->ID() == trackID) { InfoMap metadataMap; mdata->toMap(metadataMap); item->SetTextFromMap(metadataMap); } } // if (trackID == gPlayer->getCurrentMetadata()->ID()) // updateTrackInfo(gPlayer->getCurrentMetadata()); } else if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = static_cast<DialogCompletionEvent *>(event); // make sure the user didn't ESCAPE out of the menu if (dce->GetResult() < 0) return; QString resultid = dce->GetId(); QString resulttext = dce->GetResultText(); if (resultid == "searchviewmenu") { if (resulttext == tr("Add To Playlist") || resulttext == tr("Remove From Playlist")) { if (GetFocusWidget() == m_tracksList) { MythUIButtonListItem *item = m_tracksList->GetItemCurrent(); if (item) { m_playTrack = false; trackClicked(item); } } } else if (resulttext == tr("Add To Playlist And Play")) { if (GetFocusWidget() == m_tracksList) { MythUIButtonListItem *item = m_tracksList->GetItemCurrent(); if (item) { m_playTrack = true; trackClicked(item); } } } else if (resulttext == tr("Search List...")) searchButtonList(); } } if (!handled) MusicCommon::customEvent(event); }
void SearchView::updateTracksList(void) { m_tracksList->Reset(); MythUIButtonListItem *item = m_fieldList->GetItemCurrent(); if (!item) return; QString searchStr = m_criteriaEdit->GetText(); int field = item->GetData().toInt(); QString sql; MSqlQuery query(MSqlQuery::InitCon()); if (searchStr.isEmpty()) { sql = "SELECT song_id " "FROM music_songs "; query.prepare(sql); } else { switch(field) { case 1: // artist { sql = "SELECT song_id " "FROM music_songs " "LEFT JOIN music_artists ON " " music_songs.artist_id=music_artists.artist_id " "WHERE music_artists.artist_name LIKE '%" + searchStr + "%' "; query.prepare(sql); break; } case 2: // album { sql = "SELECT song_id " "FROM music_songs " "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id " "WHERE music_albums.album_name LIKE '%" + searchStr + "%' "; query.prepare(sql); break; } case 3: // title { sql = "SELECT song_id " "FROM music_songs " "WHERE music_songs.name LIKE '%" + searchStr + "%' "; query.prepare(sql); break; } case 4: // genre { sql = "SELECT song_id " "FROM music_songs " "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id " "WHERE music_genres.genre LIKE '%" + searchStr + "%' "; query.prepare(sql); break; } case 5: // tags { //TODO add tag query } case 0: // all fields default: { sql = "SELECT song_id " "FROM music_songs " "LEFT JOIN music_artists ON " " music_songs.artist_id=music_artists.artist_id " "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id " "LEFT JOIN music_artists AS music_comp_artists ON " " music_albums.artist_id=music_comp_artists.artist_id " "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id " "WHERE music_songs.name LIKE '%" + searchStr + "%' " "OR music_artists.artist_name LIKE '%" + searchStr + "%' " "OR music_albums.album_name LIKE '%" + searchStr + "%' " "OR music_genres.genre LIKE '%" + searchStr + "%' "; query.prepare(sql); } } } if (!query.exec() || !query.isActive()) { MythDB::DBError("Search music database", query); return; } while (query.next()) { int trackid = query.value(0).toInt(); MusicMetadata *mdata = gMusicData->all_music->getMetadata(trackid); if (mdata) { MythUIButtonListItem *newitem = new MythUIButtonListItem(m_tracksList, ""); newitem->SetData(qVariantFromValue(mdata)); InfoMap metadataMap; mdata->toMap(metadataMap); newitem->SetTextFromMap(metadataMap); if (gPlayer->getCurrentPlaylist() && gPlayer->getCurrentPlaylist()->checkTrack(mdata->ID())) newitem->DisplayState("on", "selectedstate"); else newitem->DisplayState("off", "selectedstate"); // TODO rating state etc } } trackVisible(m_tracksList->GetItemCurrent()); if (m_matchesText) m_matchesText->SetText(QString("%1").arg(m_tracksList->GetCount())); }
void ViewScheduled::FillList() { m_schedulesList->Reset(); MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_recList.empty()); if (m_recList.empty()) return; ProgramList plist; if (!m_recgroupList.contains(m_currentGroup)) m_currentGroup = m_defaultGroup; plist = m_recgroupList[m_currentGroup]; ProgramList::iterator pit = plist.begin(); while (pit != plist.end()) { ProgramInfo *pginfo = *pit; if (!pginfo) { ++pit; continue; } QString state; const RecStatusType recstatus = pginfo->GetRecordingStatus(); if (recstatus == rsRecording) state = "running"; else if (recstatus == rsConflict || recstatus == rsOffLine || recstatus == rsTunerBusy || recstatus == rsFailed || recstatus == rsAborted || recstatus == rsMissed) state = "error"; else if (recstatus == rsWillRecord) { if ((m_curcard == 0 && m_curinput == 0) || pginfo->GetCardID() == m_curcard || pginfo->GetInputID() == m_curinput) { if (pginfo->GetRecordingPriority2() < 0) state = "warning"; else state = "normal"; } } else if (recstatus == rsRepeat || recstatus == rsOtherShowing || recstatus == rsNeverRecord || recstatus == rsDontRecord || (recstatus != rsDontRecord && recstatus <= rsEarlierShowing)) state = "disabled"; else state = "warning"; MythUIButtonListItem *item = new MythUIButtonListItem(m_schedulesList,"", qVariantFromValue(pginfo)); InfoMap infoMap; pginfo->ToMap(infoMap); item->SetTextFromMap(infoMap, state); QString rating = QString::number(pginfo->GetStars(10)); item->DisplayState(rating, "ratingstate"); item->DisplayState(state, "status"); ++pit; } MythUIText *statusText = dynamic_cast<MythUIText*>(GetChild("status")); if (statusText) { if (m_conflictBool) { // Find first conflict and store in m_conflictDate field ProgramList::const_iterator it = plist.begin(); for (; it != plist.end(); ++it) { ProgramInfo &p = **it; if (p.GetRecordingStatus() == rsConflict) { m_conflictDate = p.GetRecordingStartTime().date(); break; } } // figure out caption based on m_conflictDate QString cstring = tr("Time Conflict"); QDate now = QDate::currentDate(); int daysToConflict = now.daysTo(m_conflictDate); if (daysToConflict == 0) cstring = tr("Conflict Today"); else if (daysToConflict > 0) cstring = QString(tr("Conflict %1")) .arg(m_conflictDate.toString(m_dateFormat)); statusText->SetText(cstring); } else statusText->SetText(tr("No Conflicts")); } MythUIText *filterText = dynamic_cast<MythUIText*>(GetChild("filter")); if (filterText) { if (m_showAll) filterText->SetText(tr("All")); else filterText->SetText(tr("Important")); } }
void GrabberSettings::Init(void) { for (QList<MetaGrabberScript*>::const_iterator it = m_movieGrabberList.begin(); it != m_movieGrabberList.end(); it++) { QString commandline = QString("%1metadata/Movie/%2") .arg(GetShareDir()).arg((*it)->GetCommand()); MetadataMap map; (*it)->toMap(map); MythUIButtonListItem *item = new MythUIButtonListItem(m_movieGrabberButtonList, (*it)->GetName()); item->SetData(commandline); item->SetTextFromMap(map); } m_movieGrabberList.clear(); for (QList<MetaGrabberScript*>::const_iterator it = m_tvGrabberList.begin(); it != m_tvGrabberList.end(); it++) { QString commandline = QString("%1metadata/Television/%2") .arg(GetShareDir()).arg((*it)->GetCommand()); MetadataMap map; (*it)->toMap(map); MythUIButtonListItem *item = new MythUIButtonListItem(m_tvGrabberButtonList, (*it)->GetName()); item->SetData(commandline); item->SetTextFromMap(map); } m_tvGrabberList.clear(); for (QList<MetaGrabberScript*>::const_iterator it = m_gameGrabberList.begin(); it != m_gameGrabberList.end(); it++) { QString commandline = QString("%1metadata/Game/%2") .arg(GetShareDir()).arg((*it)->GetCommand()); MetadataMap map; (*it)->toMap(map); MythUIButtonListItem *item = new MythUIButtonListItem(m_gameGrabberButtonList, (*it)->GetName()); item->SetData(commandline); item->SetTextFromMap(map); } m_gameGrabberList.clear(); QString currentTVGrabber = gCoreContext->GetSetting("TelevisionGrabber", QString("%1metadata/Television/%2") .arg(GetShareDir()).arg("ttvdb.py")); QString currentMovieGrabber = gCoreContext->GetSetting("MovieGrabber", QString("%1metadata/Movie/%2") .arg(GetShareDir()).arg("tmdb.py")); QString currentGameGrabber = gCoreContext->GetSetting("mythgame.MetadataGrabber", QString("%1metadata/Game/%2") .arg(GetShareDir()).arg("giantbomb.py")); m_movieGrabberButtonList->SetValueByData(qVariantFromValue(currentMovieGrabber)); m_tvGrabberButtonList->SetValueByData(qVariantFromValue(currentTVGrabber)); m_gameGrabberButtonList->SetValueByData(qVariantFromValue(currentGameGrabber)); }
bool ManualSchedule::Create(void) { if (!LoadWindowFromXML("schedule-ui.xml", "manualschedule", this)) return false; m_channelList = dynamic_cast<MythUIButtonList *>(GetChild("channel")); m_startdateList = dynamic_cast<MythUIButtonList *>(GetChild("startdate")); m_starthourSpin = dynamic_cast<MythUISpinBox *>(GetChild("starthour")); m_startminuteSpin = dynamic_cast<MythUISpinBox *>(GetChild("startminute")); m_durationSpin = dynamic_cast<MythUISpinBox *>(GetChild("duration")); m_titleEdit = dynamic_cast<MythUITextEdit *>(GetChild("title")); m_recordButton = dynamic_cast<MythUIButton *>(GetChild("next")); m_cancelButton = dynamic_cast<MythUIButton *>(GetChild("cancel")); if (!m_channelList || !m_startdateList || !m_starthourSpin || !m_startminuteSpin || !m_durationSpin || !m_titleEdit || !m_recordButton || !m_cancelButton) { LOG(VB_GENERAL, LOG_ERR, "ManualSchedule, theme is missing required elements"); return false; } QString chanorder = gCoreContext->GetSetting("ChannelOrdering", "channum"); DBChanList channels = ChannelUtil::GetChannels(0, false, "channum,callsign"); ChannelUtil::SortChannels(channels, chanorder); for (uint i = 0; i < channels.size(); i++) { QString chantext = channels[i].GetFormatted(DBChannel::kChannelLong); MythUIButtonListItem *item = new MythUIButtonListItem(m_channelList, chantext); InfoMap infomap; channels[i].ToMap(infomap); item->SetTextFromMap(infomap); m_chanids.push_back(channels[i].chanid); } for (uint index = 0; index <= 60; index++) { QString dinfo = MythDate::toString( m_nowDateTime.addDays(index), MythDate::kDateFull | MythDate::kSimplify); if (m_nowDateTime.addDays(index).toLocalTime().date().dayOfWeek() < 6) dinfo += QString(" (%1)").arg(tr("5 weekdays if daily")); else dinfo += QString(" (%1)").arg(tr("7 days per week if daily")); new MythUIButtonListItem(m_startdateList, dinfo); if (m_nowDateTime.addDays(index).toLocalTime().toString("MMdd") == m_startDateTime.toLocalTime().toString("MMdd")) m_startdateList->SetItemCurrent(m_startdateList->GetCount() - 1); } QTime thisTime = m_nowDateTime.toLocalTime().time(); thisTime = thisTime.addSecs((30 - (thisTime.minute() % 30)) * 60); if (thisTime < QTime(0,30)) m_startdateList->SetItemCurrent(m_startdateList->GetCurrentPos() + 1); m_starthourSpin->SetRange(0,23,1); m_starthourSpin->SetValue(thisTime.hour()); int minute_increment = gCoreContext->GetNumSetting("ManualScheduleMinuteIncrement", 5); m_startminuteSpin->SetRange(0, 60-minute_increment, minute_increment); m_startminuteSpin->SetValue((thisTime.minute()/5)*5); m_durationSpin->SetRange(5,360,5); m_durationSpin->SetValue(60); connectSignals(); connect(m_recordButton, SIGNAL(Clicked()), SLOT(recordClicked())); connect(m_cancelButton, SIGNAL(Clicked()), SLOT(Close())); m_titleEdit->SetMaxLength(128); BuildFocusList(); return true; }