MythTV  master
mythnews.cpp
Go to the documentation of this file.
1 // POSIX headers
2 #include <unistd.h>
3 
4 // C headers
5 #include <cmath>
6 
7 // QT headers
8 #include <QCoreApplication>
9 #include <QDateTime>
10 #include <QDir>
11 #include <QTimer>
12 #include <QRegExp>
13 #include <QUrl>
14 
15 // MythTV headers
16 #include <mythuibuttonlist.h>
17 #include <mythmainwindow.h>
18 #include <mythdialogbox.h>
19 #include <mythcontext.h>
20 #include <mythuiimage.h>
21 #include <mythsystemlegacy.h>
22 #include <mythuitext.h>
23 #include <mythdate.h>
24 #include <mythdirs.h>
25 #include <mythdb.h>
26 #include <mythdownloadmanager.h>
27 
28 // MythNews headers
29 #include "mythnews.h"
30 #include "mythnewseditor.h"
31 #include "newsdbutil.h"
32 #include "mythnewsconfig.h"
33 
34 #define LOC QString("MythNews: ")
35 #define LOC_WARN QString("MythNews, Warning: ")
36 #define LOC_ERR QString("MythNews, Error: ")
37 
42 MythNews::MythNews(MythScreenStack *parent, const QString &name) :
43  MythScreenType(parent, name),
44  m_retrieveTimer(new QTimer(this)),
45  m_updateFreq(gCoreContext->GetNumSetting("NewsUpdateFrequency", 30)),
46  m_zoom(gCoreContext->GetSetting("WebBrowserZoomLevel", "1.0")),
47  m_browser(gCoreContext->GetSetting("WebBrowserCommand", ""))
48 {
49  // Setup cache directory
50 
51  QString fileprefix = GetConfDir();
52 
53  QDir dir(fileprefix);
54  if (!dir.exists())
55  dir.mkdir(fileprefix);
56  fileprefix += "/MythNews";
57  dir = QDir(fileprefix);
58  if (!dir.exists())
59  dir.mkdir(fileprefix);
60 
61  connect(m_retrieveTimer, SIGNAL(timeout()),
62  this, SLOT(slotRetrieveNews()));
63 
64  m_retrieveTimer->stop();
65  m_retrieveTimer->setSingleShot(false);
67 }
68 
70 {
71  QMutexLocker locker(&m_lock);
72 }
73 
74 bool MythNews::Create(void)
75 {
76  QMutexLocker locker(&m_lock);
77 
78  // Load the theme for this screen
79  bool foundtheme = LoadWindowFromXML("news-ui.xml", "news", this);
80  if (!foundtheme)
81  return false;
82 
83  bool err = false;
84  UIUtilE::Assign(this, m_sitesList, "siteslist", &err);
85  UIUtilE::Assign(this, m_articlesList, "articleslist", &err);
86  UIUtilE::Assign(this, m_titleText, "title", &err);
87  UIUtilE::Assign(this, m_descText, "description", &err);
88 
89  // these are all optional
90  UIUtilW::Assign(this, m_nositesText, "nosites", &err);
91  UIUtilW::Assign(this, m_updatedText, "updated", &err);
92  UIUtilW::Assign(this, m_thumbnailImage, "thumbnail", &err);
93  UIUtilW::Assign(this, m_enclosureImage, "enclosures", &err);
94  UIUtilW::Assign(this, m_downloadImage, "download", &err);
95  UIUtilW::Assign(this, m_podcastImage, "ispodcast", &err);
96 
97  if (err)
98  {
99  LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'news'");
100  return false;
101  }
102 
103  if (m_nositesText)
104  {
105  m_nositesText->SetText(tr("You haven't configured MythNews to use any sites."));
106  m_nositesText->Hide();
107  }
108 
109  BuildFocusList();
110 
112 
113  loadSites();
115 
116  connect(m_sitesList, SIGNAL(itemSelected(MythUIButtonListItem*)),
117  this, SLOT( slotSiteSelected(MythUIButtonListItem*)));
118  connect(m_articlesList, SIGNAL(itemSelected( MythUIButtonListItem*)),
119  this, SLOT( updateInfoView(MythUIButtonListItem*)));
120  connect(m_articlesList, SIGNAL(itemClicked( MythUIButtonListItem*)),
121  this, SLOT( slotViewArticle(MythUIButtonListItem*)));
122 
123  return true;
124 }
125 
127 {
128  m_newsSites.clear();
129  m_sitesList->Reset();
130  m_articles.clear();
132 
133  m_titleText->Reset();
134  m_descText->Reset();
135 
136  if (m_updatedText)
137  m_updatedText->Reset();
138 
139  if (m_downloadImage)
141 
142  if (m_enclosureImage)
144 
145  if (m_podcastImage)
146  m_podcastImage->Hide();
147 
148  if (m_thumbnailImage)
150 }
151 
153 {
154  QMutexLocker locker(&m_lock);
155 
156  clearSites();
157 
159  query.prepare(
160  "SELECT name, url, ico, updated, podcast "
161  "FROM newssites "
162  "ORDER BY name");
163 
164  if (!query.exec())
165  {
166  MythDB::DBError(LOC_ERR + "Could not load sites from DB", query);
167  return;
168  }
169 
170  while (query.next())
171  {
172  QString name = query.value(0).toString();
173  QString url = query.value(1).toString();
174  QString icon = query.value(2).toString();
175  QDateTime time = MythDate::fromSecsSinceEpoch(query.value(3).toLongLong());
176  bool podcast = query.value(4).toBool();
177  m_newsSites.push_back(new NewsSite(name, url, time, podcast));
178  }
179  std::sort(m_newsSites.begin(), m_newsSites.end(), NewsSite::sortByName);
180 
181  for (auto & site : m_newsSites)
182  {
183  auto *item = new MythUIButtonListItem(m_sitesList, site->name());
184  item->SetData(QVariant::fromValue(site));
185 
186  connect(site, SIGNAL(finished(NewsSite*)),
187  this, SLOT(slotNewsRetrieved(NewsSite*)));
188  }
189 
191 
192  if (m_nositesText)
193  {
194  if (m_newsSites.empty())
195  m_nositesText->Show();
196  else
197  m_nositesText->Hide();
198  }
199 }
200 
202 {
203  QMutexLocker locker(&m_lock);
204 
205  if (!selected)
206  return;
207 
208  NewsSite *site = nullptr;
209  NewsArticle article;
210 
212  {
213  article = m_articles[selected];
215  site = m_sitesList->GetItemCurrent()->GetData().value<NewsSite*>();
216  }
217  else
218  {
219  site = selected->GetData().value<NewsSite*>();
222  }
223 
225  {
226  if (!article.title().isEmpty())
227  {
228 
229  if (m_titleText)
230  m_titleText->SetText(article.title());
231 
232  if (m_descText)
233  {
234  QString artText = article.description();
235  // replace a few HTML characters
236  artText.replace("&#8232;", ""); // LSEP
237  artText.replace("&#8233;", ""); // PSEP
238  artText.replace("&#163;", u8"\u00A3"); // POUND
239  artText.replace("&#173;", ""); // ?
240  artText.replace("&#8211;", "-"); // EN-DASH
241  artText.replace("&#8220;", """"); // LEFT-DOUBLE-QUOTE
242  artText.replace("&#8221;", """"); // RIGHT-DOUBLE-QUOTE
243  artText.replace("&#8216;", "'"); // LEFT-SINGLE-QUOTE
244  artText.replace("&#8217;", "'"); // RIGHT-SINGLE-QUOTE
245  // Replace paragraph and break HTML with newlines
246  if( artText.contains(QRegExp("</(p|P)>")) )
247  {
248  artText.replace( QRegExp("<(p|P)>"), "");
249  artText.replace( QRegExp("</(p|P)>"), "\n\n");
250  }
251  else
252  {
253  artText.replace( QRegExp("<(p|P)>"), "\n\n");
254  artText.replace( QRegExp("</(p|P)>"), "");
255  }
256  artText.replace( QRegExp("<(br|BR|)/>"), "\n");
257  artText.replace( QRegExp("<(br|BR|)>"), "\n");
258  // These are done instead of simplifyWhitespace
259  // because that function also strips out newlines
260  // Replace tab characters with nothing
261  artText.replace( QRegExp("\t"), "");
262  // Replace double space with single
263  artText.replace( QRegExp(" "), "");
264  // Replace whitespace at beginning of lines with newline
265  artText.replace( QRegExp("\n "), "\n");
266  // Remove any remaining HTML tags
267  QRegExp removeHTML(QRegExp("</?.+>"));
268  removeHTML.setMinimal(true);
269  artText.remove((const QRegExp&) removeHTML);
270  artText = artText.trimmed();
271  m_descText->SetText(artText);
272  }
273 
274  if (!article.thumbnail().isEmpty())
275  {
276  if (m_thumbnailImage)
277  {
280 
281  if (!m_thumbnailImage->IsVisible())
283  }
284  }
285  else
286  {
287  if (site && !site->imageURL().isEmpty())
288  {
289  if (m_thumbnailImage)
290  {
293 
294  if (!m_thumbnailImage->IsVisible())
296  }
297  }
298  else
299  {
300  if (m_thumbnailImage)
302  }
303  }
304 
305  if (m_downloadImage)
306  {
307  if (!article.enclosure().isEmpty())
308  {
309  if (!m_downloadImage->IsVisible())
311  }
312  else
314  }
315 
316  if (m_enclosureImage)
317  {
318  if (!article.enclosure().isEmpty())
319  {
320  if (!m_enclosureImage->IsVisible())
322  }
323  else
325  }
326 
327  if (m_podcastImage)
328  m_podcastImage->Hide();
329  }
330  }
331  else
332  {
333  if (m_downloadImage)
335 
336  if (m_enclosureImage)
338 
339  if (m_podcastImage)
340  m_podcastImage->Hide();
341 
342  if (site)
343  {
344  if (m_titleText)
345  m_titleText->SetText(site->name());
346 
347  if (m_descText)
348  m_descText->SetText(site->description());
349 
352 
353  if (m_podcastImage && site->podcast())
354  m_podcastImage->Show();
355 
356  if (!site->imageURL().isEmpty())
357  {
358  if (m_thumbnailImage)
359  {
362 
363  if (!m_thumbnailImage->IsVisible())
365  }
366  }
367  }
368  }
369 
370  if (m_updatedText)
371  {
372 
373  if (site)
374  {
375  QString text(tr("Updated") + " - ");
376  QDateTime updated(site->lastUpdated());
377  if (updated.isValid()) {
378  text += MythDate::toString(site->lastUpdated(),
380  }
381  else
382  text += tr("Unknown");
383  m_updatedText->SetText(text);
384  }
385  }
386 }
387 
388 QString MythNews::formatSize(long long bytes, int prec)
389 {
390  long long sizeKB = bytes / 1024;
391 
392  if (sizeKB>1024*1024*1024) // Terabytes
393  {
394  double sizeGB = sizeKB/(1024*1024*1024.0);
395  return QString("%1 TB").arg(sizeGB, 0, 'f', (sizeGB>10)?0:prec);
396  }
397  if (sizeKB>1024*1024) // Gigabytes
398  {
399  double sizeGB = sizeKB/(1024*1024.0);
400  return QString("%1 GB").arg(sizeGB, 0, 'f', (sizeGB>10)?0:prec);
401  }
402  if (sizeKB>1024) // Megabytes
403  {
404  double sizeMB = sizeKB/1024.0;
405  return QString("%1 MB").arg(sizeMB, 0, 'f', (sizeMB>10)?0:prec);
406  }
407  // Kilobytes
408  return QString("%1 KB").arg(sizeKB);
409 }
410 
411 bool MythNews::keyPressEvent(QKeyEvent *event)
412 {
413  if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
414  return true;
415 
416  QStringList actions;
417  bool handled = GetMythMainWindow()->TranslateKeyPress("News", event, actions);
418 
419  for (int i = 0; i < actions.size() && !handled; i++)
420  {
421  QString action = actions[i];
422  handled = true;
423 
424  if (action == "RETRIEVENEWS")
426  else if (action == "CANCEL")
427  cancelRetrieve();
428  else if (action == "MENU")
429  ShowMenu();
430  else if (action == "EDIT")
431  ShowEditDialog(true);
432  else if (action == "DELETE")
433  deleteNewsSite();
434  else
435  handled = false;
436  }
437 
438  if (!handled && MythScreenType::keyPressEvent(event))
439  handled = true;
440 
441  return handled;
442 }
443 
445 {
446  QMutexLocker locker(&m_lock);
447 
448  if (m_newsSites.empty())
449  return;
450 
451  m_retrieveTimer->stop();
452 
453  for (auto & site : m_newsSites)
454  {
455  if (site->timeSinceLastUpdate() > m_updateFreq)
456  site->retrieve();
457  else
458  processAndShowNews(site);
459  }
460 
461  m_retrieveTimer->stop();
462  m_retrieveTimer->setSingleShot(false);
464 }
465 
467 {
468  qint64 updated = site->lastUpdated().toSecsSinceEpoch();
469 
471  query.prepare("UPDATE newssites SET updated = :UPDATED "
472  "WHERE name = :NAME ;");
473  query.bindValue(":UPDATED", updated);
474  query.bindValue(":NAME", site->name());
475  if (!query.exec() || !query.isActive())
476  MythDB::DBError("news update time", query);
477 
478  processAndShowNews(site);
479 }
480 
482 {
483  QMutexLocker locker(&m_lock);
484 
485  for (auto & site : m_newsSites)
486  {
487  site->stop();
488  processAndShowNews(site);
489  }
490 }
491 
493 {
494  QMutexLocker locker(&m_lock);
495 
496  if (!site)
497  return;
498 
499  site->process();
500 
502  if (!siteUIItem)
503  return;
504 
505  if (site != siteUIItem->GetData().value<NewsSite*>())
506  return;
507 
508  QString currItem = m_articlesList->GetValue();
509  int topPos = m_articlesList->GetTopItemPos();
510 
512  m_articles.clear();
513 
514  NewsArticle::List articles = site->GetArticleList();
515  for (auto & article : articles)
516  {
517  auto *item =
518  new MythUIButtonListItem(m_articlesList, article.title());
519  m_articles[item] = article;
520  }
521 
522  if (m_articlesList->MoveToNamedPosition(currItem))
524 }
525 
527 {
528  QMutexLocker locker(&m_lock);
529 
530  if (!item || item->GetData().isNull())
531  return;
532 
533  auto *site = item->GetData().value<NewsSite*>();
534  if (!site)
535  return;
536 
538  m_articles.clear();
539 
540  NewsArticle::List articles = site->GetArticleList();
541  for (auto & article : articles)
542  {
543  auto *blitem = new MythUIButtonListItem(m_articlesList, article.title());
544  m_articles[blitem] = article;
545  }
546 
547  updateInfoView(item);
548 }
549 
551 {
552  QMutexLocker locker(&m_lock);
553 
554  QMap<MythUIButtonListItem*,NewsArticle>::const_iterator it =
555  m_articles.find(articlesListItem);
556 
557  if (it == m_articles.end())
558  return;
559 
560  const NewsArticle article = *it;
561 
562  if (article.articleURL().isEmpty())
563  return;
564 
565  if (article.enclosure().isEmpty())
566  {
567  QString cmdUrl(article.articleURL());
568 
569  if (m_browser.isEmpty())
570  {
571  ShowOkPopup(tr("No browser command set! MythNews needs MythBrowser to be installed."));
572  return;
573  }
574 
575  // display the web page
576  if (m_browser.toLower() == "internal")
577  {
578  GetMythMainWindow()->HandleMedia("WebBrowser", cmdUrl);
579  return;
580  }
581 
582  QString cmd = m_browser;
583  cmd.replace("%ZOOM%", m_zoom);
584  cmd.replace("%URL%", cmdUrl);
585  cmd.replace('\'', "%27");
586  cmd.replace("&","\\&");
587  cmd.replace(";","\\;");
588 
589  GetMythMainWindow()->AllowInput(false);
591  GetMythMainWindow()->AllowInput(true);
592  return;
593  }
594 
595  playVideo(article);
596 }
597 
599 {
600  QMutexLocker locker(&m_lock);
601 
602  NewsSite *site = nullptr;
603 
604  if (edit)
605  {
607 
608  if (!siteListItem || siteListItem->GetData().isNull())
609  return;
610 
611  site = siteListItem->GetData().value<NewsSite*>();
612  }
613 
615 
616  auto *mythnewseditor = new MythNewsEditor(site, edit, mainStack,
617  "mythnewseditor");
618 
619  if (mythnewseditor->Create())
620  {
621  connect(mythnewseditor, SIGNAL(Exiting()), SLOT(loadSites()));
622  mainStack->AddScreen(mythnewseditor);
623  }
624  else
625  delete mythnewseditor;
626 }
627 
629 {
631 
632  auto *mythnewsconfig = new MythNewsConfig(mainStack, "mythnewsconfig");
633 
634  if (mythnewsconfig->Create())
635  {
636  connect(mythnewsconfig, SIGNAL(Exiting()), SLOT(loadSites()));
637  mainStack->AddScreen(mythnewsconfig);
638  }
639  else
640  delete mythnewsconfig;
641 }
642 
644 {
645  QMutexLocker locker(&m_lock);
646 
647  QString label = tr("Options");
648 
649  MythScreenStack *popupStack =
650  GetMythMainWindow()->GetStack("popup stack");
651 
652  m_menuPopup = new MythDialogBox(label, popupStack, "mythnewsmenupopup");
653 
654  if (m_menuPopup->Create())
655  {
656  popupStack->AddScreen(m_menuPopup);
657 
658  m_menuPopup->SetReturnEvent(this, "options");
659 
660  m_menuPopup->AddButton(tr("Manage Feeds"));
661  m_menuPopup->AddButton(tr("Add Feed"));
662  if (!m_newsSites.empty())
663  {
664  m_menuPopup->AddButton(tr("Edit Feed"));
665  m_menuPopup->AddButton(tr("Delete Feed"));
666  }
667  }
668  else
669  {
670  delete m_menuPopup;
671  m_menuPopup = nullptr;
672  }
673 }
674 
676 {
677  QMutexLocker locker(&m_lock);
678 
680 
681  if (siteUIItem && !siteUIItem->GetData().isNull())
682  {
683  auto *site = siteUIItem->GetData().value<NewsSite*>();
684  if (site)
685  {
686  removeFromDB(site->name());
687  loadSites();
688  }
689  }
690 }
691 
692 // does not need locking
693 void MythNews::playVideo(const NewsArticle &article)
694 {
695  GetMythMainWindow()->HandleMedia("Internal", article.enclosure(),
696  article.description(), article.title());
697 }
698 
699 // does not need locking
700 void MythNews::customEvent(QEvent *event)
701 {
702  if (event->type() == DialogCompletionEvent::kEventType)
703  {
704  auto *dce = dynamic_cast<DialogCompletionEvent*>(event);
705  if (dce == nullptr)
706  return;
707 
708  QString resultid = dce->GetId();
709  int buttonnum = dce->GetResult();
710 
711  if (resultid == "options")
712  {
713  if (buttonnum == 0)
714  ShowFeedManager();
715  else if (buttonnum == 1)
716  ShowEditDialog(false);
717  else if (buttonnum == 2)
718  ShowEditDialog(true);
719  else if (buttonnum == 3)
720  deleteNewsSite();
721  }
722 
723  m_menuPopup = nullptr;
724  }
725 }
MythNews::ShowMenu
void ShowMenu(void) override
Definition: mythnews.cpp:643
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:204
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:783
newsdbutil.h
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:126
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:304
MythUIButtonList::GetTopItemPos
int GetTopItemPos(void) const
Definition: mythuibuttonlist.h:192
MythNewsEditor
Definition: mythnewseditor.h:21
NewsSite::imageURL
QString imageURL(void) const
Definition: newssite.cpp:128
MythDialogBox::SetReturnEvent
void SetReturnEvent(QObject *retobject, const QString &resultid)
Definition: mythdialogbox.cpp:275
MythNews::m_updatedText
MythUIText * m_updatedText
Definition: mythnews.h:64
MythDate::toString
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:80
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1590
myth_system
uint myth_system(const QString &command, uint flags, uint timeout)
Definition: mythsystemlegacy.cpp:501
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:103
MythNews::m_newsSites
NewsSite::List m_newsSites
Definition: mythnews.h:49
mythuitext.h
NewsArticle::articleURL
QString articleURL(void) const
Definition: newsarticle.h:25
DialogCompletionEvent::GetId
QString GetId()
Definition: mythdialogbox.h:52
MythNews::m_nositesText
MythUIText * m_nositesText
Definition: mythnews.h:63
MythUIText::Reset
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitext.cpp:84
MythNews::slotNewsRetrieved
void slotNewsRetrieved(NewsSite *site)
Definition: mythnews.cpp:466
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:550
NewsSite::podcast
bool podcast(void) const
Definition: newssite.cpp:108
mythdb.h
NewsSite::List::clear
void clear(void)
Definition: newssite.h:68
NewsArticle::title
QString title(void) const
Definition: newsarticle.h:23
MythNews::m_menuPopup
MythDialogBox * m_menuPopup
Definition: mythnews.h:57
MythNews::processAndShowNews
void processAndShowNews(NewsSite *site)
Definition: mythnews.cpp:492
mythnewsconfig.h
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
NewsArticle::thumbnail
QString thumbnail(void) const
Definition: newsarticle.h:26
MythUIImage::Load
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
Definition: mythuiimage.cpp:967
MythNews::slotRetrieveNews
void slotRetrieveNews(void)
Definition: mythnews.cpp:444
MythNews::customEvent
void customEvent(QEvent *event) override
Definition: mythnews.cpp:700
DialogCompletionEvent::kEventType
static Type kEventType
Definition: mythdialogbox.h:57
LOC_ERR
#define LOC_ERR
Definition: mythnews.cpp:36
mythdialogbox.h
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:198
MythScreenStack
Definition: mythscreenstack.h:16
MythNews::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythnews.cpp:411
MythNews::loadSites
void loadSites(void)
Definition: mythnews.cpp:152
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
NewsSite::description
QString description(void) const
Definition: newssite.cpp:114
MythNews::m_articles
QMap< MythUIButtonListItem *, NewsArticle > m_articles
Definition: mythnews.h:61
mythdirs.h
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &stackname)
Definition: mythmainwindow.cpp:309
mythuibuttonlist.h
MythNews::slotViewArticle
void slotViewArticle(MythUIButtonListItem *articlesListItem)
Definition: mythnews.cpp:550
mythuiimage.h
NewsSite::sortByName
static bool sortByName(NewsSite *a, NewsSite *b)
Definition: newssite.h:104
MythNews::MythNews
MythNews(MythScreenStack *parent, const QString &name)
Creates a new MythNews Screen.
Definition: mythnews.cpp:42
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:112
mythsystemlegacy.h
MythUIButtonListItem
Definition: mythuibuttonlist.h:28
MythNews::m_browser
QString m_browser
Definition: mythnews.h:56
MythDate::fromSecsSinceEpoch
MBASE_PUBLIC QDateTime fromSecsSinceEpoch(uint seconds)
This function takes the number of seconds since the start of the epoch and returns a QDateTime with t...
Definition: mythdate.cpp:68
mythdate.h
mythnewseditor.h
MythUIType::Show
void Show(void)
Definition: mythuitype.cpp:1123
mythnews.h
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:224
MythNews::m_downloadImage
MythUIImage * m_downloadImage
Definition: mythnews.h:69
MythNews::formatSize
static QString formatSize(long long bytes, int prec)
Definition: mythnews.cpp:388
MythNews::m_zoom
QString m_zoom
Definition: mythnews.h:55
MythUIButtonList::GetCurrentPos
int GetCurrentPos() const
Definition: mythuibuttonlist.h:190
NewsArticle
Definition: newsarticle.h:12
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:117
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:138
removeFromDB
bool removeFromDB(RSSSite *site)
Definition: netutils.cpp:686
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
MythNews::playVideo
static void playVideo(const NewsArticle &article)
Definition: mythnews.cpp:693
MythDialogBox::Create
bool Create(void) override
Definition: mythdialogbox.cpp:131
MythDialogBox::AddButton
void AddButton(const QString &title, QVariant data=0, bool newMenu=false, bool setCurrent=false)
Definition: mythdialogbox.cpp:300
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:179
MythNews::m_timerTimeout
int m_timerTimeout
Definition: mythnews.h:52
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:222
NewsSite::name
QString name(void) const
Definition: newssite.cpp:96
NewsSite::lastUpdated
QDateTime lastUpdated(void) const
Definition: newssite.cpp:140
MythNews::deleteNewsSite
void deleteNewsSite(void)
Definition: mythnews.cpp:675
NewsArticle::List
vector< NewsArticle > List
Definition: newsarticle.h:14
GetSetting
t<< doc.toString(4);f.close();LOG(VB_JOBQUEUE, LOG_INFO, "Copying video file");bool res=copyFile(filename, saveDirectory+title+"/"+baseName);if(!res) return 0;if(QFile::exists(filename+".png")) { LOG(VB_JOBQUEUE, LOG_INFO, "Copying preview image");res=copyFile(filename+".png", saveDirectory+title+"/"+baseName+".png");if(!res) return 0;} LOG(VB_JOBQUEUE, LOG_INFO, "Item Archived OK");return 1;}int NativeArchive::exportVideo(QDomElement &itemNode, const QString &saveDirectory){ QString dbVersion=gCoreContext-> GetSetting("DBSchemaVer", "")
NewsSite::GetArticleList
NewsArticle::List GetArticleList(void) const
Definition: newssite.cpp:134
MythNews::updateInfoView
void updateInfoView(void)
MythUIButtonListItem::GetData
QVariant GetData()
Definition: mythuibuttonlist.cpp:3588
MythNews::ShowFeedManager
void ShowFeedManager()
Definition: mythnews.cpp:628
MythNews::cancelRetrieve
void cancelRetrieve(void)
Definition: mythnews.cpp:481
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:57
NewsSite
Definition: newssite.h:53
MythNews::m_podcastImage
MythUIImage * m_podcastImage
Definition: mythnews.h:71
NewsSite::process
void process(void)
Definition: newssite.cpp:224
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
MythNews::m_titleText
MythUIText * m_titleText
Definition: mythnews.h:65
MythNews::m_articlesList
MythUIButtonList * m_articlesList
Definition: mythnews.h:60
NewsArticle::description
QString description(void) const
Definition: newsarticle.h:24
MythUIType::Hide
void Hide(void)
Definition: mythuitype.cpp:1118
MythNews::slotSiteSelected
void slotSiteSelected(MythUIButtonListItem *item)
Definition: mythnews.cpp:526
MythDate::kSimplify
@ kSimplify
Do Today/Yesterday/Tomorrow transform.
Definition: mythdate.h:23
MythNews::ShowEditDialog
void ShowEditDialog(bool edit)
Definition: mythnews.cpp:598
MythNews::m_retrieveTimer
QTimer * m_retrieveTimer
Definition: mythnews.h:51
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
MythNews::m_descText
MythUIText * m_descText
Definition: mythnews.h:66
musicbrainzngs.compat.bytes
bytes
Definition: compat.py:49
MythMainWindow::HandleMedia
bool HandleMedia(const QString &handler, const QString &mrl, const QString &plot="", const QString &title="", const QString &subtitle="", const QString &director="", int season=0, int episode=0, const QString &inetref="", int lenMins=120, const QString &year="1895", const QString &id="", bool useBookmarks=false)
Definition: mythmainwindow.cpp:1491
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:692
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1171
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:864
DialogCompletionEvent
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:42
MythNews::m_thumbnailImage
MythUIImage * m_thumbnailImage
Definition: mythnews.h:68
MythUIButtonList::GetValue
virtual QString GetValue() const
Definition: mythuibuttonlist.cpp:1609
MythUIText::SetText
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:134
mythcontext.h
MythUIButtonList::Reset
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuibuttonlist.cpp:114
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:107
MythUIButtonList::MoveToNamedPosition
bool MoveToNamedPosition(const QString &position_name)
Definition: mythuibuttonlist.cpp:2282
MythUIButtonList::SetItemCurrent
void SetItemCurrent(MythUIButtonListItem *item)
Definition: mythuibuttonlist.cpp:1557
MythNews::Create
bool Create(void) override
Definition: mythnews.cpp:74
build_compdb.action
action
Definition: build_compdb.py:9
MythScreenType::Exiting
void Exiting()
MythNews::m_updateFreq
unsigned int m_updateFreq
Definition: mythnews.h:53
MythNews::m_lock
QMutex m_lock
Definition: mythnews.h:48
MythNews::~MythNews
~MythNews() override
Definition: mythnews.cpp:69
MythMainWindow::AllowInput
void AllowInput(bool allow)
Definition: mythmainwindow.cpp:1521
NewsArticle::enclosure
QString enclosure(void) const
Definition: newsarticle.h:28
MythDate::kDateTimeFull
@ kDateTimeFull
Default local time.
Definition: mythdate.h:20
MythNews::m_sitesList
MythUIButtonList * m_sitesList
Definition: mythnews.h:59
kMSDontDisableDrawing
@ kMSDontDisableDrawing
avoid disabling UI drawing
Definition: mythsystem.h:35
MythUIImage::SetFilename
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
Definition: mythuiimage.cpp:675
mythdownloadmanager.h
MythUIButtonList::GetItemFirst
MythUIButtonListItem * GetItemFirst() const
Definition: mythuibuttonlist.cpp:1636
MythNewsConfig
Definition: mythnewsconfig.h:16
mythmainwindow.h
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:49
query
MSqlQuery query(MSqlQuery::InitCon())
MythUIType::IsVisible
bool IsVisible(bool recurse=false) const
Definition: mythuitype.cpp:887
MythNews::m_enclosureImage
MythUIImage * m_enclosureImage
Definition: mythnews.h:70
MythNews::clearSites
void clearSites(void)
Definition: mythnews.cpp:126
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:808