Fixed small bug when changing states of msgs via internal viewer.

This commit is contained in:
Martin Rotter 2016-06-20 07:07:59 +02:00
parent 3101d0916f
commit 752d507414
9 changed files with 629 additions and 620 deletions

File diff suppressed because it is too large Load Diff

View File

@ -93,7 +93,13 @@ bool MessagesModel::setMessageImportantById(int id, RootItem::Importance importa
int found_id = data(i, MSG_DB_ID_INDEX, Qt::EditRole).toInt();
if (found_id == id) {
return setData(index(i, MSG_DB_IMPORTANT_INDEX), important);
bool set = setData(index(i, MSG_DB_IMPORTANT_INDEX), important);
if (set) {
emit dataChanged(index(i, 0), index(i, MSG_DB_CUSTOM_HASH_INDEX));
}
return set;
}
}
@ -280,7 +286,13 @@ bool MessagesModel::setMessageReadById(int id, RootItem::ReadStatus read) {
int found_id = data(i, MSG_DB_ID_INDEX, Qt::EditRole).toInt();
if (found_id == id) {
return setData(index(i, MSG_DB_READ_INDEX), read);
bool set = setData(index(i, MSG_DB_READ_INDEX), read);
if (set) {
emit dataChanged(index(i, 0), index(i, MSG_DB_CUSTOM_HASH_INDEX));
}
return set;
}
}

4
src/definitions/definitions.h Normal file → Executable file
View File

@ -79,8 +79,8 @@
#define INTERNAL_URL_MESSAGE "rssguard.message"
#define INTERNAL_URL_BLANK "rssguard.blank"
#define INTERNAL_URL_HOST "rssguard"
#define INTERNAL_URL_MESSAGE_PORT "message"
#define INTERNAL_URL_MESSAGE_HOST "message"
#define INTERNAL_URL_BLANK_HOST "blank"
#define FEED_INITIAL_OPML_PATTERN "feeds-%1.opml"

View File

@ -87,21 +87,21 @@ void WebBrowser::loadMessage(const Message &message, RootItem *root) {
loadMessages(QList<Message>() << message, root);
}
void WebBrowser::receiveMessageStatusChangeRequest(int message_id, MessageBrowserPage::MessageStatusChange change) {
void WebBrowser::receiveMessageStatusChangeRequest(int message_id, WebPage::MessageStatusChange change) {
switch (change) {
case MessageBrowserPage::MarkRead:
case WebPage::MarkRead:
markMessageAsRead(message_id, true);
break;
case MessageBrowserPage::MarkUnread:
case WebPage::MarkUnread:
markMessageAsRead(message_id, false);
break;
case MessageBrowserPage::MarkStarred:
case WebPage::MarkStarred:
switchMessageImportance(message_id, true);
break;
case MessageBrowserPage::MarkUnstarred:
case WebPage::MarkUnstarred:
switchMessageImportance(message_id, false);
break;

View File

@ -49,7 +49,7 @@ class WebBrowser : public TabContent {
void loadMessage(const Message &message, RootItem *root);
private slots:
void receiveMessageStatusChangeRequest(int message_id, MessageBrowserPage::MessageStatusChange change);
void receiveMessageStatusChangeRequest(int message_id, WebPage::MessageStatusChange change);
signals:
void markMessageRead(int id, RootItem::ReadStatus read);

View File

@ -20,17 +20,21 @@
#include "miscellaneous/skinfactory.h"
#include "miscellaneous/application.h"
#include "definitions/definitions.h"
#include "network-web/messagebrowserpage.h"
#include "network-web/webpage.h"
WebViewer::WebViewer(QWidget *parent) : QWebEngineView(parent) {
MessageBrowserPage *page = new MessageBrowserPage(this);
WebPage *page = new WebPage(this);
connect(page, &MessageBrowserPage::messageStatusChangeRequested,
connect(page, &WebPage::messageStatusChangeRequested,
this, &WebViewer::messageStatusChangeRequested);
setPage(page);
}
void WebViewer::displayMessage() {
setHtml(m_messageContents, QUrl(INTERNAL_URL_MESSAGE));
}
void WebViewer::loadMessages(const QList<Message> &messages) {
Skin skin = qApp->skins()->currentSkin();
QString messages_layout;
@ -61,7 +65,7 @@ void WebViewer::loadMessages(const QList<Message> &messages) {
bool previously_enabled = isEnabled();
setEnabled(false);
setHtml(m_messageContents, QUrl(INTERNAL_URL_MESSAGE));
displayMessage();
setEnabled(previously_enabled);
}
@ -72,7 +76,3 @@ void WebViewer::loadMessage(const Message &message) {
void WebViewer::clear() {
setHtml("<!DOCTYPE html><html><body</body></html>", QUrl(INTERNAL_URL_BLANK));
}
void WebViewer::assignMessageContents() {
setHtml(m_messageContents, QUrl(INTERNAL_URL_MESSAGE));
}

8
src/gui/webviewer.h Normal file → Executable file
View File

@ -21,7 +21,7 @@
#include <QWebEngineView>
#include "core/message.h"
#include "network-web/messagebrowserpage.h"
#include "network-web/webpage.h"
class WebViewer : public QWebEngineView {
@ -31,15 +31,13 @@ class WebViewer : public QWebEngineView {
explicit WebViewer(QWidget* parent = 0);
public slots:
void displayMessage();
void loadMessages(const QList<Message> &messages);
void loadMessage(const Message &message);
void clear();
private:
void assignMessageContents();
signals:
void messageStatusChangeRequested(int message_id, MessageBrowserPage::MessageStatusChange change);
void messageStatusChangeRequested(int message_id, WebPage::MessageStatusChange change);
private:
QString m_messageContents;

View File

@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#include "network-web/messagebrowserpage.h"
#include "network-web/webpage.h"
#include "definitions/definitions.h"
#include "gui/webviewer.h"
@ -24,14 +24,14 @@
#include <QString>
MessageBrowserPage::MessageBrowserPage(QObject *parent) : QWebEnginePage(parent) {
WebPage::WebPage(QObject *parent) : QWebEnginePage(parent) {
}
WebViewer *MessageBrowserPage::view() const {
WebViewer *WebPage::view() const {
return qobject_cast<WebViewer*>(QWebEnginePage::view());
}
void MessageBrowserPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg) {
void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg) {
if (securityOrigin.isEmpty()) {
QStringList parts = msg.split(QL1C('-'));
@ -64,6 +64,6 @@ void MessageBrowserPage::javaScriptAlert(const QUrl &securityOrigin, const QStri
}
}
bool MessageBrowserPage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) {
bool WebPage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) {
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
}

View File

@ -15,15 +15,15 @@
// You should have received a copy of the GNU General Public License
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#ifndef MESSAGEBROWSERPAGE_H
#define MESSAGEBROWSERPAGE_H
#ifndef WEBPAGE_H
#define WEBPAGE_H
#include <QWebEnginePage>
class WebViewer;
class MessageBrowserPage : public QWebEnginePage {
class WebPage : public QWebEnginePage {
Q_OBJECT
public:
@ -34,8 +34,7 @@ class MessageBrowserPage : public QWebEnginePage {
MarkUnstarred
};
explicit MessageBrowserPage(QObject *parent = 0);
explicit WebPage(QObject *parent = 0);
WebViewer *view() const;
@ -44,7 +43,7 @@ class MessageBrowserPage : public QWebEnginePage {
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
signals:
void messageStatusChangeRequested(int message_id, MessageBrowserPage::MessageStatusChange change);
void messageStatusChangeRequested(int message_id, WebPage::MessageStatusChange change);
};
#endif // MESSAGEBROWSERPAGE_H
#endif // WEBPAGE_H