Commit a413b4d6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Clean up + rename widget

parent 21c52bf5
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.14.43")
set(PIM_VERSION "5.14.44")
project(libkdepim VERSION ${PIM_VERSION})
......
......@@ -60,7 +60,7 @@ set(kdepim_job_LIB_SRCS
)
set(kdepimakonadi_widgets_LIB_SRCS
widgets/tagselectioncombo.cpp
widgets/tagcombobox.cpp
)
......@@ -130,7 +130,7 @@ install(TARGETS
ecm_generate_headers(libkdepimakonadi_Camelcasewidgets_HEADERS
HEADER_NAMES
TagSelectionCombo
TagComboBox
REQUIRED_HEADERS libkdepimakonadi_widgets_HEADERS
PREFIX LibkdepimAkonadi
RELATIVE widgets
......
......@@ -16,55 +16,16 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "tagselectioncombo.h"
#include "tagcombobox.h"
#include <AkonadiCore/Monitor>
#include <AkonadiCore/TagModel>
#include <KCheckableProxyModel>
#include <QItemSelectionModel>
using namespace KPIM;
class MatchingCheckableProxyModel : public KCheckableProxyModel
{
public:
MatchingCheckableProxyModel(QObject *parent = nullptr) : KCheckableProxyModel(parent)
{
}
QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchExactly) const override
{
if (role == Qt::CheckStateRole) {
return selectionModel()->selectedRows();
}
return KCheckableProxyModel::match(start, role, value, hits, flags);
}
};
TagSelectionCombo::TagSelectionCombo(QWidget *parent)
: KPIM::KCheckComboBox(parent)
{
Akonadi::Monitor *monitor = new Akonadi::Monitor(this);
monitor->setObjectName(QStringLiteral("TagSelectionComboMonitor"));
monitor->setTypeMonitored(Akonadi::Monitor::Tags);
Akonadi::TagModel *model = new Akonadi::TagModel(monitor, this);
QItemSelectionModel *selectionModel = new QItemSelectionModel(model, this);
KCheckableProxyModel *checkableProxy = new MatchingCheckableProxyModel(this);
checkableProxy->setSourceModel(model);
checkableProxy->setSelectionModel(selectionModel);
setModel(checkableProxy);
//We need to reconnect from the constructor of KCheckComboBox to the new model
connect(checkableProxy, &QAbstractItemModel::dataChanged, this, [this](const QModelIndex &topLeft, const QModelIndex &bottomRight) {
updateCheckedItems(topLeft, bottomRight);
});
}
TagCombo::TagCombo(QWidget *parent)
TagComboBox::TagComboBox(QWidget *parent)
: KComboBox(parent)
{
Akonadi::Monitor *monitor = new Akonadi::Monitor(this);
......
......@@ -16,33 +16,23 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef TAGSELECTIONCOMBO_H
#define TAGSELECTIONCOMBO_H
#ifndef TAGCOMBOBOX_H
#define TAGCOMBOBOX_H
#include "kdepimakonadi_export.h"
#include <KComboBox>
#include <libkdepim/kcheckcombobox.h>
namespace KPIM {
/**
* @brief The TagSelectionCombo class
*/
class KDEPIMAKONADI_EXPORT TagSelectionCombo : public KPIM::KCheckComboBox
{
Q_OBJECT
public:
explicit TagSelectionCombo(QWidget *parent = nullptr);
};
/**
* @brief The TagCombo class
*/
class KDEPIMAKONADI_EXPORT TagCombo : public KComboBox
class KDEPIMAKONADI_EXPORT TagComboBox : public KComboBox
{
Q_OBJECT
public:
explicit TagCombo(QWidget *parent = nullptr);
explicit TagComboBox(QWidget *parent = nullptr);
};
}
#endif // TAGSELECTIONCOMBO_H
#endif
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