From 5c4b0f886619c211c758de0e55e2f5f556dd12d0 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Wed, 19 May 2010 15:15:56 +0200 Subject: [PATCH] debugger: fix resetting type formats in Locals and Watchers --- src/plugins/debugger/watchhandler.cpp | 5 ++++- src/plugins/debugger/watchwindow.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index f10e8fc5ed3..3be39eea5ac 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -1385,7 +1385,10 @@ QString WatchHandler::watcherEditPlaceHolder() void WatchHandler::setFormat(const QString &type, int format) { - m_typeFormats[type] = format; + if (format == -1) + m_typeFormats.remove(type); + else + m_typeFormats[type] = format; saveTypeFormats(); m_return->emitDataChanged(1); m_locals->emitDataChanged(1); diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index b762610b199..209944278a0 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -217,7 +217,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) const QStringList alternativeFormats = model()->data(mi0, TypeFormatListRole).toStringList(); const int typeFormat = - qMax(int(DecimalFormat), model()->data(mi0, TypeFormatRole).toInt()); + model()->data(mi0, TypeFormatRole).toInt(); const int individualFormat = model()->data(mi0, IndividualFormatRole).toInt(); const int effectiveIndividualFormat = @@ -225,12 +225,18 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) QMenu typeFormatMenu; QList<QAction *> typeFormatActions; + QAction *clearTypeFormatAction = 0; if (idx.isValid()) { typeFormatMenu.setTitle( tr("Change Format for Type \"%1\"").arg(type)); if (alternativeFormats.isEmpty()) { typeFormatMenu.setEnabled(false); } else { + clearTypeFormatAction = typeFormatMenu.addAction(tr("Clear")); + clearTypeFormatAction->setEnabled(typeFormat != -1); + clearTypeFormatAction->setCheckable(true); + clearTypeFormatAction->setChecked(typeFormat == -1); + typeFormatMenu.addSeparator(); for (int i = 0; i != alternativeFormats.size(); ++i) { const QString format = alternativeFormats.at(i); QAction *act = new QAction(format, &typeFormatMenu); @@ -257,6 +263,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) } else { clearIndividualFormatAction = individualFormatMenu.addAction(tr("Clear")); clearIndividualFormatAction->setEnabled(individualFormat != -1); + clearIndividualFormatAction->setCheckable(true); + clearIndividualFormatAction->setChecked(individualFormat == -1); individualFormatMenu.addSeparator(); for (int i = 0; i != alternativeFormats.size(); ++i) { const QString format = alternativeFormats.at(i); @@ -379,6 +387,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) m_grabbing = true; } else if (act == actClearCodeModelSnapshot) { m_manager->clearCppCodeModelSnapshot(); + } else if (clearTypeFormatAction && act == clearTypeFormatAction) { + model()->setData(mi1, -1, TypeFormatRole); } else if (clearIndividualFormatAction && act == clearIndividualFormatAction) { model()->setData(mi1, -1, IndividualFormatRole); } else { -- GitLab