Save, work on filters.

This commit is contained in:
Martin Rotter 2020-06-19 14:22:54 +02:00
parent f304d0a910
commit f211810af4
8 changed files with 48 additions and 13 deletions

View File

@ -2,6 +2,7 @@
#include "core/feeddownloader.h"
#include "core/messagefilter.h"
#include "definitions/definitions.h"
#include "services/abstract/cacheforserviceroot.h"
#include "services/abstract/feed.h"
@ -45,7 +46,7 @@ void FeedDownloader::updateAvailableFeeds() {
}
}
void FeedDownloader::updateFeeds(const QList<Feed*>& feeds) {
void FeedDownloader::updateFeeds(const QList<Feed*>& feeds, const QList<MessageFilter*>& msg_filters) {
QMutexLocker locker(m_mutex);
if (feeds.isEmpty()) {

View File

@ -10,9 +10,7 @@
#include "core/message.h"
class Feed;
class QThreadPool;
class MessageFilter;
class QMutex;
// Represents results of batch feed updates.
@ -43,7 +41,7 @@ class FeedDownloader : public QObject {
bool isUpdateRunning() const;
public slots:
void updateFeeds(const QList<Feed*>& feeds);
void updateFeeds(const QList<Feed*>& feeds, const QList<MessageFilter*>& msg_filters);
void stopRunningUpdate();
signals:
@ -58,7 +56,6 @@ class FeedDownloader : public QObject {
QList<Feed*> m_feeds;
QMutex* m_mutex;
QThreadPool* m_threadPool;
FeedDownloadResults m_results;
int m_feedsUpdated;
int m_feedsOriginalCount;

View File

@ -0,0 +1,9 @@
// For license of this file, see <project-root-folder>/LICENSE.md.
#include "core/messagefilter.h"
MessageFilter::MessageFilter(QObject* parent) : QObject(parent) {}
FilteringAction MessageFilter::filterMessage() {
return FilteringAction::Accept;
}

View File

@ -0,0 +1,25 @@
// For license of this file, see <project-root-folder>/LICENSE.md.
#ifndef MESSAGEFILTER_H
#define MESSAGEFILTER_H
#include <QObject>
#include "core/message.h"
// Class which represents one message filter.
class MessageFilter : public QObject {
Q_OBJECT
public:
explicit MessageFilter(QObject* parent = nullptr);
FilteringAction filterMessage();
private:
int m_id;
QString m_name;
QString m_script;
};
#endif // MESSAGEFILTER_H

View File

@ -33,6 +33,7 @@ HEADERS += core/feeddownloader.h \
core/feedsmodel.h \
core/feedsproxymodel.h \
core/message.h \
core/messagefilter.h \
core/messagesmodel.h \
core/messagesmodelcache.h \
core/messagesmodelsqllayer.h \
@ -176,6 +177,7 @@ SOURCES += core/feeddownloader.cpp \
core/feedsmodel.cpp \
core/feedsproxymodel.cpp \
core/message.cpp \
core/messagefilter.cpp \
core/messagesmodel.cpp \
core/messagesmodelcache.cpp \
core/messagesmodelsqllayer.cpp \

View File

@ -516,6 +516,7 @@ QString DatabaseFactory::obtainBeginTransactionSql() const {
void DatabaseFactory::sqliteSaveMemoryDatabase() {
qDebug("Saving in-memory working database back to persistent file-based storage.");
QSqlDatabase database = sqliteConnection(objectName(), DesiredType::StrictlyInMemory);
QSqlDatabase file_database = sqliteConnection(objectName(), DesiredType::StrictlyFileBased);
QSqlQuery copy_contents(database);

View File

@ -44,6 +44,7 @@ FeedReader::FeedReader(QObject* parent)
FeedReader::~FeedReader() {
qDebug("Destroying FeedReader instance.");
qDeleteAll(m_feedServices);
qDeleteAll(m_messageFilters);
}
QList<ServiceEntryPoint*> FeedReader::feedServices() {
@ -74,6 +75,7 @@ void FeedReader::updateFeeds(const QList<Feed*>& feeds) {
m_feedDownloader = new FeedDownloader();
// Downloader setup.
qRegisterMetaType<QList<MessageFilter*>>("QList<MessageFilter*>");
qRegisterMetaType<QList<Feed*>>("QList<Feed*>");
m_feedDownloader->moveToThread(m_feedDownloaderThread);
@ -89,7 +91,9 @@ void FeedReader::updateFeeds(const QList<Feed*>& feeds) {
}
QMetaObject::invokeMethod(m_feedDownloader, "updateFeeds",
Qt::ConnectionType::QueuedConnection, Q_ARG(QList<Feed*>, feeds));
Qt::ConnectionType::QueuedConnection,
Q_ARG(QList<Feed*>, feeds),
Q_ARG(QList<MessageFilter*>, m_messageFilters));
}
void FeedReader::updateAutoUpdateStatus() {

View File

@ -6,22 +6,17 @@
#include <QObject>
#include "core/feeddownloader.h"
#include "core/messagefilter.h"
#include "services/abstract/feed.h"
#include <QFutureWatcher>
class FeedsModel;
class MessagesModel;
class MessagesProxyModel;
class FeedsProxyModel;
class ServiceEntryPoint;
class QTimer;
class QThread;
class RSSGUARD_DLLSPEC FeedReader : public QObject {
@ -73,6 +68,7 @@ class RSSGUARD_DLLSPEC FeedReader : public QObject {
private:
QList<ServiceEntryPoint*> m_feedServices;
QList<MessageFilter*> m_messageFilters;
FeedsModel* m_feedsModel;
FeedsProxyModel* m_feedsProxyModel;
MessagesModel* m_messagesModel;