Skip to content

Commit

Permalink
Eliminate ProgramDetail struct
Browse files Browse the repository at this point in the history
This uselessly duplicated ProgramInfo but stored only a fraction of the
information.
  • Loading branch information
stuartm committed Jul 20, 2011
1 parent 73b6277 commit 9b5ca75
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 107 deletions.
46 changes: 42 additions & 4 deletions mythtv/libs/libmyth/programinfo.cpp
Expand Up @@ -1321,9 +1321,6 @@ void ProgramInfo::ToMap(InfoMap &progMap,
{
// NOTE: Format changes and relevant additions made here should be
// reflected in RecordingRule
QString fullDateFormat = gCoreContext->GetSetting("DateFormat", "ddd MMMM d");
if (!fullDateFormat.contains("yyyy"))
fullDateFormat += " yyyy";
QString channelFormat =
gCoreContext->GetSetting("ChannelFormat", "<num> <sign>");
QString longChannelFormat =
Expand Down Expand Up @@ -1514,7 +1511,7 @@ void ProgramInfo::ToMap(InfoMap &progMap,
{
progMap["longrepeat"] = QString("(%1 %2) ")
.arg(QObject::tr("Repeat"))
.arg(originalAirDate.toString(fullDateFormat));
.arg(MythDateToString(originalAirDate, kDateFull | kAddYear));
}
}
else
Expand Down Expand Up @@ -4697,6 +4694,47 @@ deque<int> GetPreferredSkipTypeCombinations(void)
return tmp;
}

bool GetNextRecordingList(QDateTime &nextRecordingStart,
bool *hasConflicts,
vector<ProgramInfo> *list)
{
nextRecordingStart = QDateTime();

bool dummy;
bool *conflicts = (hasConflicts) ? hasConflicts : &dummy;

ProgramList progList;
if (!LoadFromScheduler(progList, *conflicts))
return false;

// find the earliest scheduled recording
ProgramList::const_iterator it = progList.begin();
for (; it != progList.end(); ++it)
{
if (((*it)->GetRecordingStatus() == rsWillRecord) &&
(nextRecordingStart.isNull() ||
nextRecordingStart > (*it)->GetRecordingStartTime()))
{
nextRecordingStart = (*it)->GetRecordingStartTime();
}
}

if (!list)
return true;

// save the details of the earliest recording(s)
for (it = progList.begin(); it != progList.end(); ++it)
{
if (((*it)->GetRecordingStatus() == rsWillRecord) &&
((*it)->GetRecordingStartTime() == nextRecordingStart))
{
list->push_back(ProgramInfo(**it));
}
}

return true;
}

PMapDBReplacement::PMapDBReplacement() : lock(new QMutex())
{
}
Expand Down
10 changes: 8 additions & 2 deletions mythtv/libs/libmyth/programinfo.h
Expand Up @@ -5,6 +5,7 @@

// ANSI C
#include <stdint.h> // for [u]int[32,64]_t
#include <vector> // for GetNextRecordingList

#include <QStringList>
#include <QDateTime>
Expand Down Expand Up @@ -588,8 +589,7 @@ class MPUBLIC ProgramInfo
static uint64_t QueryBookmark(uint chanid, const QDateTime &recstartts);
static QMap<QString,uint32_t> QueryInUseMap(void);
static QMap<QString,bool> QueryJobsRunning(int type);
static QStringList LoadFromScheduler(
const QString &altTable, int recordid);
static QStringList LoadFromScheduler(const QString &altTable, int recordid);

protected:
// Flagging map support methods
Expand Down Expand Up @@ -766,6 +766,12 @@ bool LoadFromScheduler(AutoDeleteDeque<T> &destination)
return LoadFromScheduler(destination, dummyConflicts, "", -1);
}

// Moved from programdetails.cpp/h, used by MythWelcome/MythShutdown
// could be factored out
MPUBLIC bool GetNextRecordingList(QDateTime &nextRecordingStart,
bool *hasConflicts = NULL,
vector<ProgramInfo> *list = NULL);

class QMutex;
class MPUBLIC PMapDBReplacement
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.25.20110720-1"
#define MYTH_BINARY_VERSION "0.25.20110720-2"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/libmythtv.pro
Expand Up @@ -159,7 +159,7 @@ HEADERS += previewgenerator.h previewgeneratorqueue.h
HEADERS += transporteditor.h listingsources.h
HEADERS += myth_imgconvert.h
HEADERS += channelgroup.h channelgroupsettings.h
HEADERS += recordingrule.h programdetail.h
HEADERS += recordingrule.h
HEADERS += mythsystemevent.h
HEADERS += avfringbuffer.h ThreadedFileWriter.h
HEADERS += ringbuffer.h fileringbuffer.h
Expand Down Expand Up @@ -187,7 +187,7 @@ SOURCES += previewgenerator.cpp previewgeneratorqueue.cpp
SOURCES += transporteditor.cpp
SOURCES += channelgroup.cpp channelgroupsettings.cpp
SOURCES += myth_imgconvert.cpp
SOURCES += recordingrule.cpp programdetail.cpp
SOURCES += recordingrule.cpp
SOURCES += mythsystemevent.cpp
SOURCES += avfringbuffer.cpp ThreadedFileWriter.cpp
SOURCES += ringbuffer.cpp fileringBuffer.cpp
Expand Down
48 changes: 0 additions & 48 deletions mythtv/libs/libmythtv/programdetail.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions mythtv/libs/libmythtv/programdetail.h

This file was deleted.

4 changes: 2 additions & 2 deletions mythtv/programs/mythshutdown/main.cpp
Expand Up @@ -12,14 +12,14 @@ using namespace std;
#include "mythdb.h"
#include "mythsystem.h"
#include "mythversion.h"
#include "programdetail.h"
#include "jobqueue.h"
#include "tv.h"
#include "remoteutil.h"
#include "tvremoteutil.h"
#include "compat.h"
#include "mythlogging.h"
#include "commandlineparser.h"
#include "programinfo.h"

static void setGlobalSetting(const QString &key, const QString &value)
{
Expand Down Expand Up @@ -415,7 +415,7 @@ static int setScheduledWakeupTime()
}

QDateTime nextRecordingStart;
GetProgramDetailList(nextRecordingStart);
GetNextRecordingList(nextRecordingStart);

// set the wakeup time for the next scheduled recording
if (!nextRecordingStart.isNull())
Expand Down
26 changes: 12 additions & 14 deletions mythtv/programs/mythwelcome/welcomedialog.cpp
Expand Up @@ -388,21 +388,19 @@ void WelcomeDialog::updateScreen(void)
if (m_screenScheduledNo >= m_scheduledList.size())
m_screenScheduledNo = 0;

ProgramDetail prog = m_scheduledList[m_screenScheduledNo];
ProgramInfo progInfo = m_scheduledList[m_screenScheduledNo];

InfoMap infomap;
progInfo.ToMap(infomap);

//status = QString("%1 of %2\n").arg(m_screenScheduledNo + 1)
// .arg(m_scheduledList.size());
status = prog.channame + "\n";
status += prog.title;
if (!prog.subtitle.isEmpty())
status += "\n(" + prog.subtitle + ")";

QString dateFormat = gCoreContext->GetSetting(
"DateFormat", "ddd dd MMM yyyy");
status += "\n" + prog.startTime.toString(
dateFormat + " (" + m_timeFormat) +
" " + tr("to") + " " +
prog.endTime.toString(m_timeFormat + ")");
status = infomap["channame"] + "\n";
status += infomap["title"];
if (!infomap["subtitle"].isEmpty())
status += "\n(" + infomap["subtitle"] + ")";

status += "\n" + infomap["timedate"];

if (m_screenScheduledNo < m_scheduledList.size() - 1)
m_screenScheduledNo++;
Expand Down Expand Up @@ -512,8 +510,8 @@ bool WelcomeDialog::updateScheduledList()
return false;
}

GetProgramDetailList(
m_nextRecordingStart, &m_hasConflicts, &m_scheduledList);
GetNextRecordingList(m_nextRecordingStart, &m_hasConflicts,
&m_scheduledList);

updateStatus();
updateScreen();
Expand Down
10 changes: 7 additions & 3 deletions mythtv/programs/mythwelcome/welcomedialog.h
Expand Up @@ -4,9 +4,13 @@
// qt
#include <QDateTime>

// myth
// libmyth
#include "programinfo.h"

// libmythtv
#include "tvremoteutil.h"
#include "programdetail.h"

// libmythui
#include "mythscreentype.h"
#include "mythuibutton.h"
#include "mythuitext.h"
Expand Down Expand Up @@ -80,7 +84,7 @@ class WelcomeDialog : public MythScreenType
bool m_frontendIsRunning;

vector<TunerStatus> m_tunerList;
ProgramDetailList m_scheduledList;
vector<ProgramInfo> m_scheduledList;

QMutex m_RecListUpdateMuxtex;
bool m_pendingRecListUpdate;
Expand Down

0 comments on commit 9b5ca75

Please sign in to comment.