File indexing completed on 2024-06-23 05:48:47

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2008 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_INFOTOOL_HPP
0010 #define KASTEN_INFOTOOL_HPP
0011 
0012 // Kasten core
0013 #include <Kasten/AbstractTool>
0014 // Okteta core
0015 #include <Okteta/AddressRange>
0016 
0017 namespace Okteta {
0018 class AbstractByteArrayModel;
0019 }
0020 
0021 namespace Kasten {
0022 
0023 class StatisticTableModel;
0024 
0025 class ByteArrayView;
0026 
0027 /**
0028  */
0029 class InfoTool : public AbstractTool
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     InfoTool();
0035     ~InfoTool() override;
0036 
0037 public:
0038     StatisticTableModel* statisticTableModel() const;
0039     int size() const;
0040     bool isApplyable() const;
0041     bool isStatisticUptodate() const;
0042 
0043 public: // AbstractTool API
0044 //     virtual AbstractModel* targetModel() const;
0045     QString title() const override;
0046 
0047     void setTargetModel(AbstractModel* model) override;
0048 
0049 public Q_SLOTS:
0050     void updateStatistic();
0051 
0052 Q_SIGNALS:
0053     void isApplyableChanged(bool isApplyable);
0054     void statisticDirty(bool dirty);
0055 
0056 private Q_SLOTS:
0057     void onSelectionChanged();
0058     void onSourceChanged();
0059     void onSourceDestroyed();
0060 
0061 private:
0062     int mByteCount[256]; // TODO: here or in statistic model?
0063 
0064     StatisticTableModel* mStatisticTableModel;
0065 
0066     ByteArrayView* mByteArrayView = nullptr;
0067     Okteta::AbstractByteArrayModel* mByteArrayModel = nullptr;
0068 
0069     //
0070     bool mSourceByteArrayModelUptodate = false;
0071     // selection source
0072     Okteta::AddressRange mSourceSelection;
0073     // source of strings
0074     Okteta::AbstractByteArrayModel* mSourceByteArrayModel = nullptr;
0075 };
0076 
0077 }
0078 
0079 #endif