File indexing completed on 2025-01-05 03:57:54

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2021-08-27
0007  * Description : Showfoto folder view undo command.
0008  *
0009  * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "showfotofolderviewundo.h"
0016 
0017 // Local includes
0018 
0019 #include "digikam_debug.h"
0020 #include "digikam_globals.h"
0021 
0022 namespace ShowFoto
0023 {
0024 
0025 class Q_DECL_HIDDEN ShowfotoFolderViewUndo::Private
0026 {
0027 
0028 public:
0029 
0030     explicit Private()
0031       : view(nullptr)
0032     {
0033     }
0034 
0035     ShowfotoFolderViewSideBar* view;
0036     QString                    oldPath;
0037     QString                    newPath;
0038 };
0039 
0040 ShowfotoFolderViewUndo::ShowfotoFolderViewUndo(ShowfotoFolderViewSideBar* const view,
0041                                                const QString& newPath)
0042     : QUndoCommand(),
0043       d           (new Private)
0044 {
0045     d->view    = view;
0046     d->oldPath = d->view->currentFolder();
0047     d->newPath = newPath;
0048 }
0049 
0050 ShowfotoFolderViewUndo::~ShowfotoFolderViewUndo()
0051 {
0052     delete d;
0053 }
0054 
0055 QString ShowfotoFolderViewUndo::undoPath() const
0056 {
0057     return d->oldPath;
0058 }
0059 
0060 void ShowfotoFolderViewUndo::undo()
0061 {
0062     d->view->setCurrentPathWithoutUndo(d->oldPath);
0063 }
0064 
0065 void ShowfotoFolderViewUndo::redo()
0066 {
0067     d->view->setCurrentPathWithoutUndo(d->newPath);
0068 }
0069 
0070 } // namespace ShowFoto