OMG -> Better now.
This commit is contained in:
parent
72ace2fe43
commit
e86d98fb37
@ -79,6 +79,12 @@ void MessagesModel::loadMessages(const QList<int> feed_ids) {
|
|||||||
qDebug("Loading messages from feeds: %s.", qPrintable(assembled_ids));
|
qDebug("Loading messages from feeds: %s.", qPrintable(assembled_ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesModel::filterMessages(MessagesModel::DisplayFilter filter) {
|
||||||
|
m_filter = filter;
|
||||||
|
emit layoutAboutToBeChanged();
|
||||||
|
emit layoutChanged();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList MessagesModel::textualFeeds() const {
|
QStringList MessagesModel::textualFeeds() const {
|
||||||
QStringList stringy_ids;
|
QStringList stringy_ids;
|
||||||
stringy_ids.reserve(m_currentFeeds.size());
|
stringy_ids.reserve(m_currentFeeds.size());
|
||||||
@ -171,6 +177,25 @@ QVariant MessagesModel::data(const QModelIndex &idx, int role) const {
|
|||||||
m_normalFont :
|
m_normalFont :
|
||||||
m_boldFont;
|
m_boldFont;
|
||||||
|
|
||||||
|
case Qt::ForegroundRole:
|
||||||
|
switch (m_filter) {
|
||||||
|
case DisplayImportant:
|
||||||
|
return QSqlTableModel::data(index(idx.row(),
|
||||||
|
MSG_DB_IMPORTANT_INDEX)).toInt() == 1 ?
|
||||||
|
QColor(Qt::blue) :
|
||||||
|
QVariant();
|
||||||
|
|
||||||
|
case DisplayUnread:
|
||||||
|
return QSqlTableModel::data(index(idx.row(),
|
||||||
|
MSG_DB_READ_INDEX)).toInt() == 0 ?
|
||||||
|
QColor(Qt::blue) :
|
||||||
|
QVariant();
|
||||||
|
|
||||||
|
case DisplayAll:
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
case Qt::DecorationRole: {
|
case Qt::DecorationRole: {
|
||||||
int index_column = idx.column();
|
int index_column = idx.column();
|
||||||
|
|
||||||
|
@ -104,6 +104,8 @@ class MessagesModel : public QSqlTableModel {
|
|||||||
// Loads messages of given feeds.
|
// Loads messages of given feeds.
|
||||||
void loadMessages(const QList<int> feed_ids);
|
void loadMessages(const QList<int> feed_ids);
|
||||||
|
|
||||||
|
void filterMessages(DisplayFilter filter);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Emitted if some persistent change is made which affects
|
// Emitted if some persistent change is made which affects
|
||||||
// count of "unread/all" messages.
|
// count of "unread/all" messages.
|
||||||
|
@ -197,8 +197,8 @@ void FeedMessageViewer::createConnections() {
|
|||||||
// Filtering & searching.
|
// Filtering & searching.
|
||||||
connect(m_toolBarMessages, SIGNAL(messageSearchPatternChanged(QString)),
|
connect(m_toolBarMessages, SIGNAL(messageSearchPatternChanged(QString)),
|
||||||
m_messagesView, SLOT(searchMessages(QString)));
|
m_messagesView, SLOT(searchMessages(QString)));
|
||||||
/*connect(m_toolBarMessages, SIGNAL(messageFilterChanged(MessagesModel::DisplayFilter)),
|
connect(m_toolBarMessages, SIGNAL(messageFilterChanged(MessagesModel::DisplayFilter)),
|
||||||
m_messagesView, SLOT(filterMessages(MessagesModel::DisplayFilter)));*/
|
m_messagesView, SLOT(filterMessages(MessagesModel::DisplayFilter)));
|
||||||
|
|
||||||
// Message changers.
|
// Message changers.
|
||||||
connect(m_messagesView, SIGNAL(currentMessagesRemoved()),
|
connect(m_messagesView, SIGNAL(currentMessagesRemoved()),
|
||||||
|
@ -25,13 +25,13 @@ MessagesToolBar::MessagesToolBar(const QString &title, QWidget *parent)
|
|||||||
m_actionSearchMessages->setProperty("type", SEACRH_MESSAGES_ACTION_NAME);
|
m_actionSearchMessages->setProperty("type", SEACRH_MESSAGES_ACTION_NAME);
|
||||||
m_actionSearchMessages->setProperty("name", tr("Message search box"));
|
m_actionSearchMessages->setProperty("name", tr("Message search box"));
|
||||||
|
|
||||||
m_menuFilterMessages = new QMenu(tr("Menu for filtering messages"), this);
|
m_menuFilterMessages = new QMenu(tr("Menu for highlighting messages"), this);
|
||||||
m_menuFilterMessages->addAction(IconFactory::instance()->fromTheme("mail-mark-read"),
|
m_menuFilterMessages->addAction(IconFactory::instance()->fromTheme("mail-mark-read"),
|
||||||
tr("Display all messages"))->setData(QVariant::fromValue(MessagesModel::DisplayAll));
|
tr("No extra highlighting"))->setData(QVariant::fromValue(MessagesModel::DisplayAll));
|
||||||
m_menuFilterMessages->addAction(IconFactory::instance()->fromTheme("mail-mark-unread"),
|
m_menuFilterMessages->addAction(IconFactory::instance()->fromTheme("mail-mark-unread"),
|
||||||
tr("Display unread messages"))->setData(QVariant::fromValue(MessagesModel::DisplayUnread));
|
tr("Highlight unread messages"))->setData(QVariant::fromValue(MessagesModel::DisplayUnread));
|
||||||
m_menuFilterMessages->addAction(IconFactory::instance()->fromTheme("mail-mark-favorite"),
|
m_menuFilterMessages->addAction(IconFactory::instance()->fromTheme("mail-mark-favorite"),
|
||||||
tr("Display important messages"))->setData(QVariant::fromValue(MessagesModel::DisplayImportant));
|
tr("Highlight important messages"))->setData(QVariant::fromValue(MessagesModel::DisplayImportant));
|
||||||
|
|
||||||
m_btnFilterMessages = new QToolButton(this);
|
m_btnFilterMessages = new QToolButton(this);
|
||||||
m_btnFilterMessages->setToolTip(tr("Display all messages"));
|
m_btnFilterMessages->setToolTip(tr("Display all messages"));
|
||||||
@ -42,7 +42,7 @@ MessagesToolBar::MessagesToolBar(const QString &title, QWidget *parent)
|
|||||||
m_actionFilterMessages = new QWidgetAction(this);
|
m_actionFilterMessages = new QWidgetAction(this);
|
||||||
m_actionFilterMessages->setDefaultWidget(m_btnFilterMessages);
|
m_actionFilterMessages->setDefaultWidget(m_btnFilterMessages);
|
||||||
m_actionFilterMessages->setProperty("type", FILTER_ACTION_NAME);
|
m_actionFilterMessages->setProperty("type", FILTER_ACTION_NAME);
|
||||||
m_actionFilterMessages->setProperty("name", tr("Message filter"));
|
m_actionFilterMessages->setProperty("name", tr("Message highlighter"));
|
||||||
|
|
||||||
// Update right margin of filter textbox.
|
// Update right margin of filter textbox.
|
||||||
QMargins margins = contentsMargins();
|
QMargins margins = contentsMargins();
|
||||||
|
@ -411,6 +411,10 @@ void MessagesView::searchMessages(const QString &pattern) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesView::filterMessages(MessagesModel::DisplayFilter filter) {
|
||||||
|
m_sourceModel->filterMessages(filter);
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesView::adjustColumns() {
|
void MessagesView::adjustColumns() {
|
||||||
if (header()->count() > 0 && !m_columnsAdjusted) {
|
if (header()->count() > 0 && !m_columnsAdjusted) {
|
||||||
m_columnsAdjusted = true;
|
m_columnsAdjusted = true;
|
||||||
|
@ -78,6 +78,7 @@ class MessagesView : public QTreeView {
|
|||||||
|
|
||||||
// Searchs the visible message according to given pattern.
|
// Searchs the visible message according to given pattern.
|
||||||
void searchMessages(const QString &pattern);
|
void searchMessages(const QString &pattern);
|
||||||
|
void filterMessages(MessagesModel::DisplayFilter filter);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
// Marks given indexes as selected.
|
// Marks given indexes as selected.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user