mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-04 19:27:33 +01:00
enhance article list filtering options even more
This commit is contained in:
parent
fe02722662
commit
8adf3061fe
@ -86,8 +86,8 @@ MessagesView* MessagesModel::view() const {
|
||||
return m_view;
|
||||
}
|
||||
|
||||
void MessagesModel::setView(MessagesView* newView) {
|
||||
m_view = newView;
|
||||
void MessagesModel::setView(MessagesView* new_view) {
|
||||
m_view = new_view;
|
||||
}
|
||||
|
||||
MessagesModelCache* MessagesModel::cache() const {
|
||||
@ -773,7 +773,6 @@ QVariant MessagesModel::headerData(int section, Qt::Orientation orientation, int
|
||||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
|
||||
// Display textual headers for all columns except "read" and
|
||||
// "important" and "has enclosures" columns.
|
||||
if (section != MSG_DB_READ_INDEX && section != MSG_DB_IMPORTANT_INDEX && section != MSG_DB_SCORE_INDEX &&
|
||||
|
@ -20,14 +20,9 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
// Enum which describes basic highlighting schemes
|
||||
// for messages.
|
||||
enum class MessageHighlighter {
|
||||
NoHighlighting = 100,
|
||||
HighlightUnread = 101,
|
||||
HighlightImportant = 102
|
||||
};
|
||||
enum class MessageHighlighter { NoHighlighting = 100, HighlightUnread = 101, HighlightImportant = 102 };
|
||||
|
||||
// Constructors and destructors.
|
||||
explicit MessagesModel(QObject* parent = nullptr);
|
||||
@ -76,7 +71,9 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
||||
void loadMessages(RootItem* item);
|
||||
|
||||
MessagesView* view() const;
|
||||
void setView(MessagesView* newView);
|
||||
void setView(MessagesView* new_view);
|
||||
|
||||
static QIcon generateIconForScore(double score);
|
||||
|
||||
public slots:
|
||||
|
||||
@ -89,8 +86,6 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
||||
void setupHeaderData();
|
||||
void setupIcons();
|
||||
|
||||
static QIcon generateIconForScore(double score);
|
||||
|
||||
private:
|
||||
MessagesView* m_view;
|
||||
MessagesModelCache* m_cache;
|
||||
|
@ -155,6 +155,14 @@ bool MessagesProxyModel::filterAcceptsMessage(const Message& current_message) co
|
||||
return currentDate.addDays(-7).year() == current_message.m_created.date().year() &&
|
||||
currentDate.addDays(-7).weekNumber() == current_message.m_created.date().weekNumber();
|
||||
}
|
||||
|
||||
case MessageListFilter::ShowOnlyWithAttachments: {
|
||||
return current_message.m_enclosures.size() > 0;
|
||||
}
|
||||
|
||||
case MessageListFilter::ShowOnlyWithScore: {
|
||||
return current_message.m_score > MSG_SCORE_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -23,7 +23,9 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
||||
ShowLast24Hours = 105,
|
||||
ShowLast48Hours = 106,
|
||||
ShowThisWeek = 107,
|
||||
ShowLastWeek = 108
|
||||
ShowLastWeek = 108,
|
||||
ShowOnlyWithAttachments = 109,
|
||||
ShowOnlyWithScore = 110
|
||||
};
|
||||
|
||||
explicit MessagesProxyModel(MessagesModel* source_model, QObject* parent = nullptr);
|
||||
|
@ -7,11 +7,11 @@
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
#include <QToolButton>
|
||||
#include <QWidgetAction>
|
||||
#include <chrono>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@ -124,7 +124,8 @@ void MessagesToolBar::initializeSearchBox() {
|
||||
m_tmrSearchPattern->setSingleShot(true);
|
||||
|
||||
m_txtSearchMessages = new BaseLineEdit(this);
|
||||
m_txtSearchMessages->setSizePolicy(QSizePolicy::Policy::Expanding, m_txtSearchMessages->sizePolicy().verticalPolicy());
|
||||
m_txtSearchMessages->setSizePolicy(QSizePolicy::Policy::Expanding,
|
||||
m_txtSearchMessages->sizePolicy().verticalPolicy());
|
||||
m_txtSearchMessages->setPlaceholderText(tr("Search articles (regex only)"));
|
||||
|
||||
// Setup wrapping action for search box.
|
||||
@ -140,7 +141,11 @@ void MessagesToolBar::initializeSearchBox() {
|
||||
});
|
||||
}
|
||||
|
||||
void MessagesToolBar::addActionToMenu(QMenu* menu, const QIcon& icon, const QString& title, const QVariant& value, const QString& name) {
|
||||
void MessagesToolBar::addActionToMenu(QMenu* menu,
|
||||
const QIcon& icon,
|
||||
const QString& title,
|
||||
const QVariant& value,
|
||||
const QString& name) {
|
||||
QAction* action = menu->addAction(icon, title);
|
||||
|
||||
action->setData(value);
|
||||
@ -211,6 +216,16 @@ void MessagesToolBar::initializeHighlighter() {
|
||||
tr("Show last week's articles"),
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowLastWeek),
|
||||
"show_last_week");
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-attachment")),
|
||||
tr("Show only articles with attachments"),
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowOnlyWithAttachments),
|
||||
"show_with_attachments");
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
MessagesModel::generateIconForScore(MSG_SCORE_MAX / 2.0),
|
||||
tr("Show only articles with some score"),
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowOnlyWithScore),
|
||||
"show_with_score");
|
||||
|
||||
m_btnMessageHighlighter = new QToolButton(this);
|
||||
m_btnMessageHighlighter->setToolTip(tr("Display all articles"));
|
||||
@ -244,7 +259,8 @@ void MessagesToolBar::saveToolButtonSelection(const QString& button_name, const
|
||||
|
||||
for (QString& action_name : action_names) {
|
||||
if (action_name.startsWith(button_name)) {
|
||||
action_name = button_name + (action->objectName().isEmpty() ? "" : "[" + action->objectName().toStdString() + "]").c_str();
|
||||
action_name =
|
||||
button_name + (action->objectName().isEmpty() ? "" : "[" + action->objectName().toStdString() + "]").c_str();
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,7 +286,8 @@ void MessagesToolBar::activateAction(const QString& action_name, QWidgetAction*
|
||||
}
|
||||
|
||||
QStringList MessagesToolBar::defaultActions() const {
|
||||
return QString(GUI::MessagesToolbarDefaultButtonsDef).split(QL1C(','),
|
||||
return QString(GUI::MessagesToolbarDefaultButtonsDef)
|
||||
.split(QL1C(','),
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
@ -279,8 +296,10 @@ QStringList MessagesToolBar::defaultActions() const {
|
||||
}
|
||||
|
||||
QStringList MessagesToolBar::savedActions() const {
|
||||
return qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::MessagesToolbarDefaultButtons)).toString().split(QL1C(','),
|
||||
return qApp->settings()
|
||||
->value(GROUP(GUI), SETTING(GUI::MessagesToolbarDefaultButtons))
|
||||
.toString()
|
||||
.split(QL1C(','),
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user