Some enhancements and fixes.

This commit is contained in:
Martin Rotter 2015-05-27 10:12:27 +02:00
parent d3a9e7eee1
commit 5921b6466a
6 changed files with 45 additions and 17 deletions

View file

@ -2,13 +2,14 @@
<center><h2>2.4.0</h2></center>
Added:
<ul>
<li>Message previewer now displays MIME type of all podcasts too. This MIME type is also stored in DB.</li>
<li>Ability to fetch only new icon for feed from its online source.</li>
<li>Option to search highlighted text in web browser via Google, available from context menu. (issue #72)</li>
</ul>
Fixed:
<ul>
<li></li>
<li>Titles and descriptions of feeds are now fetched correctly in feed add/edit dialog.</li>
</ul>
<hr/>

View file

@ -278,7 +278,6 @@ QPair<FeedsModelFeed*, QNetworkReply::NetworkError> FeedsModelFeed::guessFeed(co
DOWNLOAD_TIMEOUT,
icon_data)) == QNetworkReply::NoError) {
// Icon for feed was downloaded and is stored now in _icon_data.
result.first = new FeedsModelFeed();
result.first->setIcon(icon_data);
}
}

View file

@ -31,26 +31,48 @@
struct Enclosure {
QString m_mimeType;
QString m_url;
explicit Enclosure(const QString &url = QString(), const QString &mime = QString()) : m_url(url), m_mimeType(mime) {
}
};
// Represents single enclosure.
class Enclosures {
public:
static QStringList decodeEnclosuresFromString(const QString &enclosures_data) {
QStringList enclosures;
static QList<Enclosure> decodeEnclosuresFromString(const QString &enclosures_data) {
QList<Enclosure> enclosures;
foreach (const QString &single_enclosure, enclosures_data.split(ENCLOSURES_OUTER_SEPARATOR, QString::SkipEmptyParts)) {
enclosures.append(QByteArray::fromBase64(single_enclosure.toLocal8Bit()));
Enclosure enclosure;
if (single_enclosure.contains(ECNLOSURES_INNER_SEPARATOR)) {
QStringList mime_url = single_enclosure.split(ECNLOSURES_INNER_SEPARATOR);
enclosure.m_mimeType = QByteArray::fromBase64(mime_url.at(0).toLocal8Bit());
enclosure.m_url = QByteArray::fromBase64(mime_url.at(1).toLocal8Bit());
}
else {
enclosure.m_url = QByteArray::fromBase64(single_enclosure.toLocal8Bit());
}
enclosures.append(enclosure);
}
return enclosures;
}
static QString encodeEnclosuresToString(const QStringList &enclosures) {
static QString encodeEnclosuresToString(const QList<Enclosure> &enclosures) {
QStringList enclosures_str;
foreach (const QString &enclosure, enclosures) {
enclosures_str.append(enclosure.toLocal8Bit().toBase64());
foreach (const Enclosure &enclosure, enclosures) {
if (enclosure.m_mimeType.isEmpty()) {
enclosures_str.append(enclosure.m_url.toLocal8Bit().toBase64());
}
else {
enclosures_str.append(QString(enclosure.m_mimeType.toLocal8Bit().toBase64()) +
ECNLOSURES_INNER_SEPARATOR +
enclosure.m_url.toLocal8Bit().toBase64());
}
}
return enclosures_str.join(QString(ENCLOSURES_OUTER_SEPARATOR));
@ -62,7 +84,7 @@ class Message {
public:
explicit Message() {
m_title = m_url = m_author = m_contents = "";
m_enclosures = QStringList();
m_enclosures = QList<Enclosure>();
}
QString m_title;
@ -71,7 +93,7 @@ class Message {
QString m_contents;
QDateTime m_created;
QStringList m_enclosures;
QList<Enclosure> m_enclosures;
// Is true if "created" date was obtained directly
// from the feed, otherwise is false

View file

@ -74,9 +74,9 @@ QList<Message> ParsingFactory::parseAsATOM10(const QString &data) {
QDomElement link = elem_links.at(i).toElement();
if (link.attribute("rel") == "enclosure") {
new_message.m_enclosures.append(link.attribute("href"));
new_message.m_enclosures.append(Enclosure(link.attribute("href"), link.attribute("type")));
qDebug("Adding enclosure '%s' for the message.", qPrintable(new_message.m_enclosures.last()));
qDebug("Adding enclosure '%s' for the message.", qPrintable(new_message.m_enclosures.last().m_url));
}
else {
new_message.m_url = link.attribute("href");
@ -84,7 +84,7 @@ QList<Message> ParsingFactory::parseAsATOM10(const QString &data) {
}
if (new_message.m_url.isEmpty() && !new_message.m_enclosures.isEmpty()) {
new_message.m_url = new_message.m_enclosures.first();
new_message.m_url = new_message.m_enclosures.first().m_url;
}
// Deal with authors.
@ -205,6 +205,7 @@ QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
QString elem_title = message_item.namedItem("title").toElement().text().simplified();
QString elem_description = message_item.namedItem("description").toElement().text();
QString elem_enclosure = message_item.namedItem("enclosure").toElement().attribute("url");
QString elem_enclosure_type = message_item.namedItem("enclosure").toElement().attribute("type");
if (elem_description.isEmpty()) {
elem_description = message_item.namedItem("encoded").toElement().text();
@ -229,7 +230,7 @@ QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
}
if (!elem_enclosure.isEmpty()) {
new_message.m_enclosures.append(elem_enclosure);
new_message.m_enclosures.append(Enclosure(elem_enclosure, elem_enclosure_type));
qDebug("Adding enclosure '%s' for the message.", qPrintable(elem_enclosure));
}
@ -238,7 +239,7 @@ QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
new_message.m_url = message_item.namedItem("link").toElement().text();
if (new_message.m_url.isEmpty() && !new_message.m_enclosures.isEmpty()) {
new_message.m_url = new_message.m_enclosures.first();
new_message.m_url = new_message.m_enclosures.first().m_url;
}
new_message.m_author = message_item.namedItem("author").toElement().text();

View file

@ -39,6 +39,7 @@
#define APP_DONATE_URL "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XMWPLPK893VH4"
#define ENCLOSURES_OUTER_SEPARATOR '#'
#define ECNLOSURES_INNER_SEPARATOR '&'
#define URI_SCHEME_FEED "feed://"
#define URI_SCHEME_HTTP "http://"
#define RELEASES_LIST "https://bitbucket.org/skunkos/rssguard/raw/master/resources/text/UPDATES?at=master"

View file

@ -244,8 +244,12 @@ void WebBrowser::navigateToMessages(const QList<Message> &messages) {
foreach (const Message &message, messages) {
QString enclosures;
foreach (const QString &enclosure, message.m_enclosures) {
enclosures += skin.m_enclosureMarkup.arg(enclosure);
foreach (const Enclosure &enclosure, message.m_enclosures) {
if (!enclosure.m_mimeType.isEmpty()) {
enclosures += "[" + enclosure.m_mimeType + "] ";
}
enclosures += skin.m_enclosureMarkup.arg(enclosure.m_url);
enclosures += "<br>";
}