cutter/src/widgets/BreakpointWidget.h
xarkes ab27e09b91 Splitted Cutter.h and moved everything in core (#1201)
Sometimes it is not necessary to include the whole Cutter.h file
Hence, it's been splitted so you can include only what you require
E.g. #include "core/CutterCommon.h" to have access to the common types
2019-02-22 17:50:45 +01:00

90 lines
2.1 KiB
C++

#pragma once
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
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;
};