Skip to content

Commit

Permalink
Convert mytharchive and mythbrowser to mythactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Beirdo committed Mar 9, 2012
1 parent 25e16fa commit cc8d1ff
Show file tree
Hide file tree
Showing 24 changed files with 779 additions and 376 deletions.
47 changes: 31 additions & 16 deletions mythplugins/mytharchive/mytharchive/exportnative.cpp
Expand Up @@ -32,6 +32,7 @@
#include "recordingselector.h"
#include "videoselector.h"
#include "logviewer.h"
#include "mythactions.h"

ExportNative::ExportNative(
MythScreenStack *parent, MythScreenType *previousScreen,
Expand Down Expand Up @@ -60,7 +61,7 @@ ExportNative::ExportNative(
m_minsizeText(NULL),
m_currsizeText(NULL),
m_currsizeErrText(NULL),
m_sizeBar(NULL)
m_sizeBar(NULL), m_actions(NULL)
{
}

Expand All @@ -71,6 +72,9 @@ ExportNative::~ExportNative(void)
while (!m_archiveList.isEmpty())
delete m_archiveList.takeFirst();
m_archiveList.clear();

if (m_actions)
delete m_actions;
}

bool ExportNative::Create(void)
Expand Down Expand Up @@ -130,6 +134,27 @@ bool ExportNative::Create(void)
return true;
}

static struct ActionDefStruct<ExportNative> enActions[] = {
{ "MENU", &ExportNative::doMenu },
{ "DELETE", &ExportNative::doDelete }
};
static int enActionCount = NELEMS(enActions);

bool ExportNative::doMenu(const QString &action)
{
(void)action;
showMenu();
return true;
}

bool ExportNative::doDelete(const QString &action)
{
(void)action;
removeItem();
return true;
}


bool ExportNative::keyPressEvent(QKeyEvent *event)
{
if (GetFocusWidget()->keyPressEvent(event))
Expand All @@ -139,22 +164,12 @@ bool ExportNative::keyPressEvent(QKeyEvent *event)
QStringList actions;
handled = GetMythMainWindow()->TranslateKeyPress("Archive", event, actions);

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

if (action == "MENU")
{
showMenu();
}
else if (action == "DELETE")
{
removeItem();
}

else
handled = false;
if (!m_actions)
m_actions = new MythActions<ExportNative>(this, enActions,
enActionCount);
handled = m_actions->handleActions(actions);
}

if (!handled && MythScreenType::keyPressEvent(event))
Expand Down
6 changes: 6 additions & 0 deletions mythplugins/mytharchive/mytharchive/exportnative.h
Expand Up @@ -9,6 +9,7 @@

// mythtv
#include <mythscreentype.h>
#include "mythactions.h"

// mytharchive
#include "archiveutil.h"
Expand Down Expand Up @@ -42,6 +43,9 @@ class ExportNative : public MythScreenType

void createConfigFile(const QString &filename);

bool doMenu(const QString &action);
bool doDelete(const QString &action);

public slots:

void handleNextPage(void);
Expand Down Expand Up @@ -93,6 +97,8 @@ class ExportNative : public MythScreenType
MythUIText *m_currsizeText;
MythUIText *m_currsizeErrText;
MythUIProgressBar *m_sizeBar;

MythActions<ExportNative> *m_actions;
};

#endif
31 changes: 20 additions & 11 deletions mythplugins/mytharchive/mytharchive/fileselector.cpp
Expand Up @@ -38,14 +38,17 @@ FileSelector::FileSelector(
m_okButton(NULL),
m_cancelButton(NULL),
m_backButton(NULL),
m_homeButton(NULL)
m_homeButton(NULL), m_actions(NULL)
{
}

FileSelector::~FileSelector()
{
while (!m_fileData.isEmpty())
delete m_fileData.takeFirst();

if (m_actions)
delete m_actions;
}

bool FileSelector::Create(void)
Expand Down Expand Up @@ -112,6 +115,17 @@ bool FileSelector::Create(void)
return true;
}

static struct ActionDefStruct<FileSelector> fsActions[] = {
{ "MENU", &FileSelector::doMenu }
};
static int fsActionCount = NELEMS(fsActions);

bool FileSelector::doMenu(const QString &action)
{
(void)action;
return true;
}

bool FileSelector::keyPressEvent(QKeyEvent *event)
{
if (GetFocusWidget()->keyPressEvent(event))
Expand All @@ -121,17 +135,12 @@ bool FileSelector::keyPressEvent(QKeyEvent *event)
QStringList actions;
handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions);

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

if (action == "MENU")
{

}
else
handled = false;
if (!m_actions)
m_actions = new MythActions<FileSelector>(this, fsActions,
fsActionCount);
handled = m_actions->handleActions(actions);
}

if (!handled && MythScreenType::keyPressEvent(event))
Expand Down
6 changes: 6 additions & 0 deletions mythplugins/mytharchive/mytharchive/fileselector.h
Expand Up @@ -13,6 +13,7 @@

// mytharchive
#include "archiveutil.h"
#include "mythactions.h"

typedef struct
{
Expand Down Expand Up @@ -49,6 +50,8 @@ class FileSelector : public MythScreenType

QString getSelected(void);

bool doMenu(const QString &action);

signals:
void haveResult(bool ok); // used in FSTYPE_FILELIST mode
void haveResult(QString filename); // used in FSTYPE_FILE or FSTYPE_DIRECTORY mode
Expand Down Expand Up @@ -84,6 +87,9 @@ class FileSelector : public MythScreenType
MythUIButton *m_cancelButton;
MythUIButton *m_backButton;
MythUIButton *m_homeButton;

private:
MythActions<FileSelector> *m_actions;
};

Q_DECLARE_METATYPE(FileData *)
Expand Down
30 changes: 20 additions & 10 deletions mythplugins/mytharchive/mytharchive/importnative.cpp
Expand Up @@ -23,6 +23,7 @@
#include "importnative.h"
#include "archiveutil.h"
#include "logviewer.h"
#include "mythactions.h"


////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -317,12 +318,14 @@ ImportNative::ImportNative(
m_finishButton(NULL),
m_prevButton(NULL),
m_cancelButton(NULL),
m_isValidXMLSelected(false)
m_isValidXMLSelected(false), m_actions(NULL)
{
}

ImportNative::~ImportNative()
{
if (m_actions)
delete m_actions;
}

bool ImportNative::Create(void)
Expand Down Expand Up @@ -395,6 +398,17 @@ bool ImportNative::Create(void)
return true;
}

static struct ActionDefStruct<ImportNative> inActions[] = {
{ "MENU", &ImportNative::doMenu }
};
static int inActionCount = NELEMS(inActions);

bool ImportNative::doMenu(const QString &action)
{
(void)action;
return true;
}

bool ImportNative::keyPressEvent(QKeyEvent *event)
{
if (GetFocusWidget()->keyPressEvent(event))
Expand All @@ -404,16 +418,12 @@ bool ImportNative::keyPressEvent(QKeyEvent *event)
QStringList actions;
handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions);

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

if (action == "MENU")
{
}
else
handled = false;
if (!m_actions)
m_actions = new MythActions<ImportNative>(this, inActions,
inActionCount);
handled = m_actions->handleActions(actions);
}

if (!handled && MythScreenType::keyPressEvent(event))
Expand Down
15 changes: 10 additions & 5 deletions mythplugins/mytharchive/mytharchive/importnative.h
Expand Up @@ -16,6 +16,7 @@

// mytharchive
#include "fileselector.h"
#include "mythactions.h"

typedef struct
{
Expand Down Expand Up @@ -75,12 +76,14 @@ class ImportNative : public MythScreenType
Q_OBJECT

public:
ImportNative(MythScreenStack *parent, MythScreenType *m_previousScreen,
const QString &xmlFile, FileDetails details);
~ImportNative();
ImportNative(MythScreenStack *parent, MythScreenType *m_previousScreen,
const QString &xmlFile, FileDetails details);
~ImportNative();

bool Create(void);
bool keyPressEvent(QKeyEvent *e);
bool Create(void);
bool keyPressEvent(QKeyEvent *e);

bool doMenu(const QString &action);

private slots:
void finishedPressed();
Expand Down Expand Up @@ -131,6 +134,8 @@ class ImportNative : public MythScreenType
MythUIButton *m_cancelButton;

bool m_isValidXMLSelected;

MythActions<ImportNative> *m_actions;
};

#endif
31 changes: 22 additions & 9 deletions mythplugins/mytharchive/mytharchive/logviewer.cpp
Expand Up @@ -51,7 +51,7 @@ LogViewer::LogViewer(MythScreenStack *parent) :
m_logText(NULL),
m_exitButton(NULL),
m_cancelButton(NULL),
m_updateButton(NULL)
m_updateButton(NULL), m_actions(NULL)
{
m_updateTime = gCoreContext->GetNumSetting(
"LogViewerUpdateTime", DEFAULT_UPDATE_TIME);
Expand All @@ -65,6 +65,9 @@ LogViewer::~LogViewer(void)

if (m_updateTimer)
delete m_updateTimer;

if (m_actions)
delete m_actions;
}

bool LogViewer::Create(void)
Expand Down Expand Up @@ -115,6 +118,19 @@ void LogViewer::Init(void)
m_logList->SetItemCurrent(m_logList->GetCount() - 1);
}

static struct ActionDefStruct<LogViewer> lvActions[] = {
{ "MENU", &LogViewer::doMenu }
};
static int lvActionCount = NELEMS(lvActions);

bool LogViewer::doMenu(const QString &action)
{
(void)action;
showMenu();
return true;
}


bool LogViewer::keyPressEvent(QKeyEvent *event)
{
if (GetFocusWidget()->keyPressEvent(event))
Expand All @@ -124,15 +140,12 @@ bool LogViewer::keyPressEvent(QKeyEvent *event)
QStringList actions;
handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions);

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

if (action == "MENU")
showMenu();
else
handled = false;
if (!m_actions)
m_actions = new MythActions<LogViewer>(this, lvActions,
lvActionCount);
handled = m_actions->handleActions(actions);
}

if (!handled && MythScreenType::keyPressEvent(event))
Expand Down
5 changes: 5 additions & 0 deletions mythplugins/mytharchive/mytharchive/logviewer.h
Expand Up @@ -6,6 +6,7 @@

// myth
#include <mythscreentype.h>
#include "mythactions.h"

class MythUIButton;
class MythUIButtonList;
Expand All @@ -27,6 +28,8 @@ class LogViewer : public MythScreenType

void setFilenames(const QString &progressLog, const QString &fullLog);

bool doMenu(const QString &action);

protected slots:
void cancelClicked(void);
void updateClicked(void);
Expand Down Expand Up @@ -56,6 +59,8 @@ class LogViewer : public MythScreenType
MythUIButton *m_exitButton;
MythUIButton *m_cancelButton;
MythUIButton *m_updateButton;

MythActions<LogViewer> *m_actions;
};

#endif

0 comments on commit cc8d1ff

Please sign in to comment.