File indexing completed on 2024-06-16 05:24:56

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2006-2007, 2009, 2023 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_REPLACEDIALOG_HPP
0010 #define KASTEN_REPLACEDIALOG_HPP
0011 
0012 // lib
0013 #include <abstractfinddialog.hpp>
0014 // Okteta Kasten gui
0015 #include <Kasten/Okteta/ByteArrayComboBox>
0016 
0017 namespace Kasten {
0018 
0019 class ReplaceTool;
0020 
0021 class ReplaceDialog : public AbstractFindDialog
0022 {
0023     Q_OBJECT
0024 
0025 private:
0026     static inline constexpr char ConfigGroupId[] = "ReplaceTool";
0027 
0028     static inline constexpr char FromCursorConfigKey[] = "FromCursor";
0029     static inline constexpr char DirectionConfigKey[] = "Direction";
0030     static inline constexpr char InSelectionConfigKey[] = "InSelection";
0031     static inline constexpr char ReplaceDataCodingConfigKey[] = "ReplaceDataCoding";
0032     static inline constexpr char SearchDataCodingConfigKey[] = "SearchDataCoding";
0033 
0034     static inline constexpr bool DefaultFromCursor = false;
0035     static inline constexpr Kasten::FindDirection DefaultDirection = Kasten::FindForward;
0036     static inline constexpr bool DefaultInSelection = false;
0037     static inline constexpr Okteta::ByteArrayComboBox::Coding DefaultReplaceDataCoding = Okteta::ByteArrayComboBox::HexadecimalCoding;
0038     static inline constexpr Okteta::ByteArrayComboBox::Coding DefaultSearchDataCoding = Okteta::ByteArrayComboBox::HexadecimalCoding;
0039 
0040 public:
0041     explicit ReplaceDialog(ReplaceTool* tool, QWidget* parent = nullptr);
0042     ~ReplaceDialog() override;
0043 
0044 public: // set
0045 //     void setDirection( KReplaceDirection Direction );
0046     void setCharCodec(const QString& codecName);
0047 
0048 public: // get
0049     QByteArray replaceData() const;
0050     bool prompt() const;
0051 
0052 protected: // AbstractFindDialog API
0053     void onFindButtonClicked() override;
0054     void rememberCurrentSettings() override;
0055 
0056 protected: // QWidget API
0057     void showEvent(QShowEvent* showEvent) override;
0058 
0059 private:
0060     void setReplaceDataCoding(Okteta::ByteArrayComboBox::Coding replaceDataCoding);
0061     Okteta::ByteArrayComboBox::Coding replaceDataCoding() const;
0062 
0063 private:
0064     Okteta::ByteArrayComboBox* ReplaceDataEdit;
0065     QCheckBox* PromptCheckBox;
0066 
0067     ReplaceTool* mTool;
0068 };
0069 
0070 }
0071 
0072 #endif