File indexing completed on 2024-06-16 05:24:50
0001 /* 0002 This file is part of the Okteta Kasten module, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 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_GOTOOFFSETTOOL_HPP 0010 #define KASTEN_GOTOOFFSETTOOL_HPP 0011 0012 // Okteta core 0013 #include <Okteta/Address> 0014 // Kasten core 0015 #include <Kasten/AbstractTool> 0016 0017 namespace Okteta { 0018 class AbstractByteArrayModel; 0019 } 0020 0021 namespace Kasten { 0022 0023 class ByteArrayView; 0024 0025 /** 0026 */ 0027 class GotoOffsetTool : public AbstractTool 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 GotoOffsetTool(); 0033 ~GotoOffsetTool() override; 0034 0035 public: // AbstractTool API 0036 // virtual AbstractModel* targetModel() const; 0037 QString title() const override; 0038 0039 void setTargetModel(AbstractModel* model) override; 0040 0041 public: // status 0042 int currentOffset() const; 0043 int targetOffset() const; 0044 bool isRelative() const; 0045 bool isSelectionToExtent() const; 0046 bool isBackwards() const; 0047 0048 bool isUsable() const; 0049 bool isApplyable() const; // candidate for AbstractTool API 0050 0051 public Q_SLOTS: // settings 0052 void setTargetOffset(Okteta::Address targetOffset); 0053 void setIsRelative(bool isRelative); 0054 void setIsSelectionToExtent(bool isSelectionToExtent); 0055 void setIsBackwards(bool isBackwards); 0056 0057 public Q_SLOTS: // actions 0058 void gotoOffset(); 0059 0060 Q_SIGNALS: 0061 void isUsableChanged(bool isUsable); 0062 void isApplyableChanged(bool isApplyable); // candidate for AbstractTool API 0063 // TODO: isAtLine useful, to prevent noop actions, or should they be allowed, too? 0064 0065 private Q_SLOTS: 0066 void onContentsChanged(); 0067 0068 private: 0069 int finalTargetOffset() const; 0070 0071 private: // settings 0072 int mTargetOffset = 0; 0073 bool mIsRelative = false; 0074 bool mIsSelectionToExtent = false; 0075 bool mIsBackwards = false; 0076 0077 private: // target 0078 ByteArrayView* mByteArrayView = nullptr; 0079 Okteta::AbstractByteArrayModel* mByteArrayModel = nullptr; 0080 }; 0081 0082 inline int GotoOffsetTool::targetOffset() const { return mTargetOffset; } 0083 inline bool GotoOffsetTool::isRelative() const { return mIsRelative; } 0084 inline bool GotoOffsetTool::isSelectionToExtent() const { return mIsSelectionToExtent; } 0085 inline bool GotoOffsetTool::isBackwards() const { return mIsBackwards; } 0086 0087 } 0088 0089 #endif