Verified Commit 6381780b authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Port from KPIM::TagSelectionCombo to its Akonadi equivalent

The Akonadi widgets have improved integration with the Akonadi
service and is the logical home for this kind of widgets.
parent 2cf2b182
......@@ -29,7 +29,7 @@ include(ECMAddTests)
set(EVENTVIEW_LIB_VERSION ${PIM_VERSION})
set(CALENDARUTILS_LIB_VERSION "5.14.40")
set(AKONADI_LIB_VERSION "5.14.40")
set(AKONADI_LIB_VERSION "5.14.43")
set(QT_REQUIRED_VERSION "5.12.0")
set(AKONADICALENDAR_LIB_VERSION "5.14.40")
set(KMIME_LIB_VERSION "5.14.40")
......
......@@ -26,10 +26,10 @@
#include "todomodel.h"
#include "todoviewview.h"
#include <AkonadiWidgets/TagSelectionComboBox>
#include <Akonadi/Calendar/ETMCalendar>
#include <CalendarSupport/CategoryConfig>
#include <CalendarSupport/CategoryHierarchyReader>
#include <LibkdepimAkonadi/TagSelectionCombo>
#include <Libkdepim/KCheckComboBox>
......@@ -50,10 +50,6 @@ TodoCompleteDelegate::TodoCompleteDelegate(QObject *parent)
{
}
TodoCompleteDelegate::~TodoCompleteDelegate()
{
}
void TodoCompleteDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItem opt = option;
......@@ -168,10 +164,6 @@ TodoPriorityDelegate::TodoPriorityDelegate(QObject *parent)
{
}
TodoPriorityDelegate::~TodoPriorityDelegate()
{
}
QWidget *TodoPriorityDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option);
......@@ -222,10 +214,6 @@ TodoDueDateDelegate::TodoDueDateDelegate(QObject *parent)
{
}
TodoDueDateDelegate::~TodoDueDateDelegate()
{
}
QWidget *TodoDueDateDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option);
......@@ -266,30 +254,24 @@ TodoCategoriesDelegate::TodoCategoriesDelegate(QObject *parent)
{
}
TodoCategoriesDelegate::~TodoCategoriesDelegate()
{
}
QWidget *TodoCategoriesDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option);
Q_UNUSED(index);
return new KPIM::TagSelectionCombo(parent);
return new Akonadi::TagSelectionComboBox(parent);
}
void TodoCategoriesDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
KPIM::KCheckComboBox *combo = static_cast<KPIM::KCheckComboBox *>(editor);
combo->setCheckedItems(index.data(Qt::EditRole).toStringList(), Qt::UserRole);
auto *combo = static_cast<Akonadi::TagSelectionComboBox *>(editor);
combo->setSelection(index.data(Qt::EditRole).toStringList());
}
void TodoCategoriesDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
KPIM::KCheckComboBox *combo = static_cast<KPIM::KCheckComboBox *>(editor);
model->setData(index, combo->checkedItems(Qt::UserRole));
auto *combo = static_cast<Akonadi::TagSelectionComboBox *>(editor);
model->setData(index, combo->selectionNames());
}
void TodoCategoriesDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
......@@ -313,10 +295,6 @@ TodoRichTextDelegate::TodoRichTextDelegate(QObject *parent)
m_textDoc = new QTextDocument(this);
}
TodoRichTextDelegate::~TodoRichTextDelegate()
{
}
void TodoRichTextDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.data(TodoModel::IsRichTextRole).toBool()) {
......
......@@ -46,8 +46,6 @@ class TodoCompleteDelegate : public QStyledItemDelegate
public:
explicit TodoCompleteDelegate(QObject *parent = nullptr);
~TodoCompleteDelegate() override;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
......@@ -84,8 +82,6 @@ class TodoPriorityDelegate : public QStyledItemDelegate
public:
explicit TodoPriorityDelegate(QObject *parent = nullptr);
~TodoPriorityDelegate() override;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
......@@ -105,8 +101,6 @@ class TodoDueDateDelegate : public QStyledItemDelegate
public:
explicit TodoDueDateDelegate(QObject *parent = nullptr);
~TodoDueDateDelegate() override;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
......@@ -126,8 +120,6 @@ class TodoCategoriesDelegate : public QStyledItemDelegate
public:
explicit TodoCategoriesDelegate(QObject *parent = nullptr);
~TodoCategoriesDelegate() override;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
......@@ -150,8 +142,6 @@ class TodoRichTextDelegate : public QStyledItemDelegate
public:
explicit TodoRichTextDelegate(QObject *parent = nullptr);
~TodoRichTextDelegate() override;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
......
......@@ -28,11 +28,11 @@
#include "todoviewquicksearch.h"
#include <CalendarSupport/KCalPrefs>
#include <AkonadiWidgets/TagSelectionComboBox>
#include <Akonadi/Calendar/ETMCalendar>
#include <CalendarSupport/CategoryConfig>
#include <Libkdepim/KCheckComboBox>
#include <LibkdepimAkonadi/TagSelectionCombo>
#include <CalendarSupport/CategoryHierarchyReader>
......@@ -63,7 +63,8 @@ TodoViewQuickSearch::TodoViewQuickSearch(const Akonadi::ETMCalendar::Ptr &calend
layout->addWidget(mSearchLine, 3);
mCategoryCombo = new KPIM::TagSelectionCombo(this);
mCategoryCombo = new Akonadi::TagSelectionComboBox(this);
mCategoryCombo->setCheckable(true);
mCategoryCombo->setToolTip(
i18nc("@info:tooltip", "Filter on these categories"));
mCategoryCombo->setWhatsThis(
......@@ -71,11 +72,12 @@ TodoViewQuickSearch::TodoViewQuickSearch(const Akonadi::ETMCalendar::Ptr &calend
"Use this combobox to filter the to-dos that are shown by "
"a list of selected categories."));
const QString defaultText = i18nc("@item:inlistbox", "Select Categories");
mCategoryCombo->setDefaultText(defaultText);
mCategoryCombo->setSeparator(i18nc("@item:intext delimiter for joining category names", ","));
mCategoryCombo->lineEdit()->setPlaceholderText(defaultText);
connect(mCategoryCombo, &KPIM::TagSelectionCombo::checkedItemsChanged, this,
&TodoViewQuickSearch::emitFilterCategoryChanged);
connect(mCategoryCombo, &Akonadi::TagSelectionComboBox::selectionChanged,
this, [this]() {
Q_EMIT filterCategoryChanged(mCategoryCombo->selectionNames());
});
layout->addWidget(mCategoryCombo, 1);
......@@ -103,8 +105,10 @@ TodoViewQuickSearch::TodoViewQuickSearch(const Akonadi::ETMCalendar::Ptr &calend
"Use this combobox to filter the to-dos that are shown by "
"a list of selected priorities."));
mPriorityCombo->setDefaultText(i18nc("@item:inlistbox", "Select Priority"));
connect(mPriorityCombo, &KPIM::KCheckComboBox::checkedItemsChanged, this,
&TodoViewQuickSearch::emitFilterPriorityChanged);
connect(mPriorityCombo, &KPIM::KCheckComboBox::checkedItemsChanged,
this, [this]() {
Q_EMIT filterPriorityChanged(mPriorityCombo->checkedItems(Qt::UserRole));
});
layout->addWidget(mPriorityCombo, 1);
fillPriorities();
......@@ -142,12 +146,3 @@ void TodoViewQuickSearch::fillPriorities()
CalendarSupport::CategoryHierarchyReaderQComboBox(mPriorityCombo).read(priorityValues);
}
void TodoViewQuickSearch::emitFilterCategoryChanged()
{
Q_EMIT filterCategoryChanged(mCategoryCombo->checkedItems());
}
void TodoViewQuickSearch::emitFilterPriorityChanged()
{
Q_EMIT filterPriorityChanged(mPriorityCombo->checkedItems(Qt::UserRole));
}
......@@ -32,7 +32,10 @@
namespace KPIM {
class KCheckComboBox;
class TagSelectionCombo;
}
namespace Akonadi {
class TagSelectionComboBox;
}
class QLineEdit;
......@@ -42,9 +45,6 @@ class TodoViewQuickSearch : public QWidget
Q_OBJECT
public:
TodoViewQuickSearch(const Akonadi::ETMCalendar::Ptr &calendar, QWidget *parent);
~TodoViewQuickSearch()
{
}
void setCalendar(const Akonadi::ETMCalendar::Ptr &calendar);
......@@ -63,10 +63,6 @@ Q_SIGNALS:
public Q_SLOTS:
void reset();
private Q_SLOTS:
void emitFilterCategoryChanged();
void emitFilterPriorityChanged();
private:
/** Helper method for the filling of the priority combo. */
void fillPriorities();
......@@ -74,7 +70,7 @@ private:
Akonadi::ETMCalendar::Ptr mCalendar;
QLineEdit *mSearchLine = nullptr;
KPIM::TagSelectionCombo *mCategoryCombo = nullptr;
Akonadi::TagSelectionComboBox *mCategoryCombo = nullptr;
KPIM::KCheckComboBox *mPriorityCombo = nullptr;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment