diff --git a/src/pimcommonakonadi/folderdialog/checkedcollectionwidget.cpp b/src/pimcommonakonadi/folderdialog/checkedcollectionwidget.cpp index d1c17b7..6ab95ce 100644 --- a/src/pimcommonakonadi/folderdialog/checkedcollectionwidget.cpp +++ b/src/pimcommonakonadi/folderdialog/checkedcollectionwidget.cpp @@ -1,148 +1,148 @@ /* Copyright (c) 2013-2017 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "checkedcollectionwidget.h" #include #include #include #include #include #if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) #include #else #include #endif #include #include #include #include #include using namespace PimCommon; class PimCommon::CheckedCollectionWidgetPrivate { public: CheckedCollectionWidgetPrivate() : mFolderView(nullptr) , mSelectionModel(nullptr) , mCheckProxy(nullptr) , mCollectionFilter(nullptr) , mEntityTreeModel(nullptr) { } QTreeView *mFolderView = nullptr; QItemSelectionModel *mSelectionModel = nullptr; KCheckableProxyModel *mCheckProxy = nullptr; #if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) KRecursiveFilterProxyModel *mCollectionFilter = nullptr; #else QSortFilterProxyModel *mCollectionFilter = nullptr; #endif Akonadi::EntityTreeModel *mEntityTreeModel = nullptr; }; CheckedCollectionWidget::CheckedCollectionWidget(const QString &mimetype, QWidget *parent) : QWidget(parent) , d(new PimCommon::CheckedCollectionWidgetPrivate) { QVBoxLayout *vbox = new QVBoxLayout(this); vbox->setMargin(0); // Create a new change recorder. Akonadi::Monitor *monitor = new Akonadi::Monitor(this); monitor->setObjectName(QStringLiteral("CheckedCollectionWidgetMonitor")); monitor->fetchCollection(true); monitor->setAllMonitored(true); monitor->setMimeTypeMonitored(mimetype); connect(monitor, &Akonadi::Monitor::collectionAdded, this, &CheckedCollectionWidget::collectionAdded); connect(monitor, &Akonadi::Monitor::collectionRemoved, this, &CheckedCollectionWidget::collectionRemoved); d->mEntityTreeModel = new Akonadi::EntityTreeModel(monitor, this); // Set the model to show only collections, not items. d->mEntityTreeModel->setItemPopulationStrategy(Akonadi::EntityTreeModel::NoItemPopulation); Akonadi::CollectionFilterProxyModel *mimeTypeProxy = new Akonadi::CollectionFilterProxyModel(this); mimeTypeProxy->setExcludeVirtualCollections(true); mimeTypeProxy->addMimeTypeFilters(QStringList() << mimetype); mimeTypeProxy->setSourceModel(d->mEntityTreeModel); // Create the Check proxy model. d->mSelectionModel = new QItemSelectionModel(mimeTypeProxy); d->mCheckProxy = new KCheckableProxyModel(this); d->mCheckProxy->setSelectionModel(d->mSelectionModel); d->mCheckProxy->setSourceModel(mimeTypeProxy); #if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) d->mCollectionFilter = new KRecursiveFilterProxyModel(this); d->mCollectionFilter->setDynamicSortFilter(true); #else d->mCollectionFilter = new QSortFilterProxyModel(this); - d->mCollectionFilter->setRecursiveFiltering(true); + d->mCollectionFilter->setRecursiveFilteringEnabled(true); #endif d->mCollectionFilter->setSourceModel(d->mCheckProxy); d->mCollectionFilter->setFilterCaseSensitivity(Qt::CaseInsensitive); QLineEdit *searchLine = new QLineEdit(this); searchLine->setPlaceholderText(i18n("Search...")); searchLine->setClearButtonEnabled(true); connect(searchLine, &QLineEdit::textChanged, this, &CheckedCollectionWidget::slotSetCollectionFilter); vbox->addWidget(searchLine); d->mFolderView = new QTreeView; d->mFolderView->setEditTriggers(QAbstractItemView::NoEditTriggers); d->mFolderView->setAlternatingRowColors(true); d->mFolderView->setModel(d->mCollectionFilter); vbox->addWidget(d->mFolderView); } CheckedCollectionWidget::~CheckedCollectionWidget() { delete d; } Akonadi::EntityTreeModel *CheckedCollectionWidget::entityTreeModel() const { return d->mEntityTreeModel; } QTreeView *CheckedCollectionWidget::folderTreeView() const { return d->mFolderView; } QItemSelectionModel *CheckedCollectionWidget::selectionModel() const { return d->mSelectionModel; } KCheckableProxyModel *CheckedCollectionWidget::checkableProxy() const { return d->mCheckProxy; } void CheckedCollectionWidget::slotSetCollectionFilter(const QString &filter) { d->mCollectionFilter->setFilterWildcard(filter); d->mFolderView->expandAll(); }