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

Remove historyswitchfoldermanager

parent 399ee267
Pipeline #97950 passed with stage
in 13 minutes and 57 seconds
......@@ -173,7 +173,6 @@ target_sources(kmailprivate PRIVATE
manageshowcollectionproperties.cpp
kmmigrateapplication.cpp
kmail.qrc
historyswitchfolder/historyswitchfoldermanager.cpp
attributes/taskattribute.h
folderarchive/folderarchiveaccountinfo.h
......@@ -304,7 +303,6 @@ target_sources(kmailprivate PRIVATE
kmlaunchexternalcomponent.h
manageshowcollectionproperties.h
kmmigrateapplication.h
historyswitchfolder/historyswitchfoldermanager.h
historyswitchfolder/collectionswitchertreeview.cpp
historyswitchfolder/collectionswitchertreeview.h
historyswitchfolder/collectionswitchertreeviewmanager.h
......
......@@ -43,6 +43,8 @@ QVariant CollectionSwitcherModel::data(const QModelIndex &index, int role) const
void CollectionSwitcherModel::addHistory(const Akonadi::Collection &currentCol, const QString &fullPath)
{
mCollectionsInfo.append({currentCol, fullPath});
qDebug() << " void CollectionSwitcherModel::addHistory(const Akonadi::Collection &currentCol, const QString &fullPath) " << fullPath;
qDebug() << " mCollectionsInfo " << mCollectionsInfo.count();
}
const Akonadi::Collection CollectionSwitcherModel::collection(int index)
......
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "historyswitchfoldermanager.h"
#include "kmail_debug.h"
HistorySwitchFolderManager::HistorySwitchFolderManager(QObject *parent)
: QObject{parent}
, mUndoStack(new QUndoStack(this))
{
// Not necessary to store to many info
mUndoStack->setUndoLimit(10);
}
HistorySwitchFolderManager::~HistorySwitchFolderManager()
{
}
void HistorySwitchFolderManager::addHistory(const Akonadi::Collection &currentCol, const Akonadi::Collection &col, const QString &fullPath)
{
if (col.isValid()) {
mUndoStack->push(new HistorySwitchFolderCommand(this, currentCol, col, fullPath));
}
}
void HistorySwitchFolderManager::clear()
{
mUndoStack->clear();
}
void HistorySwitchFolderManager::changeCollection(const Akonadi::Collection &currentCol)
{
if (currentCol.isValid()) {
qCDebug(KMAIL_LOG) << "HistorySwitchFolderManager::changeCollection " << currentCol;
Q_EMIT switchToFolder(currentCol);
}
}
void HistorySwitchFolderManager::undo()
{
qCDebug(KMAIL_LOG) << " void HistorySwitchFolderManager::undo()" << mUndoStack->canUndo();
if (mUndoStack->canUndo()) {
mUndoStack->undo();
}
}
void HistorySwitchFolderManager::redo()
{
qCDebug(KMAIL_LOG) << " void HistorySwitchFolderManager::redo()" << mUndoStack->canRedo();
if (mUndoStack->canRedo()) {
mUndoStack->redo();
}
}
HistorySwitchFolderCommand::HistorySwitchFolderCommand(HistorySwitchFolderManager *manager,
const Akonadi::Collection &currentCol,
const Akonadi::Collection &col,
const QString &realPath)
: mCurrentCollection(currentCol)
, mNewCollection(col)
, mFullPath(realPath)
, mManager(manager)
{
}
void HistorySwitchFolderCommand::undo()
{
mManager->changeCollection(mCurrentCollection);
}
void HistorySwitchFolderCommand::redo()
{
mManager->changeCollection(mNewCollection);
}
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <Akonadi/Collection>
#include <QObject>
#include <QUndoStack>
class QUndoStack;
class HistorySwitchFolderManager : public QObject
{
Q_OBJECT
public:
explicit HistorySwitchFolderManager(QObject *parent = nullptr);
~HistorySwitchFolderManager() override;
// Add static method
void clear();
void addHistory(const Akonadi::Collection &currentCol, const Akonadi::Collection &col, const QString &fullPath = {});
void changeCollection(const Akonadi::Collection &currentCol);
void undo();
void redo();
Q_SIGNALS:
void switchToFolder(const Akonadi::Collection &col);
private:
QUndoStack *const mUndoStack;
};
class HistorySwitchFolderCommand : public QUndoCommand
{
public:
explicit HistorySwitchFolderCommand(HistorySwitchFolderManager *manager,
const Akonadi::Collection &currentCol,
const Akonadi::Collection &col,
const QString &realPath);
void undo() override;
void redo() override;
private:
const Akonadi::Collection mCurrentCollection;
const Akonadi::Collection mNewCollection;
QString mFullPath;
HistorySwitchFolderManager *const mManager;
};
......@@ -134,7 +134,6 @@
#include <PimCommon/LogActivitiesManager>
#include "historyswitchfolder/historyswitchfoldermanager.h"
#include "kmail_debug.h"
#include <KAcceleratorManager>
......@@ -202,7 +201,6 @@ KMMainWidget::KMMainWidget(QWidget *parent, KXMLGUIClient *aGUIClient, KActionCo
: QWidget(parent)
, mLaunchExternalComponent(new KMLaunchExternalComponent(this, this))
, mManageShowCollectionProperties(new ManageShowCollectionProperties(this, this))
, mHistorySwitchFolderManager(new HistorySwitchFolderManager(this))
, mCollectionSwitcherTreeViewManager(new CollectionSwitcherTreeViewManager(this))
{
// must be the first line of the constructor:
......@@ -339,8 +337,8 @@ KMMainWidget::KMMainWidget(QWidget *parent, KXMLGUIClient *aGUIClient, KActionCo
connect(&mCheckMailTimer, &QTimer::timeout, this, &KMMainWidget::slotUpdateActionsAfterMailChecking);
setupUnifiedMailboxChecker();
connect(mHistorySwitchFolderManager, &HistorySwitchFolderManager::switchToFolder, this, &KMMainWidget::slotHistorySwitchFolder);
mCollectionSwitcherTreeViewManager->setParentWidget(this);
connect(mCollectionSwitcherTreeViewManager, &CollectionSwitcherTreeViewManager::switchToFolder, this, &KMMainWidget::slotHistorySwitchFolder);
}
QWidget *KMMainWidget::dkimWidgetInfo() const
......@@ -487,8 +485,8 @@ void KMMainWidget::slotFolderChanged(const Akonadi::Collection &collection)
if (mCurrentCollection == collection) {
return;
}
mHistorySwitchFolderManager->addHistory(mCurrentCollection, collection, MailCommon::Util::fullCollectionPath(collection));
mCollectionSwitcherTreeViewManager->addHistory(collection, MailCommon::Util::fullCollectionPath(collection));
slotHistorySwitchFolder(collection);
}
void KMMainWidget::slotHistorySwitchFolder(const Akonadi::Collection &collection)
......@@ -3549,13 +3547,11 @@ void KMMainWidget::setupActions()
void KMMainWidget::redoSwitchFolder()
{
mHistorySwitchFolderManager->redo();
mCollectionSwitcherTreeViewManager->selectBackward();
}
void KMMainWidget::undoSwitchFolder()
{
mHistorySwitchFolderManager->undo();
mCollectionSwitcherTreeViewManager->selectForward();
}
......
......@@ -91,7 +91,6 @@ class MailFilter;
}
class QStatusBar;
class KMailPluginCheckBeforeDeletingManagerInterface;
class HistorySwitchFolderManager;
class CollectionSwitcherTreeViewManager;
class KMAIL_EXPORT KMMainWidget : public QWidget
{
......@@ -656,7 +655,6 @@ private:
KUserFeedback::NotificationPopup *mUserFeedBackNotificationPopup = nullptr;
#endif
KMailPluginCheckBeforeDeletingManagerInterface *mPluginCheckBeforeDeletingManagerInterface = nullptr;
HistorySwitchFolderManager *const mHistorySwitchFolderManager;
CollectionSwitcherTreeViewManager *const mCollectionSwitcherTreeViewManager;
};
Supports Markdown
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