Debugger: Use Utils::TreeModel as base for StackHandler

Change-Id: I3fcc1b3a149f15cf414a1560d91145b623e40c63
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2019-06-24 12:28:07 +02:00
parent 33fde35c19
commit 0d49c2cd2c
7 changed files with 87 additions and 80 deletions

View File

@@ -27,9 +27,8 @@
#include "stackframe.h"
#include <QAbstractItemModel>
namespace Utils { class ItemViewEvent; }
#include <utils/basetreeview.h>
#include <utils/treemodel.h>
namespace Debugger {
namespace Internal {
@@ -46,7 +45,19 @@ enum StackColumns
StackColumnCount
};
class StackHandler : public QAbstractTableModel
class StackFrameItem : public Utils::TreeItem
{
public:
StackFrameItem();
explicit StackFrameItem(const StackFrame &frame) : frame(frame) {}
public:
StackFrame frame;
};
using StackHandlerModel = Utils::TreeModel<Utils::TypedTreeItem<StackFrameItem>, StackFrameItem>;
class StackHandler : public StackHandlerModel
{
Q_OBJECT
@@ -58,14 +69,14 @@ public:
void setFramesAndCurrentIndex(const GdbMi &frames, bool isFull);
int updateTargetFrame(bool isFull);
void prependFrames(const StackFrames &frames);
const StackFrames &frames() const;
bool isSpecialFrame(int index) const;
void setCurrentIndex(int index);
int currentIndex() const { return m_currentIndex; }
int firstUsableIndex() const;
StackFrame currentFrame() const;
const StackFrame &frameAt(int index) const { return m_stackFrames.at(index); }
int stackSize() const { return m_stackFrames.size(); }
quint64 topAddress() const { return m_stackFrames.at(0).address; }
StackFrame frameAt(int index) const;
int stackSize() const;
quint64 topAddress() const;
// Called from StackHandler after a new stack list has been received
void removeAll();
@@ -80,10 +91,7 @@ signals:
void currentIndexChanged();
private:
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) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &idx, const QVariant &data, int role) override;
@@ -93,7 +101,6 @@ private:
void saveTaskFile();
DebuggerEngine *m_engine;
StackFrames m_stackFrames;
int m_currentIndex = -1;
bool m_canExpand = false;
bool m_resetLocationScheduled = false;