File indexing completed on 2025-09-14 05:48:36
0001 /* 0002 This file is part of the Okteta Kasten module, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2006-2012 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_BYTEARRAYVIEW_HPP 0010 #define KASTEN_BYTEARRAYVIEW_HPP 0011 0012 // lib 0013 #include "oktetakastengui_export.hpp" 0014 // Okteta Kasten core 0015 #include <Kasten/Okteta/ByteArraySelection> 0016 // Kasten gui 0017 #include <Kasten/AbstractView> 0018 #include <Kasten/Zoomable> // TODO: able instead of interface? or else? 0019 #include <Kasten/DataSelectable> 0020 #include <Kasten/SelectedDataWriteable> 0021 // Okteta core 0022 #include <Okteta/AddressRange> 0023 0024 namespace Okteta { 0025 class ByteArrayJanusView; 0026 } 0027 class QRect; 0028 class QPoint; 0029 0030 namespace Kasten { 0031 class ByteArrayViewProfileSynchronizer; 0032 class ByteArrayDocument; 0033 class KCursorProxy; 0034 0035 class OKTETAKASTENGUI_EXPORT ByteArrayView : public AbstractView 0036 , public If::Zoomable 0037 , public If::DataSelectable 0038 , public If::SelectedDataWriteable 0039 { 0040 Q_OBJECT 0041 Q_INTERFACES( 0042 Kasten::If::Zoomable 0043 Kasten::If::DataSelectable 0044 Kasten::If::SelectedDataWriteable 0045 ) 0046 0047 public: 0048 enum 0049 { 0050 ColumnViewId = 0, 0051 RowViewId 0052 }; 0053 0054 public: 0055 ByteArrayView(ByteArrayDocument* document, ByteArrayViewProfileSynchronizer* synchronizer); 0056 ByteArrayView(ByteArrayView* other, ByteArrayViewProfileSynchronizer* synchronizer, 0057 Qt::Alignment alignment = {}); 0058 0059 ~ByteArrayView() override; 0060 0061 public: 0062 // KCursorObject *cursor() const; 0063 0064 public: // AbstractModel API 0065 QString title() const override; 0066 bool isModifiable() const override; 0067 bool isReadOnly() const override; 0068 void setReadOnly(bool isReadOnly) override; 0069 0070 public: // AbstractView API 0071 void setFocus() override; 0072 QWidget* widget() const override; 0073 bool hasFocus() const override; 0074 0075 public: // If::Zoomable API TODO: make all such methods slots? 0076 void setZoomLevel(double Level) override; 0077 double zoomLevel() const override; 0078 Q_SIGNALS: 0079 void zoomLevelChanged(double Level) override; 0080 0081 public: // If::DataSelectable API 0082 void selectAllData(bool selectAll) override; 0083 bool hasSelectedData() const override; 0084 QMimeData* copySelectedData() const override; 0085 const AbstractModelSelection* modelSelection() const override; 0086 // virtual void setSelection(); 0087 Q_SIGNALS: 0088 void hasSelectedDataChanged(bool hasSelectedData) override; 0089 void selectedDataChanged(const Kasten::AbstractModelSelection* modelSelection) override; 0090 0091 public: // If::SelectedDataWriteable API 0092 void insertData(const QMimeData* data) override; 0093 QMimeData* cutSelectedData() override; 0094 void deleteSelectedData() override; 0095 bool canReadData(const QMimeData* data) const override; 0096 bool canCutSelectedData() const override; 0097 Q_SIGNALS: 0098 void canCutSelectedDataChanged(bool canCutSelectedData) override; 0099 0100 public: // cursor API 0101 void setCursorPosition(Okteta::Address cursorPosition); 0102 void setSelectionCursorPosition(Okteta::Address index); 0103 Okteta::Address cursorPosition() const; 0104 Q_SIGNALS: 0105 void cursorPositionChanged(Okteta::Address cursorPosition); 0106 0107 public: // codings 0108 void setValueCoding(int valueCoding); 0109 void setCharCoding(const QString& charCodingName); 0110 QString charCodingName() const; 0111 int valueCoding() const; 0112 Q_SIGNALS: 0113 void charCodecChanged(const QString& charCodingName); 0114 void valueCodingChanged(int valueCoding); 0115 0116 public: 0117 // TODO: see how this can be solved by modelSelection 0118 Okteta::AddressRange selection() const; 0119 void setSelection(Okteta::Address start, Okteta::Address end); 0120 void insert(const QByteArray& byteArray); 0121 QRect cursorRect() const; 0122 0123 public: // overwrite 0124 void setOverwriteMode(bool overwriteMode); 0125 bool isOverwriteMode() const; 0126 bool isOverwriteOnly() const; 0127 Q_SIGNALS: 0128 void overwriteModeChanged(bool overwriteMode); 0129 0130 public: // elements 0131 void toggleOffsetColumn(bool offsetColumnVisible); 0132 void setOffsetCoding(int offsetCoding); 0133 void setVisibleByteArrayCodings(int columns); 0134 void setMarking(const Okteta::AddressRange& range, bool ensureVisible = false); 0135 bool offsetColumnVisible() const; 0136 int offsetCoding() const; 0137 int visibleByteArrayCodings() const; 0138 Q_SIGNALS: 0139 void offsetColumnVisibleChanged(bool visible); 0140 void visibleByteArrayCodingsChanged(int columns); 0141 void offsetCodingChanged(int offsetCoding); 0142 0143 public: // table layout 0144 void setLayoutStyle(int layoutStyle); 0145 void setNoOfBytesPerLine(int noOfBytesPerLine); 0146 Okteta::Address startOffset() const; 0147 Okteta::Address firstLineOffset() const; 0148 int noOfBytesPerLine() const; 0149 int layoutStyle() const; 0150 Q_SIGNALS: 0151 void layoutStyleChanged(int layoutStyle); 0152 void noOfBytesPerLineChanged(int noOfBytesPerLine); 0153 0154 public: // layout settings 0155 void setShowsNonprinting(bool showsNonprinting = true); 0156 void setNoOfGroupedBytes(int noOfGroupedBytes); 0157 void setSubstituteChar(QChar substituteChar); 0158 void setUndefinedChar(QChar undefinedChar); 0159 QChar substituteChar() const; 0160 QChar undefinedChar() const; 0161 bool showsNonprinting() const; 0162 0163 int byteSpacingWidth() const; 0164 int noOfGroupedBytes() const; 0165 int groupSpacingWidth() const; 0166 int binaryGapWidth() const; 0167 Q_SIGNALS: 0168 void showsNonprintingChanged(bool showsNonprinting); 0169 void substituteCharChanged(QChar substituteChar); 0170 void undefinedCharChanged(QChar undefinedChar); 0171 void noOfGroupedBytesChanged(int noOfGroupedBytes); 0172 0173 public: 0174 void setViewModus(int viewModus); 0175 int viewModus() const; 0176 Q_SIGNALS: 0177 void viewModusChanged(int viewModus); 0178 0179 Q_SIGNALS: 0180 void viewContextMenuRequested(QPoint pos); 0181 0182 public: 0183 ByteArrayViewProfileSynchronizer* synchronizer() const; 0184 0185 private: 0186 OKTETAKASTENGUI_NO_EXPORT void init(); 0187 0188 private Q_SLOTS: 0189 OKTETAKASTENGUI_NO_EXPORT void setFontByGlobalSettings(); 0190 0191 OKTETAKASTENGUI_NO_EXPORT void onSelectionChanged(const Okteta::AddressRange& selection); 0192 OKTETAKASTENGUI_NO_EXPORT void onOverwriteModeChanged(bool overwriteMode); 0193 0194 private: 0195 Okteta::ByteArrayJanusView* mWidget; 0196 ByteArrayDocument* mDocument; 0197 ByteArraySelection mSelection; 0198 // KCursorProxy *mCursorProxy; 0199 0200 ByteArrayViewProfileSynchronizer* const mByteArrayViewProfileSynchronizer; 0201 }; 0202 0203 } 0204 0205 #endif