cutter/src/widgets/BreakpointWidget.h

99 lines
2.3 KiB
C
Raw Normal View History

#pragma once
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "AddressableItemModel.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
2018-09-30 20:00:53 +00:00
namespace Ui {
class BreakpointWidget;
}
class MainWindow;
class QTreeWidgetItem;
class BreakpointWidget;
2021-01-24 14:50:13 +00:00
class BreakpointModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend BreakpointWidget;
private:
QList<BreakpointDescription> breakpoints;
public:
2021-01-24 14:50:13 +00:00
enum Column {
AddrColumn = 0,
NameColumn,
TypeColumn,
TraceColumn,
EnabledColumn,
CommentColumn,
ColumnCount
};
enum Role { BreakpointDescriptionRole = Qt::UserRole };
BreakpointModel(QObject *parent = nullptr);
void refresh();
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
RVA address(const QModelIndex &index) const override;
};
class BreakpointProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
BreakpointProxyModel(BreakpointModel *sourceModel, QObject *parent = nullptr);
};
class BreakpointWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit BreakpointWidget(MainWindow *main);
~BreakpointWidget();
private slots:
void delBreakpoint();
void toggleBreakpoint();
void editBreakpoint();
void addBreakpointDialog();
void refreshBreakpoint();
private:
std::unique_ptr<Ui::BreakpointWidget> ui;
BreakpointModel *breakpointModel;
BreakpointProxyModel *breakpointProxyModel;
QList<BreakpointDescription> breakpoints;
QAction *actionDelBreakpoint = nullptr;
QAction *actionToggleBreakpoint = nullptr;
QAction *actionEditBreakpoint = nullptr;
void setScrollMode();
QVector<RVA> getSelectedAddresses() const;
RefreshDeferrer *refreshDeferrer;
bool editing = false;
};