Initial implementation of #115.
This commit is contained in:
parent
e76b379bb7
commit
d635c8ae70
@ -2,6 +2,7 @@
|
||||
—————
|
||||
|
||||
Added:
|
||||
▪ Columns in message list can be hidden/shown/reordered with context menu. (issue #115)
|
||||
▪ Auto-update notification is now switchable. (issue #119)
|
||||
▪ Messages which are not removed or restored are not instantly deleted from list, they are striked-through instead. This is more resource friendly.
|
||||
▪ Message list is now not reloaded when doing batch message operations.
|
||||
|
@ -331,7 +331,8 @@ HEADERS += src/core/feeddownloader.h \
|
||||
src/services/tt-rss/gui/formeditttrssaccount.h \
|
||||
src/gui/guiutilities.h \
|
||||
src/core/messagesmodelcache.h \
|
||||
src/core/messagesmodelsqllayer.h
|
||||
src/core/messagesmodelsqllayer.h \
|
||||
src/gui/treeviewcolumnsmenu.h
|
||||
|
||||
SOURCES += src/core/feeddownloader.cpp \
|
||||
src/core/feedsmodel.cpp \
|
||||
@ -454,7 +455,8 @@ SOURCES += src/core/feeddownloader.cpp \
|
||||
src/services/tt-rss/gui/formeditttrssaccount.cpp \
|
||||
src/gui/guiutilities.cpp \
|
||||
src/core/messagesmodelcache.cpp \
|
||||
src/core/messagesmodelsqllayer.cpp
|
||||
src/core/messagesmodelsqllayer.cpp \
|
||||
src/gui/treeviewcolumnsmenu.cpp
|
||||
|
||||
FORMS += src/gui/toolbareditor.ui \
|
||||
src/network-web/downloaditem.ui \
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "network-web/webfactory.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "gui/messagebox.h"
|
||||
|
||||
#include "gui/treeviewcolumnsmenu.h"
|
||||
#include "gui/styleditemdelegatewithoutfocus.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
@ -43,6 +43,12 @@ MessagesView::MessagesView(QWidget *parent)
|
||||
createConnections();
|
||||
setModel(m_proxyModel);
|
||||
setupAppearance();
|
||||
|
||||
header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(header(), &QHeaderView::customContextMenuRequested, [=](const QPoint &point) {
|
||||
TreeViewColumnsMenu mm(header());
|
||||
mm.exec(header()->mapToGlobal(point));
|
||||
});
|
||||
}
|
||||
|
||||
MessagesView::~MessagesView() {
|
||||
|
52
src/gui/treeviewcolumnsmenu.cpp
Executable file
52
src/gui/treeviewcolumnsmenu.cpp
Executable file
@ -0,0 +1,52 @@
|
||||
// This file is part of RSS Guard.
|
||||
//
|
||||
// Copyright (C) 2011-2017 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/>.
|
||||
|
||||
#include "gui/treeviewcolumnsmenu.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
|
||||
|
||||
TreeViewColumnsMenu::TreeViewColumnsMenu(QHeaderView *parent) : QMenu(parent) {
|
||||
connect(this, &TreeViewColumnsMenu::aboutToShow, this, &TreeViewColumnsMenu::prepareMenu);
|
||||
}
|
||||
|
||||
TreeViewColumnsMenu::~TreeViewColumnsMenu() {
|
||||
}
|
||||
|
||||
void TreeViewColumnsMenu::prepareMenu() {
|
||||
QHeaderView *header_view = header();
|
||||
|
||||
for (int i = 0; i < header_view->count(); i++) {
|
||||
QAction *act = addAction(header_view->model()->headerData(i, Qt::Horizontal, Qt::EditRole).toString());
|
||||
|
||||
act->setData(i);
|
||||
act->setCheckable(true);
|
||||
act->setChecked(!header_view->isSectionHidden(i));
|
||||
|
||||
connect(act, &QAction::toggled, this, &TreeViewColumnsMenu::actionTriggered);
|
||||
}
|
||||
}
|
||||
|
||||
void TreeViewColumnsMenu::actionTriggered(bool toggle) {
|
||||
QAction *send_act = qobject_cast<QAction*>(sender());
|
||||
|
||||
header()->setSectionHidden(send_act->data().toInt(), !send_act->isChecked());
|
||||
}
|
||||
|
||||
QHeaderView *TreeViewColumnsMenu::header() {
|
||||
return qobject_cast<QHeaderView*>(parent());
|
||||
}
|
39
src/gui/treeviewcolumnsmenu.h
Executable file
39
src/gui/treeviewcolumnsmenu.h
Executable file
@ -0,0 +1,39 @@
|
||||
// This file is part of RSS Guard.
|
||||
//
|
||||
// Copyright (C) 2011-2017 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/>.
|
||||
|
||||
#ifndef TREEVIEWCOLUMNSMENU_H
|
||||
#define TREEVIEWCOLUMNSMENU_H
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
class QHeaderView;
|
||||
|
||||
class TreeViewColumnsMenu : public QMenu {
|
||||
public:
|
||||
explicit TreeViewColumnsMenu(QHeaderView *parent);
|
||||
virtual ~TreeViewColumnsMenu();
|
||||
|
||||
private slots:
|
||||
void prepareMenu();
|
||||
void actionTriggered(bool toggle);
|
||||
|
||||
private:
|
||||
QHeaderView *header();
|
||||
};
|
||||
|
||||
#endif // TREEVIEWCOLUMNSMENU_H
|
Loading…
x
Reference in New Issue
Block a user