File indexing completed on 2024-05-12 04:37:36
0001 /* 0002 SPDX-FileCopyrightText: 2009 Niko Sams <niko.sams@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_FRAMESTACKMODEL_H 0008 #define KDEVPLATFORM_FRAMESTACKMODEL_H 0009 0010 #include <QModelIndex> 0011 0012 #include <debugger/debuggerexport.h> 0013 #include <debugger/interfaces/idebugsession.h> 0014 #include <debugger/interfaces/iframestackmodel.h> 0015 0016 namespace KDevelop { 0017 class FrameStackModelPrivate; 0018 0019 /** FIXME: This class needs rework, since at present it is not true model. 0020 Client cannot just obtain frames by grabbing a thread and listing 0021 children. It should first setCurrentThread beforehand, and it is the 0022 method that will actually fetch threads. Therefore, if this model 0023 is submitted to plain QTreeView, it won't work at all. 0024 0025 Ideally, this should hold current thread and current frame numbers, 0026 and only fetch the list of threads, and list of frames inside thread 0027 when asked for by the view. 0028 */ 0029 class KDEVPLATFORMDEBUGGER_EXPORT FrameStackModel : public IFrameStackModel 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 explicit FrameStackModel(IDebugSession* session); 0035 ~FrameStackModel() override; 0036 0037 struct ThreadItem { 0038 int nr; 0039 QString name; 0040 }; 0041 0042 void setThreads(const QVector<ThreadItem>& threads); 0043 /** 0044 * Update frames for thread @p threadNumber 0045 * 0046 * @note The currentFrame property will be set to the first frame 0047 * containing debug information 0048 */ 0049 void setFrames(int threadNumber, const QVector<FrameItem>& frames); 0050 void insertFrames(int threadNumber, const QVector<FrameItem>& frames); 0051 void setHasMoreFrames(int threadNumber, bool hasMoreFrames); 0052 FrameItem frame(const QModelIndex &index) override; 0053 QVector<FrameItem> frames(int threadNumber) const; 0054 0055 //ItemModel implementation 0056 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 0057 int columnCount(const QModelIndex& parent = QModelIndex()) const override; 0058 int rowCount(const QModelIndex& parent = QModelIndex()) const override; 0059 QModelIndex parent(const QModelIndex& child) const override; 0060 QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; 0061 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0062 0063 void setCurrentThread(int threadNumber) override; 0064 void setCurrentThread(const QModelIndex &index) override; 0065 int currentThread() const override; 0066 QModelIndex currentThreadIndex() const override; 0067 0068 int currentFrame() const override; 0069 QModelIndex currentFrameIndex() const override; 0070 void setCurrentFrame(int frame) override; 0071 0072 void fetchMoreFrames() override; 0073 0074 void setCrashedThreadIndex(int index); 0075 int crashedThreadIndex() const; 0076 0077 private Q_SLOTS: 0078 void stateChanged(KDevelop::IDebugSession::DebuggerState state); 0079 0080 private: 0081 void handleEvent(IDebugSession::event_t event) override; 0082 0083 private: 0084 const QScopedPointer<class FrameStackModelPrivate> d_ptr; 0085 Q_DECLARE_PRIVATE(FrameStackModel) 0086 }; 0087 0088 } 0089 0090 Q_DECLARE_TYPEINFO(KDevelop::FrameStackModel::ThreadItem, Q_MOVABLE_TYPE); 0091 0092 #endif