Some performance tweaks etc.
This commit is contained in:
parent
ba3fcde339
commit
45aa2f4ae2
@ -35,6 +35,7 @@ MessagePreviewer::MessagePreviewer(QWidget *parent) : QWidget(parent),
|
|||||||
m_ui->m_txtMessage->viewport()->setAutoFillBackground(true);
|
m_ui->m_txtMessage->viewport()->setAutoFillBackground(true);
|
||||||
|
|
||||||
connect(m_ui->m_txtMessage, &QTextBrowser::anchorClicked, [=](const QUrl &url) {
|
connect(m_ui->m_txtMessage, &QTextBrowser::anchorClicked, [=](const QUrl &url) {
|
||||||
|
if (!url.isEmpty()) {
|
||||||
// User clicked some URL. Open it in external browser or download?
|
// User clicked some URL. Open it in external browser or download?
|
||||||
MessageBox box(qApp->mainForm());
|
MessageBox box(qApp->mainForm());
|
||||||
|
|
||||||
@ -58,6 +59,11 @@ MessagePreviewer::MessagePreviewer(QWidget *parent) : QWidget(parent),
|
|||||||
btn_download->deleteLater();
|
btn_download->deleteLater();
|
||||||
btn_open->deleteLater();
|
btn_open->deleteLater();
|
||||||
btn_cancel->deleteLater();
|
btn_cancel->deleteLater();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox::show(qApp->mainForm(), QMessageBox::Warning, tr("Incorrect link"),
|
||||||
|
tr("Selected hyperlink is invalid."));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
m_toolBar = new QToolBar(this);
|
m_toolBar = new QToolBar(this);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
|
#include "network-web/networkfactory.h"
|
||||||
|
|
||||||
|
|
||||||
MessageTextBrowser::MessageTextBrowser(QWidget *parent) : QTextBrowser(parent) {
|
MessageTextBrowser::MessageTextBrowser(QWidget *parent) : QTextBrowser(parent) {
|
||||||
|
@ -220,20 +220,20 @@ QMap<int,int> DatabaseQueries::getMessageCountsForCategory(QSqlDatabase db, int
|
|||||||
return counts;
|
return counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<int,int> DatabaseQueries::getMessageCountsForAccount(QSqlDatabase db, int account_id,
|
QMap<int, QPair<int,int> > DatabaseQueries::getMessageCountsForAccount(QSqlDatabase db, int account_id,
|
||||||
bool including_total_counts, bool *ok) {
|
bool including_total_counts, bool *ok) {
|
||||||
QMap<int,int> counts;
|
QMap<int, QPair<int,int> > counts;
|
||||||
QSqlQuery q(db);
|
QSqlQuery q(db);
|
||||||
q.setForwardOnly(true);
|
q.setForwardOnly(true);
|
||||||
|
|
||||||
if (including_total_counts) {
|
if (including_total_counts) {
|
||||||
q.prepare("SELECT feed, count(*) FROM Messages "
|
q.prepare("SELECT feed, sum((is_read + 1) % 2), count(*) FROM Messages "
|
||||||
"WHERE feed IN (SELECT custom_id FROM Feeds WHERE account_id = :account_id) AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id "
|
"WHERE feed IN (SELECT custom_id FROM Feeds WHERE account_id = :account_id) AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id "
|
||||||
"GROUP BY feed;");
|
"GROUP BY feed;");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
q.prepare("SELECT feed, count(*) FROM Messages "
|
q.prepare("SELECT feed, sum((is_read + 1) % 2) FROM Messages "
|
||||||
"WHERE feed IN (SELECT custom_id FROM Feeds WHERE account_id = :account_id) AND is_deleted = 0 AND is_pdeleted = 0 AND is_read = 0 AND account_id = :account_id "
|
"WHERE feed IN (SELECT custom_id FROM Feeds WHERE account_id = :account_id) AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id "
|
||||||
"GROUP BY feed;");
|
"GROUP BY feed;");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,9 +242,16 @@ QMap<int,int> DatabaseQueries::getMessageCountsForAccount(QSqlDatabase db, int a
|
|||||||
if (q.exec()) {
|
if (q.exec()) {
|
||||||
while (q.next()) {
|
while (q.next()) {
|
||||||
int feed_id = q.value(0).toInt();
|
int feed_id = q.value(0).toInt();
|
||||||
int new_count = q.value(1).toInt();
|
int unread_count = q.value(1).toInt();
|
||||||
|
|
||||||
counts.insert(feed_id, new_count);
|
if (including_total_counts) {
|
||||||
|
int total_count = q.value(2).toInt();
|
||||||
|
|
||||||
|
counts.insert(feed_id, QPair<int,int>(unread_count, total_count));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
counts.insert(feed_id, QPair<int,int>(unread_count, 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok != NULL) {
|
if (ok != NULL) {
|
||||||
|
@ -43,7 +43,7 @@ class DatabaseQueries {
|
|||||||
static bool purgeRecycleBin(QSqlDatabase db);
|
static bool purgeRecycleBin(QSqlDatabase db);
|
||||||
static QMap<int,int> getMessageCountsForCategory(QSqlDatabase db, int custom_id, int account_id,
|
static QMap<int,int> getMessageCountsForCategory(QSqlDatabase db, int custom_id, int account_id,
|
||||||
bool including_total_counts, bool *ok = NULL);
|
bool including_total_counts, bool *ok = NULL);
|
||||||
static QMap<int,int> getMessageCountsForAccount(QSqlDatabase db, int account_id,
|
static QMap<int,QPair<int,int> > getMessageCountsForAccount(QSqlDatabase db, int account_id,
|
||||||
bool including_total_counts, bool *ok = NULL);
|
bool including_total_counts, bool *ok = NULL);
|
||||||
static int getMessageCountsForFeed(QSqlDatabase db, int feed_custom_id, int account_id,
|
static int getMessageCountsForFeed(QSqlDatabase db, int feed_custom_id, int account_id,
|
||||||
bool including_total_counts, bool *ok = NULL);
|
bool including_total_counts, bool *ok = NULL);
|
||||||
|
@ -93,22 +93,13 @@ void ServiceRoot::updateCounts(bool including_total_count) {
|
|||||||
|
|
||||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||||
bool ok;
|
bool ok;
|
||||||
|
QMap<int,QPair<int,int> > counts = DatabaseQueries::getMessageCountsForAccount(database, accountId(), including_total_count, &ok);
|
||||||
|
|
||||||
|
foreach (Feed *feed, feeds) {
|
||||||
|
feed->setCountOfUnreadMessages(counts.value(feed->customId()).first);
|
||||||
|
|
||||||
if (including_total_count) {
|
if (including_total_count) {
|
||||||
QMap<int,int> counts = DatabaseQueries::getMessageCountsForAccount(database, accountId(), including_total_count, &ok);
|
feed->setCountOfAllMessages(counts.value(feed->customId()).second);
|
||||||
|
|
||||||
if (ok) {
|
|
||||||
foreach (Feed *feed, feeds) {
|
|
||||||
feed->setCountOfAllMessages(counts.value(feed->customId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<int,int> counts = DatabaseQueries::getMessageCountsForAccount(database, accountId(), false, &ok);
|
|
||||||
|
|
||||||
if (ok) {
|
|
||||||
foreach (Feed *feed, feeds) {
|
|
||||||
feed->setCountOfUnreadMessages(counts.value(feed->customId()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user