rssguard/src/gui/messagesview.h

127 lines
3.8 KiB
C
Raw Normal View History

2014-02-26 07:41:40 +01:00
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2014 by Martin Rotter <rotter.martinos@gmail.com>
//
// 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"
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-01-15 21:51:54 +01:00
inline void setSortingEnabled(bool enable) {
QTreeView::setSortingEnabled(enable);
header()->setSortIndicatorShown(false);
}
2013-11-19 21:25:55 +01:00
2013-11-18 21:45:15 +01:00
// Model accessors.
2014-01-15 21:51:54 +01:00
inline MessagesProxyModel *model() {
return m_proxyModel;
}
inline MessagesModel *sourceModel() {
return m_sourceModel;
}
2013-11-17 20:42:02 +01:00
2014-01-06 21:22:00 +01:00
// Creates needed connections.
void createConnections();
2013-12-24 13:35:58 +01:00
2013-11-20 21:54:30 +01:00
public slots:
void keyboardSearch(const QString &search);
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.
void reloadSelections(int mark_current_index_read);
// Loads un-deleted messages from selected feeds.
void loadFeeds(const QList<int> &feed_ids);
2013-11-20 21:54:30 +01:00
// Message manipulators.
2013-12-08 14:02:28 +01:00
void openSelectedSourceArticlesExternally();
2013-12-07 20:33:41 +01:00
void openSelectedSourceMessagesInternally();
2013-12-08 14:02:28 +01:00
void openSelectedMessagesInternally();
// Works with SELECTED messages only.
2013-12-08 14:02:28 +01:00
void setSelectedMessagesReadStatus(int read);
void markSelectedMessagesRead();
void markSelectedMessagesUnread();
2013-12-03 21:39:26 +01:00
void switchSelectedMessagesImportance();
2014-09-20 17:13:12 +02:00
void deleteSelectedMessages();
2014-09-21 21:12:51 +02:00
void restoreSelectedMessages();
2013-11-24 14:44:17 +01:00
void selectNextItem();
void selectPreviousItem();
2014-04-09 08:26:33 +02:00
// Searchs the visible message according to given pattern.
void searchMessages(const QString &pattern);
2014-09-20 17:13:12 +02:00
void filterMessages(MessagesModel::MessageFilter filter);
2014-04-07 14:24:28 +02:00
2013-12-04 21:03:09 +01:00
protected 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);
// Changes resize mode for all columns.
void adjustColumns();
2013-11-15 22:09:38 +01:00
protected:
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 currentChanged(const QModelIndex &current, const QModelIndex &previous);
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
2013-11-17 16:41:44 +01:00
signals:
2014-02-02 09:48:53 +01:00
// Link/message openers.
2014-01-05 18:43:07 +01:00
void openLinkNewTab(const QString &link);
void openMessagesInNewspaperView(const QList<Message> &messages);
2014-01-03 13:15:05 +01:00
2014-01-05 18:43:07 +01:00
// Notify others about message selections.
void currentMessagesChanged(const QList<Message> &messages);
void currentMessagesRemoved();
2013-11-17 16:41:44 +01:00
2013-11-15 22:09:38 +01:00
private:
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;
bool m_columnsAdjusted;
bool m_batchUnreadSwitch;
2013-10-13 16:12:15 +02:00
};
#endif // MESSAGESVIEW_H