File indexing completed on 2025-01-05 05:23:36

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2006-2009 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef KASTEN_REPLACECONTROLLER_HPP
0010 #define KASTEN_REPLACECONTROLLER_HPP
0011 
0012 // controller
0013 #include "replaceuserqueryable.hpp"
0014 // libfinddialog
0015 #include "finddirection.hpp"
0016 // Kasten gui
0017 #include <Kasten/AbstractXmlGuiController>
0018 
0019 class KXMLGUIClient;
0020 class QAction;
0021 class QWidget;
0022 
0023 namespace Kasten {
0024 
0025 class ReplaceDialog;
0026 class ReplacePrompt;
0027 class ReplaceTool;
0028 
0029 class ReplaceController : public AbstractXmlGuiController
0030                         , public If::ReplaceUserQueryable
0031 {
0032     Q_OBJECT
0033     Q_INTERFACES(
0034         Kasten::If::ReplaceUserQueryable
0035     )
0036 
0037 public:
0038     ReplaceController(KXMLGUIClient* guiClient, QWidget* parentWidget);
0039 
0040     ~ReplaceController() override;
0041 
0042 public: // AbstractXmlGuiController API
0043     void setTargetModel(AbstractModel* model) override;
0044 
0045 public: // If::ReplaceUserQueryable API
0046     void queryContinue(FindDirection direction, int noOfReplacements) override;
0047     void queryReplaceCurrent() override;
0048 
0049 Q_SIGNALS: // If::ReplaceUserQueryable API
0050     void queryContinueFinished(bool result) override;
0051     void queryReplaceCurrentFinished(Kasten::ReplaceBehaviour result) override;
0052 
0053 private Q_SLOTS: // action slots
0054     void replace();
0055 
0056     void onPromptReply(Kasten::ReplaceBehaviour behaviour);
0057     void onFinished(bool previousFound, int noOfReplacements);
0058 
0059 private:
0060     QWidget* mParentWidget;
0061 
0062     QAction* mReplaceAction;
0063 
0064     ReplaceDialog* mReplaceDialog = nullptr;
0065     mutable ReplacePrompt* mReplacePrompt = nullptr;
0066     ReplaceTool* mTool;
0067 };
0068 
0069 }
0070 
0071 #endif