File indexing completed on 2024-12-22 05:01:09

0001 /*
0002 This file is part of KMail, the KDE mail client.
0003 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0004 
0005 SPDX-License-Identifier: GPL-2.0-only
0006 */
0007 #pragma once
0008 
0009 #include "kmail_private_export.h"
0010 #include <Akonadi/Collection>
0011 #include <QList>
0012 #include <QObject>
0013 class CollectionSwitcherTreeView;
0014 class CollectionSwitcherModel;
0015 class QAction;
0016 
0017 class KMAILTESTS_TESTS_EXPORT CollectionSwitcherTreeViewManager : public QObject
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit CollectionSwitcherTreeViewManager(QObject *parent = nullptr);
0022     ~CollectionSwitcherTreeViewManager() override;
0023 
0024     void addActions(const QList<QAction *> &lst);
0025 
0026     [[nodiscard]] QWidget *parentWidget() const;
0027     void setParentWidget(QWidget *newParentWidget);
0028 
0029     void selectForward();
0030     void selectBackward();
0031     void updateViewGeometry();
0032 
0033     void addHistory(const Akonadi::Collection &currentCol, const QString &fullPath);
0034 
0035     [[nodiscard]] CollectionSwitcherTreeView *collectionSwitcherTreeView() const;
0036 
0037 Q_SIGNALS:
0038     void switchToFolder(const Akonadi::Collection &col);
0039 
0040 private:
0041     void activateCollection(const QModelIndex &index);
0042     void switchToCollectionClicked(const QModelIndex &index);
0043     void selectCollection(const int from, const int to);
0044     QWidget *mParentWidget = nullptr;
0045     CollectionSwitcherTreeView *const mCollectionSwitcherTreeView;
0046     CollectionSwitcherModel *const mCollectionSwitcherModel;
0047 };