mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-31 01:24:49 +01:00
Refactorings, some optimizations.
This commit is contained in:
parent
57f651f970
commit
77078d932f
@ -402,10 +402,10 @@ if(${USE_QT_5})
|
||||
|
||||
# Load translations.
|
||||
if(Qt5LinguistTools_FOUND)
|
||||
message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools found. Translations will get refreshed.")
|
||||
message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools found. Translations will get compiled.")
|
||||
qt5_add_translation(APP_QM ${APP_TRANSLATIONS})
|
||||
else(Qt5LinguistTools_FOUND)
|
||||
message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools NOT found. No refreshing for translations.")
|
||||
message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools NOT found. No compilation for translations.")
|
||||
endif(Qt5LinguistTools_FOUND)
|
||||
else(${USE_QT_5})
|
||||
qt4_wrap_cpp(APP_MOC ${APP_HEADERS})
|
||||
|
@ -69,11 +69,12 @@ class FeedsModelRootItem {
|
||||
|
||||
protected:
|
||||
Kind m_kind;
|
||||
QString m_title;
|
||||
int m_id;
|
||||
QString m_title;
|
||||
QString m_description;
|
||||
QIcon m_icon;
|
||||
QDateTime m_creationDate;
|
||||
QString m_description;
|
||||
|
||||
QList<FeedsModelRootItem*> m_childItems;
|
||||
FeedsModelRootItem *m_parentItem;
|
||||
};
|
||||
|
@ -26,8 +26,8 @@ MessagesModel *MessagesProxyModel::sourceModel() {
|
||||
}
|
||||
|
||||
bool MessagesProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
||||
// TODO: mozna pouzit QString::localeAwareCompare tady
|
||||
// pro title a author.
|
||||
// TODO: Maybe use QString::localeAwareCompare() here for
|
||||
// title at least, but this will be probably little slower.
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList &ind
|
||||
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
if (deep) {
|
||||
// Construct new source index.
|
||||
mapped_indexes << mapFromSource(m_sourceModel->index(index.row(), index.column()));
|
||||
}
|
||||
else {
|
||||
|
@ -103,6 +103,32 @@ QString TextFactory::stripTags(QString text) {
|
||||
}
|
||||
|
||||
QString TextFactory::escapeHtml(const QString &html) {
|
||||
static QMap<QString, QString> escape_sequences = generetaEscapes();
|
||||
|
||||
QList<QString> keys = escape_sequences.uniqueKeys();
|
||||
QString output = html;
|
||||
|
||||
foreach (const QString &key, keys) {
|
||||
output.replace(key, escape_sequences.value(key));
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
QString TextFactory::deEscapeHtrml(const QString &text) {
|
||||
static QMap<QString, QString> deescape_sequences = generateDeescapes();
|
||||
|
||||
QList<QString> keys = deescape_sequences.uniqueKeys();
|
||||
QString output = text;
|
||||
|
||||
foreach (const QString &key, keys) {
|
||||
output.replace(key, deescape_sequences.value(key));
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
QMap<QString, QString> TextFactory::generetaEscapes() {
|
||||
QMap<QString, QString> sequences;
|
||||
|
||||
sequences["<"] = '<';
|
||||
@ -114,17 +140,10 @@ QString TextFactory::escapeHtml(const QString &html) {
|
||||
sequences["×"] = "×";
|
||||
sequences["'"] = '\'';
|
||||
|
||||
QList<QString> keys = sequences.uniqueKeys();
|
||||
QString output = html;
|
||||
|
||||
foreach (const QString &key, keys) {
|
||||
output.replace(key, sequences.value(key));
|
||||
}
|
||||
|
||||
return output;
|
||||
return sequences;
|
||||
}
|
||||
|
||||
QString TextFactory::deEscapeHtrml(const QString &text) {
|
||||
QMap<QString, QString> TextFactory::generateDeescapes() {
|
||||
QMap<QString, QString> sequences;
|
||||
|
||||
sequences["<"] = "<";
|
||||
@ -135,12 +154,5 @@ QString TextFactory::deEscapeHtrml(const QString &text) {
|
||||
sequences["×"] = "×";
|
||||
sequences["\'"] = "'";
|
||||
|
||||
QList<QString> keys = sequences.uniqueKeys();
|
||||
QString output = text;
|
||||
|
||||
foreach (const QString &key, keys) {
|
||||
output.replace(key, sequences.value(key));
|
||||
}
|
||||
|
||||
return output;
|
||||
return sequences;
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ class TextFactory {
|
||||
static QString escapeHtml(const QString &html);
|
||||
static QString deEscapeHtrml(const QString &text);
|
||||
|
||||
static QMap<QString, QString> generetaEscapes();
|
||||
static QMap<QString, QString> generateDeescapes();
|
||||
|
||||
// Shortens input string according to given length limit.
|
||||
static QString shorten(const QString &input, int text_length_limit = TEXT_TITLE_LIMIT);
|
||||
};
|
||||
|
@ -1,10 +1,24 @@
|
||||
#include "core/webbrowsernetworkaccessmanager.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
||||
|
||||
WebBrowserNetworkAccessManager::WebBrowserNetworkAccessManager(QObject *parent)
|
||||
: BaseNetworkAccessManager(parent) {
|
||||
connect(this, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
|
||||
this, SLOT(onSslErrors(QNetworkReply*,QList<QSslError>)));
|
||||
}
|
||||
|
||||
WebBrowserNetworkAccessManager::~WebBrowserNetworkAccessManager() {
|
||||
qDebug("Destroying WebBrowserNetworkAccessManager instance.");
|
||||
}
|
||||
|
||||
void WebBrowserNetworkAccessManager::onSslErrors(QNetworkReply *reply,
|
||||
const QList<QSslError> &error) {
|
||||
qDebug("SSL errors for '%s': '%s' (code %d).",
|
||||
qPrintable(reply->url().toString()),
|
||||
qPrintable(reply->errorString()),
|
||||
(int) reply->error());
|
||||
|
||||
reply->ignoreSslErrors(error);
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ class WebBrowserNetworkAccessManager : public BaseNetworkAccessManager {
|
||||
// Constructors and destructors.
|
||||
explicit WebBrowserNetworkAccessManager(QObject *parent = 0);
|
||||
virtual ~WebBrowserNetworkAccessManager();
|
||||
|
||||
protected slots:
|
||||
void onSslErrors(QNetworkReply *reply, const QList<QSslError> &error);
|
||||
};
|
||||
|
||||
#endif // WEBBROWSERNETWORKACCESSMANAGER_H
|
||||
|
@ -29,7 +29,3 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame,
|
||||
|
||||
return QWebPage::acceptNavigationRequest(frame, request, type);
|
||||
}
|
||||
|
||||
QWebPage *WebPage::createWindow(WebWindowType type) {
|
||||
return QWebPage::createWindow(type);
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ class WebPage : public QWebPage {
|
||||
virtual ~WebPage();
|
||||
|
||||
protected:
|
||||
QWebPage *createWindow(WebWindowType type);
|
||||
bool acceptNavigationRequest(QWebFrame *frame,
|
||||
const QNetworkRequest &request,
|
||||
NavigationType type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user