mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-01 18:06:51 +01:00
Remove recycle bin for gmail - has to have labels support, fix error when sorting according to has_enclosures column.
This commit is contained in:
parent
d8e47a19e6
commit
1c364cb22a
@ -12,6 +12,7 @@
|
||||
#include "services/abstract/recyclebin.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
|
||||
#include <QSqlError>
|
||||
#include <QSqlField>
|
||||
|
||||
MessagesModel::MessagesModel(QObject* parent)
|
||||
@ -51,6 +52,10 @@ void MessagesModel::repopulate() {
|
||||
m_cache->clear();
|
||||
setQuery(selectStatement(), m_db);
|
||||
|
||||
if (lastError().isValid()) {
|
||||
qCritical() << "Error when setting new msg view query:" << lastError().text();
|
||||
}
|
||||
|
||||
while (canFetchMore()) {
|
||||
fetchMore();
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ MessagesModelSqlLayer::MessagesModelSqlLayer()
|
||||
: m_filter(QSL(DEFAULT_SQL_MESSAGES_FILTER)), m_fieldNames(QMap<int, QString>()),
|
||||
m_sortColumns(QList<int>()), m_sortOrders(QList<Qt::SortOrder>()) {
|
||||
m_db = qApp->database()->connection(QSL("MessagesModel"), DatabaseFactory::FromSettings);
|
||||
|
||||
// Used is <x>: SELECT <x1>, <x2> FROM ....;
|
||||
m_fieldNames[MSG_DB_ID_INDEX] = "Messages.id";
|
||||
m_fieldNames[MSG_DB_READ_INDEX] = "Messages.is_read";
|
||||
m_fieldNames[MSG_DB_DELETED_INDEX] = "Messages.is_deleted";
|
||||
@ -26,6 +28,25 @@ MessagesModelSqlLayer::MessagesModelSqlLayer()
|
||||
m_fieldNames[MSG_DB_CUSTOM_HASH_INDEX] = "Messages.custom_hash";
|
||||
m_fieldNames[MSG_DB_FEED_CUSTOM_ID_INDEX] = "Messages.feed";
|
||||
m_fieldNames[MSG_DB_HAS_ENCLOSURES] = "CASE WHEN length(Messages.enclosures) > 10 THEN 'true' ELSE 'false' END AS has_enclosures";
|
||||
|
||||
// Used is <x>: SELECT ... FROM ... ORDER BY <x1> DESC, <x2> ASC;
|
||||
m_orderByNames[MSG_DB_ID_INDEX] = "Messages.id";
|
||||
m_orderByNames[MSG_DB_READ_INDEX] = "Messages.is_read";
|
||||
m_orderByNames[MSG_DB_DELETED_INDEX] = "Messages.is_deleted";
|
||||
m_orderByNames[MSG_DB_IMPORTANT_INDEX] = "Messages.is_important";
|
||||
m_orderByNames[MSG_DB_FEED_TITLE_INDEX] = "Feeds.title";
|
||||
m_orderByNames[MSG_DB_TITLE_INDEX] = "Messages.title";
|
||||
m_orderByNames[MSG_DB_URL_INDEX] = "Messages.url";
|
||||
m_orderByNames[MSG_DB_AUTHOR_INDEX] = "Messages.author";
|
||||
m_orderByNames[MSG_DB_DCREATED_INDEX] = "Messages.date_created";
|
||||
m_orderByNames[MSG_DB_CONTENTS_INDEX] = "Messages.contents";
|
||||
m_orderByNames[MSG_DB_PDELETED_INDEX] = "Messages.is_pdeleted";
|
||||
m_orderByNames[MSG_DB_ENCLOSURES_INDEX] = "Messages.enclosures";
|
||||
m_orderByNames[MSG_DB_ACCOUNT_ID_INDEX] = "Messages.account_id";
|
||||
m_orderByNames[MSG_DB_CUSTOM_ID_INDEX] = "Messages.custom_id";
|
||||
m_orderByNames[MSG_DB_CUSTOM_HASH_INDEX] = "Messages.custom_hash";
|
||||
m_orderByNames[MSG_DB_FEED_CUSTOM_ID_INDEX] = "Messages.feed";
|
||||
m_orderByNames[MSG_DB_HAS_ENCLOSURES] = "has_enclosures";
|
||||
}
|
||||
|
||||
void MessagesModelSqlLayer::addSortState(int column, Qt::SortOrder order) {
|
||||
@ -79,7 +100,7 @@ QString MessagesModelSqlLayer::orderByClause() const {
|
||||
QStringList sorts;
|
||||
|
||||
for (int i = 0; i < m_sortColumns.size(); i++) {
|
||||
QString field_name(m_fieldNames[m_sortColumns[i]]);
|
||||
QString field_name(m_orderByNames[m_sortColumns[i]]);
|
||||
|
||||
sorts.append(field_name + (m_sortOrders[i] == Qt::AscendingOrder ? QSL(" ASC") : QSL(" DESC")));
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class MessagesModelSqlLayer {
|
||||
// They are always same length. Most important sort column/order
|
||||
// are located at the start of lists;
|
||||
QMap<int, QString> m_fieldNames;
|
||||
QMap<int, QString> m_orderByNames;
|
||||
QList<int> m_sortColumns;
|
||||
QList<Qt::SortOrder> m_sortOrders;
|
||||
};
|
||||
|
@ -46,7 +46,7 @@
|
||||
#define MESSAGES_VIEW_DEFAULT_COL 170
|
||||
#define MESSAGES_VIEW_MINIMUM_COL 16
|
||||
#define FEEDS_VIEW_COLUMN_COUNT 2
|
||||
#define FEED_DOWNLOADER_MAX_THREADS 6
|
||||
#define FEED_DOWNLOADER_MAX_THREADS 3
|
||||
#define DEFAULT_DAYS_TO_DELETE_MSG 14
|
||||
#define ELLIPSIS_LENGTH 3
|
||||
#define MIN_CATEGORY_NAME_LENGTH 1
|
||||
|
@ -112,8 +112,12 @@ void FeedMessageViewer::loadSize() {
|
||||
m_feedSplitter->restoreState(QByteArray::fromBase64(settings->value(GROUP(GUI), SETTING(GUI::SplitterFeeds)).toString().toLocal8Bit()));
|
||||
m_messageSplitter->restoreState(QByteArray::fromBase64(settings->value(GROUP(GUI),
|
||||
SETTING(GUI::SplitterMessages)).toString().toLocal8Bit()));
|
||||
m_messagesView->header()->restoreState(QByteArray::fromBase64(settings->value(GROUP(GUI),
|
||||
SETTING(GUI::MessageViewState)).toString().toLocal8Bit()));
|
||||
|
||||
QString settings_msg_header = settings->value(GROUP(GUI), SETTING(GUI::MessageViewState)).toString();
|
||||
|
||||
if (!settings_msg_header.isEmpty()) {
|
||||
m_messagesView->header()->restoreState(QByteArray::fromBase64(settings_msg_header.toLocal8Bit()));
|
||||
}
|
||||
}
|
||||
|
||||
void FeedMessageViewer::loadMessageViewerFonts() {
|
||||
|
@ -612,7 +612,8 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
|
||||
|
||||
if (query_insert.exec() && query_insert.numRowsAffected() == 1) {
|
||||
updated_messages++;
|
||||
qDebug("Added new message '%s' to DB.", qPrintable(message.m_title));
|
||||
|
||||
//qDebug("Added new message '%s' to DB.", qPrintable(message.m_title));
|
||||
}
|
||||
else if (query_insert.lastError().isValid()) {
|
||||
qWarning("Failed to insert message to DB: '%s' - message title is '%s'.",
|
||||
|
@ -128,7 +128,9 @@ void FeedReader::updateAllFeeds() {
|
||||
|
||||
void FeedReader::stopRunningFeedUpdate() {
|
||||
if (m_feedDownloader != nullptr) {
|
||||
QMetaObject::invokeMethod(m_feedDownloader, "stopRunningUpdate");
|
||||
m_feedDownloader->stopRunningUpdate();
|
||||
|
||||
//QMetaObject::invokeMethod(m_feedDownloader, "stopRunningUpdate");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,6 +267,10 @@ void ServiceRoot::restoreCustomFeedsData(const QMap<QString, QVariant>& data, co
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceRoot::setRecycleBin(RecycleBin* recycle_bin) {
|
||||
m_recycleBin = recycle_bin;
|
||||
}
|
||||
|
||||
void ServiceRoot::syncIn() {
|
||||
QIcon original_icon = icon();
|
||||
|
||||
|
@ -32,7 +32,11 @@ class ServiceRoot : public RootItem {
|
||||
void updateCounts(bool including_total_count);
|
||||
bool deleteViaGui();
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
|
||||
virtual RecycleBin* recycleBin() const;
|
||||
|
||||
void setRecycleBin(RecycleBin* recycle_bin);
|
||||
|
||||
virtual bool downloadAttachmentOnMyOwn(const QUrl& url) const;
|
||||
|
||||
QList<Message> undeletedMessages() const;
|
||||
|
@ -28,6 +28,9 @@ GmailServiceRoot::GmailServiceRoot(GmailNetworkFactory* network, RootItem* paren
|
||||
|
||||
m_network->setService(this);
|
||||
setIcon(GmailEntryPoint().icon());
|
||||
|
||||
recycleBin()->deleteLater();
|
||||
setRecycleBin(nullptr);
|
||||
}
|
||||
|
||||
GmailServiceRoot::~GmailServiceRoot() {}
|
||||
@ -70,7 +73,6 @@ void GmailServiceRoot::loadFromDatabase() {
|
||||
}
|
||||
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(recycleBin());
|
||||
updateCounts(true);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user