void LookerUpper::HandleAllRecordings() { QMap< QString, ProgramInfo* > recMap; QMap< QString, uint32_t > inUseMap = ProgramInfo::QueryInUseMap(); QMap< QString, bool > isJobRunning = ProgramInfo::QueryJobsRunning(JOB_COMMFLAG); ProgramList progList; LoadFromRecorded( progList, false, inUseMap, isJobRunning, recMap, -1 ); for( int n = 0; n < (int)progList.size(); n++) { ProgramInfo *pginfo = new ProgramInfo(*(progList[n])); if (pginfo->GetInetRef().isEmpty() || (!pginfo->GetSubtitle().isEmpty() && (pginfo->GetSeason() == 0) && (pginfo->GetEpisode() == 0))) { QString msg = QString("Looking up: %1 %2").arg(pginfo->GetTitle()) .arg(pginfo->GetSubtitle()); VERBOSE(VB_IMPORTANT, msg); m_busyRecList.append(pginfo); m_metadataFactory->Lookup(pginfo, false, false); } } }
void LookerUpper::HandleAllRecordings(bool updaterules) { QMap< QString, ProgramInfo* > recMap; QMap< QString, uint32_t > inUseMap = ProgramInfo::QueryInUseMap(); QMap< QString, bool > isJobRunning = ProgramInfo::QueryJobsRunning(JOB_COMMFLAG); m_updaterules = updaterules; ProgramList progList; LoadFromRecorded( progList, false, inUseMap, isJobRunning, recMap, -1 ); for( int n = 0; n < (int)progList.size(); n++) { ProgramInfo *pginfo = new ProgramInfo(*(progList[n])); if ((pginfo->GetRecordingGroup() != "Deleted") && (pginfo->GetRecordingGroup() != "LiveTV") && (pginfo->GetInetRef().isEmpty() || (!pginfo->GetSubtitle().isEmpty() && (pginfo->GetSeason() == 0) && (pginfo->GetEpisode() == 0)))) { QString msg = QString("Looking up: %1 %2").arg(pginfo->GetTitle()) .arg(pginfo->GetSubtitle()); LOG(VB_GENERAL, LOG_INFO, msg); m_busyRecList.append(pginfo); m_metadataFactory->Lookup(pginfo, true, false, false); } else delete pginfo; } }
void LookerUpper::CopyRuleInetrefsToRecordings() { QMap< QString, ProgramInfo* > recMap; QMap< QString, uint32_t > inUseMap = ProgramInfo::QueryInUseMap(); QMap< QString, bool > isJobRunning = ProgramInfo::QueryJobsRunning(JOB_COMMFLAG); ProgramList progList; LoadFromRecorded( progList, false, inUseMap, isJobRunning, recMap, -1 ); for( int n = 0; n < (int)progList.size(); n++) { ProgramInfo *pginfo = new ProgramInfo(*(progList[n])); if (pginfo && pginfo->GetInetRef().isEmpty()) { RecordingRule *rule = new RecordingRule(); rule->m_recordID = pginfo->GetRecordingRuleID(); rule->Load(); if (!rule->m_inetref.isEmpty()) { QString msg = QString("%1").arg(pginfo->GetTitle()); if (!pginfo->GetSubtitle().isEmpty()) msg += QString(": %1").arg(pginfo->GetSubtitle()); msg += " has no inetref, but its recording rule does. Copying..."; LOG(VB_GENERAL, LOG_INFO, msg); pginfo->SaveInetRef(rule->m_inetref); } delete rule; } delete pginfo; } }
void RecordingSelector::titleChanged(MythUIButtonListItem *item) { ProgramInfo *p; p = qVariantValue<ProgramInfo *>(item->GetData()); if (!p) return; if (m_titleText) m_titleText->SetText(p->GetTitle()); if (m_datetimeText) m_datetimeText->SetText(p->GetScheduledStartTime() .toString("dd MMM yy (hh:mm)")); if (m_descriptionText) { m_descriptionText->SetText( ((!p->GetSubtitle().isEmpty()) ? p->GetSubtitle() + "\n" : "") + p->GetDescription()); } if (m_filesizeText) { m_filesizeText->SetText(formatSize(p->GetFilesize() / 1024)); } if (m_cutlistImage) { if (p->HasCutlist()) m_cutlistImage->Show(); else m_cutlistImage->Hide(); } if (m_previewImage) { // try to locate a preview image if (QFile::exists(p->GetPathname() + ".png")) { m_previewImage->SetFilename(p->GetPathname() + ".png"); m_previewImage->Load(); } else { m_previewImage->SetFilename("blank.png"); m_previewImage->Load(); } } }
void LookerUpper::HandleAllRecordingRules() { m_updaterules = true; vector<ProgramInfo *> recordingList; RemoteGetAllScheduledRecordings(recordingList); for( int n = 0; n < (int)recordingList.size(); n++) { ProgramInfo *pginfo = new ProgramInfo(*(recordingList[n])); if (pginfo->GetInetRef().isEmpty()) { QString msg = QString("Looking up: %1 %2").arg(pginfo->GetTitle()) .arg(pginfo->GetSubtitle()); LOG(VB_GENERAL, LOG_INFO, msg); m_busyRecList.append(pginfo); m_metadataFactory->Lookup(pginfo, false, false); } } }
void LookerUpper::customEvent(QEvent *levent) { if (levent->type() == MetadataFactoryMultiResult::kEventType) { MetadataFactoryMultiResult *mfmr = dynamic_cast<MetadataFactoryMultiResult*>(levent); if (!mfmr) return; MetadataLookupList list = mfmr->results; if (list.count() > 1) { int yearindex = -1; for (int p = 0; p != list.size(); ++p) { ProgramInfo *pginfo = list[p]->GetData().value<ProgramInfo *>(); if (pginfo && !pginfo->GetSeriesID().isEmpty() && pginfo->GetSeriesID() == (list[p])->GetTMSref()) { MetadataLookup *lookup = list[p]; if (lookup->GetSubtype() != kProbableGenericTelevision) pginfo->SaveSeasonEpisode(lookup->GetSeason(), lookup->GetEpisode()); pginfo->SaveInetRef(lookup->GetInetref()); m_busyRecList.removeAll(pginfo); return; } else if (pginfo && pginfo->GetYearOfInitialRelease() != 0 && (list[p])->GetYear() != 0 && pginfo->GetYearOfInitialRelease() == (list[p])->GetYear()) { if (yearindex != -1) { LOG(VB_GENERAL, LOG_INFO, "Multiple results matched on year. No definite " "match could be found."); m_busyRecList.removeAll(pginfo); return; } else { LOG(VB_GENERAL, LOG_INFO, "Matched from multiple results based on year. "); yearindex = p; } } } if (yearindex > -1) { MetadataLookup *lookup = list[yearindex]; ProgramInfo *pginfo = lookup->GetData().value<ProgramInfo *>(); if (lookup->GetSubtype() != kProbableGenericTelevision) pginfo->SaveSeasonEpisode(lookup->GetSeason(), lookup->GetEpisode()); pginfo->SaveInetRef(lookup->GetInetref()); m_busyRecList.removeAll(pginfo); return; } LOG(VB_GENERAL, LOG_INFO, "Unable to match this title, too many possible matches. " "You may wish to manually set the season, episode, and " "inetref in the 'Watch Recordings' screen."); ProgramInfo *pginfo = list[0]->GetData().value<ProgramInfo *>(); if (pginfo) { m_busyRecList.removeAll(pginfo); } } } else if (levent->type() == MetadataFactorySingleResult::kEventType) { MetadataFactorySingleResult *mfsr = dynamic_cast<MetadataFactorySingleResult*>(levent); if (!mfsr) return; MetadataLookup *lookup = mfsr->result; if (!lookup) return; ProgramInfo *pginfo = lookup->GetData().value<ProgramInfo *>(); // This null check could hang us as this pginfo would then never be // removed if (!pginfo) return; LOG(VB_GENERAL, LOG_DEBUG, "I found the following data:"); LOG(VB_GENERAL, LOG_DEBUG, QString(" Input Title: %1").arg(pginfo->GetTitle())); LOG(VB_GENERAL, LOG_DEBUG, QString(" Input Sub: %1").arg(pginfo->GetSubtitle())); LOG(VB_GENERAL, LOG_DEBUG, QString(" Title: %1").arg(lookup->GetTitle())); LOG(VB_GENERAL, LOG_DEBUG, QString(" Subtitle: %1").arg(lookup->GetSubtitle())); LOG(VB_GENERAL, LOG_DEBUG, QString(" Season: %1").arg(lookup->GetSeason())); LOG(VB_GENERAL, LOG_DEBUG, QString(" Episode: %1").arg(lookup->GetEpisode())); LOG(VB_GENERAL, LOG_DEBUG, QString(" Inetref: %1").arg(lookup->GetInetref())); LOG(VB_GENERAL, LOG_DEBUG, QString(" User Rating: %1").arg(lookup->GetUserRating())); if (lookup->GetSubtype() != kProbableGenericTelevision) pginfo->SaveSeasonEpisode(lookup->GetSeason(), lookup->GetEpisode()); pginfo->SaveInetRef(lookup->GetInetref()); if (m_updaterules) { RecordingRule *rule = new RecordingRule(); if (rule) { rule->LoadByProgram(pginfo); if (rule->m_inetref.isEmpty() && (rule->m_searchType == kNoSearch)) { rule->m_inetref = lookup->GetInetref(); } rule->m_season = lookup->GetSeason(); rule->m_episode = lookup->GetEpisode(); rule->Save(); delete rule; } } if (m_updateartwork) { ArtworkMap map = lookup->GetDownloads(); SetArtwork(lookup->GetInetref(), lookup->GetIsCollection() ? 0 : lookup->GetSeason(), gCoreContext->GetMasterHostName(), map); } m_busyRecList.removeAll(pginfo); } else if (levent->type() == MetadataFactoryNoResult::kEventType) { MetadataFactoryNoResult *mfnr = dynamic_cast<MetadataFactoryNoResult*>(levent); if (!mfnr) return; MetadataLookup *lookup = mfnr->result; if (!lookup) return; ProgramInfo *pginfo = lookup->GetData().value<ProgramInfo *>(); // This null check could hang us as this pginfo would then never be removed if (!pginfo) return; m_busyRecList.removeAll(pginfo); } }
void LookerUpper::HandleAllArtwork(bool aggressive) { m_updateartwork = true; if (aggressive) m_updaterules = true; // First, handle all recording rules w/ inetrefs vector<ProgramInfo *> recordingList; RemoteGetAllScheduledRecordings(recordingList); int maxartnum = 3; for( int n = 0; n < (int)recordingList.size(); n++) { ProgramInfo *pginfo = new ProgramInfo(*(recordingList[n])); bool dolookup = true; if (pginfo->GetInetRef().isEmpty()) dolookup = false; if (dolookup || aggressive) { ArtworkMap map = GetArtwork(pginfo->GetInetRef(), pginfo->GetSeason(), true); if (map.isEmpty() || (aggressive && map.count() < maxartnum)) { QString msg = QString("Looking up artwork for recording rule: %1 %2") .arg(pginfo->GetTitle()) .arg(pginfo->GetSubtitle()); LOG(VB_GENERAL, LOG_INFO, msg); m_busyRecList.append(pginfo); m_metadataFactory->Lookup(pginfo, true, true, true); continue; } } delete pginfo; } // Now, Attempt to fill in the gaps for recordings QMap< QString, ProgramInfo* > recMap; QMap< QString, uint32_t > inUseMap = ProgramInfo::QueryInUseMap(); QMap< QString, bool > isJobRunning = ProgramInfo::QueryJobsRunning(JOB_COMMFLAG); ProgramList progList; LoadFromRecorded( progList, false, inUseMap, isJobRunning, recMap, -1 ); for( int n = 0; n < (int)progList.size(); n++) { ProgramInfo *pginfo = new ProgramInfo(*(progList[n])); bool dolookup = true; LookupType type = GuessLookupType(pginfo); if (type == kProbableMovie) maxartnum = 2; if ((!aggressive && type == kProbableGenericTelevision) || pginfo->GetRecordingGroup() == "Deleted" || pginfo->GetRecordingGroup() == "LiveTV") dolookup = false; if (dolookup || aggressive) { ArtworkMap map = GetArtwork(pginfo->GetInetRef(), pginfo->GetSeason(), true); if (map.isEmpty() || (aggressive && map.count() < maxartnum)) { QString msg = QString("Looking up artwork for recording: %1 %2") .arg(pginfo->GetTitle()) .arg(pginfo->GetSubtitle()); LOG(VB_GENERAL, LOG_INFO, msg); m_busyRecList.append(pginfo); m_metadataFactory->Lookup(pginfo, true, true, aggressive); continue; } } delete pginfo; } }
void RecordingSelector::OKPressed() { // loop though selected recordings and add them to the list ProgramInfo *p; ArchiveItem *a; // remove any items that have been removed from the list QList<ArchiveItem *> tempAList; for (int x = 0; x < m_archiveList->size(); x++) { a = m_archiveList->at(x); bool found = false; for (int y = 0; y < m_selectedList.size(); y++) { p = m_selectedList.at(y); if (a->type != "Recording" || a->filename == p->GetPlaybackURL(false, true)) { found = true; break; } } if (!found) tempAList.append(a); } for (int x = 0; x < tempAList.size(); x++) m_archiveList->removeAll(tempAList.at(x)); // remove any items that are already in the list QList<ProgramInfo *> tempSList; for (int x = 0; x < m_selectedList.size(); x++) { p = m_selectedList.at(x); for (int y = 0; y < m_archiveList->size(); y++) { a = m_archiveList->at(y); if (a->filename == p->GetPlaybackURL(false, true)) { tempSList.append(p); break; } } } for (int x = 0; x < tempSList.size(); x++) m_selectedList.removeAll(tempSList.at(x)); // add all that are left for (int x = 0; x < m_selectedList.size(); x++) { p = m_selectedList.at(x); a = new ArchiveItem; a->type = "Recording"; a->title = p->GetTitle(); a->subtitle = p->GetSubtitle(); a->description = p->GetDescription(); a->startDate = p->GetScheduledStartTime().toString("dd MMM yy"); a->startTime = p->GetScheduledStartTime().toString("(hh:mm)"); a->size = p->GetFilesize(); a->filename = p->GetPlaybackURL(false, true); a->hasCutlist = p->HasCutlist(); a->useCutlist = false; a->duration = 0; a->cutDuration = 0; a->videoWidth = 0; a->videoHeight = 0; a->fileCodec = ""; a->videoCodec = ""; a->encoderProfile = NULL; a->editedDetails = false; m_archiveList->append(a); } emit haveResult(true); Close(); }
void LookerUpper::customEvent(QEvent *levent) { if (levent->type() == MetadataFactoryMultiResult::kEventType) { VERBOSE(VB_IMPORTANT, "Got a multiresult."); // We shouldn't get any of these. If we do, metadataFactory->Lookup // was called with the wrong arguments. } else if (levent->type() == MetadataFactorySingleResult::kEventType) { MetadataFactorySingleResult *mfsr = dynamic_cast<MetadataFactorySingleResult*>(levent); if (!mfsr) return; MetadataLookup *lookup = mfsr->result; if (!lookup) return; ProgramInfo *pginfo = qVariantValue<ProgramInfo *>(lookup->GetData()); // This null check could hang us as this pginfo would then never be removed if (!pginfo) return; VERBOSE(VB_GENERAL|VB_EXTRA, QString("I found the following data:")); VERBOSE(VB_GENERAL|VB_EXTRA, QString(" Input Title: %1").arg(pginfo->GetTitle())); VERBOSE(VB_GENERAL|VB_EXTRA, QString(" Input Sub: %1").arg(pginfo->GetSubtitle())); VERBOSE(VB_GENERAL|VB_EXTRA, QString(" Title: %1").arg(lookup->GetTitle())); VERBOSE(VB_GENERAL|VB_EXTRA, QString(" Subtitle: %1").arg(lookup->GetSubtitle())); VERBOSE(VB_GENERAL|VB_EXTRA, QString(" Season: %1").arg(lookup->GetSeason())); VERBOSE(VB_GENERAL|VB_EXTRA, QString(" Episode: %1").arg(lookup->GetEpisode())); VERBOSE(VB_GENERAL|VB_EXTRA, QString(" Inetref: %1").arg(lookup->GetInetref())); VERBOSE(VB_GENERAL|VB_EXTRA, QString(" User Rating: %1").arg(lookup->GetUserRating())); pginfo->SaveSeasonEpisode(lookup->GetSeason(), lookup->GetEpisode()); pginfo->SaveInetRef(lookup->GetInetref()); m_busyRecList.removeAll(pginfo); } else if (levent->type() == MetadataFactoryNoResult::kEventType) { MetadataFactoryNoResult *mfnr = dynamic_cast<MetadataFactoryNoResult*>(levent); if (!mfnr) return; MetadataLookup *lookup = mfnr->result; if (!lookup) return; ProgramInfo *pginfo = qVariantValue<ProgramInfo *>(lookup->GetData()); // This null check could hang us as this pginfo would then never be removed if (!pginfo) return; m_busyRecList.removeAll(pginfo); } }
void ProgLister::FillItemList(bool restorePosition, bool updateDisp) { if (m_type == plPreviouslyRecorded && m_curviewText) { if (!m_titleSort) { if (!m_reverseSort) m_curView = 0; else m_curView = 1; } else { if (!m_reverseSort) m_curView = 2; else m_curView = 3; } } if (m_curView < 0) return; bool oneChanid = false; QString where; QString startstr = m_startTime.toString("yyyy-MM-dd hh:mm:50"); QString qphrase = m_viewList[m_curView]; MSqlBindings bindings; if (m_type != plPreviouslyRecorded) bindings[":PGILSTART"] = startstr; if (m_type == plTitle) // per title listings { where = "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND program.title = :PGILPHRASE0 "; bindings[":PGILPHRASE0"] = qphrase; } else if (m_type == plNewListings) // what's new list { where = "LEFT JOIN oldprogram ON " " oldprogram.oldtitle = program.title " "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND oldprogram.oldtitle IS NULL " " AND program.manualid = 0 "; if (qphrase == "premieres") { where += " AND ( "; where += " ( program.originalairdate=DATE(program.starttime) "; where += " AND (program.category = 'Special' "; where += " OR program.programid LIKE 'EP%0001')) "; where += " OR (program.category_type='movie' "; where += " AND program.stars > 0.5 "; where += " AND program.airdate >= YEAR(NOW()) - 2) "; where += " ) "; } else if (qphrase == "movies") { where += " AND program.category_type = 'movie' "; } else if (qphrase == "series") { where += " AND program.category_type = 'series' "; } else if (qphrase == "specials") { where += " AND program.category_type = 'tvshow' "; } else { where += " AND (program.category_type <> 'movie' "; where += " OR program.airdate >= YEAR(NOW()) - 3) "; } } else if (m_type == plTitleSearch) // keyword search { where = "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND program.title LIKE :PGILLIKEPHRASE0 "; bindings[":PGILLIKEPHRASE0"] = QString("%") + qphrase + '%'; } else if (m_type == plKeywordSearch) // keyword search { where = "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND (program.title LIKE :PGILLIKEPHRASE1 " " OR program.subtitle LIKE :PGILLIKEPHRASE2 " " OR program.description LIKE :PGILLIKEPHRASE3 ) "; bindings[":PGILLIKEPHRASE1"] = QString("%") + qphrase + '%'; bindings[":PGILLIKEPHRASE2"] = QString("%") + qphrase + '%'; bindings[":PGILLIKEPHRASE3"] = QString("%") + qphrase + '%'; } else if (m_type == plPeopleSearch) // people search { where = ", people, credits WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND people.name LIKE :PGILPHRASE1 " " AND credits.person = people.person " " AND program.chanid = credits.chanid " " AND program.starttime = credits.starttime"; bindings[":PGILPHRASE1"] = qphrase; } else if (m_type == plPowerSearch) // complex search { QString powerWhere; MSqlBindings powerBindings; bool genreflag = PowerStringToSQL(qphrase, powerWhere, powerBindings); if (!powerWhere.isEmpty()) { if (genreflag) where = QString("LEFT JOIN programgenres ON " "program.chanid = programgenres.chanid AND " "program.starttime = programgenres.starttime "); where += QString("WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND ( ") + powerWhere + " ) "; MSqlAddMoreBindings(bindings, powerBindings); } } else if (m_type == plSQLSearch) // complex search { qphrase.remove(QRegExp("^\\s*AND\\s+", Qt::CaseInsensitive)); where = QString("WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND ( %1 ) ").arg(qphrase); if (!m_addTables.isEmpty()) where = m_addTables + ' ' + where; } else if (m_type == plChannel) // list by channel { oneChanid = true; where = "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND channel.chanid = :PGILPHRASE2 "; bindings[":PGILPHRASE2"] = qphrase; } else if (m_type == plCategory) // list by category { if (!m_useGenres) { where = "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND program.category = :PGILPHRASE3 "; bindings[":PGILPHRASE3"] = qphrase; } else if (m_viewList[m_curView].indexOf(":/:") < 0) { where = "JOIN programgenres g ON " " program.chanid = g.chanid AND " " program.starttime = g.starttime AND " " genre = :PGILPHRASE4 " "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART "; bindings[":PGILPHRASE4"] = qphrase; } else { where = "JOIN programgenres g1 ON " " program.chanid = g1.chanid AND " " program.starttime = g1.starttime AND " " g1.genre = :GENRE1 " "JOIN programgenres g2 ON " " program.chanid = g2.chanid AND " " program.starttime = g2.starttime AND " " g2.genre = :GENRE2 " "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART "; bindings[":GENRE1"] = m_viewList[m_curView].section(":/:", 0, 0); bindings[":GENRE2"] = m_viewList[m_curView].section(":/:", 1, 1); } } else if (m_type == plMovies) // list movies { where = "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND program.category_type = 'movie' " " AND program.stars " + qphrase + ' '; } else if (m_type == plTime) // list by time { bindings[":PGILSEARCHTIME1"] = m_searchTime.toString("yyyy-MM-dd hh:00:00"); where = "WHERE channel.visible = 1 " " AND program.starttime >= :PGILSEARCHTIME1 "; if (m_titleSort) { where += " AND program.starttime < DATE_ADD(:PGILSEARCHTIME2, " "INTERVAL '1' HOUR) "; bindings[":PGILSEARCHTIME2"] = bindings[":PGILSEARCHTIME1"]; } } else if (m_type == plRecordid) // list by recordid { where = "JOIN recordmatch ON " " (program.starttime = recordmatch.starttime " " AND program.chanid = recordmatch.chanid) " "WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND recordmatch.recordid = :PGILPHRASE5 "; bindings[":PGILPHRASE5"] = qphrase; } else if (m_type == plStoredSearch) // stored search { MSqlQuery query(MSqlQuery::InitCon()); query.prepare("SELECT fromclause, whereclause FROM customexample " "WHERE rulename = :RULENAME;"); query.bindValue(":RULENAME", qphrase); if (query.exec() && query.next()) { QString fromc = query.value(0).toString(); QString wherec = query.value(1).toString(); where = QString("WHERE channel.visible = 1 " " AND program.endtime > :PGILSTART " " AND ( %1 ) ").arg(wherec); if (!fromc.isEmpty()) where = fromc + ' ' + where; } } else if (m_type == plPreviouslyRecorded) { if (m_recid && !m_title.isEmpty()) { where = QString("WHERE recordid = %1 OR title = :MTITLE ") .arg(m_recid); bindings[":MTITLE"] = m_title; } else if (!m_title.isEmpty()) { where = QString("WHERE title = :MTITLE "); bindings[":MTITLE"] = m_title; } else if (m_recid) { where = QString("WHERE recordid = %1 ").arg(m_recid); } } ProgramInfo selected; const ProgramInfo *selectedP = (restorePosition) ? GetCurrent() : NULL; if (selectedP) { selected = *selectedP; selectedP = &selected; } int selectedOffset = m_progList->GetCurrentPos() - m_progList->GetTopItemPos(); m_progList->Reset(); m_itemList.clear(); if (m_type == plPreviouslyRecorded) { LoadFromOldRecorded(m_itemList, where, bindings); } else { LoadFromScheduler(m_schedList); LoadFromProgram(m_itemList, where, bindings, m_schedList, oneChanid); } const QRegExp prefixes( tr("^(The |A |An )", "Regular Expression for what to ignore when sorting")); for (uint i = 0; i < m_itemList.size(); i++) { ProgramInfo *s = m_itemList[i]; s->sortTitle = (m_type == plTitle) ? s->GetSubtitle() : s->GetTitle(); s->sortTitle.remove(prefixes); } if (m_type == plNewListings || m_titleSort) { SortList(kTitleSort, m_reverseSort); if (m_type != plPreviouslyRecorded) { // Prune to one per title QString curtitle; ProgramList::iterator it = m_itemList.begin(); while (it != m_itemList.end()) { if ((*it)->sortTitle != curtitle) { curtitle = (*it)->sortTitle; ++it; } else { it = m_itemList.erase(it); } } } } if (!m_titleSort) SortList(GetSortBy(), m_reverseSort); if (updateDisp) UpdateDisplay(selectedP, selectedOffset); }
void RecordingSelector::updateRecordingList(void) { if (!m_recordingList || m_recordingList->empty()) return; m_recordingButtonList->Reset(); if (m_categorySelector) { ProgramInfo *p; vector<ProgramInfo *>::iterator i = m_recordingList->begin(); for ( ; i != m_recordingList->end(); ++i) { p = *i; if (p->GetTitle() == m_categorySelector->GetValue() || m_categorySelector->GetValue() == tr("All Recordings")) { MythUIButtonListItem* item = new MythUIButtonListItem( m_recordingButtonList, p->GetTitle() + " ~ " + p->GetScheduledStartTime().toLocalTime() .toString("dd MMM yy (hh:mm)")); item->setCheckable(true); if (m_selectedList.indexOf((ProgramInfo *) p) != -1) { item->setChecked(MythUIButtonListItem::FullChecked); } else { item->setChecked(MythUIButtonListItem::NotChecked); } QString title = p->GetTitle(); QString subtitle = p->GetSubtitle(); QDateTime recstartts = p->GetScheduledStartTime(); QDateTime recendts = p->GetScheduledEndTime(); QString timedate = QString("%1 - %2") .arg(MythDate::toString(recstartts,MythDate::kDateTimeFull)) .arg(MythDate::toString(recendts, MythDate::kTime)); uint season = p->GetSeason(); uint episode = p->GetEpisode(); QString seasone, seasonx; if (season && episode) { seasone = QString("s%1e%2") .arg(format_season_and_episode(season, 2)) .arg(format_season_and_episode(episode, 2)); seasonx = QString("%1x%2") .arg(format_season_and_episode(season, 1)) .arg(format_season_and_episode(episode, 2)); } item->SetText(title, "title"); item->SetText(subtitle, "subtitle"); if (subtitle.isEmpty()) item->SetText(title, "titlesubtitle"); else item->SetText(title + " - \"" + subtitle + '"', "titlesubtitle"); item->SetText(timedate, "timedate"); item->SetText(p->GetDescription(), "description"); item->SetText(formatSize(p->GetFilesize() / 1024), "filesize_str"); item->SetText(QString::number(season), "season"); item->SetText(QString::number(episode), "episode"); item->SetText(seasonx, "00x00"); item->SetText(seasone, "s00e00"); item->DisplayState(p->HasCutlist() ? "yes" : "no", "cutlist"); item->SetData(qVariantFromValue(p)); } qApp->processEvents(); } } m_recordingButtonList->SetItemCurrent(m_recordingButtonList->GetItemFirst()); titleChanged(m_recordingButtonList->GetItemCurrent()); }