forked from qt-creator/qt-creator
Debugger: Add a tab widget for separate value display.
Debugger display in separate windows currently opens several widgets without title at the same location that disappear below the main window when stepping. Put them in a tabwidget and raise it when setting new values. Task-number: QTCREATORBUG-8344 Change-Id: Icb6dd8942ab851aeeb6a9248c4a1360e8841cf61 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
#include <QTabWidget>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -1611,6 +1612,39 @@ static void swapEndian(char *d, int nchar)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int indexOf(const QTabWidget *tw, const QWidget *w)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < tw->count(); ++i)
|
||||||
|
if (tw->widget(i) == w)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WatchHandler::removeSeparateWidget(QObject *o)
|
||||||
|
{
|
||||||
|
const int index = o && o->isWidgetType() && !m_separateWindow.isNull() ?
|
||||||
|
indexOf(m_separateWindow, static_cast<QWidget *>(o)) : -1;
|
||||||
|
if (index != -1)
|
||||||
|
m_separateWindow->removeTab(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WatchHandler::showSeparateWidget(QWidget *w)
|
||||||
|
{
|
||||||
|
if (m_separateWindow.isNull()) {
|
||||||
|
m_separateWindow = new QTabWidget(debuggerCore()->mainWindow());
|
||||||
|
m_separateWindow->setWindowFlags(m_separateWindow->windowFlags() | Qt::Window);
|
||||||
|
m_separateWindow->setWindowTitle(WatchHandler::tr("Debugger - Qt Creator"));
|
||||||
|
}
|
||||||
|
const int index = indexOf(m_separateWindow, w);
|
||||||
|
if (index != -1) {
|
||||||
|
m_separateWindow->setTabText(index, w->windowTitle());
|
||||||
|
} else {
|
||||||
|
m_separateWindow->addTab(w, w->windowTitle());
|
||||||
|
}
|
||||||
|
m_separateWindow->show();
|
||||||
|
m_separateWindow->raise();
|
||||||
|
}
|
||||||
|
|
||||||
void WatchHandler::showEditValue(const WatchData &data)
|
void WatchHandler::showEditValue(const WatchData &data)
|
||||||
{
|
{
|
||||||
const QByteArray key = data.address ? data.hexAddress() : data.iname;
|
const QByteArray key = data.address ? data.hexAddress() : data.iname;
|
||||||
@@ -1623,6 +1657,7 @@ void WatchHandler::showEditValue(const WatchData &data)
|
|||||||
// QImage
|
// QImage
|
||||||
QLabel *l = qobject_cast<QLabel *>(w);
|
QLabel *l = qobject_cast<QLabel *>(w);
|
||||||
if (!l) {
|
if (!l) {
|
||||||
|
removeSeparateWidget(w);
|
||||||
delete w;
|
delete w;
|
||||||
l = new QLabel;
|
l = new QLabel;
|
||||||
const QString title = data.address ?
|
const QString title = data.address ?
|
||||||
@@ -1630,6 +1665,7 @@ void WatchHandler::showEditValue(const WatchData &data)
|
|||||||
QLatin1String(data.hexAddress())) :
|
QLatin1String(data.hexAddress())) :
|
||||||
tr("%1 Object at Unknown Address").arg(QLatin1String(data.type));
|
tr("%1 Object at Unknown Address").arg(QLatin1String(data.type));
|
||||||
l->setWindowTitle(title);
|
l->setWindowTitle(title);
|
||||||
|
showSeparateWidget(l);
|
||||||
m_model->m_editHandlers[key] = l;
|
m_model->m_editHandlers[key] = l;
|
||||||
}
|
}
|
||||||
int width, height, format;
|
int width, height, format;
|
||||||
@@ -1655,13 +1691,14 @@ void WatchHandler::showEditValue(const WatchData &data)
|
|||||||
QImage im(bits, width, height, QImage::Format(format));
|
QImage im(bits, width, height, QImage::Format(format));
|
||||||
l->setPixmap(QPixmap::fromImage(im));
|
l->setPixmap(QPixmap::fromImage(im));
|
||||||
l->resize(width, height);
|
l->resize(width, height);
|
||||||
l->show();
|
showSeparateWidget(l);
|
||||||
} else if (data.editformat == DisplayUtf16String
|
} else if (data.editformat == DisplayUtf16String
|
||||||
|| data.editformat == DisplayLatin1String
|
|| data.editformat == DisplayLatin1String
|
||||||
|| data.editformat == DisplayUtf16String) {
|
|| data.editformat == DisplayUtf16String) {
|
||||||
// String data.
|
// String data.
|
||||||
QTextEdit *t = qobject_cast<QTextEdit *>(w);
|
QTextEdit *t = qobject_cast<QTextEdit *>(w);
|
||||||
if (!t) {
|
if (!t) {
|
||||||
|
removeSeparateWidget(w);
|
||||||
delete w;
|
delete w;
|
||||||
t = new QTextEdit;
|
t = new QTextEdit;
|
||||||
m_model->m_editHandlers[key] = t;
|
m_model->m_editHandlers[key] = t;
|
||||||
@@ -1674,9 +1711,11 @@ void WatchHandler::showEditValue(const WatchData &data)
|
|||||||
str = QString::fromLatin1(ba.constData(), ba.size());
|
str = QString::fromLatin1(ba.constData(), ba.size());
|
||||||
else if (data.editformat == DisplayUtf8String)
|
else if (data.editformat == DisplayUtf8String)
|
||||||
str = QString::fromUtf8(ba.constData(), ba.size());
|
str = QString::fromUtf8(ba.constData(), ba.size());
|
||||||
|
t->setWindowTitle(QString::fromLatin1("%1 (%2)").
|
||||||
|
arg(data.name, data.displayedType.isEmpty() ?
|
||||||
|
QLatin1String(data.type) : data.displayedType));
|
||||||
t->setText(str);
|
t->setText(str);
|
||||||
t->resize(400, 200);
|
showSeparateWidget(t);
|
||||||
t->show();
|
|
||||||
} else if (data.editformat == 4) {
|
} else if (data.editformat == 4) {
|
||||||
// Generic Process.
|
// Generic Process.
|
||||||
int pos = data.editvalue.indexOf('|');
|
int pos = data.editvalue.indexOf('|');
|
||||||
|
|||||||
@@ -35,8 +35,11 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QPointer>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QTabWidget)
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
class DebuggerEngine;
|
class DebuggerEngine;
|
||||||
@@ -136,6 +139,9 @@ public:
|
|||||||
void resetValueCache();
|
void resetValueCache();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void removeSeparateWidget(QObject *o);
|
||||||
|
void showSeparateWidget(QWidget *w);
|
||||||
|
|
||||||
friend class WatchModel;
|
friend class WatchModel;
|
||||||
|
|
||||||
void saveWatchers();
|
void saveWatchers();
|
||||||
@@ -146,6 +152,7 @@ private:
|
|||||||
|
|
||||||
WatchModel *m_model;
|
WatchModel *m_model;
|
||||||
DebuggerEngine *m_engine;
|
DebuggerEngine *m_engine;
|
||||||
|
QPointer<QTabWidget> m_separateWindow;
|
||||||
|
|
||||||
int m_watcherCounter;
|
int m_watcherCounter;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user