Skip to content

Commit

Permalink
Convert mythfrontend to using mythactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Beirdo committed Mar 8, 2012
1 parent 214f24f commit b597f99
Show file tree
Hide file tree
Showing 26 changed files with 1,564 additions and 788 deletions.
128 changes: 80 additions & 48 deletions mythtv/programs/mythfrontend/channelrecpriority.cpp
Expand Up @@ -20,6 +20,7 @@ using namespace std;
#include "mythuibuttonlist.h"
#include "mythdialogbox.h"
#include "mythmainwindow.h"
#include "mythactions.h"

typedef struct RecPriorityInfo
{
Expand Down Expand Up @@ -49,16 +50,30 @@ class channelRecPrioritySort
}
};

ChannelRecPriority::ChannelRecPriority(MythScreenStack *parent)
: MythScreenType(parent, "ChannelRecPriority"),
m_channelList(NULL), m_chanstringText(NULL),
m_channameText(NULL), m_channumText(NULL),
m_callsignText(NULL), m_sourcenameText(NULL),
m_sourceidText(NULL), m_priorityText(NULL),
m_iconImage(NULL)

static struct ActionDefStruct<ChannelRecPriority> crpActions[] = {
{ "UPCOMING", &ChannelRecPriority::doUpcoming },
{ "RANKINC", &ChannelRecPriority::doRankInc },
{ "RANKDEC", &ChannelRecPriority::doRankDec },
{ "1", &ChannelRecPriority::doOne },
{ "2", &ChannelRecPriority::doTwo },
{ "PREVVIEW", &ChannelRecPriority::doPrevNext },
{ "NEXTVIEW", &ChannelRecPriority::doPrevNext }
};
static int crpActionCount = NELEMS(crpActions);


ChannelRecPriority::ChannelRecPriority(MythScreenStack *parent) :
MythScreenType(parent, "ChannelRecPriority"),
m_channelList(NULL), m_chanstringText(NULL), m_channameText(NULL),
m_channumText(NULL), m_callsignText(NULL), m_sourcenameText(NULL),
m_sourceidText(NULL), m_priorityText(NULL), m_iconImage(NULL),
m_actions(new MythActions<ChannelRecPriority>(this, crpActions,
crpActionCount))
{
m_sortType = (SortType)gCoreContext->GetNumSetting("ChannelRecPrioritySorting",
(int)byChannel);
m_sortType =
(SortType)gCoreContext->GetNumSetting("ChannelRecPrioritySorting",
(int)byChannel);

m_currentItem = NULL;

Expand All @@ -71,6 +86,9 @@ ChannelRecPriority::~ChannelRecPriority()
gCoreContext->SaveSetting("ChannelRecPrioritySorting",
(int)m_sortType);
gCoreContext->removeListener(this);

if (m_actions)
delete m_actions;
}

bool ChannelRecPriority::Create()
Expand Down Expand Up @@ -101,53 +119,67 @@ bool ChannelRecPriority::Create()
return true;
}

bool ChannelRecPriority::doUpcoming(const QString &action)
{
upcoming();
return true;
}

bool ChannelRecPriority::doRankInc(const QString &action)
{
changeRecPriority(1);
return true;
}

bool ChannelRecPriority::doRankDec(const QString &action)
{
changeRecPriority(-1);
return true;
}

bool ChannelRecPriority::doOne(const QString &action)
{
if (m_sortType != byChannel)
{
m_sortType = byChannel;
SortList();
}
return true;
}

bool ChannelRecPriority::doTwo(const QString &action)
{
if (m_sortType != byRecPriority)
{
m_sortType = byRecPriority;
SortList();
}
return true;
}

bool ChannelRecPriority::doPrevNext(const QString &action)
{
if (m_sortType == byChannel)
m_sortType = byRecPriority;
else
m_sortType = byChannel;
SortList();
return true;
}


bool ChannelRecPriority::keyPressEvent(QKeyEvent *event)
{
if (GetFocusWidget()->keyPressEvent(event))
return true;

bool handled = false;
QStringList actions;
handled = GetMythMainWindow()->TranslateKeyPress("TV Frontend", event, actions);

for (int i = 0; i < actions.size() && !handled; i++)
{
QString action = actions[i];
handled = true;
handled = GetMythMainWindow()->TranslateKeyPress("TV Frontend", event,
actions);

if (action == "UPCOMING")
upcoming();
else if (action == "RANKINC")
changeRecPriority(1);
else if (action == "RANKDEC")
changeRecPriority(-1);
else if (action == "1")
{
if (m_sortType != byChannel)
{
m_sortType = byChannel;
SortList();
}
}
else if (action == "2")
{
if (m_sortType != byRecPriority)
{
m_sortType = byRecPriority;
SortList();
}
}
else if (action == "PREVVIEW" || action == "NEXTVIEW")
{
if (m_sortType == byChannel)
m_sortType = byRecPriority;
else
m_sortType = byChannel;
SortList();
}
else
handled = false;
}
if (!handled)
handled = m_actions->handleActions(actions);

if (!handled && MythScreenType::keyPressEvent(event))
handled = true;
Expand Down
10 changes: 10 additions & 0 deletions mythtv/programs/mythfrontend/channelrecpriority.h
Expand Up @@ -4,6 +4,7 @@
#include "mythscreentype.h"

#include "programinfo.h"
#include "mythactions.h"

class ChannelInfo;

Expand Down Expand Up @@ -36,6 +37,13 @@ class ChannelRecPriority : public MythScreenType
byRecPriority,
};

bool doUpcoming(const QString &action);
bool doRankInc(const QString &action);
bool doRankDec(const QString &action);
bool doOne(const QString &action);
bool doTwo(const QString &action);
bool doPrevNext(const QString &action);

protected slots:
void updateInfo(MythUIButtonListItem *);

Expand Down Expand Up @@ -70,6 +78,8 @@ class ChannelRecPriority : public MythScreenType
SortType m_sortType;

ChannelInfo *m_currentItem;

MythActions<ChannelRecPriority> *m_actions;
};

#endif
45 changes: 27 additions & 18 deletions mythtv/programs/mythfrontend/customedit.cpp
Expand Up @@ -22,9 +22,17 @@
// mythfrontend
#include "scheduleeditor.h"
#include "proglist.h"
#include "mythactions.h"

CustomEdit::CustomEdit(MythScreenStack *parent, ProgramInfo *pginfo)
: MythScreenType(parent, "CustomEdit")
static struct ActionDefStruct<CustomEdit> ceActions[] = {
{ "DELETE", &CustomEdit::doDelete }
};
static int ceActionCount = NELEMS(ceActions);


CustomEdit::CustomEdit(MythScreenStack *parent, ProgramInfo *pginfo) :
MythScreenType(parent, "CustomEdit"),
m_actions(new MythActions<CustomEdit>(this, ceActions, ceActionCount))
{
if (pginfo)
m_pginfo = new ProgramInfo(*pginfo);
Expand All @@ -43,6 +51,9 @@ CustomEdit::CustomEdit(MythScreenStack *parent, ProgramInfo *pginfo)

CustomEdit::~CustomEdit(void)
{
if (m_actions)
delete m_actions;

delete m_pginfo;

gCoreContext->removeListener(this);
Expand Down Expand Up @@ -846,30 +857,28 @@ void CustomEdit::customEvent(QEvent *event)
}
}

bool CustomEdit::doDelete(const QString &action)
{
if (GetFocusWidget() == m_clauseList)
deleteRule();
// else if (GetFocusWidget() == m_ruleList)
// deleteRecordingRule();

return true;
}

bool CustomEdit::keyPressEvent(QKeyEvent *event)
{
if (GetFocusWidget()->keyPressEvent(event))
return true;

bool handled = false;
QStringList actions;
handled = GetMythMainWindow()->TranslateKeyPress("TV Frontend", event, actions);
handled = GetMythMainWindow()->TranslateKeyPress("TV Frontend", event,
actions);

for (int i = 0; i < actions.size() && !handled; i++)
{
QString action = actions[i];
handled = true;

if (action == "DELETE")
{
if (GetFocusWidget() == m_clauseList)
deleteRule();
// else if (GetFocusWidget() == m_ruleList)
// deleteRecordingRule();
}
else
handled = false;
}
if (!handled)
handled = m_actions->handleActions(actions);

if (!handled && MythScreenType::keyPressEvent(event))
handled = true;
Expand Down
5 changes: 5 additions & 0 deletions mythtv/programs/mythfrontend/customedit.h
Expand Up @@ -4,6 +4,7 @@
#include "mythplayer.h"
#include "programinfo.h"
#include "mythscreentype.h"
#include "mythactions.h"

class MythUITextEdit;
class MythUIButton;
Expand All @@ -22,6 +23,8 @@ class CustomEdit : public MythScreenType
bool keyPressEvent(QKeyEvent *);
void customEvent(QEvent *event);

bool doDelete(const QString &action);

protected slots:
void ruleChanged(MythUIButtonListItem *item);
void textChanged(void);
Expand Down Expand Up @@ -63,6 +66,8 @@ class CustomEdit : public MythScreenType
MythUIButton *m_recordButton;
MythUIButton *m_storeButton;
MythUIButton *m_cancelButton;

MythActions<CustomEdit> *m_actions;
};

struct CustomRuleInfo {
Expand Down

0 comments on commit b597f99

Please sign in to comment.