summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Montel <[email protected]>2019-01-04 09:14:19 +0100
committerLaurent Montel <[email protected]>2019-01-04 09:14:19 +0100
commit36c8375d8bc44580cadd9dc7478a637ec0677ebf (patch)
treee2a1ff54597372bc00c0ca78dc5d740d0755c0af
parente7b78b23bc4330a96a4c2605b4700de4897bb1fc (diff)
Fix Bug 402132 - Make it more obvious that the search didn't find anything
FIXED-IN: 5.10.2 BUG: 402132
-rw-r--r--src/articlelistview.cpp29
-rw-r--r--src/articlelistview.h5
-rw-r--r--src/widgets/searchbar.cpp19
-rw-r--r--src/widgets/searchbar.h1
4 files changed, 49 insertions, 5 deletions
diff --git a/src/articlelistview.cpp b/src/articlelistview.cpp
index 97ad6b5..7095dd7 100644
--- a/src/articlelistview.cpp
+++ b/src/articlelistview.cpp
@@ -43,6 +43,7 @@
#include <QApplication>
#include <QContextMenuEvent>
#include <QHeaderView>
+#include <QPainter>
#include <QPalette>
#include <QScrollBar>
@@ -206,6 +207,34 @@ void ArticleListView::showHeaderMenu(const QPoint &pos)
delete menu;
}
+void ArticleListView::generalPaletteChanged()
+{
+ const QPalette palette = viewport()->palette();
+ QColor color = palette.text().color();
+ color.setAlpha(128);
+ mTextColor = color;
+}
+
+void ArticleListView::paintEvent(QPaintEvent *event)
+{
+ if ((m_matchers.size() != 0) && (model() && model()->rowCount() == 0)) {
+ QPainter p(viewport());
+
+ QFont font = p.font();
+ font.setItalic(true);
+ p.setFont(font);
+
+ if (!mTextColor.isValid()) {
+ generalPaletteChanged();
+ }
+ p.setPen(mTextColor);
+
+ p.drawText(QRect(0, 0, width(), height()), Qt::AlignCenter, i18n("No result found"));
+ } else {
+ QTreeView::paintEvent(event);
+ }
+}
+
void ArticleListView::saveHeaderSettings()
{
if (model()) {
diff --git a/src/articlelistview.h b/src/articlelistview.h
index 88d903f..e0a5d6a 100644
--- a/src/articlelistview.h
+++ b/src/articlelistview.h
@@ -116,6 +116,8 @@ public:
protected:
void mousePressEvent(QMouseEvent *ev) override;
+ void paintEvent(QPaintEvent *event) override;
+
Q_SIGNALS:
void signalMouseButtonPressed(int, const QUrl &);
@@ -153,11 +155,12 @@ private Q_SLOTS:
void finishResizingTitleColumn();
private:
-
+ void generalPaletteChanged();
enum ColumnMode {
GroupMode, FeedMode
};
ColumnMode m_columnMode;
+ QColor mTextColor;
QPointer<SortColorizeProxyModel> m_proxy;
std::vector<QSharedPointer<const Filters::AbstractMatcher> > m_matchers;
QByteArray m_feedHeaderState;
diff --git a/src/widgets/searchbar.cpp b/src/widgets/searchbar.cpp
index a84f83d..19dd0db 100644
--- a/src/widgets/searchbar.cpp
+++ b/src/widgets/searchbar.cpp
@@ -117,7 +117,7 @@ void SearchBar::slotClearSearch()
d->searchLine->clear();
d->searchLine->setStatus(Akregator::StatusSearchLine::AllArticles);
d->timer.stop();
- slotActivateSearch();
+ slotStopActiveSearch();
}
}
@@ -154,6 +154,16 @@ void SearchBar::slotSearchStringChanged(const QString &search)
d->triggerTimer();
}
+void SearchBar::slotStopActiveSearch()
+{
+ std::vector<QSharedPointer<const AbstractMatcher> > matchers;
+ Settings::setStatusFilter(d->searchLine->status());
+ Settings::setTextFilter(d->searchText);
+ d->matchers = matchers;
+ Q_EMIT signalSearch(matchers);
+
+}
+
void SearchBar::slotActivateSearch()
{
QVector<Criterion> textCriteria;
@@ -194,9 +204,10 @@ void SearchBar::slotActivateSearch()
}
std::vector<QSharedPointer<const AbstractMatcher> > matchers;
-
- matchers.push_back(QSharedPointer<const AbstractMatcher>(new ArticleMatcher(textCriteria, ArticleMatcher::LogicalOr)));
- matchers.push_back(QSharedPointer<const AbstractMatcher>(new ArticleMatcher(statusCriteria, ArticleMatcher::LogicalOr)));
+ if (!textCriteria.isEmpty())
+ matchers.push_back(QSharedPointer<const AbstractMatcher>(new ArticleMatcher(textCriteria, ArticleMatcher::LogicalOr)));
+ if (!statusCriteria.isEmpty())
+ matchers.push_back(QSharedPointer<const AbstractMatcher>(new ArticleMatcher(statusCriteria, ArticleMatcher::LogicalOr)));
Settings::setStatusFilter(d->searchLine->status());
Settings::setTextFilter(d->searchText);
d->matchers = matchers;
diff --git a/src/widgets/searchbar.h b/src/widgets/searchbar.h
index df4f3fa..641d63d 100644
--- a/src/widgets/searchbar.h
+++ b/src/widgets/searchbar.h
@@ -66,6 +66,7 @@ public Q_SLOTS:
private Q_SLOTS:
void slotSearchStringChanged(const QString &search);
+ void slotStopActiveSearch();
void slotActivateSearch();
void slotStatusChanged(Akregator::StatusSearchLine::Status);
private: