29#define LOC QString("RSSEditor: ")
30#define LOC_WARN QString("RSSEditor, Warning: ")
31#define LOC_ERR QString("RSSEditor, Error: ")
41 QList<QByteArray> exts = QImageReader::supportedImageFormats();
42 for (
const auto & ext : std::as_const(exts))
43 ret.append(QString(
"*.").append(ext));
81 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditpopup'");
104 if (!thumb.isEmpty())
161 connect(
m_manager, &QNetworkAccessManager::finished,
this,
167 const QUrl& oldRedirectUrl)
170 if(!possibleRedirectUrl.isEmpty() && possibleRedirectUrl != oldRedirectUrl)
177 QVariant possibleRedirectUrl =
178 reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
180 QUrl urlRedirectedTo;
182 possibleRedirectUrl.toUrl(), urlRedirectedTo);
184 if (!urlRedirectedTo.isEmpty())
187 m_manager->get(QNetworkRequest(urlRedirectedTo));
194 reply->deleteLater();
199 QDomDocument document;
200#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
201 document.setContent(reply->read(reply->bytesAvailable()),
true);
203 document.setContent(reply->read(reply->bytesAvailable()),
204 QDomDocument::ParseOption::UseNamespaceProcessing);
207 QString text = document.toString();
214 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Text to Parse: %1").arg(text));
216 QDomElement root = document.documentElement();
217 QDomElement channel = root.firstChildElement (
"channel");
218 if (!channel.isNull())
222 title = channel.firstChildElement(
"title").text().trimmed();
223 if (description.isEmpty())
224 description = channel.firstChildElement(
"description").text();
225 if (author.isEmpty())
227 if (author.isEmpty())
228 author = channel.firstChildElement(
"managingEditor").text();
229 if (author.isEmpty())
230 author = channel.firstChildElement(
"webMaster").text();
232 QString thumbnailURL =
233 channel.firstChildElement(
"image").attribute(
"url");
234 if (thumbnailURL.isEmpty())
236 QDomElement thumbElem = channel.firstChildElement(
"image");
237 if (!thumbElem.isNull())
238 thumbnailURL = thumbElem.firstChildElement(
"url").text();
240 if (thumbnailURL.isEmpty())
242 QDomNodeList nodes = channel.elementsByTagNameNS(
243 "http://www.itunes.com/dtds/podcast-1.0.dtd",
248 nodes.at(0).toElement().attributeNode(
"href").value();
249 if (thumbnailURL.isEmpty())
250 thumbnailURL = nodes.at(0).toElement().text();
259 else if (!thumbnailURL.isEmpty())
281 QObject &inst,
const QString &returnEvent)
289 fb->SetReturnEvent(&inst, returnEvent);
314 QMutexLocker locker(&
m_lock);
322 QMutexLocker locker(&
m_lock);
344 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditor'");
401 for (
int i = 0; i < actions.size() && !handled; i++)
403 const QString&
action = actions[i];
429 QMutexLocker locker(&
m_lock);
433 for (
const auto & site : std::as_const(
m_siteList))
436 item->SetText(site->GetTitle(),
"title");
437 item->SetText(site->GetDescription(),
"description");
438 item->SetText(site->GetURL(),
"url");
439 item->SetText(site->GetAuthor(),
"author");
440 item->SetData(QVariant::fromValue(site));
441 item->SetImage(site->GetImage());
452 const QString& thumb = site->
GetImage();
456 if (!thumb.isEmpty())
475 QMutexLocker locker(&
m_lock);
478 tr(
"Are you sure you want to unsubscribe from this feed?");
485 if (confirmdialog->Create())
494 delete confirmdialog;
500 QMutexLocker locker(&
m_lock);
508 new RSSEditPopup(site->GetURL(),
true, mainStack,
"rsseditpopup");
510 if (rsseditpopup->Create())
525 QMutexLocker locker(&
m_lock);
529 auto *rsseditpopup =
new RSSEditPopup(
"",
false, mainStack,
"rsseditpopup");
531 if (rsseditpopup->Create())
545 QMutexLocker locker(&
m_lock);
562#include "moc_rsseditor.cpp"
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
static const Type kEventType
Dialog asking for user confirmation.
MythScreenStack * GetMainStack()
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)
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
void SetCheckState(MythUIStateType::StateType state)
MythUIStateType::StateType GetCheckState() const
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
QString GetFilename(void) const
void Reset(void) override
Reset the image back to the default defined in the theme.
QString GetText(void) const
void SetText(const QString &text, bool moveCursor=true)
void SetMaxLength(int length)
virtual void SetText(const QString &text)
virtual void SetVisible(bool visible)
static QString GetAuthor(const QDomElement &parent)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
std::shared_ptr< MythSortHelper > getMythSortHelper(void)
Get a pointer to the MythSortHelper singleton.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
bool removeFromDB(RSSSite *site)
RSSSite * findByURL(const QString &url, ArticleType type)
RSSSite::rssList findAllDBRSS()
bool insertInDB(RSSSite *site)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)