Commit 57602e0c authored by Laurent Montel's avatar Laurent Montel 😁

Save list of Collections

parent 9e50c42c
......@@ -39,13 +39,6 @@ FolderConfigureSettingsWidget::~FolderConfigureSettingsWidget()
void FolderConfigureSettingsWidget::save()
{
#if 0
const auto indexes = checkable->selectionModel()->selectedIndexes();
QSet<qint64> list;
list.reserve(indexes.count());
for (const auto &index : indexes) {
list << index.data(Akonadi::EntityTreeModel::CollectionIdRole).toLongLong();
}
#endif
//TODO
const Akonadi::Collection::List collections = mFolderConfigureTreeWidget->listCollections();
mFolderConfigureSettingsPageWidget->save(collections);
}
......@@ -32,11 +32,11 @@ FolderConfigureTreeWidget::FolderConfigureTreeWidget(QWidget *parent)
checkable->setSourceModel(sourceModel);
checkable->setSelectionModel(selectionModel);
auto folderSettingFilterProxyModel = new FolderSettingFilterProxyModel(this);
folderSettingFilterProxyModel->setObjectName(QStringLiteral("folderSettingFilterProxyModel"));
folderSettingFilterProxyModel->setSourceModel(checkable);
mFolderSettingFilterProxyModel = new FolderSettingFilterProxyModel(this);
mFolderSettingFilterProxyModel->setObjectName(QStringLiteral("folderSettingFilterProxyModel"));
mFolderSettingFilterProxyModel->setSourceModel(checkable);
ftv->setModel(folderSettingFilterProxyModel);
ftv->setModel(mFolderSettingFilterProxyModel);
ftv->expandAll();
mainLayout->addWidget(ftw);
......@@ -45,3 +45,8 @@ FolderConfigureTreeWidget::FolderConfigureTreeWidget(QWidget *parent)
FolderConfigureTreeWidget::~FolderConfigureTreeWidget()
{
}
Akonadi::Collection::List FolderConfigureTreeWidget::listCollections() const
{
return mFolderSettingFilterProxyModel->listCollections();
}
......@@ -9,12 +9,17 @@
#include <QWidget>
#include "folderconfiguresettings_private_export.h"
#include <AkonadiCore/Collection>
class FolderSettingFilterProxyModel;
class LIBFOLDERCONFIGURESETTINGS_TESTS_EXPORT FolderConfigureTreeWidget : public QWidget
{
Q_OBJECT
public:
explicit FolderConfigureTreeWidget(QWidget *parent = nullptr);
~FolderConfigureTreeWidget();
Q_REQUIRED_RESULT Akonadi::Collection::List listCollections() const;
private:
FolderSettingFilterProxyModel *mFolderSettingFilterProxyModel = nullptr;
};
#endif // FOLDERCONFIGURETREEWIDGET_H
......@@ -40,6 +40,11 @@ Qt::ItemFlags FolderSettingFilterProxyModel::flags(const QModelIndex &index) con
}
}
Akonadi::Collection::List FolderSettingFilterProxyModel::listCollections() const
{
return mListCollections;
}
bool FolderSettingFilterProxyModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (role == Qt::CheckStateRole) {
......@@ -51,7 +56,6 @@ bool FolderSettingFilterProxyModel::setData(const QModelIndex &index, const QVar
} else {
mListCollections.removeAll(collection);
}
qDebug() << " collectionId " << collection.id();
Q_EMIT dataChanged(index, index);
}
}
......
......@@ -21,6 +21,9 @@ public:
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Q_REQUIRED_RESULT Qt::ItemFlags flags(const QModelIndex &index) const override;
Q_REQUIRED_RESULT Akonadi::Collection::List listCollections() const;
private:
Akonadi::Collection::List mListCollections;
};
......
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