Skip to content

Commit 246d631

Browse files
committed
Converted mythnetvision, mythnews, mythweather, mythzoneminder
1 parent 39aaf5e commit 246d631

File tree

22 files changed

+619
-321
lines changed

22 files changed

+619
-321
lines changed

mythplugins/mythnetvision/mythnetvision/netsearch.cpp

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@
2828
#include "netcommon.h"
2929
#include "rsseditor.h"
3030
#include "searcheditor.h"
31+
#include "mythactions.h"
3132

3233
using namespace std;
3334

3435
// ---------------------------------------------------
3536

36-
NetSearch::NetSearch(MythScreenStack *parent, const char *name)
37-
: MythScreenType(parent, name),
38-
m_searchResultList(NULL), m_siteList(NULL),
39-
m_search(NULL), m_thumbImage(NULL),
40-
m_downloadable(NULL), m_progress(NULL),
41-
m_busyPopup(NULL), m_okPopup(NULL),
42-
m_popupStack(), m_progressDialog(NULL),
43-
m_netSearch(NULL), m_reply(NULL),
44-
m_currentSearch(QString()), m_currentGrabber(0),
45-
m_currentCmd(QString()), m_downloadFile(QString()),
46-
m_pagenum(0)
37+
NetSearch::NetSearch(MythScreenStack *parent, const char *name) :
38+
MythScreenType(parent, name),
39+
m_searchResultList(NULL), m_siteList(NULL),
40+
m_search(NULL), m_thumbImage(NULL),
41+
m_downloadable(NULL), m_progress(NULL),
42+
m_busyPopup(NULL), m_okPopup(NULL),
43+
m_popupStack(), m_progressDialog(NULL),
44+
m_netSearch(NULL), m_reply(NULL),
45+
m_currentSearch(QString()), m_currentGrabber(0),
46+
m_currentCmd(QString()), m_downloadFile(QString()),
47+
m_pagenum(0), m_actions(NULL)
4748
{
4849
m_mythXML = GetMythXMLURL();
4950
m_playing = false;
@@ -150,6 +151,9 @@ NetSearch::~NetSearch()
150151
}
151152

152153
gCoreContext->removeListener(this);
154+
155+
if (m_actions)
156+
delete m_actions;
153157
}
154158

155159
void NetSearch::loadData(void)
@@ -165,26 +169,35 @@ void NetSearch::loadData(void)
165169
runSearchEditor();
166170
}
167171

172+
static struct ActionDefStruct<NetSearch> nsActions[] = {
173+
{ "MENU", &NetSearch::doMenu }
174+
};
175+
static int nsActionCount = NELEMS(nsActions);
176+
177+
bool NetSearch::doMenu(const QString &action)
178+
{
179+
(void)action;
180+
showMenu();
181+
return true;
182+
}
183+
184+
168185
bool NetSearch::keyPressEvent(QKeyEvent *event)
169186
{
170187
if (GetFocusWidget()->keyPressEvent(event))
171188
return true;
172189

173190
bool handled = false;
174191
QStringList actions;
175-
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event, actions);
192+
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event,
193+
actions);
176194

177-
for (int i = 0; i < actions.size() && !handled; i++)
195+
if (!handled)
178196
{
179-
QString action = actions[i];
180-
handled = true;
181-
182-
if (action == "MENU")
183-
{
184-
showMenu();
185-
}
186-
else
187-
handled = false;
197+
if (!m_actions)
198+
m_actions = new MythActions<NetSearch>(this, nsActions,
199+
nsActionCount);
200+
handled = m_actions->handleActions(actions);
188201
}
189202

190203
if (!handled && MythScreenType::keyPressEvent(event))

mythplugins/mythnetvision/mythnetvision/netsearch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <mythrssmanager.h>
1515
#include <mythdownloadmanager.h>
1616
#include <metadata/metadataimagedownload.h>
17+
#include "mythactions.h"
1718

1819
class MythUIBusyDialog;
1920

@@ -34,6 +35,8 @@ class NetSearch : public MythScreenType
3435

3536
void populateResultList(ResultItem::resultList list);
3637

38+
bool doMenu(const QString &action);
39+
3740
public slots:
3841

3942
protected:
@@ -111,6 +114,9 @@ class NetSearch : public MythScreenType
111114
void DownloadVideo(QString url, QString dest);
112115

113116
void customEvent(QEvent *levent);
117+
118+
private:
119+
MythActions<NetSearch> *m_actions;
114120
};
115121

116122
#endif

mythplugins/mythnetvision/mythnetvision/nettree.cpp

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "nettree.h"
2424
#include "rsseditor.h"
2525
#include "netcommon.h"
26+
#include "mythactions.h"
2627

2728
class ResultItem;
2829
class GrabberScript;
@@ -42,14 +43,14 @@ namespace
4243
}
4344
}
4445

45-
NetTree::NetTree(DialogType type, MythScreenStack *parent, const char *name)
46-
: MythScreenType(parent, name),
47-
m_siteMap(NULL), m_siteButtonList(NULL),
48-
m_noSites(NULL), m_thumbImage(NULL),
49-
m_downloadable(NULL), m_busyPopup(NULL),
50-
m_menuPopup(NULL), m_popupStack(),
51-
m_progressDialog(NULL), m_downloadFile(QString()),
52-
m_type(type)
46+
NetTree::NetTree(DialogType type, MythScreenStack *parent, const char *name) :
47+
MythScreenType(parent, name),
48+
m_siteMap(NULL), m_siteButtonList(NULL),
49+
m_noSites(NULL), m_thumbImage(NULL),
50+
m_downloadable(NULL), m_busyPopup(NULL),
51+
m_menuPopup(NULL), m_popupStack(),
52+
m_progressDialog(NULL), m_downloadFile(QString()),
53+
m_type(type), m_actions(NULL)
5354
{
5455
m_imageDownload = new MetadataImageDownload(this);
5556
m_gdt = new GrabberDownloadThread(this);
@@ -189,6 +190,9 @@ NetTree::~NetTree()
189190
cleanCacheDir();
190191

191192
gCoreContext->removeListener(this);
193+
194+
if (m_actions)
195+
delete m_actions;
192196
}
193197

194198
void NetTree::cleanCacheDir()
@@ -408,35 +412,44 @@ bool NetTree::goBack()
408412
return handled;
409413
}
410414

415+
static struct ActionDefStruct<NetTree> ntActions[] = {
416+
{ "MENU", &NetTree::doMenu },
417+
{ "ESCAPE", &NetTree::doEscape }
418+
};
419+
static int ntActionCount = NELEMS(ntActions);
420+
421+
bool NetTree::doMenu(const QString &action)
422+
{
423+
(void)action;
424+
showMenu();
425+
return true;
426+
}
427+
428+
bool NetTree::doEscape(const QString &action)
429+
{
430+
(void)action;
431+
if (m_type != DLG_TREE && !GetMythMainWindow()->IsExitingToMain() &&
432+
m_currentNode != m_siteGeneric)
433+
return goBack();
434+
return false;
435+
}
436+
411437
bool NetTree::keyPressEvent(QKeyEvent *event)
412438
{
413439
if (GetFocusWidget()->keyPressEvent(event))
414440
return true;
415441

416442
bool handled = false;
417443
QStringList actions;
418-
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event, actions);
444+
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event,
445+
actions);
419446

420-
for (int i = 0; i < actions.size() && !handled; i++)
447+
if (!handled)
421448
{
422-
QString action = actions[i];
423-
handled = true;
424-
425-
if (action == "MENU")
426-
{
427-
showMenu();
428-
}
429-
else if (action == "ESCAPE")
430-
{
431-
if (m_type != DLG_TREE
432-
&& !GetMythMainWindow()->IsExitingToMain()
433-
&& m_currentNode != m_siteGeneric)
434-
handled = goBack();
435-
else
436-
handled = false;
437-
}
438-
else
439-
handled = false;
449+
if (!m_actions)
450+
m_actions = new MythActions<NetTree>(this, ntActions,
451+
ntActionCount);
452+
handled = m_actions->handleActions(actions);
440453
}
441454

442455
if (!handled && MythScreenType::keyPressEvent(event))

mythplugins/mythnetvision/mythnetvision/nettree.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <mythrssmanager.h>
1515
#include <mythdownloadmanager.h>
1616
#include <metadata/metadataimagedownload.h>
17+
#include "mythactions.h"
1718

1819
enum DialogType { DLG_DEFAULT = 0, DLG_GALLERY = 0x1, DLG_TREE = 0x2,
1920
DLG_BROWSER = 0x4, dtLast };
@@ -51,6 +52,9 @@ class NetTree : public MythScreenType
5152

5253
void populateResultList(ResultItem::resultList list);
5354

55+
bool doMenu(const QString &action);
56+
bool doEscape(const QString &action);
57+
5458
public slots:
5559

5660
protected:
@@ -159,6 +163,9 @@ class NetTree : public MythScreenType
159163
static const QString RSSNode;
160164
static const QString SearchNode;
161165
static const QString DownloadNode;
166+
167+
private:
168+
MythActions<NetTree> *m_actions;
162169
};
163170

164171
#endif

mythplugins/mythnetvision/mythnetvision/rsseditor.cpp

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020

2121
// RSS headers
2222
#include "rsseditor.h"
23+
#include "mythactions.h"
2324

2425
#define LOC QString("RSSEditor: ")
25-
#define LOC_WARN QString("RSSEditor, Warning: ")
26-
#define LOC_ERR QString("RSSEditor, Error: ")
2726

2827
namespace
2928
{
@@ -138,7 +137,8 @@ bool RSSEditPopup::keyPressEvent(QKeyEvent *event)
138137

139138
bool handled = false;
140139
QStringList actions;
141-
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event, actions);
140+
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event,
141+
actions);
142142

143143
if (!handled && MythScreenType::keyPressEvent(event))
144144
handled = true;
@@ -355,7 +355,8 @@ void RSSEditPopup::customEvent(QEvent *levent)
355355
RSSEditor::RSSEditor(MythScreenStack *parent, const QString &name) :
356356
MythScreenType(parent, name), m_lock(QMutex::Recursive),
357357
m_changed(false), m_sites(NULL), m_new(NULL), m_delete(NULL), m_edit(NULL),
358-
m_image(NULL), m_title(NULL), m_url(NULL), m_desc(NULL), m_author(NULL)
358+
m_image(NULL), m_title(NULL), m_url(NULL), m_desc(NULL), m_author(NULL),
359+
m_actions(NULL)
359360
{
360361
}
361362

@@ -365,6 +366,9 @@ RSSEditor::~RSSEditor()
365366

366367
if (m_changed)
367368
emit itemsChanged();
369+
370+
if (m_actions)
371+
delete m_actions;
368372
}
369373

370374
bool RSSEditor::Create(void)
@@ -439,33 +443,44 @@ void RSSEditor::loadData()
439443
}
440444
}
441445

446+
static struct ActionDefStruct<RSSEditor> reActions[] = {
447+
{ "DELETE", &RSSEditor::doDelete },
448+
{ "EDIT", &RSSEditor::doEdit }
449+
};
450+
static int reActionCount = NELEMS(reActions);
451+
452+
bool RSSEditor::doDelete(const QString &action)
453+
{
454+
(void)action;
455+
slotDeleteSite();
456+
return true;
457+
}
458+
459+
bool RSSEditor::doEdit(const QString &action)
460+
{
461+
(void)action;
462+
slotEditSite();
463+
return true;
464+
}
465+
442466
bool RSSEditor::keyPressEvent(QKeyEvent *event)
443467
{
444468
if (GetFocusWidget()->keyPressEvent(event))
445469
return true;
446470

447471
bool handled = false;
448472
QStringList actions;
449-
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event, actions);
473+
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event,
474+
actions);
450475

451-
for (int i = 0; i < actions.size() && !handled; i++)
476+
if (!handled)
452477
{
453-
QString action = actions[i];
454-
handled = true;
455-
456-
if (action == "DELETE" && GetFocusWidget() == m_sites)
457-
{
458-
slotDeleteSite();
459-
}
460-
if (action == "EDIT" && GetFocusWidget() == m_sites)
461-
{
462-
slotEditSite();
463-
}
464-
else
465-
handled = false;
478+
if (!m_actions)
479+
m_actions = new MythActions<RSSEditor>(this, reActions,
480+
reActionCount);
481+
handled = m_actions->handleActions(actions);
466482
}
467483

468-
469484
if (!handled && MythScreenType::keyPressEvent(event))
470485
handled = true;
471486

mythplugins/mythnetvision/mythnetvision/rsseditor.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <mythscreentype.h>
1414

1515
#include "mythrssmanager.h"
16+
#include "mythactions.h"
1617

1718
class MythUITextEdit;
1819
class MythUIButton;
@@ -83,6 +84,9 @@ class RSSEditor : public MythScreenType
8384
bool Create(void);
8485
bool keyPressEvent(QKeyEvent*);
8586

87+
bool doDelete(const QString &action);
88+
bool doEdit(const QString &action);
89+
8690
private:
8791
void fillRSSButtonList();
8892
mutable QMutex m_lock;
@@ -112,6 +116,9 @@ class RSSEditor : public MythScreenType
112116
void slotEditSite(void);
113117
void slotNewSite(void);
114118
void listChanged(void);
119+
120+
private:
121+
MythActions<RSSEditor> *m_actions;
115122
};
116123

117124
#endif /* RSSEDITOR_H */

mythplugins/mythnetvision/mythnetvision/searcheditor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ bool SearchEditor::keyPressEvent(QKeyEvent *event)
178178

179179
bool handled = false;
180180
QStringList actions;
181-
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event, actions);
181+
handled = GetMythMainWindow()->TranslateKeyPress("Internet Video", event,
182+
actions);
182183

183184
if (!handled && MythScreenType::keyPressEvent(event))
184185
handled = true;

0 commit comments

Comments
 (0)