11#include "todoviewquicksearch.h"
12#include <CalendarSupport/KCalPrefs>
14#include <Akonadi/TagSelectionComboBox>
16#include <Libkdepim/KCheckComboBox>
18#include <CalendarSupport/CategoryHierarchyReader>
20#include <KCalendarCore/CalFilter>
22#include <KLocalizedString>
27TodoViewQuickSearch::TodoViewQuickSearch(
QWidget *parent)
30 , mCategoryCombo(new
Akonadi::TagSelectionComboBox(this))
31 , mPriorityCombo(new
KPIM::KCheckComboBox(this))
35 layout->setContentsMargins({});
37 mSearchLine->setToolTip(
i18nc(
"@info:tooltip",
"Filter on matching summaries"));
38 mSearchLine->setWhatsThis(
i18nc(
"@info:whatsthis",
"Enter text here to filter the to-dos that are shown by matching summaries."));
39 mSearchLine->setPlaceholderText(
i18nc(
"@label in QuickSearchLine",
"Search Summaries…"));
40 mSearchLine->setClearButtonEnabled(
true);
43 layout->addWidget(mSearchLine, 3);
45 mCategoryCombo->setCheckable(
true);
46 mCategoryCombo->setToolTip(
i18nc(
"@info:tooltip",
"Filter on these tags"));
47 mCategoryCombo->setWhatsThis(
i18nc(
"@info:whatsthis",
48 "Use this combobox to filter the to-dos that are shown by "
49 "a list of selected tags."));
50 const QString defaultText =
i18nc(
"@item:inlistbox",
"Select Tags");
51 mCategoryCombo->lineEdit()->setPlaceholderText(defaultText);
53 connect(mCategoryCombo, &Akonadi::TagSelectionComboBox::selectionChanged,
this, [
this]() {
54 Q_EMIT filterCategoryChanged(mCategoryCombo->selectionNames());
57 layout->addWidget(mCategoryCombo, 1);
61 QFontMetrics fm = mCategoryCombo->lineEdit()->fontMetrics();
64 const int currentPreferedWidth = mCategoryCombo->lineEdit()->sizeHint().width();
69 const int pixelsToAdd = newPreferedWidth - mCategoryCombo->lineEdit()->width();
70 mCategoryCombo->setMinimumWidth(mCategoryCombo->width() + pixelsToAdd);
73 mPriorityCombo->setToolTip(
i18nc(
"@info:tooltip",
"Filter on these priorities"));
74 mPriorityCombo->setWhatsThis(
i18nc(
"@info:whatsthis",
75 "Use this combobox to filter the to-dos that are shown by "
76 "a list of selected priorities."));
77 mPriorityCombo->lineEdit()->setPlaceholderText(
i18nc(
"@item:inlistbox",
"Select Priority"));
79 Q_EMIT filterPriorityChanged(mPriorityCombo->checkedItems(
Qt::UserRole));
82 layout->addWidget(mPriorityCombo, 1);
86void TodoViewQuickSearch::reset()
93void TodoViewQuickSearch::fillPriorities()
96 priorityValues.
append(
i18nc(
"@action:inmenu priority is unspecified",
"unspecified"));
97 priorityValues.
append(
i18nc(
"@action:inmenu highest priority",
"%1 (highest)", 1));
98 for (
int p = 2; p < 10; ++p) {
100 priorityValues.
append(
i18nc(
"@action:inmenu medium priority",
"%1 (medium)", p));
102 priorityValues.
append(
i18nc(
"@action:inmenu lowest priority",
"%1 (lowest)", p));
104 priorityValues.
append(
i18nc(
"@action:inmenu",
"%1", p));
108 CalendarSupport::CategoryHierarchyReaderQComboBox(mPriorityCombo).read(priorityValues);
111#include "moc_todoviewquicksearch.cpp"
void checkedItemsChanged(const QStringList &items)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setCurrentIndex(int index)
QRect boundingRect(QChar ch) const const
void textChanged(const QString &text)
void append(QList< T > &&value)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)