MythTV master
bookmarkeditor.cpp
Go to the documentation of this file.
1
2// MythTV
7
8// mythbrowser
9#include "bookmarkeditor.h"
10#include "bookmarkmanager.h"
11#include "browserdbutil.h"
12
20 MythScreenStack *parent, const char *name)
21 : MythScreenType (parent, name),
22 m_site(site),
23 m_editing(edit)
24{
25 if (m_editing)
26 {
29 }
30}
31
33{
34 if (!LoadWindowFromXML("browser-ui.xml", "bookmarkeditor", this))
35 return false;
36
37 bool err = false;
38
39 UIUtilW::Assign(this, m_titleText, "title", &err);
40 UIUtilE::Assign(this, m_categoryEdit, "category", &err);
41 UIUtilE::Assign(this, m_nameEdit, "name", &err);
42 UIUtilE::Assign(this, m_urlEdit, "url", &err);
43 UIUtilE::Assign(this, m_isHomepage, "homepage", &err);
44 UIUtilE::Assign(this, m_okButton, "ok", &err);
45 UIUtilE::Assign(this, m_cancelButton, "cancel", &err);
46 UIUtilE::Assign(this, m_findCategoryButton, "findcategory", &err);
47
48 if (err)
49 {
50 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'bookmarkeditor'");
51 return false;
52 }
53
54 if (m_titleText)
55 {
56 if (m_editing)
57 m_titleText->SetText(tr("Edit Bookmark Details"));
58 else
59 m_titleText->SetText(tr("Enter Bookmark Details"));
60 }
61
65
66 if (m_editing && m_site)
67 {
71
74 }
75
77
79
80 return true;
81}
82
83bool BookmarkEditor::keyPressEvent(QKeyEvent *event)
84{
85 if (GetFocusWidget()->keyPressEvent(event))
86 return true;
87
88 QStringList actions;
89 bool handled = GetMythMainWindow()->TranslateKeyPress("News", event, actions);
90
91 if (!handled && MythScreenType::keyPressEvent(event))
92 handled = true;
93
94 return handled;
95}
96
98{
99 Close();
100}
101
103{
104 if (m_editing && m_siteCategory != "" && m_siteName != "")
106
108
109 bool isHomepage = m_isHomepage->GetCheckState() == MythUIStateType::Full;
111
112 if (m_site)
113 {
117 m_site->m_isHomepage = isHomepage;
118 }
119
120 Exit();
121}
122
124{
125 QStringList list;
126
127 GetCategoryList(list);
128
129 QString title = tr("Select a category");
130
131 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
132
133 m_searchDialog = new MythUISearchDialog(popupStack, title, list,
134 true, m_categoryEdit->GetText());
135
136 if (!m_searchDialog->Create())
137 {
138 delete m_searchDialog;
139 m_searchDialog = nullptr;
140 return;
141 }
142
144
145 popupStack->AddScreen(m_searchDialog);
146}
147
148void BookmarkEditor::slotCategoryFound(const QString& category)
149{
150 m_categoryEdit->SetText(category);
151}
bool InsertInDB(Bookmark *site)
bool RemoveFromDB(Bookmark *site)
int GetCategoryList(QStringList &list)
bool ResetHomepageFromDB()
QString m_siteCategory
MythUISearchDialog * m_searchDialog
QString m_siteName
MythUITextEdit * m_categoryEdit
bool Create(void) override
MythUIButton * m_findCategoryButton
MythUIButton * m_cancelButton
void slotFindCategory(void)
Bookmark * m_site
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
MythUITextEdit * m_urlEdit
MythUIButton * m_okButton
MythUIText * m_titleText
MythUITextEdit * m_nameEdit
BookmarkEditor(Bookmark *site, bool edit, MythScreenStack *parent, const char *name)
Creates a new BookmarkEditor Screen.
MythUICheckBox * m_isHomepage
void slotCategoryFound(const QString &category)
QString m_category
QString m_name
QString m_url
bool m_isHomepage
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythScreenStack * GetStack(const QString &Stackname)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
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 Clicked()
void SetCheckState(MythUIStateType::StateType state)
MythUIStateType::StateType GetCheckState() const
Provide a dialog to quickly find an entry in a list.
void haveResult(QString)
bool Create(void) override
QString GetText(void) const
void SetText(const QString &text, bool moveCursor=true)
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:115
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMainWindow * GetMythMainWindow(void)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27