2014-02-26 07:41:40 +01:00
|
|
|
// This file is part of RSS Guard.
|
|
|
|
//
|
2016-01-13 09:57:05 +01:00
|
|
|
// Copyright (C) 2011-2016 by Martin Rotter <rotter.martinos@gmail.com>
|
2014-02-26 07:41:40 +01:00
|
|
|
//
|
|
|
|
// RSS Guard is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// RSS Guard is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2013-10-13 16:12:15 +02:00
|
|
|
#ifndef MESSAGESVIEW_H
|
|
|
|
#define MESSAGESVIEW_H
|
|
|
|
|
2013-11-17 16:41:44 +01:00
|
|
|
#include "core/messagesmodel.h"
|
|
|
|
|
2015-12-11 09:58:13 +01:00
|
|
|
#include "services/abstract/rootitem.h"
|
2015-05-02 19:32:23 +02:00
|
|
|
|
2013-12-21 21:08:52 +01:00
|
|
|
#include <QTreeView>
|
2014-01-15 21:51:54 +01:00
|
|
|
#include <QHeaderView>
|
2013-12-21 21:08:52 +01:00
|
|
|
|
2013-10-13 16:12:15 +02:00
|
|
|
|
2013-11-15 22:09:38 +01:00
|
|
|
class MessagesProxyModel;
|
|
|
|
|
2013-10-13 16:12:15 +02:00
|
|
|
class MessagesView : public QTreeView {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2013-11-15 22:09:38 +01:00
|
|
|
// Constructors and destructors.
|
2013-10-13 16:12:15 +02:00
|
|
|
explicit MessagesView(QWidget *parent = 0);
|
|
|
|
virtual ~MessagesView();
|
2013-11-15 22:09:38 +01:00
|
|
|
|
2014-11-04 20:09:16 +01:00
|
|
|
void setSortingEnabled(bool enable);
|
2013-11-19 21:25:55 +01:00
|
|
|
|
2013-11-18 21:45:15 +01:00
|
|
|
// Model accessors.
|
2016-01-13 09:57:05 +01:00
|
|
|
inline MessagesProxyModel *model() const {
|
2014-01-15 21:51:54 +01:00
|
|
|
return m_proxyModel;
|
|
|
|
}
|
|
|
|
|
2016-01-13 09:57:05 +01:00
|
|
|
inline MessagesModel *sourceModel() const {
|
2014-01-15 21:51:54 +01:00
|
|
|
return m_sourceModel;
|
|
|
|
}
|
2013-11-17 20:42:02 +01:00
|
|
|
|
2013-11-20 21:54:30 +01:00
|
|
|
public slots:
|
2014-09-17 12:21:19 +02:00
|
|
|
void keyboardSearch(const QString &search);
|
2014-09-17 10:00:04 +02:00
|
|
|
|
2013-12-28 11:22:00 +01:00
|
|
|
// Called after data got changed externally
|
|
|
|
// and it needs to be reloaded to the view.
|
|
|
|
// If "mark_current_index_read" is 0, then message with
|
|
|
|
// "current" index is not marked as read.
|
2015-05-13 07:09:28 +02:00
|
|
|
void reloadSelections(bool mark_current_index_read);
|
2013-12-28 11:22:00 +01:00
|
|
|
|
2013-12-22 18:47:00 +01:00
|
|
|
// Loads un-deleted messages from selected feeds.
|
2015-12-10 11:30:10 +01:00
|
|
|
void loadItem(RootItem *item);
|
2013-12-16 20:49:42 +01:00
|
|
|
|
2016-01-21 10:53:15 +01:00
|
|
|
void sortByColumn(int column, Qt::SortOrder order);
|
|
|
|
|
2013-11-20 21:54:30 +01:00
|
|
|
// Message manipulators.
|
2015-06-11 13:48:38 +02:00
|
|
|
void openSelectedSourceMessagesExternally();
|
2013-12-07 20:33:41 +01:00
|
|
|
void openSelectedSourceMessagesInternally();
|
2015-06-11 13:48:38 +02:00
|
|
|
void openSelectedSourceMessagesInternallyNoNewTab();
|
2013-12-08 14:02:28 +01:00
|
|
|
void openSelectedMessagesInternally();
|
2015-05-12 09:48:22 +02:00
|
|
|
void sendSelectedMessageViaEmail();
|
2013-12-08 14:02:28 +01:00
|
|
|
|
2013-12-19 11:35:17 +01:00
|
|
|
// Works with SELECTED messages only.
|
2015-11-13 08:44:37 +01:00
|
|
|
void setSelectedMessagesReadStatus(RootItem::ReadStatus read);
|
2013-12-08 14:02:28 +01:00
|
|
|
void markSelectedMessagesRead();
|
|
|
|
void markSelectedMessagesUnread();
|
2013-12-03 21:39:26 +01:00
|
|
|
void switchSelectedMessagesImportance();
|
2014-09-20 17:13:12 +02:00
|
|
|
void deleteSelectedMessages();
|
2015-11-23 19:31:03 +01:00
|
|
|
void restoreSelectedMessages();
|
2013-11-24 14:44:17 +01:00
|
|
|
|
2014-02-14 16:51:10 +01:00
|
|
|
void selectNextItem();
|
|
|
|
void selectPreviousItem();
|
2015-11-25 11:58:35 +01:00
|
|
|
void selectNextUnreadItem();
|
2014-02-14 16:51:10 +01:00
|
|
|
|
2014-04-09 08:26:33 +02:00
|
|
|
// Searchs the visible message according to given pattern.
|
|
|
|
void searchMessages(const QString &pattern);
|
2015-11-13 11:18:47 +01:00
|
|
|
void filterMessages(MessagesModel::MessageHighlighter filter);
|
2014-04-07 14:24:28 +02:00
|
|
|
|
2014-11-04 20:09:16 +01:00
|
|
|
private slots:
|
2013-12-08 14:02:28 +01:00
|
|
|
// Marks given indexes as selected.
|
2013-12-04 21:03:09 +01:00
|
|
|
void reselectIndexes(const QModelIndexList &indexes);
|
|
|
|
|
2013-12-26 19:57:14 +01:00
|
|
|
// Changes resize mode for all columns.
|
|
|
|
void adjustColumns();
|
|
|
|
|
2014-11-12 16:40:06 +01:00
|
|
|
// Saves current sort state.
|
2014-11-04 20:09:16 +01:00
|
|
|
void saveSortState(int column, Qt::SortOrder order);
|
|
|
|
|
2015-11-13 08:44:37 +01:00
|
|
|
signals:
|
|
|
|
// Link/message openers.
|
|
|
|
void openLinkNewTab(const QString &link);
|
|
|
|
void openLinkMiniBrowser(const QString &link);
|
|
|
|
void openMessagesInNewspaperView(const QList<Message> &messages);
|
|
|
|
|
|
|
|
// Notify others about message selections.
|
|
|
|
void currentMessagesChanged(const QList<Message> &messages);
|
|
|
|
void currentMessagesRemoved();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Creates needed connections.
|
|
|
|
void createConnections();
|
|
|
|
|
2014-02-02 09:48:53 +01:00
|
|
|
// Initializes context menu.
|
2013-12-07 20:33:41 +01:00
|
|
|
void initializeContextMenu();
|
2014-02-02 09:48:53 +01:00
|
|
|
|
|
|
|
// Sets up appearance.
|
2013-11-15 22:09:38 +01:00
|
|
|
void setupAppearance();
|
2013-12-07 20:33:41 +01:00
|
|
|
|
2014-02-02 09:48:53 +01:00
|
|
|
// Event reimplementations.
|
2013-12-07 20:33:41 +01:00
|
|
|
void contextMenuEvent(QContextMenuEvent *event);
|
2013-12-03 21:39:26 +01:00
|
|
|
void mousePressEvent(QMouseEvent *event);
|
2013-11-18 21:45:15 +01:00
|
|
|
void keyPressEvent(QKeyEvent *event);
|
2014-02-17 20:32:45 +01:00
|
|
|
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
2013-11-17 16:41:44 +01:00
|
|
|
|
2013-12-07 20:33:41 +01:00
|
|
|
QMenu *m_contextMenu;
|
|
|
|
|
2013-11-15 22:09:38 +01:00
|
|
|
MessagesProxyModel *m_proxyModel;
|
2013-11-17 16:41:44 +01:00
|
|
|
MessagesModel *m_sourceModel;
|
2013-12-17 21:26:14 +01:00
|
|
|
|
2013-12-26 19:57:14 +01:00
|
|
|
bool m_columnsAdjusted;
|
2013-12-17 21:26:14 +01:00
|
|
|
bool m_batchUnreadSwitch;
|
2013-10-13 16:12:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MESSAGESVIEW_H
|