cutter/src/widgets/BreakpointWidget.h

90 lines
2.1 KiB
C
Raw Normal View History

#pragma once
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.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;
class BreakpointModel: public QAbstractListModel
{
Q_OBJECT
friend BreakpointWidget;
private:
QList<BreakpointDescription> *breakpoints;
public:
enum Column { AddrColumn = 0, PermColumn, HwColumn, TraceColumn, EnabledColumn, ColumnCount };
enum Role { BreakpointDescriptionRole = Qt::UserRole };
BreakpointModel(QList<BreakpointDescription> *breakpoints, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
};
class BreakpointProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
BreakpointProxyModel(BreakpointModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class BreakpointWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit BreakpointWidget(MainWindow *main, QAction *action = nullptr);
~BreakpointWidget();
private slots:
void on_breakpointTreeView_doubleClicked(const QModelIndex &index);
void showBreakpointContextMenu(const QPoint &pt);
void delBreakpoint();
void toggleBreakpoint();
void addBreakpointDialog();
void refreshBreakpoint();
private:
std::unique_ptr<Ui::BreakpointWidget> ui;
BreakpointModel *breakpointModel;
BreakpointProxyModel *breakpointProxyModel;
QList<BreakpointDescription> breakpoints;
QAction *actionDelBreakpoint = nullptr;
QAction *actionToggleBreakpoint = nullptr;
void setScrollMode();
RefreshDeferrer *refreshDeferrer;
};