remove all qregexp usages
This commit is contained in:
parent
54ce2d6cf6
commit
484849dd0c
@ -30,7 +30,7 @@
|
||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="3.5.7" date="2019-04-10"/>
|
||||
<release version="3.5.7" date="2019-04-11"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||
|
@ -85,7 +85,7 @@ void MessagesModel::loadMessages(RootItem* item) {
|
||||
}
|
||||
else {
|
||||
if (!item->getParentServiceRoot()->loadMessagesForItem(item, this)) {
|
||||
setFilter(QSL("true != true"));
|
||||
setFilter(QSL(DEFAULT_SQL_MESSAGES_FILTER));
|
||||
qWarning("Loading of messages from item '%s' failed.", qPrintable(item->title()));
|
||||
qApp->showGuiMessage(tr("Loading of messages from item '%1' failed.").arg(item->title()),
|
||||
tr("Loading of messages failed, maybe messages could not be downloaded."),
|
||||
@ -500,7 +500,7 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList& messages, RootIt
|
||||
|
||||
msgs.append(msg);
|
||||
message_ids.append(QString::number(msg.m_id));
|
||||
setData(index(message.row(), MSG_DB_READ_INDEX), (int) read);
|
||||
setData(index(message.row(), MSG_DB_READ_INDEX), int(read));
|
||||
}
|
||||
|
||||
reloadWholeLayout();
|
||||
|
@ -87,8 +87,9 @@ QString MessagesModelSqlLayer::formatFields() const {
|
||||
}
|
||||
|
||||
QString MessagesModelSqlLayer::selectStatement() const {
|
||||
return QL1S("SELECT ") + formatFields() +
|
||||
QSL(" FROM Messages LEFT JOIN Feeds ON Messages.feed = Feeds.custom_id AND Messages.account_id = Feeds.account_id WHERE ") +
|
||||
return QL1S("SELECT ") + formatFields() + QL1C(' ') +
|
||||
QL1S("FROM Messages LEFT JOIN Feeds ON Messages.feed = Feeds.custom_id AND Messages.account_id = Feeds.account_id "
|
||||
"WHERE ") +
|
||||
m_filter + orderByClause() + QL1C(';');
|
||||
}
|
||||
|
||||
|
@ -91,8 +91,8 @@
|
||||
|
||||
#define FEED_INITIAL_OPML_PATTERN "feeds-%1.opml"
|
||||
|
||||
#define FEED_REGEX_MATCHER "<link[^>]+type=\\\"application/(atom|rss)\\+xml\\\"[^>]*>"
|
||||
#define FEED_HREF_REGEX_MATCHER "href\\=\\\"[^\\\"]+\\\""
|
||||
#define FEED_REGEX_MATCHER "<link[^>]+type=\"application\\/(?:atom|rss)\\+xml\"[^>]*>"
|
||||
#define FEED_HREF_REGEX_MATCHER "href=\"([^\"]+)\""
|
||||
|
||||
#define PLACEHOLDER_UNREAD_COUNTS "%unread"
|
||||
#define PLACEHOLDER_ALL_COUNTS "%all"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QEventLoop>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QRegularExpression>
|
||||
#include <QTextDocument>
|
||||
#include <QTimer>
|
||||
|
||||
@ -17,25 +18,26 @@ NetworkFactory::NetworkFactory() {}
|
||||
|
||||
QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html) {
|
||||
QStringList feeds;
|
||||
const QRegExp rx(FEED_REGEX_MATCHER, Qt::CaseInsensitive);
|
||||
const QRegExp rx_href(FEED_HREF_REGEX_MATCHER, Qt::CaseInsensitive);
|
||||
QRegularExpression rx(FEED_REGEX_MATCHER, QRegularExpression::PatternOption::CaseInsensitiveOption);
|
||||
QRegularExpression rx_href(FEED_HREF_REGEX_MATCHER, QRegularExpression::PatternOption::CaseInsensitiveOption);
|
||||
|
||||
for (int pos = 0; (pos = rx.indexIn(html, pos)) != -1; pos += rx.matchedLength()) {
|
||||
QString link_element = html.mid(pos, rx.matchedLength());
|
||||
rx_href.optimize();
|
||||
|
||||
if (rx_href.indexIn(link_element) != -1) {
|
||||
QString href_attribute = rx_href.capturedTexts().at(0);
|
||||
QString feed_link = href_attribute.mid(6, href_attribute.size() - 7);
|
||||
QRegularExpressionMatchIterator it_rx = rx.globalMatch(html);
|
||||
|
||||
if (feed_link.startsWith(QL1S("//"))) {
|
||||
feed_link = QString(URI_SCHEME_HTTP) + feed_link.mid(2);
|
||||
}
|
||||
else if (feed_link.startsWith(QL1C('/'))) {
|
||||
feed_link = url.toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::StripTrailingSlash) + feed_link;
|
||||
}
|
||||
while (it_rx.hasNext()) {
|
||||
QRegularExpressionMatch mat_tx = it_rx.next();
|
||||
QString link_tag = mat_tx.captured();
|
||||
QString feed_link = rx_href.match(link_tag).captured(1);
|
||||
|
||||
feeds.append(feed_link);
|
||||
if (feed_link.startsWith(QL1S("//"))) {
|
||||
feed_link = QString(URI_SCHEME_HTTP) + feed_link.mid(2);
|
||||
}
|
||||
else if (feed_link.startsWith(QL1C('/'))) {
|
||||
feed_link = url.toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::StripTrailingSlash) + feed_link;
|
||||
}
|
||||
|
||||
feeds.append(feed_link);
|
||||
}
|
||||
|
||||
return feeds;
|
||||
|
@ -538,12 +538,13 @@ bool ServiceRoot::onAfterMessagesDelete(RootItem* selected_item, const QList<Mes
|
||||
|
||||
// User deleted some messages he selected in message list.
|
||||
selected_item->updateCounts(true);
|
||||
RecycleBin* bin = recycleBin();
|
||||
|
||||
if (selected_item->kind() == RootItemKind::Bin) {
|
||||
itemChanged(QList<RootItem*>() << bin);
|
||||
itemChanged(QList<RootItem*>() << selected_item);
|
||||
}
|
||||
else {
|
||||
RecycleBin* bin = recycleBin();
|
||||
|
||||
if (bin != nullptr) {
|
||||
bin->updateCounts(true);
|
||||
itemChanged(QList<RootItem*>() << selected_item << bin);
|
||||
|
@ -155,23 +155,21 @@ QPair<StandardFeed*, QNetworkReply::NetworkError> StandardFeed::guessFeed(const
|
||||
result.second = network_result.first;
|
||||
|
||||
if (result.second == QNetworkReply::NoError || !feed_contents.isEmpty()) {
|
||||
if (result.first == nullptr) {
|
||||
result.first = new StandardFeed();
|
||||
}
|
||||
|
||||
// Feed XML was obtained, now we need to try to guess
|
||||
// its encoding before we can read further data.
|
||||
QString xml_schema_encoding;
|
||||
QString xml_contents_encoded;
|
||||
QRegExp encoding_rexp(QSL("encoding=\"[^\"]\\S+\""));
|
||||
QString enc = QRegularExpression(QSL("encoding=\"([A-Z0-9\\-]+)\""),
|
||||
QRegularExpression::PatternOption::CaseInsensitiveOption).match(feed_contents).captured(1);
|
||||
|
||||
if (encoding_rexp.indexIn(feed_contents) != -1 &&
|
||||
!(xml_schema_encoding = encoding_rexp.cap(0)).isEmpty()) {
|
||||
if (!enc.isEmpty()) {
|
||||
// Some "encoding" attribute was found get the encoding
|
||||
// out of it.
|
||||
encoding_rexp.setPattern(QSL("[^\"]\\S+[^\"]"));
|
||||
encoding_rexp.indexIn(xml_schema_encoding, 9);
|
||||
xml_schema_encoding = encoding_rexp.cap(0);
|
||||
}
|
||||
|
||||
if (result.first == nullptr) {
|
||||
result.first = new StandardFeed();
|
||||
xml_schema_encoding = enc;
|
||||
}
|
||||
|
||||
QTextCodec* custom_codec = QTextCodec::codecForName(xml_schema_encoding.toLocal8Bit());
|
||||
|
Loading…
x
Reference in New Issue
Block a user