debugger: disable parts of L&W context menu when no item is selected

This commit is contained in:
hjk
2009-07-08 09:02:36 +02:00
parent eb83377f5a
commit ee9894bf7a

View File

@@ -213,10 +213,13 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
int individualFormat = int individualFormat =
model()->data(mi0, IndividualFormatRole).toInt(); model()->data(mi0, IndividualFormatRole).toInt();
QMenu typeFormatMenu(tr("Change format for type '%1'").arg(type)); QMenu typeFormatMenu;
QMenu individualFormatMenu(tr("Change format for expression '%1'").arg(exp)); QMenu individualFormatMenu;
QList<QAction *> typeFormatActions; QList<QAction *> typeFormatActions;
QList<QAction *> individualFormatActions; QList<QAction *> individualFormatActions;
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) { for (int i = 0; i != alternativeFormats.size(); ++i) {
const QString format = alternativeFormats.at(i); const QString format = alternativeFormats.at(i);
QAction *act = new QAction(format, &typeFormatMenu); QAction *act = new QAction(format, &typeFormatMenu);
@@ -232,8 +235,12 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
individualFormatMenu.addAction(act); individualFormatMenu.addAction(act);
individualFormatActions.append(act); individualFormatActions.append(act);
} }
//typeFormatMenu.setActive(!alternativeFormats.isEmpty()); } else {
//individualFormatMenu.setActive(!alternativeFormats.isEmpty()); typeFormatMenu.setTitle(tr("Change format for type"));
typeFormatMenu.setEnabled(false);
individualFormatMenu.setTitle(tr("Change format for expression"));
individualFormatMenu.setEnabled(false);
}
QMenu menu; QMenu menu;
QAction *act1 = new QAction(tr("Adjust column widths to contents"), &menu); QAction *act1 = new QAction(tr("Adjust column widths to contents"), &menu);