forked from qt-creator/qt-creator
Debugger: Use Utils::TreeModel for breakpoints
Change-Id: I7f62f9d64daf7624794aa82495d4b2c8d97b33df Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include "breakpoint.h"
|
#include "breakpoint.h"
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -47,13 +47,12 @@ namespace Internal {
|
|||||||
class BreakpointMarker;
|
class BreakpointMarker;
|
||||||
class DebuggerEngine;
|
class DebuggerEngine;
|
||||||
|
|
||||||
class BreakHandler : public QAbstractItemModel
|
class BreakHandler : public Utils::TreeModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BreakHandler();
|
BreakHandler();
|
||||||
~BreakHandler();
|
|
||||||
|
|
||||||
void loadSessionData();
|
void loadSessionData();
|
||||||
void saveSessionData();
|
void saveSessionData();
|
||||||
@@ -69,7 +68,6 @@ public:
|
|||||||
BreakpointModelIds allBreakpointIds() const;
|
BreakpointModelIds allBreakpointIds() const;
|
||||||
BreakpointModelIds engineBreakpointIds(DebuggerEngine *engine) const;
|
BreakpointModelIds engineBreakpointIds(DebuggerEngine *engine) const;
|
||||||
BreakpointModelIds unclaimedBreakpointIds() const;
|
BreakpointModelIds unclaimedBreakpointIds() const;
|
||||||
int size() const { return m_storage.size(); }
|
|
||||||
QStringList engineBreakpointPaths(DebuggerEngine *engine) const;
|
QStringList engineBreakpointPaths(DebuggerEngine *engine) const;
|
||||||
|
|
||||||
// Find a breakpoint matching approximately the data in needle.
|
// Find a breakpoint matching approximately the data in needle.
|
||||||
@@ -166,20 +164,10 @@ public:
|
|||||||
void setWatchpointAtAddress(quint64 address, unsigned size);
|
void setWatchpointAtAddress(quint64 address, unsigned size);
|
||||||
void setWatchpointAtExpression(const QString &exp);
|
void setWatchpointAtExpression(const QString &exp);
|
||||||
|
|
||||||
private:
|
signals:
|
||||||
// QAbstractItemModel implementation.
|
void requestExpansion(QModelIndex);
|
||||||
int columnCount(const QModelIndex &parent) const;
|
|
||||||
int rowCount(const QModelIndex &parent) const;
|
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
|
||||||
QModelIndex index(int row, int col, const QModelIndex &parent) const;
|
|
||||||
QModelIndex parent(const QModelIndex &parent) const;
|
|
||||||
QModelIndex createIndex(int row, int column, quint32 id) const;
|
|
||||||
QModelIndex createIndex(int row, int column, void *ptr) const;
|
|
||||||
|
|
||||||
int indexOf(BreakpointModelId id) const;
|
private:
|
||||||
BreakpointModelId at(int index) const;
|
|
||||||
bool isEngineRunning(BreakpointModelId id) const;
|
bool isEngineRunning(BreakpointModelId id) const;
|
||||||
void setState(BreakpointModelId id, BreakpointState state);
|
void setState(BreakpointModelId id, BreakpointState state);
|
||||||
void loadBreakpoints();
|
void loadBreakpoints();
|
||||||
@@ -188,32 +176,42 @@ private:
|
|||||||
void appendBreakpointInternal(const BreakpointParameters &data);
|
void appendBreakpointInternal(const BreakpointParameters &data);
|
||||||
Q_SLOT void changeLineNumberFromMarkerHelper(Debugger::Internal::BreakpointModelId id, int lineNumber);
|
Q_SLOT void changeLineNumberFromMarkerHelper(Debugger::Internal::BreakpointModelId id, int lineNumber);
|
||||||
|
|
||||||
struct BreakpointItem
|
struct BreakpointItem : public Utils::TreeItem
|
||||||
{
|
{
|
||||||
BreakpointItem();
|
BreakpointItem();
|
||||||
|
~BreakpointItem();
|
||||||
|
|
||||||
|
int columnCount() const { return 8; }
|
||||||
|
QVariant data(int column, int role) const;
|
||||||
|
|
||||||
void destroyMarker();
|
void destroyMarker();
|
||||||
bool needsChange() const;
|
bool needsChange() const;
|
||||||
bool isLocatedAt(const QString &fileName, int lineNumber,
|
bool isLocatedAt(const QString &fileName, int lineNumber,
|
||||||
bool useMarkerPosition) const;
|
bool useMarkerPosition) const;
|
||||||
void updateMarker(BreakpointModelId id);
|
void updateMarker();
|
||||||
void updateMarkerIcon();
|
void updateMarkerIcon();
|
||||||
QString toToolTip() const;
|
QString toToolTip() const;
|
||||||
QString markerFileName() const;
|
QString markerFileName() const;
|
||||||
int markerLineNumber() const;
|
int markerLineNumber() const;
|
||||||
QIcon icon() const;
|
QIcon icon() const;
|
||||||
|
|
||||||
BreakpointParameters data;
|
BreakpointModelId id;
|
||||||
|
BreakpointParameters params;
|
||||||
BreakpointState state; // Current state of breakpoint.
|
BreakpointState state; // Current state of breakpoint.
|
||||||
DebuggerEngine *engine; // Engine currently handling the breakpoint.
|
DebuggerEngine *engine; // Engine currently handling the breakpoint.
|
||||||
BreakpointResponse response;
|
BreakpointResponse response;
|
||||||
BreakpointMarker *marker;
|
BreakpointMarker *marker;
|
||||||
QList<BreakpointResponse> subItems;
|
|
||||||
};
|
};
|
||||||
typedef QHash<BreakpointModelId, BreakpointItem> BreakpointStorage;
|
|
||||||
typedef BreakpointStorage::ConstIterator ConstIterator;
|
struct LocationItem : public Utils::TreeItem
|
||||||
typedef BreakpointStorage::Iterator Iterator;
|
{
|
||||||
BreakpointStorage m_storage;
|
int columnCount() const { return 8; }
|
||||||
|
QVariant data(int column, int role) const;
|
||||||
|
|
||||||
|
BreakpointResponse params;
|
||||||
|
};
|
||||||
|
|
||||||
|
BreakpointItem *breakpointById(BreakpointModelId id) const;
|
||||||
|
|
||||||
void scheduleSynchronization();
|
void scheduleSynchronization();
|
||||||
void timerEvent(QTimerEvent *event);
|
void timerEvent(QTimerEvent *event);
|
||||||
|
@@ -1,88 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/licensing. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "breakpointmarker.h"
|
|
||||||
#include "breakhandler.h"
|
|
||||||
#include "debuggercore.h"
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// BreakpointMarker
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
namespace Debugger {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
BreakpointMarker::BreakpointMarker(BreakpointModelId id,
|
|
||||||
const QString &fileName, int lineNumber)
|
|
||||||
: TextMark(fileName, lineNumber), m_id(id)
|
|
||||||
{
|
|
||||||
setIcon(breakHandler()->icon(m_id));
|
|
||||||
setPriority(TextEditor::TextMark::NormalPriority);
|
|
||||||
//qDebug() << "CREATE MARKER " << fileName << lineNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
BreakpointMarker::~BreakpointMarker()
|
|
||||||
{
|
|
||||||
//qDebug() << "REMOVE MARKER ";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakpointMarker::removedFromEditor()
|
|
||||||
{
|
|
||||||
breakHandler()->removeBreakpoint(m_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakpointMarker::updateLineNumber(int lineNumber)
|
|
||||||
{
|
|
||||||
TextMark::updateLineNumber(lineNumber);
|
|
||||||
breakHandler()->updateLineNumberFromMarker(m_id, lineNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakpointMarker::dragToLine(int lineNumber)
|
|
||||||
{
|
|
||||||
breakHandler()->changeLineNumberFromMarker(m_id, lineNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakpointMarker::clicked()
|
|
||||||
{
|
|
||||||
breakHandler()->removeBreakpoint(m_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakpointMarker::updateFileName(const QString &fileName)
|
|
||||||
{
|
|
||||||
TextMark::updateFileName(fileName);
|
|
||||||
breakHandler()->updateFileNameFromMarker(m_id, fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Debugger
|
|
||||||
|
|
@@ -1,63 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/licensing. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef DEBUGGER_BREAKPOINTMARKER_H
|
|
||||||
#define DEBUGGER_BREAKPOINTMARKER_H
|
|
||||||
|
|
||||||
#include "breakpoint.h"
|
|
||||||
|
|
||||||
#include <texteditor/textmark.h>
|
|
||||||
|
|
||||||
namespace Debugger {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
// The red blob on the left side in the cpp editor.
|
|
||||||
class BreakpointMarker : public TextEditor::TextMark
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BreakpointMarker(BreakpointModelId id, const QString &fileName, int lineNumber);
|
|
||||||
~BreakpointMarker();
|
|
||||||
void removedFromEditor();
|
|
||||||
void updateLineNumber(int lineNumber);
|
|
||||||
void updateFileName(const QString &fileName);
|
|
||||||
bool isDraggable() const { return true; }
|
|
||||||
void dragToLine(int lineNumber);
|
|
||||||
bool isClickable() const { return true; }
|
|
||||||
void clicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
BreakpointModelId m_id;
|
|
||||||
friend class BreakHandler;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Debugger
|
|
||||||
|
|
||||||
#endif
|
|
@@ -692,17 +692,17 @@ void BreakTreeView::keyPressEvent(QKeyEvent *ev)
|
|||||||
if (ev->key() == Qt::Key_Delete) {
|
if (ev->key() == Qt::Key_Delete) {
|
||||||
QItemSelectionModel *sm = selectionModel();
|
QItemSelectionModel *sm = selectionModel();
|
||||||
QTC_ASSERT(sm, return);
|
QTC_ASSERT(sm, return);
|
||||||
QModelIndexList si = sm->selectedIndexes();
|
QModelIndexList si = sm->selectedRows();
|
||||||
if (si.isEmpty())
|
if (si.isEmpty())
|
||||||
si.append(currentIndex());
|
si.append(currentIndex());
|
||||||
const BreakpointModelIds ids = breakHandler()->findBreakpointsByIndex(si);
|
const BreakpointModelIds ids = breakHandler()->findBreakpointsByIndex(si);
|
||||||
int row = qMin(model()->rowCount() - ids.size() - 1, currentIndex().row());
|
int row = qMin(model()->rowCount() - ids.size() - 1, currentIndex().row());
|
||||||
deleteBreakpoints(ids);
|
deleteBreakpoints(ids);
|
||||||
setCurrentIndex(si.at(0).sibling(row, 0));
|
setCurrentIndex(model()->index(row, 0));
|
||||||
} else if (ev->key() == Qt::Key_Space) {
|
} else if (ev->key() == Qt::Key_Space) {
|
||||||
QItemSelectionModel *sm = selectionModel();
|
QItemSelectionModel *sm = selectionModel();
|
||||||
QTC_ASSERT(sm, return);
|
QTC_ASSERT(sm, return);
|
||||||
const QModelIndexList selectedIds = sm->selectedIndexes();
|
const QModelIndexList selectedIds = sm->selectedRows();
|
||||||
if (!selectedIds.isEmpty()) {
|
if (!selectedIds.isEmpty()) {
|
||||||
BreakHandler *handler = breakHandler();
|
BreakHandler *handler = breakHandler();
|
||||||
const BreakpointModelIds validIds = handler->findBreakpointsByIndex(selectedIds);
|
const BreakpointModelIds validIds = handler->findBreakpointsByIndex(selectedIds);
|
||||||
@@ -734,7 +734,7 @@ void BreakTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
QMenu menu;
|
QMenu menu;
|
||||||
QItemSelectionModel *sm = selectionModel();
|
QItemSelectionModel *sm = selectionModel();
|
||||||
QTC_ASSERT(sm, return);
|
QTC_ASSERT(sm, return);
|
||||||
QModelIndexList selectedIndices = sm->selectedIndexes();
|
QModelIndexList selectedIndices = sm->selectedRows();
|
||||||
QModelIndex indexUnderMouse = indexAt(ev->pos());
|
QModelIndex indexUnderMouse = indexAt(ev->pos());
|
||||||
if (selectedIndices.isEmpty() && indexUnderMouse.isValid())
|
if (selectedIndices.isEmpty() && indexUnderMouse.isValid())
|
||||||
selectedIndices.append(indexUnderMouse);
|
selectedIndices.append(indexUnderMouse);
|
||||||
|
@@ -15,7 +15,6 @@ CONFIG += exceptions
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
breakhandler.h \
|
breakhandler.h \
|
||||||
breakpoint.h \
|
breakpoint.h \
|
||||||
breakpointmarker.h \
|
|
||||||
breakwindow.h \
|
breakwindow.h \
|
||||||
commonoptionspage.h \
|
commonoptionspage.h \
|
||||||
debugger_global.h \
|
debugger_global.h \
|
||||||
@@ -75,7 +74,6 @@ HEADERS += \
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
breakhandler.cpp \
|
breakhandler.cpp \
|
||||||
breakpoint.cpp \
|
breakpoint.cpp \
|
||||||
breakpointmarker.cpp \
|
|
||||||
breakwindow.cpp \
|
breakwindow.cpp \
|
||||||
commonoptionspage.cpp \
|
commonoptionspage.cpp \
|
||||||
debuggeractions.cpp \
|
debuggeractions.cpp \
|
||||||
|
@@ -28,7 +28,6 @@ QtcPlugin {
|
|||||||
files: [
|
files: [
|
||||||
"breakhandler.cpp", "breakhandler.h",
|
"breakhandler.cpp", "breakhandler.h",
|
||||||
"breakpoint.cpp", "breakpoint.h",
|
"breakpoint.cpp", "breakpoint.h",
|
||||||
"breakpointmarker.cpp", "breakpointmarker.h",
|
|
||||||
"breakwindow.cpp", "breakwindow.h",
|
"breakwindow.cpp", "breakwindow.h",
|
||||||
"commonoptionspage.cpp", "commonoptionspage.h",
|
"commonoptionspage.cpp", "commonoptionspage.h",
|
||||||
"debugger.qrc",
|
"debugger.qrc",
|
||||||
|
Reference in New Issue
Block a user