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

Now we select/unselect several folder

CCBUG: 434063
parent 7b365138
Pipeline #53386 canceled with stage
in 5 minutes and 22 seconds
......@@ -7,9 +7,11 @@
#include "folderconfiguretreewidget.h"
#include "foldersettingfilterproxymodel.h"
#include <KCheckableProxyModel>
#include <KLocalizedString>
#include <MailCommon/FolderTreeView>
#include <MailCommon/FolderTreeWidget>
#include <QMenu>
#include <QPushButton>
#include <QVBoxLayout>
FolderConfigureTreeWidget::FolderConfigureTreeWidget(QWidget *parent)
......@@ -19,20 +21,23 @@ FolderConfigureTreeWidget::FolderConfigureTreeWidget(QWidget *parent)
auto mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainLayout"));
mainLayout->setContentsMargins({});
auto ftw = new MailCommon::FolderTreeWidget(this,
nullptr,
MailCommon::FolderTreeWidget::TreeViewOptions(MailCommon::FolderTreeWidget::UseDistinctSelectionModel
| MailCommon::FolderTreeWidget::HideStatistics
| MailCommon::FolderTreeWidget::HideHeaderViewMenu));
ftw->setObjectName(QStringLiteral("foldertreewidget"));
ftw->folderTreeView()->setDragEnabled(false);
ftw->folderTreeView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
ftw->folderTreeView()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ftw->folderTreeView(), &MailCommon::FolderTreeView::customContextMenuRequested, this, &FolderConfigureTreeWidget::slotCustomContextMenuRequested);
mFolderTreeWidget = new MailCommon::FolderTreeWidget(this,
nullptr,
MailCommon::FolderTreeWidget::TreeViewOptions(MailCommon::FolderTreeWidget::UseDistinctSelectionModel
| MailCommon::FolderTreeWidget::HideStatistics
| MailCommon::FolderTreeWidget::HideHeaderViewMenu));
mFolderTreeWidget->setObjectName(QStringLiteral("foldertreewidget"));
mFolderTreeWidget->folderTreeView()->setDragEnabled(false);
mFolderTreeWidget->folderTreeView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
mFolderTreeWidget->folderTreeView()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(mFolderTreeWidget->folderTreeView(),
&MailCommon::FolderTreeView::customContextMenuRequested,
this,
&FolderConfigureTreeWidget::slotCustomContextMenuRequested);
auto ftv = ftw->folderTreeView();
auto ftv = mFolderTreeWidget->folderTreeView();
auto sourceModel = ftv->model();
auto selectionModel = ftw->selectionModel();
auto selectionModel = mFolderTreeWidget->selectionModel();
auto checkable = new KCheckableProxyModel(this);
checkable->setObjectName(QStringLiteral("checkable"));
......@@ -44,14 +49,39 @@ FolderConfigureTreeWidget::FolderConfigureTreeWidget(QWidget *parent)
ftv->setModel(mFolderSettingFilterProxyModel);
ftv->expandAll();
mainLayout->addWidget(mFolderTreeWidget);
mainLayout->addWidget(ftw);
auto buttonLayout = new QHBoxLayout;
buttonLayout->setObjectName(QStringLiteral("buttonLayout"));
mainLayout->addLayout(buttonLayout);
auto selectFolder = new QPushButton(i18n("Select"), this);
selectFolder->setObjectName(QStringLiteral("selectFolder"));
buttonLayout->addWidget(selectFolder);
connect(selectFolder, &QPushButton::clicked, this, [this]() {
changeFolderSelection(true);
});
auto unSelectFolder = new QPushButton(i18n("Unselect"), this);
unSelectFolder->setObjectName(QStringLiteral("unSelectFolder"));
buttonLayout->addWidget(unSelectFolder);
connect(unSelectFolder, &QPushButton::clicked, this, [this]() {
changeFolderSelection(false);
});
}
FolderConfigureTreeWidget::~FolderConfigureTreeWidget()
{
}
void FolderConfigureTreeWidget::changeFolderSelection(bool select)
{
const QModelIndexList indexes = mFolderTreeWidget->folderTreeView()->selectionModel()->selectedIndexes();
for (const QModelIndex &selectedIndex : indexes) {
mFolderSettingFilterProxyModel->setData(selectedIndex, select ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
}
}
void FolderConfigureTreeWidget::slotCustomContextMenuRequested(const QPoint &)
{
QMenu menu(this);
......
......@@ -11,6 +11,10 @@
#include <AkonadiCore/Collection>
#include <QWidget>
class FolderSettingFilterProxyModel;
namespace MailCommon
{
class FolderTreeWidget;
}
class LIBFOLDERCONFIGURESETTINGS_TESTS_EXPORT FolderConfigureTreeWidget : public QWidget
{
Q_OBJECT
......@@ -21,7 +25,9 @@ public:
private:
void slotCustomContextMenuRequested(const QPoint &);
void changeFolderSelection(bool select);
FolderSettingFilterProxyModel *const mFolderSettingFilterProxyModel;
MailCommon::FolderTreeWidget *mFolderTreeWidget = nullptr;
};
#endif // FOLDERCONFIGURETREEWIDGET_H
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