28#define LOC QString("RSSEditor: ")
29#define LOC_WARN QString("RSSEditor, Warning: ")
30#define LOC_ERR QString("RSSEditor, Error: ")
40 QList<QByteArray> exts = QImageReader::supportedImageFormats();
41 for (
const auto & ext : std::as_const(exts))
42 ret.append(QString(
"*.").append(ext));
80 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditpopup'");
103 if (!thumb.isEmpty())
160 connect(
m_manager, &QNetworkAccessManager::finished,
this,
166 const QUrl& oldRedirectUrl)
169 if(!possibleRedirectUrl.isEmpty() && possibleRedirectUrl != oldRedirectUrl)
176 QVariant possibleRedirectUrl =
177 reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
179 QUrl urlRedirectedTo;
181 possibleRedirectUrl.toUrl(), urlRedirectedTo);
183 if (!urlRedirectedTo.isEmpty())
186 m_manager->get(QNetworkRequest(urlRedirectedTo));
193 reply->deleteLater();
198 QDomDocument document;
199#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
200 document.setContent(reply->read(reply->bytesAvailable()),
true);
202 document.setContent(reply->read(reply->bytesAvailable()),
203 QDomDocument::ParseOption::UseNamespaceProcessing);
206 QString text = document.toString();
213 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Text to Parse: %1").arg(text));
215 QDomElement root = document.documentElement();
216 QDomElement channel = root.firstChildElement (
"channel");
217 if (!channel.isNull())
221 title = channel.firstChildElement(
"title").text().trimmed();
222 if (description.isEmpty())
223 description = channel.firstChildElement(
"description").text();
224 if (author.isEmpty())
226 if (author.isEmpty())
227 author = channel.firstChildElement(
"managingEditor").text();
228 if (author.isEmpty())
229 author = channel.firstChildElement(
"webMaster").text();
231 QString thumbnailURL =
232 channel.firstChildElement(
"image").attribute(
"url");
233 if (thumbnailURL.isEmpty())
235 QDomElement thumbElem = channel.firstChildElement(
"image");
236 if (!thumbElem.isNull())
237 thumbnailURL = thumbElem.firstChildElement(
"url").text();
239 if (thumbnailURL.isEmpty())
241 QDomNodeList nodes = channel.elementsByTagNameNS(
242 "http://www.itunes.com/dtds/podcast-1.0.dtd",
247 nodes.at(0).toElement().attributeNode(
"href").value();
248 if (thumbnailURL.isEmpty())
249 thumbnailURL = nodes.at(0).toElement().text();
258 else if (!thumbnailURL.isEmpty())
280 QObject &inst,
const QString &returnEvent)
288 fb->SetReturnEvent(&inst, returnEvent);
313 QMutexLocker locker(&
m_lock);
321 QMutexLocker locker(&
m_lock);
343 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditor'");
400 for (
int i = 0; i < actions.size() && !handled; i++)
402 const QString&
action = actions[i];
428 QMutexLocker locker(&
m_lock);
432 for (
const auto & site : std::as_const(
m_siteList))
435 item->SetText(site->GetTitle(),
"title");
436 item->SetText(site->GetDescription(),
"description");
437 item->SetText(site->GetURL(),
"url");
438 item->SetText(site->GetAuthor(),
"author");
439 item->SetData(QVariant::fromValue(site));
440 item->SetImage(site->GetImage());
451 const QString& thumb = site->
GetImage();
455 if (!thumb.isEmpty())
474 QMutexLocker locker(&
m_lock);
477 tr(
"Are you sure you want to unsubscribe from this feed?");
484 if (confirmdialog->Create())
493 delete confirmdialog;
499 QMutexLocker locker(&
m_lock);
507 new RSSEditPopup(site->GetURL(),
true, mainStack,
"rsseditpopup");
509 if (rsseditpopup->Create())
524 QMutexLocker locker(&
m_lock);
528 auto *rsseditpopup =
new RSSEditPopup(
"",
false, mainStack,
"rsseditpopup");
530 if (rsseditpopup->Create())
544 QMutexLocker locker(&
m_lock);
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)
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)