30 #include <kcombobox.h>
31 #include <kiconloader.h>
32 #include <klineedit.h>
34 #include <kstandarddirs.h>
45 using namespace boost;
46 using namespace Akregator;
47 using namespace Akregator::Filters;
52 class SearchBar::SearchBarPrivate
57 KLineEdit* searchLine;
58 KComboBox* searchCombo;
60 std::vector<shared_ptr<const AbstractMatcher> > matchers;
74 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) );
76 QLabel* searchLabel =
new QLabel(
this);
77 searchLabel->setText( i18nc(
"Title of article searchbar",
"S&earch:") );
79 d->searchLine =
new KLineEdit(
this);
80 d->searchLine->setClearButtonShown(
true);
82 connect(d->searchLine, SIGNAL(textChanged(QString)),
83 this, SLOT(slotSearchStringChanged(QString)));
85 searchLabel->setBuddy(d->searchLine);
87 QLabel* statusLabel =
new QLabel(
this);
88 statusLabel->setText( i18n(
"Status:") );
90 d->searchCombo =
new KComboBox(
this);
92 QIcon iconAll = KIconLoader::global()->loadIcon(
"system-run", KIconLoader::Small);
93 QIcon iconNew(KStandardDirs::locate(
"data",
"akregator/pics/kmmsgnew.png"));
94 QIcon iconUnread(KStandardDirs::locate(
"data",
"akregator/pics/kmmsgunseen.png"));
95 const KIcon iconKeep(
"mail-mark-important" );
97 d->searchCombo->addItem(iconAll, i18n(
"All Articles"));
98 d->searchCombo->addItem(iconUnread, i18nc(
"Unread articles filter",
"Unread"));
99 d->searchCombo->addItem(iconNew, i18nc(
"New articles filter",
"New"));
100 d->searchCombo->addItem(iconKeep, i18nc(
"Important articles filter",
"Important"));
102 d->searchLine->setToolTip( i18n(
"Enter space-separated terms to filter article list" ) );
103 d->searchCombo->setToolTip( i18n(
"Choose what kind of articles to show in article list" ) );
105 connect(d->searchCombo, SIGNAL(activated(
int)),
106 this, SLOT(slotSearchComboChanged(
int)));
108 connect(&(d->timer), SIGNAL(timeout()),
this, SLOT(slotActivateSearch()));
109 d->timer.setSingleShot(
true);
120 return d->searchText;
125 return d->searchCombo->currentIndex();
140 if (
status() != 0 || !d->searchLine->text().isEmpty())
142 d->searchLine->clear();
143 d->searchCombo->setCurrentIndex(0);
145 slotActivateSearch();
151 d->searchCombo->setCurrentIndex(status);
157 d->searchLine->setText(text);
161 void SearchBar::slotSearchComboChanged(
int )
171 void SearchBar::slotSearchStringChanged(
const QString& search)
173 d->searchText = search;
177 void SearchBar::slotActivateSearch()
182 if (!d->searchText.isEmpty())
184 Criterion subjCrit( Criterion::Title, Criterion::Contains, d->searchText);
185 textCriteria << subjCrit;
186 Criterion crit1( Criterion::Description, Criterion::Contains, d->searchText);
187 textCriteria << crit1;
188 Criterion authCrit( Criterion::Author, Criterion::Contains, d->searchText);
189 textCriteria << authCrit;
192 if (d->searchCombo->currentIndex())
194 switch (d->searchCombo->currentIndex())
200 statusCriteria << crit1;
201 statusCriteria << crit2;
207 statusCriteria << crit;
212 Criterion crit( Criterion::KeepFlag, Criterion::Equals,
true);
213 statusCriteria << crit;
221 std::vector<boost::shared_ptr<const AbstractMatcher> >
matchers;
223 matchers.push_back( boost::shared_ptr<const AbstractMatcher>(
new ArticleMatcher( textCriteria, ArticleMatcher::LogicalOr ) ) );
224 matchers.push_back( boost::shared_ptr<const AbstractMatcher>(
new ArticleMatcher( statusCriteria, ArticleMatcher::LogicalOr ) ) );
233 #include "searchbar.moc"
void slotSetStatus(int status)
std::vector< boost::shared_ptr< const Filters::AbstractMatcher > > matchers() const
article was fetched in the last fetch of it's feed and not read yet.
static void setStatusFilter(int v)
Set Status Filter.
static void setTextFilter(const QString &v)
Set Text Filter.
void slotSetText(const QString &text)
Criterion for ArticleMatcher.
a powerful matcher supporting multiple criterions, which can be combined via logical OR or AND ...
article wasn't read yet by the user
void signalSearch(const std::vector< boost::shared_ptr< const Akregator::Filters::AbstractMatcher > > &)
emitted when the text and status filters were updated.