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;
|
return m_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesModel::setView(MessagesView* newView) {
|
void MessagesModel::setView(MessagesView* new_view) {
|
||||||
m_view = newView;
|
m_view = new_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesModelCache* MessagesModel::cache() const {
|
MessagesModelCache* MessagesModel::cache() const {
|
||||||
@ -773,7 +773,6 @@ QVariant MessagesModel::headerData(int section, Qt::Orientation orientation, int
|
|||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
|
|
||||||
// Display textual headers for all columns except "read" and
|
// Display textual headers for all columns except "read" and
|
||||||
// "important" and "has enclosures" columns.
|
// "important" and "has enclosures" columns.
|
||||||
if (section != MSG_DB_READ_INDEX && section != MSG_DB_IMPORTANT_INDEX && section != MSG_DB_SCORE_INDEX &&
|
if (section != MSG_DB_READ_INDEX && section != MSG_DB_IMPORTANT_INDEX && section != MSG_DB_SCORE_INDEX &&
|
||||||
|
@ -17,17 +17,12 @@ class MessagesView;
|
|||||||
class MessagesModelCache;
|
class MessagesModelCache;
|
||||||
|
|
||||||
class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Enum which describes basic highlighting schemes
|
// Enum which describes basic highlighting schemes
|
||||||
// for messages.
|
// for messages.
|
||||||
enum class MessageHighlighter {
|
enum class MessageHighlighter { NoHighlighting = 100, HighlightUnread = 101, HighlightImportant = 102 };
|
||||||
NoHighlighting = 100,
|
|
||||||
HighlightUnread = 101,
|
|
||||||
HighlightImportant = 102
|
|
||||||
};
|
|
||||||
|
|
||||||
// Constructors and destructors.
|
// Constructors and destructors.
|
||||||
explicit MessagesModel(QObject* parent = nullptr);
|
explicit MessagesModel(QObject* parent = nullptr);
|
||||||
@ -76,7 +71,9 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
|||||||
void loadMessages(RootItem* item);
|
void loadMessages(RootItem* item);
|
||||||
|
|
||||||
MessagesView* view() const;
|
MessagesView* view() const;
|
||||||
void setView(MessagesView* newView);
|
void setView(MessagesView* new_view);
|
||||||
|
|
||||||
|
static QIcon generateIconForScore(double score);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
@ -89,8 +86,6 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
|||||||
void setupHeaderData();
|
void setupHeaderData();
|
||||||
void setupIcons();
|
void setupIcons();
|
||||||
|
|
||||||
static QIcon generateIconForScore(double score);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessagesView* m_view;
|
MessagesView* m_view;
|
||||||
MessagesModelCache* m_cache;
|
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() &&
|
return currentDate.addDays(-7).year() == current_message.m_created.date().year() &&
|
||||||
currentDate.addDays(-7).weekNumber() == current_message.m_created.date().weekNumber();
|
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;
|
return false;
|
||||||
|
@ -23,7 +23,9 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
|||||||
ShowLast24Hours = 105,
|
ShowLast24Hours = 105,
|
||||||
ShowLast48Hours = 106,
|
ShowLast48Hours = 106,
|
||||||
ShowThisWeek = 107,
|
ShowThisWeek = 107,
|
||||||
ShowLastWeek = 108
|
ShowLastWeek = 108,
|
||||||
|
ShowOnlyWithAttachments = 109,
|
||||||
|
ShowOnlyWithScore = 110
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit MessagesProxyModel(MessagesModel* source_model, QObject* parent = nullptr);
|
explicit MessagesProxyModel(MessagesModel* source_model, QObject* parent = nullptr);
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
@ -124,7 +124,8 @@ void MessagesToolBar::initializeSearchBox() {
|
|||||||
m_tmrSearchPattern->setSingleShot(true);
|
m_tmrSearchPattern->setSingleShot(true);
|
||||||
|
|
||||||
m_txtSearchMessages = new BaseLineEdit(this);
|
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)"));
|
m_txtSearchMessages->setPlaceholderText(tr("Search articles (regex only)"));
|
||||||
|
|
||||||
// Setup wrapping action for search box.
|
// 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);
|
QAction* action = menu->addAction(icon, title);
|
||||||
|
|
||||||
action->setData(value);
|
action->setData(value);
|
||||||
@ -211,6 +216,16 @@ void MessagesToolBar::initializeHighlighter() {
|
|||||||
tr("Show last week's articles"),
|
tr("Show last week's articles"),
|
||||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowLastWeek),
|
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowLastWeek),
|
||||||
"show_last_week");
|
"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 = new QToolButton(this);
|
||||||
m_btnMessageHighlighter->setToolTip(tr("Display all articles"));
|
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) {
|
for (QString& action_name : action_names) {
|
||||||
if (action_name.startsWith(button_name)) {
|
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,21 +286,24 @@ void MessagesToolBar::activateAction(const QString& action_name, QWidgetAction*
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList MessagesToolBar::defaultActions() const {
|
QStringList MessagesToolBar::defaultActions() const {
|
||||||
return QString(GUI::MessagesToolbarDefaultButtonsDef).split(QL1C(','),
|
return QString(GUI::MessagesToolbarDefaultButtonsDef)
|
||||||
|
.split(QL1C(','),
|
||||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||||
#else
|
#else
|
||||||
QString::SplitBehavior::SkipEmptyParts);
|
QString::SplitBehavior::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList MessagesToolBar::savedActions() const {
|
QStringList MessagesToolBar::savedActions() const {
|
||||||
return qApp->settings()->value(GROUP(GUI),
|
return qApp->settings()
|
||||||
SETTING(GUI::MessagesToolbarDefaultButtons)).toString().split(QL1C(','),
|
->value(GROUP(GUI), SETTING(GUI::MessagesToolbarDefaultButtons))
|
||||||
|
.toString()
|
||||||
|
.split(QL1C(','),
|
||||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||||
#else
|
#else
|
||||||
QString::SplitBehavior::SkipEmptyParts);
|
QString::SplitBehavior::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user