File indexing completed on 2024-05-26 05:56:32

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_ABSTRACTFINDDIALOG_HPP
0010 #define KASTEN_ABSTRACTFINDDIALOG_HPP
0011 
0012 // lib
0013 #include "finddirection.hpp"
0014 // Okteta Kasten gui
0015 #include <Kasten/Okteta/ByteArrayComboBox>
0016 // Qt
0017 #include <QDialog>
0018 #include <QByteArray>
0019 #include <QString>
0020 
0021 class QGroupBox;
0022 class QCheckBox;
0023 class QPushButton;
0024 class QVBoxLayout;
0025 
0026 namespace Kasten {
0027 
0028 class AbstractFindDialog : public QDialog
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     explicit AbstractFindDialog(QWidget* parent = nullptr);
0034     ~AbstractFindDialog() override;
0035 
0036 public: // set
0037     void setSearchDataCoding(Okteta::ByteArrayComboBox::Coding codecId);
0038     void setDirection(FindDirection Direction);
0039     void setInSelection(bool InSelection);
0040     void setInSelectionEnabled(bool inSelectionEnabled);
0041     void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity);
0042     void setFromCursor(bool fromCursor);
0043 
0044 public: // get
0045     QByteArray searchData() const;
0046     Okteta::ByteArrayComboBox::Coding searchDataCoding() const;
0047     bool fromCursor() const;
0048     bool inSelection() const;
0049     bool persistentInSelection() const;
0050     Qt::CaseSensitivity caseSensitivity() const;
0051     FindDirection direction() const;
0052 
0053 public Q_SLOTS:
0054     void setCharCodec(const QString& codecName);
0055 
0056 protected: // QWidget API
0057     void showEvent(QShowEvent* showEvent) override;
0058 
0059 protected:
0060     void setFindButton(const QString& buttonText, const QString& buttonIconName,
0061                        const QString& buttonToolTip, const QString& buttonWhatsThis);
0062     void setFindButtonEnabled(bool enabled);
0063     void setupFindBox();
0064     void setupOperationBox(QGroupBox* operationBox = nullptr);
0065     void setupCheckBoxes(QCheckBox* optionCheckBox = nullptr);
0066 
0067 protected: // API to be implemented
0068     virtual void onFindButtonClicked();
0069     virtual void rememberCurrentSettings();
0070 
0071 private Q_SLOTS:
0072     void onSearchDataChanged(const QByteArray& data);
0073     void onSearchDataFormatChanged(int index);
0074     void onSelectedToggled(bool checked);
0075     void forwardFindButtonClicked();
0076 
0077 private:
0078     QVBoxLayout* MainWidgetLayout;
0079     Okteta::ByteArrayComboBox* SearchDataEdit;
0080     QCheckBox* BackwardsCheckBox;
0081     QCheckBox* AtCursorCheckBox;
0082     QCheckBox* SelectedCheckBox;
0083     QCheckBox* WholeWordsCheckBox;
0084     QCheckBox* CaseSensitiveCheckBox;
0085     QPushButton* FindButton;
0086 
0087     // used to store the value when inSelection is disabled
0088     bool ShadowInSelection;
0089 };
0090 
0091 }
0092 
0093 #endif