Fixed newspaper handling.
This commit is contained in:
parent
6c12059987
commit
8c20ca7025
@ -148,7 +148,7 @@ message(rssguard: Prefix directory: \"$$PREFIX\".)
|
|||||||
message(rssguard: Build revision: \"$$APP_REVISION\".)
|
message(rssguard: Build revision: \"$$APP_REVISION\".)
|
||||||
message(rssguard: lrelease executable name: \"$$LRELEASE_EXECUTABLE\".)
|
message(rssguard: lrelease executable name: \"$$LRELEASE_EXECUTABLE\".)
|
||||||
|
|
||||||
QT += core gui widgets sql network xml printsupport # webenginewidgets
|
QT += core gui widgets sql network xml printsupport
|
||||||
CONFIG *= c++11 debug_and_release warn_on
|
CONFIG *= c++11 debug_and_release warn_on
|
||||||
DEFINES *= QT_USE_QSTRINGBUILDER QT_USE_FAST_CONCATENATION QT_USE_FAST_OPERATOR_PLUS UNICODE _UNICODE
|
DEFINES *= QT_USE_QSTRINGBUILDER QT_USE_FAST_CONCATENATION QT_USE_FAST_OPERATOR_PLUS UNICODE _UNICODE
|
||||||
VERSION = $$APP_VERSION
|
VERSION = $$APP_VERSION
|
||||||
|
@ -88,19 +88,17 @@ void MessagesModel::loadMessages(RootItem *item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesModel::setMessageImportantById(int id, RootItem::Importance important) {
|
bool MessagesModel::setMessageImportantById(int id, RootItem::Importance important) {
|
||||||
Q_UNUSED(important)
|
|
||||||
|
|
||||||
for (int i = 0; i < rowCount(); i++) {
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
int found_id = data(i, MSG_DB_ID_INDEX, Qt::EditRole).toInt();
|
int found_id = data(i, MSG_DB_ID_INDEX, Qt::EditRole).toInt();
|
||||||
|
|
||||||
if (found_id == id) {
|
if (found_id == id) {
|
||||||
bool result;
|
bool set = setData(index(i, MSG_DB_IMPORTANT_INDEX), important);
|
||||||
|
|
||||||
if (result = switchMessageImportance(i)) {
|
if (set) {
|
||||||
emit dataChanged(index(i, 0), index(i, MSG_DB_CUSTOM_HASH_INDEX));
|
emit dataChanged(index(i, 0), index(i, MSG_DB_CUSTOM_HASH_INDEX));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,13 +285,13 @@ bool MessagesModel::setMessageReadById(int id, RootItem::ReadStatus read) {
|
|||||||
int found_id = data(i, MSG_DB_ID_INDEX, Qt::EditRole).toInt();
|
int found_id = data(i, MSG_DB_ID_INDEX, Qt::EditRole).toInt();
|
||||||
|
|
||||||
if (found_id == id) {
|
if (found_id == id) {
|
||||||
bool result;
|
bool set = setData(index(i, MSG_DB_READ_INDEX), read);
|
||||||
|
|
||||||
if (result = setMessageRead(i, read)) {
|
if (set) {
|
||||||
emit dataChanged(index(i, 0), index(i, MSG_DB_CUSTOM_HASH_INDEX));
|
emit dataChanged(index(i, 0), index(i, MSG_DB_CUSTOM_HASH_INDEX));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,25 +137,51 @@ void MessagePreviewer::loadMessage(const Message &message, RootItem *root) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagePreviewer::markMessageAsRead() {
|
void MessagePreviewer::markMessageAsRead() {
|
||||||
if (!m_root.isNull()) {
|
markMessageAsReadUnread(RootItem::Read);
|
||||||
emit markMessageRead(m_message.m_id, RootItem::Read);
|
|
||||||
m_message.m_isRead = true;
|
|
||||||
updateButtons();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagePreviewer::markMessageAsUnread() {
|
void MessagePreviewer::markMessageAsUnread() {
|
||||||
|
markMessageAsReadUnread(RootItem::Unread);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessagePreviewer::markMessageAsReadUnread(RootItem::ReadStatus read) {
|
||||||
if (!m_root.isNull()) {
|
if (!m_root.isNull()) {
|
||||||
emit markMessageRead(m_message.m_id, RootItem::Unread);
|
if (m_root->getParentServiceRoot()->onBeforeSetMessagesRead(m_root.data(),
|
||||||
m_message.m_isRead = false;
|
QList<Message>() << m_message,
|
||||||
updateButtons();
|
read)) {
|
||||||
|
DatabaseQueries::markMessagesReadUnread(qApp->database()->connection(objectName(), DatabaseFactory::FromSettings),
|
||||||
|
QStringList() << QString::number(m_message.m_id),
|
||||||
|
read);
|
||||||
|
m_root->getParentServiceRoot()->onAfterSetMessagesRead(m_root.data(),
|
||||||
|
QList<Message>() << m_message,
|
||||||
|
read);
|
||||||
|
m_message.m_isRead = true;
|
||||||
|
|
||||||
|
emit markMessageRead(m_message.m_id, read);
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagePreviewer::switchMessageImportance(bool checked) {
|
void MessagePreviewer::switchMessageImportance(bool checked) {
|
||||||
if (!m_root.isNull()) {
|
if (!m_root.isNull()) {
|
||||||
emit markMessageImportant(m_message.m_id, checked ? RootItem::Important : RootItem::NotImportant);
|
if (m_root->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_root.data(),
|
||||||
m_message.m_isImportant = checked;
|
QList<ImportanceChange>() << ImportanceChange(m_message,
|
||||||
|
m_message.m_isImportant ?
|
||||||
|
RootItem::NotImportant :
|
||||||
|
RootItem::Important))) {
|
||||||
|
DatabaseQueries::switchMessagesImportance(qApp->database()->connection(objectName(), DatabaseFactory::FromSettings),
|
||||||
|
QStringList() << QString::number(m_message.m_id));
|
||||||
|
|
||||||
|
m_root->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_root.data(),
|
||||||
|
QList<ImportanceChange>() << ImportanceChange(m_message,
|
||||||
|
m_message.m_isImportant ?
|
||||||
|
RootItem::NotImportant :
|
||||||
|
RootItem::Important));
|
||||||
|
|
||||||
|
emit markMessageImportant(m_message.m_id, checked ? RootItem::Important : RootItem::NotImportant);
|
||||||
|
m_message.m_isImportant = checked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ class MessagePreviewer : public QWidget {
|
|||||||
private slots:
|
private slots:
|
||||||
void markMessageAsRead();
|
void markMessageAsRead();
|
||||||
void markMessageAsUnread();
|
void markMessageAsUnread();
|
||||||
|
void markMessageAsReadUnread(RootItem::ReadStatus read);
|
||||||
void switchMessageImportance(bool checked);
|
void switchMessageImportance(bool checked);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -262,8 +262,19 @@ void WebBrowser::markMessageAsRead(int id, bool read) {
|
|||||||
if (!m_root.isNull()) {
|
if (!m_root.isNull()) {
|
||||||
Message *msg = findMessage(id);
|
Message *msg = findMessage(id);
|
||||||
|
|
||||||
emit markMessageRead(msg->m_id, read ? RootItem::Read : RootItem::Unread);
|
if (msg != nullptr && m_root->getParentServiceRoot()->onBeforeSetMessagesRead(m_root.data(),
|
||||||
msg->m_isRead = read ? RootItem::Read : RootItem::Unread;
|
QList<Message>() << *msg,
|
||||||
|
read ? RootItem::Read : RootItem::Unread)) {
|
||||||
|
DatabaseQueries::markMessagesReadUnread(qApp->database()->connection(objectName(), DatabaseFactory::FromSettings),
|
||||||
|
QStringList() << QString::number(msg->m_id),
|
||||||
|
read ? RootItem::Read : RootItem::Unread);
|
||||||
|
m_root->getParentServiceRoot()->onAfterSetMessagesRead(m_root.data(),
|
||||||
|
QList<Message>() << *msg,
|
||||||
|
read ? RootItem::Read : RootItem::Unread);
|
||||||
|
|
||||||
|
emit markMessageRead(msg->m_id, read ? RootItem::Read : RootItem::Unread);
|
||||||
|
msg->m_isRead = read ? RootItem::Read : RootItem::Unread;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,8 +282,23 @@ void WebBrowser::switchMessageImportance(int id, bool checked) {
|
|||||||
if (!m_root.isNull()) {
|
if (!m_root.isNull()) {
|
||||||
Message *msg = findMessage(id);
|
Message *msg = findMessage(id);
|
||||||
|
|
||||||
emit markMessageImportant(msg->m_id, msg->m_isImportant ? RootItem::NotImportant : RootItem::Important);
|
if (msg != nullptr && m_root->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_root.data(),
|
||||||
msg->m_isImportant = checked;
|
QList<ImportanceChange>() << ImportanceChange(*msg,
|
||||||
|
msg->m_isImportant ?
|
||||||
|
RootItem::NotImportant :
|
||||||
|
RootItem::Important))) {
|
||||||
|
DatabaseQueries::switchMessagesImportance(qApp->database()->connection(objectName(), DatabaseFactory::FromSettings),
|
||||||
|
QStringList() << QString::number(msg->m_id));
|
||||||
|
|
||||||
|
m_root->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_root.data(),
|
||||||
|
QList<ImportanceChange>() << ImportanceChange(*msg,
|
||||||
|
msg->m_isImportant ?
|
||||||
|
RootItem::NotImportant :
|
||||||
|
RootItem::Important));
|
||||||
|
|
||||||
|
emit markMessageImportant(msg->m_id, msg->m_isImportant ? RootItem::NotImportant : RootItem::Important);
|
||||||
|
msg->m_isImportant = checked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user