summaryrefslogtreecommitdiff
path: root/src/plugins/debugger/watchwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/debugger/watchwindow.cpp')
-rw-r--r--src/plugins/debugger/watchwindow.cpp44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp
index b4c7a55aff..005aa5954b 100644
--- a/src/plugins/debugger/watchwindow.cpp
+++ b/src/plugins/debugger/watchwindow.cpp
@@ -210,36 +210,40 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
QStringList alternativeFormats =
model()->data(mi0, TypeFormatListRole).toStringList();
- int typeFormat =
- model()->data(mi0, TypeFormatRole).toInt();
- int individualFormat =
- model()->data(mi0, IndividualFormatRole).toInt();
+ const int typeFormat = qMax(int(DecimalFormat), model()->data(mi0, TypeFormatRole).toInt());
+ const int individualFormat = model()->data(mi0, IndividualFormatRole).toInt();
+ const int effectiveIndividualFormat = individualFormat == -1 ? typeFormat : individualFormat;
QMenu typeFormatMenu;
QMenu individualFormatMenu;
QList<QAction *> typeFormatActions;
QList<QAction *> individualFormatActions;
+ QAction *clearIndividualFormatAction = 0;
if (idx.isValid()) {
typeFormatMenu.setTitle(tr("Change format for type '%1'").arg(type));
individualFormatMenu.setTitle(tr("Change format for expression '%1'").arg(exp));
- for (int i = 0; i != alternativeFormats.size(); ++i) {
- const QString format = alternativeFormats.at(i);
- QAction *act = new QAction(format, &typeFormatMenu);
- act->setCheckable(true);
- if (i == typeFormat)
- act->setChecked(true);
- typeFormatMenu.addAction(act);
- typeFormatActions.append(act);
- act = new QAction(format, &individualFormatMenu);
- act->setCheckable(true);
- if (i == individualFormat)
- act->setChecked(true);
- individualFormatMenu.addAction(act);
- individualFormatActions.append(act);
- }
if (alternativeFormats.isEmpty()) {
typeFormatMenu.setEnabled(false);
individualFormatMenu.setEnabled(false);
+ } else {
+ clearIndividualFormatAction = individualFormatMenu.addAction(tr("Clear"));
+ clearIndividualFormatAction->setEnabled(individualFormat != -1);
+ individualFormatMenu.addSeparator();
+ for (int i = 0; i != alternativeFormats.size(); ++i) {
+ const QString format = alternativeFormats.at(i);
+ QAction *act = new QAction(format, &typeFormatMenu);
+ act->setCheckable(true);
+ if (i == typeFormat)
+ act->setChecked(true);
+ typeFormatMenu.addAction(act);
+ typeFormatActions.append(act);
+ act = new QAction(format, &individualFormatMenu);
+ act->setCheckable(true);
+ if (i == effectiveIndividualFormat)
+ act->setChecked(true);
+ individualFormatMenu.addAction(act);
+ individualFormatActions.append(act);
+ }
}
} else {
typeFormatMenu.setTitle(tr("Change format for type"));
@@ -316,6 +320,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
m_grabbing = true;
} else if (act == actClearCodeModelSnapshot) {
m_manager->clearCppCodeModelSnapshot();
+ } else if (clearIndividualFormatAction && act == clearIndividualFormatAction) {
+ model()->setData(mi1, -1, IndividualFormatRole);
} else {
for (int i = 0; i != alternativeFormats.size(); ++i) {
if (act == typeFormatActions.at(i))