Skip to content

Commit

Permalink
Stop passing around ChannelChangeDirection enum values as ints which …
Browse files Browse the repository at this point in the history
…defeats the point of using enums in the first place.
  • Loading branch information
stuartm committed Jun 4, 2013
1 parent fb48465 commit dcc6981
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
3 changes: 1 addition & 2 deletions mythtv/libs/libmythtv/channelutil.cpp
Expand Up @@ -15,7 +15,6 @@ using namespace std;
#include "channelutil.h"
#include "mythdb.h"
#include "dvbtables.h"
#include "tv.h" // for CHANNEL_DIRECTION

#define LOC QString("ChanUtil: ")

Expand Down Expand Up @@ -2359,7 +2358,7 @@ uint ChannelUtil::GetNextChannel(
const ChannelInfoList &sorted,
uint old_chanid,
uint mplexid_restriction,
int direction,
ChannelChangeDirection direction,
bool skip_non_visible,
bool skip_same_channum_and_callsign)
{
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmythtv/channelutil.h
Expand Up @@ -18,6 +18,7 @@ using namespace std;
#include "dtvmultiplex.h"
#include "channelinfo.h"
#include "iptvtuningdata.h"
#include "tv.h" // for CHANNEL_DIRECTION

class NetworkInformationTable;

Expand Down Expand Up @@ -214,7 +215,7 @@ class MTV_PUBLIC ChannelUtil
static uint GetNextChannel(const ChannelInfoList &sorted,
uint old_chanid,
uint mplexid_restriction,
int direction,
ChannelChangeDirection direction,
bool skip_non_visible = true,
bool skip_same_channum_and_callsign = false);

Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/recorders/channelbase.cpp
Expand Up @@ -236,7 +236,7 @@ bool ChannelBase::IsTunable(const QString &input, const QString &channum) const
return true;
}

uint ChannelBase::GetNextChannel(uint chanid, int direction) const
uint ChannelBase::GetNextChannel(uint chanid, ChannelChangeDirection direction) const
{
if (!chanid)
{
Expand All @@ -254,7 +254,7 @@ uint ChannelBase::GetNextChannel(uint chanid, int direction) const
m_allchannels, chanid, mplexid_restriction, direction);
}

uint ChannelBase::GetNextChannel(const QString &channum, int direction) const
uint ChannelBase::GetNextChannel(const QString &channum, ChannelChangeDirection direction) const
{
InputMap::const_iterator it = m_inputs.find(m_currentInputID);
if (it == m_inputs.end())
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/recorders/channelbase.h
Expand Up @@ -59,8 +59,8 @@ class ChannelBase
virtual bool IsExternalChannelChangeSupported(void) { return false; }

// Gets
virtual uint GetNextChannel(uint chanid, int direction) const;
virtual uint GetNextChannel(const QString &channum, int direction) const;
virtual uint GetNextChannel(uint chanid, ChannelChangeDirection direction) const;
virtual uint GetNextChannel(const QString &channum, ChannelChangeDirection direction) const;
virtual int GetInputByName(const QString &input) const;
virtual QString GetInputByNum(int capchannel) const;
virtual QString GetCurrentName(void) const
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -7435,7 +7435,7 @@ bool TV::CommitQueuedInput(PlayerContext *ctx)
return commited;
}

void TV::ChangeChannel(PlayerContext *ctx, int direction)
void TV::ChangeChannel(PlayerContext *ctx, ChannelChangeDirection direction)
{
if (db_use_channel_groups || (direction == CHANNEL_DIRECTION_FAVORITE))
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/tv_play.h
Expand Up @@ -511,7 +511,7 @@ class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer
// Channels
void ToggleChannelFavorite(PlayerContext *ctx);
void ToggleChannelFavorite(PlayerContext*, QString);
void ChangeChannel(PlayerContext*, int direction);
void ChangeChannel(PlayerContext*, ChannelChangeDirection direction);
void ChangeChannel(PlayerContext*, uint chanid, const QString &channum);

void ShowPreviousChannel(PlayerContext*);
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmythtv/tv_rec.cpp
Expand Up @@ -3431,8 +3431,9 @@ QString TVRec::TuningGetChanNum(const TuningRequest &request,

if (channel && !channum.isEmpty() && (channum.indexOf("NextChannel") >= 0))
{
// FIXME This is just horrible
int dir = channum.right(channum.length() - 12).toInt();
uint chanid = channel->GetNextChannel(0, dir);
uint chanid = channel->GetNextChannel(0, static_cast<ChannelChangeDirection>(dir));
channum = ChannelUtil::GetChanNum(chanid);
}

Expand Down
5 changes: 3 additions & 2 deletions mythtv/libs/libmythtv/tvbrowsehelper.cpp
Expand Up @@ -359,7 +359,8 @@ void TVBrowseHelper::GetNextProgramDB(
{
chanid = ChannelUtil::GetNextChannel(
db_all_visible_channels, chanid, 0 /*mplexid_restriction*/,
chandir, true /*skip non visible*/, true /*skip same callsign*/);
static_cast<ChannelChangeDirection>(chandir),
true /*skip non visible*/, true /*skip same callsign*/);
}

infoMap["chanid"] = QString::number(chanid);
Expand Down Expand Up @@ -487,7 +488,7 @@ void TVBrowseHelper::run()
m_tv->channelGroupLock.lock();
if (m_tv->channelGroupId > -1)
{
int dir = CHANNEL_DIRECTION_SAME;
ChannelChangeDirection dir = CHANNEL_DIRECTION_SAME;
if ((direction == BROWSE_UP) || (direction == BROWSE_FAVORITE))
dir = CHANNEL_DIRECTION_UP;
else if (direction == BROWSE_DOWN)
Expand Down

0 comments on commit dcc6981

Please sign in to comment.