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 <QRegularExpression>
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 
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 
119  this, qOverload<MythUIButtonListItem *>(&MythNews::updateInfoView));
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, &NewsSite::finished,
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  {
231  QString title = cleanText(article.title());
233  }
234 
235  if (m_descText)
236  {
237  QString artText = cleanText(article.description());
238  m_descText->SetText(artText);
239  }
240 
241  if (!article.thumbnail().isEmpty())
242  {
243  if (m_thumbnailImage)
244  {
247 
248  if (!m_thumbnailImage->IsVisible())
250  }
251  }
252  else
253  {
254  if (site && !site->imageURL().isEmpty())
255  {
256  if (m_thumbnailImage)
257  {
260 
261  if (!m_thumbnailImage->IsVisible())
263  }
264  }
265  else
266  {
267  if (m_thumbnailImage)
269  }
270  }
271 
272  if (m_downloadImage)
273  {
274  if (!article.enclosure().isEmpty())
275  {
276  if (!m_downloadImage->IsVisible())
278  }
279  else
281  }
282 
283  if (m_enclosureImage)
284  {
285  if (!article.enclosure().isEmpty())
286  {
287  if (!m_enclosureImage->IsVisible())
289  }
290  else
292  }
293 
294  if (m_podcastImage)
295  m_podcastImage->Hide();
296  }
297  }
298  else
299  {
300  if (m_downloadImage)
302 
303  if (m_enclosureImage)
305 
306  if (m_podcastImage)
307  m_podcastImage->Hide();
308 
309  if (site)
310  {
311  if (m_titleText)
312  m_titleText->SetText(site->name());
313 
314  if (m_descText)
315  m_descText->SetText(site->description());
316 
319 
320  if (m_podcastImage && site->podcast())
321  m_podcastImage->Show();
322 
323  if (!site->imageURL().isEmpty())
324  {
325  if (m_thumbnailImage)
326  {
329 
330  if (!m_thumbnailImage->IsVisible())
332  }
333  }
334  }
335  }
336 
337  if (m_updatedText)
338  {
339 
340  if (site)
341  {
342  QString text(tr("Updated") + " - ");
343  QDateTime updated(site->lastUpdated());
344  if (updated.isValid()) {
345  text += MythDate::toString(site->lastUpdated(),
347  }
348  else
349  text += tr("Unknown");
350  m_updatedText->SetText(text);
351  }
352  }
353 }
354 
355 QString MythNews::formatSize(long long bytes, int prec)
356 {
357  long long sizeKB = bytes / 1024;
358 
359  if (sizeKB>1024*1024*1024) // Terabytes
360  {
361  double sizeGB = sizeKB/(1024*1024*1024.0);
362  return QString("%1 TB").arg(sizeGB, 0, 'f', (sizeGB>10)?0:prec);
363  }
364  if (sizeKB>1024*1024) // Gigabytes
365  {
366  double sizeGB = sizeKB/(1024*1024.0);
367  return QString("%1 GB").arg(sizeGB, 0, 'f', (sizeGB>10)?0:prec);
368  }
369  if (sizeKB>1024) // Megabytes
370  {
371  double sizeMB = sizeKB/1024.0;
372  return QString("%1 MB").arg(sizeMB, 0, 'f', (sizeMB>10)?0:prec);
373  }
374  // Kilobytes
375  return QString("%1 KB").arg(sizeKB);
376 }
377 
378 bool MythNews::keyPressEvent(QKeyEvent *event)
379 {
380  if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
381  return true;
382 
383  QStringList actions;
384  bool handled = GetMythMainWindow()->TranslateKeyPress("News", event, actions);
385 
386  for (int i = 0; i < actions.size() && !handled; i++)
387  {
388  QString action = actions[i];
389  handled = true;
390 
391  if (action == "RETRIEVENEWS")
393  else if (action == "CANCEL")
394  cancelRetrieve();
395  else if (action == "MENU")
396  ShowMenu();
397  else if (action == "EDIT")
398  ShowEditDialog(true);
399  else if (action == "DELETE")
400  deleteNewsSite();
401  else
402  handled = false;
403  }
404 
405  if (!handled && MythScreenType::keyPressEvent(event))
406  handled = true;
407 
408  return handled;
409 }
410 
412 {
413  QMutexLocker locker(&m_lock);
414 
415  if (m_newsSites.empty())
416  return;
417 
418  m_retrieveTimer->stop();
419 
420  for (auto & site : m_newsSites)
421  {
422  if (site->timeSinceLastUpdate() > m_updateFreq)
423  site->retrieve();
424  else
425  processAndShowNews(site);
426  }
427 
428  m_retrieveTimer->stop();
429  m_retrieveTimer->setSingleShot(false);
431 }
432 
434 {
435  qint64 updated = site->lastUpdated().toSecsSinceEpoch();
436 
438  query.prepare("UPDATE newssites SET updated = :UPDATED "
439  "WHERE name = :NAME ;");
440  query.bindValue(":UPDATED", updated);
441  query.bindValue(":NAME", site->name());
442  if (!query.exec() || !query.isActive())
443  MythDB::DBError("news update time", query);
444 
445  processAndShowNews(site);
446 }
447 
449 {
450  QMutexLocker locker(&m_lock);
451 
452  for (auto & site : m_newsSites)
453  {
454  site->stop();
455  processAndShowNews(site);
456  }
457 }
458 
460 {
461  QMutexLocker locker(&m_lock);
462 
463  if (!site)
464  return;
465 
466  site->process();
467 
469  if (!siteUIItem)
470  return;
471 
472  if (site != siteUIItem->GetData().value<NewsSite*>())
473  return;
474 
475  QString currItem = m_articlesList->GetValue();
476  int topPos = m_articlesList->GetTopItemPos();
477 
479  m_articles.clear();
480 
481  NewsArticle::List articles = site->GetArticleList();
482  for (auto & article : articles)
483  {
484  auto *item =
485  new MythUIButtonListItem(m_articlesList, cleanText(article.title()));
486  m_articles[item] = article;
487  }
488 
489  if (m_articlesList->MoveToNamedPosition(currItem))
491 }
492 
494 {
495  QMutexLocker locker(&m_lock);
496 
497  if (!item || item->GetData().isNull())
498  return;
499 
500  auto *site = item->GetData().value<NewsSite*>();
501  if (!site)
502  return;
503 
505  m_articles.clear();
506 
507  NewsArticle::List articles = site->GetArticleList();
508  for (auto & article : articles)
509  {
510  auto *blitem = new MythUIButtonListItem(m_articlesList, cleanText(article.title()));
511  m_articles[blitem] = article;
512  }
513 
514  updateInfoView(item);
515 }
516 
518 {
519  QMutexLocker locker(&m_lock);
520 
521  QMap<MythUIButtonListItem*,NewsArticle>::const_iterator it =
522  m_articles.constFind(articlesListItem);
523 
524  if (it == m_articles.constEnd())
525  return;
526 
527  const NewsArticle article = *it;
528 
529  if (article.articleURL().isEmpty())
530  return;
531 
532  if (article.enclosure().isEmpty())
533  {
534  QString cmdUrl(article.articleURL());
535 
536  if (m_browser.isEmpty())
537  {
538  ShowOkPopup(tr("No browser command set! MythNews needs MythBrowser to be installed."));
539  return;
540  }
541 
542  // display the web page
543  if (m_browser.toLower() == "internal")
544  {
545  GetMythMainWindow()->HandleMedia("WebBrowser", cmdUrl);
546  return;
547  }
548 
549  QString cmd = m_browser;
550  cmd.replace("%ZOOM%", m_zoom);
551  cmd.replace("%URL%", cmdUrl);
552  cmd.replace('\'', "%27");
553  cmd.replace("&","\\&");
554  cmd.replace(";","\\;");
555 
556  GetMythMainWindow()->AllowInput(false);
558  GetMythMainWindow()->AllowInput(true);
559  return;
560  }
561 
562  playVideo(article);
563 }
564 
566 {
567  QMutexLocker locker(&m_lock);
568 
569  NewsSite *site = nullptr;
570 
571  if (edit)
572  {
574 
575  if (!siteListItem || siteListItem->GetData().isNull())
576  return;
577 
578  site = siteListItem->GetData().value<NewsSite*>();
579  }
580 
582 
583  auto *mythnewseditor = new MythNewsEditor(site, edit, mainStack,
584  "mythnewseditor");
585 
586  if (mythnewseditor->Create())
587  {
588  connect(mythnewseditor, &MythScreenType::Exiting, this, &MythNews::loadSites);
589  mainStack->AddScreen(mythnewseditor);
590  }
591  else
592  delete mythnewseditor;
593 }
594 
596 {
598 
599  auto *mythnewsconfig = new MythNewsConfig(mainStack, "mythnewsconfig");
600 
601  if (mythnewsconfig->Create())
602  {
603  connect(mythnewsconfig, &MythScreenType::Exiting, this, &MythNews::loadSites);
604  mainStack->AddScreen(mythnewsconfig);
605  }
606  else
607  delete mythnewsconfig;
608 }
609 
611 {
612  QMutexLocker locker(&m_lock);
613 
614  QString label = tr("Options");
615 
616  MythScreenStack *popupStack =
617  GetMythMainWindow()->GetStack("popup stack");
618 
619  m_menuPopup = new MythDialogBox(label, popupStack, "mythnewsmenupopup");
620 
621  if (m_menuPopup->Create())
622  {
623  popupStack->AddScreen(m_menuPopup);
624 
625  m_menuPopup->SetReturnEvent(this, "options");
626 
627  m_menuPopup->AddButton(tr("Manage Feeds"));
628  m_menuPopup->AddButton(tr("Add Feed"));
629  if (!m_newsSites.empty())
630  {
631  m_menuPopup->AddButton(tr("Edit Feed"));
632  m_menuPopup->AddButton(tr("Delete Feed"));
633  }
634  }
635  else
636  {
637  delete m_menuPopup;
638  m_menuPopup = nullptr;
639  }
640 }
641 
643 {
644  QMutexLocker locker(&m_lock);
645 
647 
648  if (siteUIItem && !siteUIItem->GetData().isNull())
649  {
650  auto *site = siteUIItem->GetData().value<NewsSite*>();
651  if (site)
652  {
653  removeFromDB(site->name());
654  loadSites();
655  }
656  }
657 }
658 
659 // does not need locking
660 void MythNews::playVideo(const NewsArticle &article)
661 {
662  GetMythMainWindow()->HandleMedia("Internal", article.enclosure(),
663  article.description(), article.title());
664 }
665 
666 // does not need locking
667 void MythNews::customEvent(QEvent *event)
668 {
669  if (event->type() == DialogCompletionEvent::kEventType)
670  {
671  auto *dce = dynamic_cast<DialogCompletionEvent*>(event);
672  if (dce == nullptr)
673  return;
674 
675  QString resultid = dce->GetId();
676  int buttonnum = dce->GetResult();
677 
678  if (resultid == "options")
679  {
680  if (buttonnum == 0)
681  ShowFeedManager();
682  else if (buttonnum == 1)
683  ShowEditDialog(false);
684  else if (buttonnum == 2)
685  ShowEditDialog(true);
686  else if (buttonnum == 3)
687  deleteNewsSite();
688  }
689 
690  m_menuPopup = nullptr;
691  }
692 }
693 
694 QString MythNews::cleanText(const QString &text)
695 {
696  QString result = text;
697 
698  // replace a few HTML characters
699  result.replace("&#8232;", ""); // LSEP
700  result.replace("&#8233;", ""); // PSEP
701  result.replace("&#163;", u8"\u00A3"); // POUND
702  result.replace("&#173;", ""); // ?
703  result.replace("&#8211;", "-"); // EN-DASH
704  result.replace("&#8220;", """"); // LEFT-DOUBLE-QUOTE
705  result.replace("&#8221;", """"); // RIGHT-DOUBLE-QUOTE
706  result.replace("&#8216;", "'"); // LEFT-SINGLE-QUOTE
707  result.replace("&#8217;", "'"); // RIGHT-SINGLE-QUOTE
708  result.replace("&#39;", "'"); // Apostrophe
709 
710  // Replace paragraph and break HTML with newlines
711  if( result.contains(QRegularExpression("</(p|P)>")) )
712  {
713  result.replace( QRegularExpression("<(p|P)>"), "");
714  result.replace( QRegularExpression("</(p|P)>"), "\n\n");
715  }
716  else
717  {
718  result.replace( QRegularExpression("<(p|P)>"), "\n\n");
719  result.replace( QRegularExpression("</(p|P)>"), "");
720  }
721  result.replace( QRegularExpression("<(br|BR|)/>"), "\n");
722  result.replace( QRegularExpression("<(br|BR|)>"), "\n");
723  // These are done instead of simplifyWhitespace
724  // because that function also strips out newlines
725  // Replace tab characters with nothing
726  result.replace( QRegularExpression("\t"), "");
727  // Replace double space with single
728  result.replace( QRegularExpression(" "), "");
729  // Replace whitespace at beginning of lines with newline
730  result.replace( QRegularExpression("\n "), "\n");
731  // Remove any remaining HTML tags
732  QRegularExpression removeHTML(QRegularExpression("</?.+>"));
733  result.remove((const QRegularExpression&) removeHTML);
734  result = result.trimmed();
735 
736  return result;
737 }
MythNews::ShowMenu
void ShowMenu(void) override
Definition: mythnews.cpp:610
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:321
MythUIButtonList::GetTopItemPos
int GetTopItemPos(void) const
Definition: mythuibuttonlist.h:200
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:300
MythNews::m_updatedText
MythUIText * m_updatedText
Definition: mythnews.h:65
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:50
mythuitext.h
NewsArticle::articleURL
QString articleURL(void) const
Definition: newsarticle.h:24
MythNews::cleanText
static QString cleanText(const QString &text)
Definition: mythnews.cpp:694
DialogCompletionEvent::GetId
QString GetId()
Definition: mythdialogbox.h:52
MythNews::m_nositesText
MythUIText * m_nositesText
Definition: mythnews.h:64
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:433
NewsSite::podcast
bool podcast(void) const
Definition: newssite.cpp:108
mythdb.h
NewsSite::List::clear
void clear(void)
Definition: newssite.h:67
NewsArticle::title
QString title(void) const
Definition: newsarticle.h:22
MythNews::m_menuPopup
MythDialogBox * m_menuPopup
Definition: mythnews.h:58
MythNews::processAndShowNews
void processAndShowNews(NewsSite *site)
Definition: mythnews.cpp:459
mythnewsconfig.h
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:636
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:1139
NewsArticle::thumbnail
QString thumbnail(void) const
Definition: newsarticle.h:25
MythUIImage::Load
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
Definition: mythuiimage.cpp:968
MythNews::slotRetrieveNews
void slotRetrieveNews(void)
Definition: mythnews.cpp:411
MythNews::customEvent
void customEvent(QEvent *event) override
Definition: mythnews.cpp:667
DialogCompletionEvent::kEventType
static Type kEventType
Definition: mythdialogbox.h:57
MythUIButtonList::itemSelected
void itemSelected(MythUIButtonListItem *item)
NewsSite::finished
void finished(NewsSite *item)
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:378
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:62
mythdirs.h
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &stackname)
Definition: mythmainwindow.cpp:326
mythuibuttonlist.h
MythNews::slotViewArticle
void slotViewArticle(MythUIButtonListItem *articlesListItem)
Definition: mythnews.cpp:517
mythuiimage.h
NewsSite::sortByName
static bool sortByName(NewsSite *a, NewsSite *b)
Definition: newssite.h:103
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:57
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:1125
mythnews.h
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:224
MythNews::m_downloadImage
MythUIImage * m_downloadImage
Definition: mythnews.h:70
MythNews::ShowFeedManager
void ShowFeedManager() const
Definition: mythnews.cpp:595
MythNews::formatSize
static QString formatSize(long long bytes, int prec)
Definition: mythnews.cpp:355
MythUIButtonList::itemClicked
void itemClicked(MythUIButtonListItem *item)
MythNews::m_zoom
QString m_zoom
Definition: mythnews.h:56
MythUIButtonList::GetCurrentPos
int GetCurrentPos() const
Definition: mythuibuttonlist.h:198
NewsArticle
Definition: newsarticle.h:11
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:117
MythDialogBox::AddButton
void AddButton(const QString &title)
Definition: mythdialogbox.h:197
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:167
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:660
MythDialogBox::Create
bool Create(void) override
Definition: mythdialogbox.cpp:127
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:178
MythNews::m_timerTimeout
int m_timerTimeout
Definition: mythnews.h:53
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:642
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:3580
MythNews::cancelRetrieve
void cancelRetrieve(void)
Definition: mythnews.cpp:448
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:56
NewsSite
Definition: newssite.h:52
MythNews::m_podcastImage
MythUIImage * m_podcastImage
Definition: mythnews.h:72
NewsSite::process
void process(void)
Definition: newssite.cpp:225
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:66
MythNews::m_articlesList
MythUIButtonList * m_articlesList
Definition: mythnews.h:61
NewsArticle::description
QString description(void) const
Definition: newsarticle.h:23
MythUIType::Hide
void Hide(void)
Definition: mythuitype.cpp:1120
MythNews::slotSiteSelected
void slotSiteSelected(MythUIButtonListItem *item)
Definition: mythnews.cpp:493
MythDate::kSimplify
@ kSimplify
Do Today/Yesterday/Tomorrow transform.
Definition: mythdate.h:23
MythNews::ShowEditDialog
void ShowEditDialog(bool edit)
Definition: mythnews.cpp:565
MythNews::m_retrieveTimer
QTimer * m_retrieveTimer
Definition: mythnews.h:52
NewsArticle::List
std::vector< NewsArticle > List
Definition: newsarticle.h:13
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
MythNews::m_descText
MythUIText * m_descText
Definition: mythnews.h:67
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:1524
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:1174
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:69
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:105
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:54
MythNews::m_lock
QMutex m_lock
Definition: mythnews.h:49
MythNews::~MythNews
~MythNews() override
Definition: mythnews.cpp:69
MythMainWindow::AllowInput
void AllowInput(bool allow)
Definition: mythmainwindow.cpp:1554
NewsArticle::enclosure
QString enclosure(void) const
Definition: newsarticle.h:27
MythDate::kDateTimeFull
@ kDateTimeFull
Default local time.
Definition: mythdate.h:20
MythNews::m_sitesList
MythUIButtonList * m_sitesList
Definition: mythnews.h:60
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:676
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())
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:557
MythUIType::IsVisible
bool IsVisible(bool recurse=false) const
Definition: mythuitype.cpp:888
MythNews::m_enclosureImage
MythUIImage * m_enclosureImage
Definition: mythnews.h:71
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