From a8a3b3767661717632da1dc89aecf526f1c557bf Mon Sep 17 00:00:00 2001
From: Roger Siddons <dizygotheca@ntlworld.com>
Date: Fri, 3 Oct 2014 16:38:52 +0100
Subject: [PATCH 2/6] Watchlist: Select by episode numbers and date
diff --git a/mythtv/programs/mythfrontend/playbackbox.cpp b/mythtv/programs/mythfrontend/playbackbox.cpp
index 8abc2ea..23c129f 100644
|
a
|
b
|
bool PlaybackBox::UpdateUILists(void)
|
| 1640 | 1640 | QMap<QString, QString> sortedList; |
| 1641 | 1641 | QMap<int, QString> searchRule; |
| 1642 | 1642 | QMap<QString, int> watchlistCount; |
| | 1643 | TitleMap watchEpisode; |
| 1643 | 1644 | |
| 1644 | 1645 | m_programInfoCache.Refresh(); |
| 1645 | 1646 | |
| … |
… |
bool PlaybackBox::UpdateUILists(void)
|
| 1788 | 1789 | { |
| 1789 | 1790 | QString title = extract_watchlist_title(*p); |
| 1790 | 1791 | ++watchlistCount[title]; |
| 1791 | | if (watchlistCount[title] == 1) |
| | 1792 | |
| | 1793 | ProgramInfo* curEp = watchEpisode[title]; |
| | 1794 | if (curEp) |
| 1792 | 1795 | { |
| 1793 | | m_progLists[m_watchGroupLabel].push_front(p); |
| 1794 | | m_progLists[m_watchGroupLabel].setAutoDelete(false); |
| | 1796 | // duplicate title |
| | 1797 | uint cs = curEp->GetSeason(), |
| | 1798 | ce = curEp->GetEpisode(), |
| | 1799 | ps = p->GetSeason(), |
| | 1800 | pe = p->GetEpisode(); |
| | 1801 | |
| | 1802 | // succeed earliest if; |
| | 1803 | // - it was recorded earlier, or |
| | 1804 | // - both have seasons and season is earlier, or |
| | 1805 | // - seasons are same and both have episodes and |
| | 1806 | // episode is earlier |
| | 1807 | if ((p->GetRecordingStartTime() |
| | 1808 | < curEp->GetRecordingStartTime()) |
| | 1809 | // earlier non-zero season |
| | 1810 | || (ps < cs && ps) |
| | 1811 | // earlier non-zero episode of same season |
| | 1812 | || (ps == cs && pe && pe < ce)) |
| | 1813 | { |
| | 1814 | // replace existing show |
| | 1815 | watchEpisode[title] = p; |
| | 1816 | |
| | 1817 | LOG(VB_GUI, LOG_DEBUG, |
| | 1818 | QString("Watchlist: Replace - %1 %2 (%3x%4) " |
| | 1819 | "succeeding %5 (%6x%7)") |
| | 1820 | .arg(MythDate::toString(p->GetScheduledStartTime(), |
| | 1821 | Qt::ISODate)) |
| | 1822 | .arg(p->GetTitle()) |
| | 1823 | .arg(ps).arg(pe) |
| | 1824 | .arg(MythDate::toString(curEp->GetScheduledStartTime(), |
| | 1825 | Qt::ISODate)) |
| | 1826 | .arg(cs).arg(ce)); |
| | 1827 | } |
| | 1828 | else |
| | 1829 | { |
| | 1830 | p->SetRecordingPriority2(wlEarlier); |
| | 1831 | LOG(VB_FILE, LOG_INFO, |
| | 1832 | QString("Not the earliest: %1") |
| | 1833 | .arg(p->GetTitle())); |
| | 1834 | } |
| 1795 | 1835 | } |
| 1796 | 1836 | else |
| 1797 | 1837 | { |
| 1798 | | p->SetRecordingPriority2(wlEarlier); |
| 1799 | | LOG(VB_FILE, LOG_INFO, |
| 1800 | | QString("Not the earliest: %1") |
| 1801 | | .arg(p->GetTitle())); |
| | 1838 | // first show with this title |
| | 1839 | watchEpisode[title] = p; |
| | 1840 | |
| | 1841 | LOG(VB_GUI, LOG_DEBUG, |
| | 1842 | QString("Watchlist: Earliest - %1 %2 (%3x%4)") |
| | 1843 | .arg(MythDate::toString(p->GetScheduledStartTime(), |
| | 1844 | Qt::ISODate)) |
| | 1845 | .arg(p->GetTitle()) |
| | 1846 | .arg(p->GetSeason()) |
| | 1847 | .arg(p->GetEpisode())); |
| 1802 | 1848 | } |
| 1803 | 1849 | } |
| 1804 | 1850 | } |
| … |
… |
bool PlaybackBox::UpdateUILists(void)
|
| 1876 | 1922 | } |
| 1877 | 1923 | } |
| 1878 | 1924 | |
| 1879 | | if (!m_progLists[m_watchGroupLabel].empty()) |
| | 1925 | if (!watchEpisode.empty()) |
| 1880 | 1926 | { |
| | 1927 | // populate watchlist |
| | 1928 | foreach (ProgramInfo* wp, watchEpisode.values()) |
| | 1929 | m_progLists[m_watchGroupLabel].push_front(wp); |
| | 1930 | m_progLists[m_watchGroupLabel].setAutoDelete(false); |
| | 1931 | |
| 1881 | 1932 | QDateTime now = MythDate::current(); |
| 1882 | 1933 | int baseValue = m_watchListMaxAge * 2 / 3; |
| 1883 | 1934 | |
| … |
… |
void PlaybackBox::HandleUpdateProgramInfoEvent(const ProgramInfo &evinfo)
|
| 4360 | 4411 | if (!m_programInfoCache.Update(evinfo)) |
| 4361 | 4412 | return; |
| 4362 | 4413 | |
| 4363 | | // If the recording group has changed, reload lists from the recently |
| 4364 | | // updated cache; if not, only update UI for the updated item |
| 4365 | | if (evinfo.GetRecordingGroup() == old_recgroup) |
| | 4414 | // Reload lists from the recently updated cache if |
| | 4415 | // - the recording group has changed, or |
| | 4416 | // - the watchlist is in use: season/episode edits may change the displayed prog |
| | 4417 | // Otherwise only update UI for the updated item |
| | 4418 | if (evinfo.GetRecordingGroup() != old_recgroup |
| | 4419 | || (m_viewMask & VIEW_WATCHLIST)) |
| | 4420 | |
| | 4421 | ScheduleUpdateUIList(); |
| | 4422 | |
| | 4423 | else |
| 4366 | 4424 | { |
| 4367 | 4425 | ProgramInfo *dst = FindProgramInUILists(evinfo); |
| 4368 | 4426 | if (dst) |
| 4369 | 4427 | UpdateUIListItem(dst, true); |
| 4370 | | return; |
| 4371 | 4428 | } |
| 4372 | | |
| 4373 | | ScheduleUpdateUIList(); |
| 4374 | 4429 | } |
| 4375 | 4430 | |
| 4376 | 4431 | void PlaybackBox::HandleUpdateProgramInfoFileSizeEvent( |
diff --git a/mythtv/programs/mythfrontend/playbackbox.h b/mythtv/programs/mythfrontend/playbackbox.h
index 25964bb..be160d3 100644
|
a
|
b
|
class PlaybackBox : public ScheduleCommon
|
| 262 | 262 | void coverartLoad(void); |
| 263 | 263 | |
| 264 | 264 | private: |
| | 265 | typedef QMap<QString, ProgramInfo*> TitleMap; // progs keyed by title |
| | 266 | |
| 265 | 267 | bool UpdateUILists(void); |
| 266 | 268 | void UpdateUIGroupList(const QStringList &groupPreferences); |
| 267 | 269 | void UpdateUIRecGroupList(void); |