forked from qt-creator/qt-creator
Debugger: Expose WatchModel signals
This opens it up to be used with Qt5 connects in the TooltipManager and simpler user code. Change-Id: Ifc6fcc3a04d325437f5a2bdf1da463d28d650ee3 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -1140,14 +1140,13 @@ public:
|
||||
DebuggerEngine *m_currentEngine;
|
||||
DebuggerSettings *m_debuggerSettings;
|
||||
QStringList m_arguments;
|
||||
DebuggerToolTipManager *m_toolTipManager;
|
||||
DebuggerToolTipManager m_toolTipManager;
|
||||
CommonOptionsPage *m_commonOptionsPage;
|
||||
DummyEngine *m_dummyEngine;
|
||||
const QSharedPointer<GlobalDebuggerOptions> m_globalDebuggerOptions;
|
||||
};
|
||||
|
||||
DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) :
|
||||
m_toolTipManager(new DebuggerToolTipManager(this)),
|
||||
m_dummyEngine(0),
|
||||
m_globalDebuggerOptions(new GlobalDebuggerOptions)
|
||||
{
|
||||
@@ -2036,7 +2035,7 @@ void DebuggerPluginPrivate::setInitialState()
|
||||
setBusyCursor(false);
|
||||
m_reverseDirectionAction->setChecked(false);
|
||||
m_reverseDirectionAction->setEnabled(false);
|
||||
m_toolTipManager->closeAllToolTips();
|
||||
m_toolTipManager.closeAllToolTips();
|
||||
|
||||
m_startAndDebugApplicationAction->setEnabled(true);
|
||||
m_attachToQmlPortAction->setEnabled(true);
|
||||
@@ -2269,14 +2268,14 @@ void DebuggerPluginPrivate::onModeChanged(IMode *mode)
|
||||
m_mainWindow->onModeChanged(mode);
|
||||
|
||||
if (mode->id() != Constants::MODE_DEBUG) {
|
||||
m_toolTipManager->leavingDebugMode();
|
||||
m_toolTipManager.leavingDebugMode();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IEditor *editor = EditorManager::currentEditor())
|
||||
editor->widget()->setFocus();
|
||||
|
||||
m_toolTipManager->debugModeEntered();
|
||||
m_toolTipManager.debugModeEntered();
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::showSettingsDialog()
|
||||
@@ -2334,7 +2333,7 @@ void DebuggerPluginPrivate::sessionLoaded()
|
||||
|
||||
void DebuggerPluginPrivate::aboutToUnloadSession()
|
||||
{
|
||||
m_toolTipManager->sessionAboutToChange();
|
||||
m_toolTipManager.sessionAboutToChange();
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::aboutToSaveSession()
|
||||
|
||||
@@ -65,31 +65,34 @@
|
||||
using namespace Core;
|
||||
using namespace TextEditor;
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
// Expire tooltips after n days on (no longer load them) in order
|
||||
// to avoid them piling up.
|
||||
enum { toolTipsExpiryDays = 6 };
|
||||
|
||||
static const char sessionSettingsKeyC[] = "DebuggerToolTips";
|
||||
static const char sessionDocumentC[] = "DebuggerToolTips";
|
||||
static const char sessionVersionAttributeC[] = "version";
|
||||
static const char toolTipElementC[] = "DebuggerToolTip";
|
||||
static const char toolTipClassAttributeC[] = "class";
|
||||
static const char fileNameAttributeC[] = "name";
|
||||
static const char functionAttributeC[] = "function";
|
||||
static const char textPositionAttributeC[] = "position";
|
||||
static const char textLineAttributeC[] = "line";
|
||||
static const char textColumnAttributeC[] = "column";
|
||||
static const char offsetXAttributeC[] = "offset_x";
|
||||
static const char offsetYAttributeC[] = "offset_y";
|
||||
static const char engineTypeAttributeC[] = "engine";
|
||||
static const char dateAttributeC[] = "date";
|
||||
static const char treeElementC[] = "tree";
|
||||
static const char treeExpressionAttributeC[] = "expression";
|
||||
static const char treeInameAttributeC[] = "iname";
|
||||
static const char modelElementC[] = "model";
|
||||
static const char modelColumnCountAttributeC[] = "columncount";
|
||||
static const char modelRowElementC[] = "row";
|
||||
static const char modelItemElementC[] = "item";
|
||||
const char sessionSettingsKeyC[] = "DebuggerToolTips";
|
||||
const char sessionDocumentC[] = "DebuggerToolTips";
|
||||
const char sessionVersionAttributeC[] = "version";
|
||||
const char toolTipElementC[] = "DebuggerToolTip";
|
||||
const char toolTipClassAttributeC[] = "class";
|
||||
const char fileNameAttributeC[] = "name";
|
||||
const char functionAttributeC[] = "function";
|
||||
const char textPositionAttributeC[] = "position";
|
||||
const char textLineAttributeC[] = "line";
|
||||
const char textColumnAttributeC[] = "column";
|
||||
const char offsetXAttributeC[] = "offset_x";
|
||||
const char offsetYAttributeC[] = "offset_y";
|
||||
const char engineTypeAttributeC[] = "engine";
|
||||
const char dateAttributeC[] = "date";
|
||||
const char treeElementC[] = "tree";
|
||||
const char treeExpressionAttributeC[] = "expression";
|
||||
const char treeInameAttributeC[] = "iname";
|
||||
const char modelElementC[] = "model";
|
||||
const char modelColumnCountAttributeC[] = "columncount";
|
||||
const char modelRowElementC[] = "row";
|
||||
const char modelItemElementC[] = "item";
|
||||
|
||||
// Forward a stream reader across end elements looking for the
|
||||
// next start element of a desired type.
|
||||
@@ -112,19 +115,6 @@ static bool readStartElement(QXmlStreamReader &r, const char *name)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void debugMode(const QAbstractItemModel *model)
|
||||
{
|
||||
QDebug nospace = qDebug().nospace();
|
||||
nospace << model << '\n';
|
||||
for (int r = 0; r < model->rowCount(); r++)
|
||||
nospace << '#' << r << ' ' << model->data(model->index(r, 0)).toString() << '\n';
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
// A label that can be dragged to drag something else.
|
||||
|
||||
class DraggableLabel : public QLabel
|
||||
@@ -503,8 +493,6 @@ static DebuggerToolTipManagerData *d = 0;
|
||||
|
||||
class DebuggerToolTipWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DebuggerToolTipWidget(const DebuggerToolTipContext &context);
|
||||
|
||||
@@ -519,10 +507,13 @@ public:
|
||||
void releaseEngine();
|
||||
|
||||
void saveSessionData(QXmlStreamWriter &w) const;
|
||||
void setWatchModel(QAbstractItemModel *watchModel);
|
||||
void setWatchModel(WatchModelBase *watchModel);
|
||||
void handleStackFrameCompleted(const QString &frameFile, const QString &frameFunction);
|
||||
|
||||
public slots:
|
||||
void copy();
|
||||
void positionShow(const TextEditorWidget *editorWidget);
|
||||
void pin();
|
||||
|
||||
void handleItemIsExpanded(const QModelIndex &sourceIdx)
|
||||
{
|
||||
QTC_ASSERT(m_filterModel.sourceModel() == sourceIdx.model(), return);
|
||||
@@ -531,10 +522,6 @@ public slots:
|
||||
m_treeView->expand(mappedIdx);
|
||||
}
|
||||
|
||||
void copy();
|
||||
void positionShow(const TextEditorWidget *editorWidget);
|
||||
void pin();
|
||||
|
||||
public:
|
||||
bool m_isPinned;
|
||||
QToolButton *m_toolButton;
|
||||
@@ -691,14 +678,14 @@ DebuggerToolTipWidget::DebuggerToolTipWidget(const DebuggerToolTipContext &conte
|
||||
connect(copyButton, &QAbstractButton::clicked, this, &DebuggerToolTipWidget::copy);
|
||||
}
|
||||
|
||||
void DebuggerToolTipWidget::setWatchModel(QAbstractItemModel *watchModel)
|
||||
void DebuggerToolTipWidget::setWatchModel(WatchModelBase *watchModel)
|
||||
{
|
||||
QTC_ASSERT(watchModel, return);
|
||||
m_filterModel.setSourceModel(watchModel);
|
||||
connect(watchModel, SIGNAL(itemIsExpanded(QModelIndex)),
|
||||
this, SLOT(handleItemIsExpanded(QModelIndex)), Qt::UniqueConnection);
|
||||
connect(watchModel, SIGNAL(columnAdjustmentRequested()),
|
||||
m_treeView, SLOT(computeSize()), Qt::UniqueConnection);
|
||||
connect(watchModel, &WatchModelBase::itemIsExpanded,
|
||||
this, &DebuggerToolTipWidget::handleItemIsExpanded, Qt::UniqueConnection);
|
||||
connect(watchModel, &WatchModelBase::columnAdjustmentRequested,
|
||||
m_treeView, &DebuggerToolTipTreeView::computeSize, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
void DebuggerToolTipWidget::handleStackFrameCompleted(const QString &frameFile, const QString &frameFunction)
|
||||
@@ -938,15 +925,15 @@ DebuggerToolTipTreeView::DebuggerToolTipTreeView(QWidget *parent) :
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(computeSize()),
|
||||
connect(this, &QTreeView::collapsed, this, &DebuggerToolTipTreeView::computeSize,
|
||||
Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(computeSize()),
|
||||
connect(this, &QTreeView::expanded, this, &DebuggerToolTipTreeView::computeSize,
|
||||
Qt::QueuedConnection);
|
||||
|
||||
connect(this, SIGNAL(expanded(QModelIndex)),
|
||||
SLOT(expandNode(QModelIndex)));
|
||||
connect(this, SIGNAL(collapsed(QModelIndex)),
|
||||
SLOT(collapseNode(QModelIndex)));
|
||||
connect(this, &QTreeView::expanded,
|
||||
this, &DebuggerToolTipTreeView::expandNode);
|
||||
connect(this, &QTreeView::collapsed,
|
||||
this, &DebuggerToolTipTreeView::collapseNode);
|
||||
}
|
||||
|
||||
void DebuggerToolTipTreeView::expandNode(const QModelIndex &idx)
|
||||
@@ -1046,19 +1033,14 @@ QString DebuggerToolTipManager::treeModelClipboardContents(const QAbstractItemMo
|
||||
(by file name and function) acquire the engine, others release.
|
||||
*/
|
||||
|
||||
static DebuggerToolTipManager *m_instance = 0;
|
||||
|
||||
DebuggerToolTipManager::DebuggerToolTipManager(QObject *parent) :
|
||||
QObject(parent)
|
||||
DebuggerToolTipManager::DebuggerToolTipManager()
|
||||
{
|
||||
d = new DebuggerToolTipManagerData;
|
||||
m_instance = this;
|
||||
}
|
||||
|
||||
DebuggerToolTipManager::~DebuggerToolTipManager()
|
||||
{
|
||||
delete d;
|
||||
m_instance = 0;
|
||||
}
|
||||
|
||||
void DebuggerToolTipManager::registerEngine(DebuggerEngine *)
|
||||
@@ -1227,32 +1209,14 @@ void DebuggerToolTipManager::slotUpdateVisibleToolTips()
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerToolTipManager::slotDebuggerStateChanged(DebuggerState state)
|
||||
{
|
||||
const QObject *engine = sender();
|
||||
QTC_ASSERT(engine, return);
|
||||
|
||||
// Release at earliest possible convenience.
|
||||
switch (state) {
|
||||
case InferiorShutdownRequested:
|
||||
case EngineShutdownRequested:
|
||||
case DebuggerFinished:
|
||||
case EngineShutdownOk: {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerToolTipManager::slotEditorOpened(IEditor *e)
|
||||
{
|
||||
// Move tooltip along when scrolled.
|
||||
if (BaseTextEditor *textEditor = qobject_cast<BaseTextEditor *>(e)) {
|
||||
TextEditorWidget *widget = textEditor->editorWidget();
|
||||
connect(widget->verticalScrollBar(), &QScrollBar::valueChanged,
|
||||
QObject::connect(widget->verticalScrollBar(), &QScrollBar::valueChanged,
|
||||
this, &DebuggerToolTipManager::slotUpdateVisibleToolTips);
|
||||
connect(widget, &TextEditorWidget::tooltipOverrideRequested,
|
||||
QObject::connect(widget, &TextEditorWidget::tooltipOverrideRequested,
|
||||
this, &DebuggerToolTipManager::slotTooltipOverrideRequested);
|
||||
}
|
||||
}
|
||||
@@ -1273,7 +1237,7 @@ void DebuggerToolTipManager::debugModeEntered()
|
||||
slotEditorOpened(e);
|
||||
// Position tooltips delayed once all the editor placeholder layouting is done.
|
||||
if (!d->m_tooltips.isEmpty())
|
||||
QTimer::singleShot(0, this, SLOT(slotUpdateVisibleToolTips()));
|
||||
QTimer::singleShot(0, this, &DebuggerToolTipManager::slotUpdateVisibleToolTips);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1358,5 +1322,3 @@ DebuggerToolTipContexts DebuggerToolTipManager::treeWidgetExpressions
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Debugger
|
||||
|
||||
#include "debuggertooltipmanager.moc"
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
#include "debuggerconstants.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDate>
|
||||
#include <QPointer>
|
||||
#include <QTreeView>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -77,20 +77,17 @@ QDebug operator<<(QDebug, const DebuggerToolTipContext &);
|
||||
|
||||
class DebuggerToolTipTreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DebuggerToolTipTreeView(QWidget *parent = 0);
|
||||
|
||||
QAbstractItemModel *swapModel(QAbstractItemModel *model);
|
||||
QSize sizeHint() const { return m_size; }
|
||||
|
||||
private slots:
|
||||
void computeSize();
|
||||
void expandNode(const QModelIndex &idx);
|
||||
void collapseNode(const QModelIndex &idx);
|
||||
|
||||
private:
|
||||
void expandNode(const QModelIndex &idx);
|
||||
void collapseNode(const QModelIndex &idx);
|
||||
int computeHeight(const QModelIndex &index) const;
|
||||
|
||||
QSize m_size;
|
||||
@@ -98,10 +95,10 @@ private:
|
||||
|
||||
class DebuggerToolTipManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_TR_FUNCTIONS(Debugger::DebuggerToolTipManager)
|
||||
|
||||
public:
|
||||
explicit DebuggerToolTipManager(QObject *parent = 0);
|
||||
DebuggerToolTipManager();
|
||||
~DebuggerToolTipManager();
|
||||
|
||||
static void registerEngine(DebuggerEngine *engine);
|
||||
@@ -120,7 +117,6 @@ public:
|
||||
|
||||
static QString treeModelClipboardContents(const QAbstractItemModel *model);
|
||||
|
||||
public slots:
|
||||
void debugModeEntered();
|
||||
void leavingDebugMode();
|
||||
void sessionAboutToChange();
|
||||
@@ -129,9 +125,8 @@ public slots:
|
||||
static void closeAllToolTips();
|
||||
static void hide();
|
||||
|
||||
private slots:
|
||||
private:
|
||||
static void slotUpdateVisibleToolTips();
|
||||
void slotDebuggerStateChanged(Debugger::DebuggerState);
|
||||
void slotEditorOpened(Core::IEditor *);
|
||||
void slotTooltipOverrideRequested(TextEditor::TextEditorWidget *editorWidget,
|
||||
const QPoint &point, int pos, bool *handled);
|
||||
|
||||
@@ -141,7 +141,7 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WatchModel
|
||||
// SeparatedView
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
SeparatedView() : QTabWidget(Internal::mainWindow())
|
||||
{
|
||||
setTabsClosable(true);
|
||||
connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeTab(int)));
|
||||
connect(this, &QTabWidget::tabCloseRequested, this, &SeparatedView::closeTab);
|
||||
setWindowFlags(windowFlags() | Qt::Window);
|
||||
setWindowTitle(WatchHandler::tr("Debugger - Qt Creator"));
|
||||
|
||||
@@ -175,7 +175,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
Q_SLOT void closeTab(int index)
|
||||
void closeTab(int index)
|
||||
{
|
||||
if (QObject *o = widget(index)) {
|
||||
QByteArray iname = o->property(INameProperty).toByteArray();
|
||||
@@ -224,10 +224,14 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class WatchModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WatchModel
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
class WatchModel : public WatchModelBase
|
||||
{
|
||||
private:
|
||||
explicit WatchModel(WatchHandler *handler);
|
||||
~WatchModel();
|
||||
@@ -242,11 +246,6 @@ public:
|
||||
static QString nameForFormat(int format);
|
||||
TypeFormatList typeFormatList(const WatchData &value) const;
|
||||
|
||||
signals:
|
||||
void currentIndexRequested(const QModelIndex &idx);
|
||||
void itemIsExpanded(const QModelIndex &idx);
|
||||
void columnAdjustmentRequested();
|
||||
|
||||
private:
|
||||
QVariant data(const QModelIndex &idx, int role) const;
|
||||
bool setData(const QModelIndex &idx, const QVariant &value, int role);
|
||||
@@ -272,7 +271,7 @@ private:
|
||||
const WatchItem *parentItem, const QModelIndex &parentIndex) const;
|
||||
|
||||
void insertDataItem(const WatchData &data, bool destructive);
|
||||
Q_SLOT void reinsertAllData();
|
||||
void reinsertAllData();
|
||||
void reinsertAllDataHelper(WatchItem *item, QList<WatchData> *data);
|
||||
bool ancestorChanged(const QSet<QByteArray> &parentINames, WatchItem *item) const;
|
||||
void insertBulkData(const QList<WatchData> &data);
|
||||
@@ -288,7 +287,7 @@ private:
|
||||
|
||||
void dump();
|
||||
void dumpHelper(WatchItem *item);
|
||||
Q_SLOT void emitAllChanged();
|
||||
void emitAllChanged();
|
||||
|
||||
void showInEditorHelper(QString *contents, WatchItem *item, int level);
|
||||
void setCurrentItem(const QByteArray &iname);
|
||||
@@ -350,12 +349,12 @@ WatchModel::WatchModel(WatchHandler *handler)
|
||||
m_returnRoot = createItem("return", tr("Return Value"), m_root);
|
||||
m_tooltipRoot = createItem("tooltip", tr("Tooltip"), m_root);
|
||||
|
||||
connect(action(SortStructMembers), SIGNAL(valueChanged(QVariant)),
|
||||
SLOT(reinsertAllData()));
|
||||
connect(action(ShowStdNamespace), SIGNAL(valueChanged(QVariant)),
|
||||
SLOT(reinsertAllData()));
|
||||
connect(action(ShowQtNamespace), SIGNAL(valueChanged(QVariant)),
|
||||
SLOT(reinsertAllData()));
|
||||
connect(action(SortStructMembers), &Utils::SavedAction::valueChanged,
|
||||
this, &WatchModel::reinsertAllData);
|
||||
connect(action(ShowStdNamespace), &Utils::SavedAction::valueChanged,
|
||||
this, &WatchModel::reinsertAllData);
|
||||
connect(action(ShowQtNamespace), &Utils::SavedAction::valueChanged,
|
||||
this, &WatchModel::reinsertAllData);
|
||||
}
|
||||
|
||||
WatchModel::~WatchModel()
|
||||
@@ -1987,7 +1986,7 @@ void WatchHandler::loadSessionData()
|
||||
watchExpression(exp);
|
||||
}
|
||||
|
||||
QAbstractItemModel *WatchHandler::model() const
|
||||
WatchModelBase *WatchHandler::model() const
|
||||
{
|
||||
return m_model;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
class SeparatedView;
|
||||
class WatchModel;
|
||||
|
||||
// Special formats. Keep in sync with dumper.py.
|
||||
enum DisplayFormat
|
||||
@@ -112,8 +113,6 @@ class DebuggerEngine;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class WatchModel;
|
||||
|
||||
class UpdateParameters
|
||||
{
|
||||
public:
|
||||
@@ -126,6 +125,19 @@ public:
|
||||
|
||||
typedef QHash<QString, QStringList> DumperTypeFormats; // Type name -> Dumper Formats
|
||||
|
||||
class WatchModelBase : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WatchModelBase() {}
|
||||
|
||||
signals:
|
||||
void currentIndexRequested(const QModelIndex &idx);
|
||||
void itemIsExpanded(const QModelIndex &idx);
|
||||
void columnAdjustmentRequested();
|
||||
};
|
||||
|
||||
class WatchHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -134,7 +146,7 @@ public:
|
||||
explicit WatchHandler(DebuggerEngine *engine);
|
||||
~WatchHandler();
|
||||
|
||||
QAbstractItemModel *model() const;
|
||||
WatchModelBase *model() const;
|
||||
|
||||
void cleanup();
|
||||
void watchExpression(const QString &exp, const QString &name = QString());
|
||||
|
||||
Reference in New Issue
Block a user