MythTV  master
bookmarkeditor.cpp
Go to the documentation of this file.
1 
2 // myth
3 #include <mythmainwindow.h>
4 #include <mythdate.h>
5 #include <mythcontext.h>
6 #include <mythdbcon.h>
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 
62  connect(m_okButton, SIGNAL(Clicked()), this, SLOT(Save()));
63  connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Exit()));
64  connect(m_findCategoryButton, SIGNAL(Clicked()), this, SLOT(slotFindCategory()));
65 
66  if (m_editing && m_site)
67  {
71 
72  if (m_site->m_isHomepage)
74  }
75 
77 
79 
80  return true;
81 }
82 
83 bool 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 
143  connect(m_searchDialog, SIGNAL(haveResult(QString)), SLOT(slotCategoryFound(QString)));
144 
145  popupStack->AddScreen(m_searchDialog);
146 }
147 
149 {
151 }
MythUISearchDialog
Provide a dialog to quickly find an entry in a list.
Definition: mythdialogbox.h:348
BookmarkEditor::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: bookmarkeditor.cpp:83
InsertInDB
bool InsertInDB(Bookmark *site)
Definition: browserdbutil.cpp:116
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:402
BookmarkEditor::m_cancelButton
MythUIButton * m_cancelButton
Definition: bookmarkeditor.h:45
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:633
BookmarkEditor::m_findCategoryButton
MythUIButton * m_findCategoryButton
Definition: bookmarkeditor.h:46
MythMainWindow::TranslateKeyPress
bool TranslateKeyPress(const QString &context, QKeyEvent *e, QStringList &actions, bool allowJumps=true)
Get a list of actions for a keypress in the given context.
Definition: mythmainwindow.cpp:1106
bookmarkmanager.h
MythScreenStack
Definition: mythscreenstack.h:15
mythdbcon.h
RemoveFromDB
bool RemoveFromDB(Bookmark *site)
Definition: browserdbutil.cpp:158
category
QString category
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1419
Bookmark::m_url
QString m_url
Definition: bookmarkmanager.h:21
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:44
BookmarkEditor::m_searchDialog
MythUISearchDialog * m_searchDialog
Definition: bookmarkeditor.h:48
MythUITextEdit::GetText
QString GetText(void) const
Definition: mythuitextedit.h:47
Bookmark::m_isHomepage
bool m_isHomepage
Definition: bookmarkmanager.h:22
BookmarkEditor::m_siteCategory
QString m_siteCategory
Definition: bookmarkeditor.h:34
BookmarkEditor::m_urlEdit
MythUITextEdit * m_urlEdit
Definition: bookmarkeditor.h:41
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &stackname)
Definition: mythmainwindow.cpp:309
MythUISearchDialog::Create
bool Create(void) override
Definition: mythdialogbox.cpp:803
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:112
BookmarkEditor::Save
void Save(void)
Definition: bookmarkeditor.cpp:102
BookmarkEditor::m_isHomepage
MythUICheckBox * m_isHomepage
Definition: bookmarkeditor.h:42
BookmarkEditor::Create
bool Create(void) override
Definition: bookmarkeditor.cpp:32
MythUITextEdit::SetText
void SetText(const QString &text, bool moveCursor=true)
Definition: mythuitextedit.cpp:216
bookmarkeditor.h
mythdate.h
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:117
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:222
Bookmark::m_category
QString m_category
Definition: bookmarkmanager.h:18
browserdbutil.h
BookmarkEditor::m_categoryEdit
MythUITextEdit * m_categoryEdit
Definition: bookmarkeditor.h:39
ResetHomepageFromDB
bool ResetHomepageFromDB()
Definition: browserdbutil.cpp:96
MythUIStateType::Full
@ Full
Definition: mythuistatetype.h:25
Bookmark
Definition: bookmarkmanager.h:13
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
BookmarkEditor::slotCategoryFound
void slotCategoryFound(const QString &category)
Definition: bookmarkeditor.cpp:148
BookmarkEditor::BookmarkEditor
BookmarkEditor(Bookmark *site, bool edit, MythScreenStack *parent, const char *name)
Creates a new BookmarkEditor Screen.
Definition: bookmarkeditor.cpp:19
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
BookmarkEditor::m_editing
bool m_editing
Definition: bookmarkeditor.h:35
MythUICheckBox::SetCheckState
void SetCheckState(MythUIStateType::StateType state)
Definition: mythuicheckbox.cpp:66
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:692
BookmarkEditor::Exit
void Exit(void)
Definition: bookmarkeditor.cpp:97
MythUIText::SetText
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:135
mythcontext.h
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:107
BookmarkEditor::m_okButton
MythUIButton * m_okButton
Definition: bookmarkeditor.h:44
BookmarkEditor::m_site
Bookmark * m_site
Definition: bookmarkeditor.h:32
GetCategoryList
int GetCategoryList(QStringList &list)
Definition: browserdbutil.cpp:182
Bookmark::m_name
QString m_name
Definition: bookmarkmanager.h:19
MythUICheckBox::GetCheckState
MythUIStateType::StateType GetCheckState() const
Definition: mythuicheckbox.cpp:98
mythmainwindow.h
BookmarkEditor::m_titleText
MythUIText * m_titleText
Definition: bookmarkeditor.h:37
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:49
BookmarkEditor::slotFindCategory
void slotFindCategory(void)
Definition: bookmarkeditor.cpp:123
BookmarkEditor::m_siteName
QString m_siteName
Definition: bookmarkeditor.h:33
BookmarkEditor::m_nameEdit
MythUITextEdit * m_nameEdit
Definition: bookmarkeditor.h:40