mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-31 09:34:52 +01:00
Enable msg status change from previewer.
This commit is contained in:
parent
27d892cb71
commit
d7bcf3c3fc
@ -243,7 +243,9 @@ void FeedMessageViewer::createConnections() {
|
||||
connect(m_messagesView, SIGNAL(currentMessageChanged(Message,RootItem*)), m_messagesBrowser, SLOT(loadMessage(Message,RootItem*)));
|
||||
connect(m_messagesView, SIGNAL(currentMessageRemoved()), this, SLOT(updateMessageButtonsAvailability()));
|
||||
connect(m_messagesView, SIGNAL(currentMessageChanged(Message,RootItem*)), this, SLOT(updateMessageButtonsAvailability()));
|
||||
|
||||
connect(m_messagesBrowser, SIGNAL(requestMessageListReload(bool)), m_messagesView, SLOT(reloadSelections(bool)));
|
||||
|
||||
|
||||
connect(m_feedsView, SIGNAL(itemSelected(RootItem*)), this, SLOT(updateFeedButtonsAvailability()));
|
||||
connect(qApp->feedUpdateLock(), SIGNAL(locked()), this, SLOT(updateFeedButtonsAvailability()));
|
||||
connect(qApp->feedUpdateLock(), SIGNAL(unlocked()), this, SLOT(updateFeedButtonsAvailability()));
|
||||
|
@ -21,9 +21,11 @@
|
||||
#include "network-web/webfactory.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
|
||||
#include <QScrollBar>
|
||||
#include <QToolBar>
|
||||
#include <QSqlQuery>
|
||||
|
||||
|
||||
MessagePreviewer::MessagePreviewer(QWidget *parent) : QWidget(parent),
|
||||
@ -100,15 +102,61 @@ void MessagePreviewer::loadMessage(const Message &message, RootItem *root) {
|
||||
}
|
||||
|
||||
void MessagePreviewer::markMessageAsRead() {
|
||||
if (!m_root.isNull()) {
|
||||
if (m_root->getParentServiceRoot()->onBeforeSetMessagesRead(m_root.data(),
|
||||
QList<Message>() << m_message,
|
||||
RootItem::Read)) {
|
||||
|
||||
// TODO: upravit v db.
|
||||
QSqlQuery query_read_msg(qApp->database()->connection(objectName(), DatabaseFactory::FromSettings));
|
||||
query_read_msg.setForwardOnly(true);
|
||||
|
||||
query_read_msg.prepare(QSL("UPDATE Messages SET is_read = :read WHERE id = :id;"));
|
||||
query_read_msg.bindValue(QSL(":id"), m_message.m_id);
|
||||
query_read_msg.bindValue(QSL(":read"), 1);
|
||||
query_read_msg.exec();
|
||||
|
||||
m_root->getParentServiceRoot()->onAfterSetMessagesRead(m_root.data(),
|
||||
QList<Message>() << m_message,
|
||||
RootItem::Read);
|
||||
|
||||
emit requestMessageListReload(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePreviewer::markMessageAsUnread() {
|
||||
if (!m_root.isNull()) {
|
||||
if (m_root->getParentServiceRoot()->onBeforeSetMessagesRead(m_root.data(),
|
||||
QList<Message>() << m_message,
|
||||
RootItem::Unread)) {
|
||||
|
||||
// TODO: upravit v db.
|
||||
|
||||
m_root->getParentServiceRoot()->onAfterSetMessagesRead(m_root.data(),
|
||||
QList<Message>() << m_message,
|
||||
RootItem::Unread);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePreviewer::switchMessageImportance(bool checked) {
|
||||
if (!m_root.isNull()) {
|
||||
if (m_root->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_root.data(),
|
||||
QList<ImportanceChange>() << ImportanceChange(m_message,
|
||||
m_message.m_isImportant ?
|
||||
RootItem::NotImportant :
|
||||
RootItem::Important))) {
|
||||
|
||||
// TODO: upravit v db.
|
||||
|
||||
m_root->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_root.data(),
|
||||
QList<ImportanceChange>() << ImportanceChange(m_message,
|
||||
m_message.m_isImportant ?
|
||||
RootItem::NotImportant :
|
||||
RootItem::Important));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString MessagePreviewer::prepareHtmlForMessage(const Message &message) {
|
||||
|
@ -50,6 +50,9 @@ class MessagePreviewer : public QWidget {
|
||||
void markMessageAsUnread();
|
||||
void switchMessageImportance(bool checked);
|
||||
|
||||
signals:
|
||||
void requestMessageListReload(bool mark_current_as_read);
|
||||
|
||||
private:
|
||||
QString prepareHtmlForMessage(const Message &message);
|
||||
|
||||
|
@ -201,6 +201,7 @@ void MessagesView::selectionChanged(const QItemSelection &selected, const QItemS
|
||||
// Set this message as read only if current item
|
||||
// wasn't changed by "mark selected messages unread" action.
|
||||
m_sourceModel->setMessageRead(mapped_current_index.row(), RootItem::Read);
|
||||
message.m_isRead = true;
|
||||
}
|
||||
|
||||
emit currentMessageChanged(message, m_sourceModel->loadedItem());
|
||||
|
Loading…
x
Reference in New Issue
Block a user