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 ret.reserve(exts.size());
43 for (
const auto & ext : std::as_const(exts))
44 ret.append(QString(
"*.").append(ext));
82 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditpopup'");
105 if (!thumb.isEmpty())
162 connect(
m_manager, &QNetworkAccessManager::finished,
this,
168 const QUrl& oldRedirectUrl)
171 if(!possibleRedirectUrl.isEmpty() && possibleRedirectUrl != oldRedirectUrl)
178 QVariant possibleRedirectUrl =
179 reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
181 QUrl urlRedirectedTo;
183 possibleRedirectUrl.toUrl(), urlRedirectedTo);
185 if (!urlRedirectedTo.isEmpty())
188 m_manager->get(QNetworkRequest(urlRedirectedTo));
195 reply->deleteLater();
200 QDomDocument document;
201#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
202 document.setContent(reply->read(reply->bytesAvailable()),
true);
204 document.setContent(reply->read(reply->bytesAvailable()),
205 QDomDocument::ParseOption::UseNamespaceProcessing);
208 QString text = document.toString();
215 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Text to Parse: %1").arg(text));
217 QDomElement root = document.documentElement();
218 QDomElement channel = root.firstChildElement (
"channel");
219 if (!channel.isNull())
223 title = channel.firstChildElement(
"title").text().trimmed();
224 if (description.isEmpty())
225 description = channel.firstChildElement(
"description").text();
226 if (author.isEmpty())
228 if (author.isEmpty())
229 author = channel.firstChildElement(
"managingEditor").text();
230 if (author.isEmpty())
231 author = channel.firstChildElement(
"webMaster").text();
233 QString thumbnailURL =
234 channel.firstChildElement(
"image").attribute(
"url");
235 if (thumbnailURL.isEmpty())
237 QDomElement thumbElem = channel.firstChildElement(
"image");
238 if (!thumbElem.isNull())
239 thumbnailURL = thumbElem.firstChildElement(
"url").text();
241 if (thumbnailURL.isEmpty())
243 QDomNodeList nodes = channel.elementsByTagNameNS(
244 "http://www.itunes.com/dtds/podcast-1.0.dtd",
249 nodes.at(0).toElement().attributeNode(
"href").value();
250 if (thumbnailURL.isEmpty())
251 thumbnailURL = nodes.at(0).toElement().text();
260 else if (!thumbnailURL.isEmpty())
282 QObject &inst,
const QString &returnEvent)
290 fb->SetReturnEvent(&inst, returnEvent);
315 QMutexLocker locker(&
m_lock);
323 QMutexLocker locker(&
m_lock);
345 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditor'");
402 for (
int i = 0; i < actions.size() && !handled; i++)
404 const QString&
action = actions[i];
430 QMutexLocker locker(&
m_lock);
434 for (
const auto & site : std::as_const(
m_siteList))
437 item->SetText(site->GetTitle(),
"title");
438 item->SetText(site->GetDescription(),
"description");
439 item->SetText(site->GetURL(),
"url");
440 item->SetText(site->GetAuthor(),
"author");
441 item->SetData(QVariant::fromValue(site));
442 item->SetImage(site->GetImage());
453 const QString& thumb = site->
GetImage();
457 if (!thumb.isEmpty())
476 QMutexLocker locker(&
m_lock);
479 tr(
"Are you sure you want to unsubscribe from this feed?");
486 if (confirmdialog->Create())
495 delete confirmdialog;
501 QMutexLocker locker(&
m_lock);
509 new RSSEditPopup(site->GetURL(),
true, mainStack,
"rsseditpopup");
511 if (rsseditpopup->Create())
526 QMutexLocker locker(&
m_lock);
530 auto *rsseditpopup =
new RSSEditPopup(
"",
false, mainStack,
"rsseditpopup");
532 if (rsseditpopup->Create())
546 QMutexLocker locker(&
m_lock);
563#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)