rssguard/src/gui/messagesview.cpp

506 lines
19 KiB
C++
Raw Normal View History

2014-02-26 07:41:40 +01:00
// This file is part of RSS Guard.
//
2015-01-04 14:12:14 +01:00
// Copyright (C) 2011-2015 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-12-21 21:08:52 +01:00
#include "gui/messagesview.h"
#include "core/messagesproxymodel.h"
#include "core/messagesmodel.h"
2014-03-27 08:40:23 +01:00
#include "miscellaneous/settings.h"
2014-03-26 12:23:27 +01:00
#include "network-web/networkfactory.h"
#include "network-web/webfactory.h"
2015-06-26 07:21:30 +02:00
#include "gui/dialogs/formmain.h"
2014-01-20 13:59:08 +01:00
#include "gui/messagebox.h"
#include "gui/styleditemdelegatewithoutfocus.h"
2013-12-21 21:08:52 +01:00
2013-11-18 21:45:15 +01:00
#include <QKeyEvent>
2013-12-04 21:03:09 +01:00
#include <QScrollBar>
2013-12-07 20:33:41 +01:00
#include <QMenu>
2013-11-17 16:41:44 +01:00
2013-10-13 16:12:15 +02:00
2013-12-07 20:33:41 +01:00
MessagesView::MessagesView(QWidget *parent)
: QTreeView(parent),
m_contextMenu(NULL),
m_columnsAdjusted(false),
m_batchUnreadSwitch(false) {
2013-11-15 22:09:38 +01:00
m_proxyModel = new MessagesProxyModel(this);
2013-11-17 16:41:44 +01:00
m_sourceModel = m_proxyModel->sourceModel();
2013-11-15 22:09:38 +01:00
// Forward count changes to the view.
createConnections();
2013-11-15 22:09:38 +01:00
setModel(m_proxyModel);
2013-12-13 16:35:52 +01:00
setupAppearance();
}
MessagesView::~MessagesView() {
qDebug("Destroying MessagesView instance.");
}
2014-11-04 20:09:16 +01:00
void MessagesView::setSortingEnabled(bool enable) {
disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
QTreeView::setSortingEnabled(enable);
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
}
void MessagesView::createConnections() {
2015-06-11 13:48:38 +02:00
connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openSelectedSourceMessagesInternallyNoNewTab()));
// Adjust columns when layout gets changed.
connect(header(), SIGNAL(geometriesChanged()), this, SLOT(adjustColumns()));
2014-11-04 20:09:16 +01:00
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
}
void MessagesView::keyboardSearch(const QString &search) {
2014-10-29 16:38:23 +01:00
// WARNING: This is quite hacky way how to force selection of next item even
// with extended selection enabled.
setSelectionMode(QAbstractItemView::SingleSelection);
QTreeView::keyboardSearch(search);
setSelectionMode(QAbstractItemView::ExtendedSelection);
}
2015-05-13 07:09:28 +02:00
void MessagesView::reloadSelections(bool mark_current_index_read) {
2013-12-28 11:22:00 +01:00
QModelIndex current_index = selectionModel()->currentIndex();
QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index);
QModelIndexList selected_indexes = selectionModel()->selectedRows();
QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
// Reload the model now.
2015-11-13 11:18:47 +01:00
m_sourceModel->fetchAllData();
2013-12-28 11:22:00 +01:00
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
2014-11-11 18:49:55 +01:00
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), mapped_current_index.column()));
2013-12-28 11:22:00 +01:00
if (current_index.isValid()) {
2015-06-08 08:47:02 +02:00
if (!mark_current_index_read) {
// User selected to mark some messages as unread, if one
// of them will be marked as current, then it will be read again.
m_batchUnreadSwitch = true;
}
2014-11-11 18:49:55 +01:00
setCurrentIndex(current_index);
scrollTo(current_index);
reselectIndexes(selected_indexes);
2014-11-11 18:49:55 +01:00
m_batchUnreadSwitch = false;
2013-12-28 11:22:00 +01:00
}
else {
// Messages were probably removed from the model, nothing can
// be selected and no message can be displayed.
// TOTO: Check if this is OKAY. If not, then emit this signal
// from FeedsView itself.
2014-01-05 18:43:07 +01:00
emit currentMessagesRemoved();
2013-12-28 11:22:00 +01:00
}
}
2013-12-13 16:35:52 +01:00
void MessagesView::setupAppearance() {
2013-11-18 21:45:15 +01:00
setUniformRowHeights(true);
2013-11-15 22:09:38 +01:00
setAcceptDrops(false);
setDragEnabled(false);
setDragDropMode(QAbstractItemView::NoDragDrop);
setExpandsOnDoubleClick(false);
setRootIsDecorated(false);
2013-12-28 23:11:28 +01:00
setEditTriggers(QAbstractItemView::NoEditTriggers);
2013-11-15 22:24:38 +01:00
setItemsExpandable(false);
2013-11-18 21:45:15 +01:00
setSortingEnabled(true);
setAllColumnsShowFocus(false);
2013-11-17 16:41:44 +01:00
setSelectionMode(QAbstractItemView::ExtendedSelection);
2014-10-02 20:34:21 +02:00
setItemDelegate(new StyledItemDelegateWithoutFocus(this));
header()->setDefaultSectionSize(MESSAGES_VIEW_DEFAULT_COL);
header()->setStretchLastSection(false);
header()->setSortIndicatorShown(false);
2013-11-17 16:41:44 +01:00
}
2013-11-18 21:45:15 +01:00
void MessagesView::keyPressEvent(QKeyEvent *event) {
QTreeView::keyPressEvent(event);
2013-12-09 16:05:16 +01:00
if (event->key() == Qt::Key_Delete) {
deleteSelectedMessages();
}
2013-11-18 21:45:15 +01:00
}
2013-12-07 20:33:41 +01:00
void MessagesView::contextMenuEvent(QContextMenuEvent *event) {
QModelIndex clicked_index = indexAt(event->pos());
if (!clicked_index.isValid()) {
qDebug("Context menu for MessagesView will not be shown because user clicked on invalid item.");
2013-12-07 20:33:41 +01:00
return;
}
if (m_contextMenu == NULL) {
// Context menu is not initialized, initialize.
initializeContextMenu();
}
m_contextMenu->exec(event->globalPos());
}
void MessagesView::initializeContextMenu() {
m_contextMenu = new QMenu(tr("Context menu for messages"), this);
m_contextMenu->addActions(QList<QAction*>() <<
2015-05-12 09:48:22 +02:00
qApp->mainForm()->m_ui->m_actionSendMessageViaEmail <<
2014-08-22 09:27:01 +02:00
qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally <<
qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesInternally <<
qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally <<
qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead <<
qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread <<
qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages <<
qApp->mainForm()->m_ui->m_actionDeleteSelectedMessages);
2013-12-07 20:33:41 +01:00
}
2013-12-03 21:39:26 +01:00
void MessagesView::mousePressEvent(QMouseEvent *event) {
QTreeView::mousePressEvent(event);
2013-12-20 14:59:41 +01:00
switch (event->button()) {
case Qt::LeftButton: {
// Make sure that message importance is switched when user
// clicks the "important" column.
QModelIndex clicked_index = indexAt(event->pos());
2013-12-03 21:39:26 +01:00
2013-12-20 14:59:41 +01:00
if (clicked_index.isValid()) {
QModelIndex mapped_index = m_proxyModel->mapToSource(clicked_index);
2013-12-03 21:39:26 +01:00
2013-12-20 14:59:41 +01:00
if (mapped_index.column() == MSG_DB_IMPORTANT_INDEX) {
m_sourceModel->switchMessageImportance(mapped_index.row());
}
}
break;
}
2013-12-03 21:39:26 +01:00
2013-12-20 14:59:41 +01:00
case Qt::MiddleButton: {
// Open selected messages in new tab on mouse middle button click.
openSelectedSourceMessagesInternally();
break;
}
2013-12-03 21:39:26 +01:00
2013-12-20 14:59:41 +01:00
default:
break;
2013-12-03 21:39:26 +01:00
}
}
2014-11-11 18:49:55 +01:00
void MessagesView::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
QTreeView::currentChanged(current, previous);
}
void MessagesView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) {
QModelIndexList selected_rows = selectionModel()->selectedRows();
QModelIndex current_index = currentIndex();
QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index);
2013-11-17 16:41:44 +01:00
2013-12-20 14:59:41 +01:00
qDebug("Current row changed - row [%d,%d] source [%d, %d].",
2014-11-11 18:49:55 +01:00
current_index.row(), current_index.column(),
2013-12-04 21:03:09 +01:00
mapped_current_index.row(), mapped_current_index.column());
2013-11-17 16:41:44 +01:00
2014-11-12 16:40:06 +01:00
if (mapped_current_index.isValid() && selected_rows.count() == 1) {
if (!m_batchUnreadSwitch) {
// Set this message as read only if current item
// wasn't changed by "mark selected messages unread" action.
2013-12-08 14:02:28 +01:00
m_sourceModel->setMessageRead(mapped_current_index.row(), 1);
}
2014-11-12 16:40:06 +01:00
emit currentMessagesChanged(QList<Message>() << m_sourceModel->messageAt(m_proxyModel->mapToSource(selected_rows.at(0)).row()));
}
else {
2014-01-05 18:43:07 +01:00
emit currentMessagesRemoved();
2013-12-04 21:03:09 +01:00
}
2013-11-19 21:25:55 +01:00
2014-11-12 17:56:05 +01:00
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()) {
2014-02-18 17:15:05 +01:00
scrollTo(currentIndex(), QAbstractItemView::PositionAtCenter);
}
2014-02-17 20:32:45 +01:00
QTreeView::selectionChanged(selected, deselected);
}
void MessagesView::loadFeeds(RootItem *item) {
m_sourceModel->loadMessages(item);
2014-11-12 17:56:05 +01:00
int col = qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortColumnMessages)).toInt();
Qt::SortOrder ord = static_cast<Qt::SortOrder>(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortOrderMessages)).toInt());
2014-11-04 20:09:16 +01:00
2014-11-05 16:56:02 +01:00
sortByColumn(col, ord);
2015-06-24 09:10:43 +02:00
#if QT_VERSION >= 0x050000
// Messages are loaded, make sure that previously
// active message is not shown in browser.
// BUG: Qt 5 is probably bugged here. Selections
// should be cleared automatically when SQL model is reset.
emit currentMessagesRemoved();
#endif
}
2015-06-11 13:48:38 +02:00
void MessagesView::openSelectedSourceMessagesExternally() {
2013-12-10 22:06:45 +01:00
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
2014-03-14 11:16:43 +01:00
if (!WebFactory::instance()->openUrlInExternalBrowser(link)) {
qApp->showGuiMessage(tr("Problem with starting external web browser"),
tr("External web browser could not be started."),
QSystemTrayIcon::Critical);
return;
}
2013-12-10 22:06:45 +01:00
}
// Finally, mark opened messages as read.
2015-06-11 13:48:38 +02:00
if (selectionModel()->selectedRows().size() > 1) {
markSelectedMessagesRead();
}
2013-12-07 20:33:41 +01:00
}
void MessagesView::openSelectedSourceMessagesInternally() {
2013-12-10 18:54:55 +01:00
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
2013-12-31 17:33:42 +01:00
Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row());
if (message.m_url.isEmpty()) {
2014-01-22 16:59:39 +01:00
MessageBox::show(this,
QMessageBox::Warning,
tr("Meesage without URL"),
2014-01-22 17:32:00 +01:00
tr("Message '%s' does not contain URL.").arg(message.m_title));
2013-12-31 17:33:42 +01:00
}
else {
2014-01-05 18:43:07 +01:00
emit openLinkNewTab(message.m_url);
2013-12-31 17:33:42 +01:00
}
2013-12-10 18:54:55 +01:00
}
// Finally, mark opened messages as read.
2015-06-11 13:48:38 +02:00
if (selectionModel()->selectedRows().size() > 1) {
markSelectedMessagesRead();
}
}
void MessagesView::openSelectedSourceMessagesInternallyNoNewTab() {
if (selectionModel()->selectedRows().size() == 1) {
emit openLinkMiniBrowser(
m_sourceModel->messageAt(m_proxyModel->mapToSource(selectionModel()->selectedRows().at(0)).row()).m_url);
}
2013-12-07 20:33:41 +01:00
}
2013-12-08 14:02:28 +01:00
void MessagesView::openSelectedMessagesInternally() {
2014-01-05 18:43:07 +01:00
QList<Message> messages;
2013-12-10 13:29:38 +01:00
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
2014-01-05 18:43:07 +01:00
messages << m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row());
2013-12-10 13:29:38 +01:00
}
2014-01-05 18:43:07 +01:00
if (!messages.isEmpty()) {
emit openMessagesInNewspaperView(messages);
// Finally, mark opened messages as read.
markSelectedMessagesRead();
}
2013-12-07 20:33:41 +01:00
}
2015-05-12 09:48:22 +02:00
void MessagesView::sendSelectedMessageViaEmail() {
if (selectionModel()->selectedRows().size() == 1) {
Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(selectionModel()->selectedRows().at(0)).row());
if (!WebFactory::instance()->sendMessageViaEmail(message)) {
MessageBox::show(this,
QMessageBox::Critical,
tr("Problem with starting external e-mail client"),
tr("External e-mail client could not be started."));
}
}
}
2013-12-08 14:02:28 +01:00
void MessagesView::markSelectedMessagesRead() {
setSelectedMessagesReadStatus(RootItem::Read);
2013-12-08 14:02:28 +01:00
}
void MessagesView::markSelectedMessagesUnread() {
setSelectedMessagesReadStatus(RootItem::Unread);
2013-12-08 14:02:28 +01:00
}
void MessagesView::setSelectedMessagesReadStatus(RootItem::ReadStatus read) {
2013-12-07 20:33:41 +01:00
QModelIndex current_index = selectionModel()->currentIndex();
if (!current_index.isValid()) {
return;
}
2013-12-07 20:33:41 +01:00
QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index);
QModelIndexList selected_indexes = selectionModel()->selectedRows();
QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
2013-12-03 21:39:26 +01:00
2013-12-08 14:02:28 +01:00
m_sourceModel->setBatchMessagesRead(mapped_indexes, read);
2013-12-04 21:03:09 +01:00
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
2013-12-06 15:12:30 +01:00
2013-12-08 14:02:28 +01:00
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
2014-11-11 18:49:55 +01:00
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), mapped_current_index.column()));
2013-12-08 14:02:28 +01:00
if (read == RootItem::Unread) {
2013-12-08 14:02:28 +01:00
// User selected to mark some messages as unread, if one
// of them will be marked as current, then it will be read again.
m_batchUnreadSwitch = true;
2013-12-08 14:02:28 +01:00
}
2014-11-11 18:49:55 +01:00
setCurrentIndex(current_index);
2013-12-08 14:02:28 +01:00
scrollTo(current_index);
reselectIndexes(selected_indexes);
2014-11-11 18:49:55 +01:00
m_batchUnreadSwitch = false;
2013-12-08 14:02:28 +01:00
}
2015-11-13 09:08:06 +01:00
// TODO: restore messages je uplně stejně jako tahle fce
// akorat se vola jina metoda na source modelu.
2013-12-08 14:02:28 +01:00
void MessagesView::deleteSelectedMessages() {
QModelIndex current_index = selectionModel()->currentIndex();
if (!current_index.isValid()) {
return;
}
2013-12-08 14:02:28 +01:00
QModelIndexList selected_indexes = selectionModel()->selectedRows();
QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
m_sourceModel->setBatchMessagesDeleted(mapped_indexes, 1);
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
2014-09-21 21:12:51 +02:00
int row_count = m_sourceModel->rowCount();
if (row_count > 0) {
QModelIndex last_item = current_index.row() < row_count ?
2014-11-12 18:34:50 +01:00
m_proxyModel->index(current_index.row(), MSG_DB_TITLE_INDEX) :
m_proxyModel->index(row_count - 1, MSG_DB_TITLE_INDEX);
2014-09-21 21:12:51 +02:00
setCurrentIndex(last_item);
scrollTo(last_item);
reselectIndexes(QModelIndexList() << last_item);
}
else {
emit currentMessagesRemoved();
}
}
2013-12-08 14:02:28 +01:00
void MessagesView::switchSelectedMessagesImportance() {
QModelIndex current_index = selectionModel()->currentIndex();
if (!current_index.isValid()) {
return;
}
2013-12-08 14:02:28 +01:00
QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index);
QModelIndexList selected_indexes = selectionModel()->selectedRows();
QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
m_sourceModel->switchBatchMessageImportance(mapped_indexes);
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true);
2013-12-07 20:33:41 +01:00
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(),
2013-12-08 14:02:28 +01:00
mapped_current_index.column()));
2013-12-03 21:39:26 +01:00
2013-12-07 20:33:41 +01:00
setCurrentIndex(current_index);
scrollTo(current_index);
reselectIndexes(selected_indexes);
2013-12-04 21:03:09 +01:00
}
void MessagesView::reselectIndexes(const QModelIndexList &indexes) {
2014-04-09 08:26:33 +02:00
QItemSelection selection;
2013-12-07 20:33:41 +01:00
foreach (const QModelIndex &index, indexes) {
2015-05-13 07:09:28 +02:00
// TODO: THIS IS very slow. Try to select 4000 messages and hit "mark as read" button.
2014-04-09 08:26:33 +02:00
selection.merge(QItemSelection(index, index), QItemSelectionModel::Select);
2013-12-04 21:03:09 +01:00
}
2014-04-09 08:26:33 +02:00
selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
2013-11-24 14:44:17 +01:00
}
void MessagesView::selectNextItem() {
QModelIndex index_next = moveCursor(QAbstractItemView::MoveDown, Qt::NoModifier);
if (index_next.isValid()) {
setCurrentIndex(index_next);
selectionModel()->select(index_next, QItemSelectionModel::Select | QItemSelectionModel::Rows);
2014-10-29 16:38:23 +01:00
setFocus();
}
}
void MessagesView::selectPreviousItem() {
QModelIndex index_previous = moveCursor(QAbstractItemView::MoveUp, Qt::NoModifier);
if (index_previous.isValid()) {
setCurrentIndex(index_previous);
selectionModel()->select(index_previous, QItemSelectionModel::Select | QItemSelectionModel::Rows);
2014-10-29 16:38:23 +01:00
setFocus();
}
}
2014-04-09 08:26:33 +02:00
void MessagesView::searchMessages(const QString &pattern) {
2014-04-09 14:16:16 +02:00
m_proxyModel->setFilterRegExp(pattern);
2014-04-07 14:24:28 +02:00
if (selectionModel()->selectedRows().size() == 0) {
emit currentMessagesRemoved();
}
else {
// Scroll to selected message, it could become scrolled out due to filter change.
scrollTo(selectionModel()->selectedRows().at(0));
}
2014-04-07 14:24:28 +02:00
}
2015-11-13 11:18:47 +01:00
void MessagesView::filterMessages(MessagesModel::MessageHighlighter filter) {
m_sourceModel->highlightMessages(filter);
2014-04-09 08:42:26 +02:00
}
void MessagesView::adjustColumns() {
2014-01-06 21:22:00 +01:00
if (header()->count() > 0 && !m_columnsAdjusted) {
m_columnsAdjusted = true;
#if QT_VERSION >= 0x050000
// Setup column resize strategies.
header()->setSectionResizeMode(MSG_DB_ID_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_READ_INDEX, QHeaderView::ResizeToContents);
header()->setSectionResizeMode(MSG_DB_DELETED_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_IMPORTANT_INDEX, QHeaderView::ResizeToContents);
header()->setSectionResizeMode(MSG_DB_FEED_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_TITLE_INDEX, QHeaderView::Stretch);
header()->setSectionResizeMode(MSG_DB_URL_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_AUTHOR_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_PDELETED_INDEX, QHeaderView::Interactive);
#else
// Setup column resize strategies.
header()->setResizeMode(MSG_DB_ID_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_READ_INDEX, QHeaderView::ResizeToContents);
header()->setResizeMode(MSG_DB_DELETED_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_IMPORTANT_INDEX, QHeaderView::ResizeToContents);
header()->setResizeMode(MSG_DB_FEED_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_TITLE_INDEX, QHeaderView::Stretch);
header()->setResizeMode(MSG_DB_URL_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_AUTHOR_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_PDELETED_INDEX, QHeaderView::Interactive);
#endif
// Hide columns.
hideColumn(MSG_DB_ID_INDEX);
hideColumn(MSG_DB_DELETED_INDEX);
hideColumn(MSG_DB_FEED_INDEX);
hideColumn(MSG_DB_URL_INDEX);
hideColumn(MSG_DB_CONTENTS_INDEX);
hideColumn(MSG_DB_PDELETED_INDEX);
hideColumn(MSG_DB_ENCLOSURES_INDEX);
qDebug("Adjusting column resize modes for MessagesView.");
}
}
2014-11-04 20:09:16 +01:00
void MessagesView::saveSortState(int column, Qt::SortOrder order) {
2014-11-12 17:56:05 +01:00
qApp->settings()->setValue(GROUP(GUI), GUI::DefaultSortColumnMessages, column);
qApp->settings()->setValue(GROUP(GUI), GUI::DefaultSortOrderMessages, order);
2014-11-04 20:09:16 +01:00
}