MythTV master
mythnewseditor.cpp
Go to the documentation of this file.
1
2// MythTV headers
12
13// MythNews headers
14#include "mythnewseditor.h"
15#include "newsdbutil.h"
16#include "newssite.h"
17
18#define LOC QString("MythNewsEditor: ")
19#define LOC_WARN QString("MythNewsEditor, Warning: ")
20#define LOC_ERR QString("MythNewsEditor, Error: ")
21
30 MythScreenStack *parent,
31 const QString &name) :
32 MythScreenType(parent, name),
33 m_site(site),
34 m_siteName((edit && site) ? site->name() : QString()),
35 m_editing(edit)
36{
37}
38
40{
41 QMutexLocker locker(&m_lock);
42}
43
45{
46 QMutexLocker locker(&m_lock);
47
48 // Load the theme for this screen
49 bool foundtheme = LoadWindowFromXML("news-ui.xml", "editor", this);
50
51 if (!foundtheme)
52 return false;
53
54 bool err = false;
55 UIUtilW::Assign(this, m_titleText, "title", &err);
56 UIUtilW::Assign(this, m_nameLabelText, "namelabel", &err);
57 UIUtilW::Assign(this, m_urlLabelText, "urllabel", &err);
58 UIUtilW::Assign(this, m_iconLabelText, "iconlabel", &err);
59 UIUtilW::Assign(this, m_podcastLabelText, "podcastlabel", &err);
60 UIUtilE::Assign(this, m_nameEdit, "name", &err);
61 UIUtilE::Assign(this, m_urlEdit, "url", &err);
62 UIUtilE::Assign(this, m_iconEdit, "icon", &err);
63 UIUtilE::Assign(this, m_podcastCheck, "podcast_check", &err);
64 UIUtilE::Assign(this, m_okButton, "ok", &err);
65 UIUtilE::Assign(this, m_cancelButton, "cancel", &err);
66
67 if (err)
68 {
69 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'editor'");
70 return false;
71 }
72
73 if (m_titleText)
74 {
76 (m_editing) ? tr("Edit Site Details") : tr("Enter Site Details"));
77 }
78
80 m_nameLabelText->SetText(tr("Name:"));
82 m_urlLabelText->SetText(tr("URL:"));
84 m_iconLabelText->SetText(tr("Icon:"));
86 m_podcastLabelText->SetText(tr("Podcast:"));
87
88 m_okButton->SetText(tr("OK"));
89 m_cancelButton->SetText(tr("Cancel"));
90
93
94 if (m_editing)
95 {
99 if (m_site->podcast())
101 }
102
104
106
107 return true;
108}
109
110bool MythNewsEditor::keyPressEvent(QKeyEvent *event)
111{
112 if (GetFocusWidget()->keyPressEvent(event))
113 return true;
114
115 QStringList actions;
116 bool handled = GetMythMainWindow()->TranslateKeyPress("News", event, actions);
117
118 if (!handled && MythScreenType::keyPressEvent(event))
119 handled = true;
120
121 return handled;
122}
123
125{
126 {
127 QMutexLocker locker(&m_lock);
128
129 if (m_editing && !m_siteName.isEmpty())
131
133 m_iconEdit->GetText(), "custom",
135 }
136 Close();
137}
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythUITextEdit * m_urlEdit
MythUIButton * m_cancelButton
MythUIText * m_podcastLabelText
MythUITextEdit * m_iconEdit
MythUIButton * m_okButton
NewsSite * m_site
MythUIText * m_iconLabelText
QString m_siteName
QRecursiveMutex m_lock
MythUIText * m_nameLabelText
MythUIText * m_titleText
MythUITextEdit * m_nameEdit
MythNewsEditor(NewsSite *site, bool edit, MythScreenStack *parent, const QString &name="MythNewsEditor")
Creates a new MythNewsEditor Screen.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool Create(void) override
MythUIText * m_urlLabelText
~MythNewsEditor() override
MythUICheckBox * m_podcastCheck
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
virtual void Close()
void SetText(const QString &msg)
void Clicked()
void SetCheckState(MythUIStateType::StateType state)
MythUIStateType::StateType GetCheckState() const
QString GetText(void) const
void SetText(const QString &text, bool moveCursor=true)
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:115
QString imageURL(void) const
Definition: newssite.cpp:128
bool podcast(void) const
Definition: newssite.cpp:108
QString name(void) const
Definition: newssite.cpp:96
QString url(void) const
Definition: newssite.cpp:90
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMainWindow * GetMythMainWindow(void)
bool removeFromDB(RSSSite *site)
Definition: netutils.cpp:686
bool insertInDB(RSSSite *site)
Definition: netutils.cpp:643
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27