@@ -81,8 +81,11 @@ ExtendedTableWidget::ExtendedTableWidget(QWidget* parent) :
8181
8282 // Set up table view context menu
8383 m_contextMenu = new QMenu (this );
84- QAction* copyAction = new QAction (QIcon (" :/icons/copy" ), " Copy" , m_contextMenu);
85- QAction* pasteAction = new QAction (QIcon (" :/icons/paste" ), " Paste" , m_contextMenu);
84+ QAction* nullAction = new QAction (tr (" Set to NULL" ), m_contextMenu);
85+ QAction* copyAction = new QAction (QIcon (" :/icons/copy" ), tr (" Copy" ), m_contextMenu);
86+ QAction* pasteAction = new QAction (QIcon (" :/icons/paste" ), tr (" Paste" ), m_contextMenu);
87+ m_contextMenu->addAction (nullAction);
88+ m_contextMenu->addSeparator ();
8689 m_contextMenu->addAction (copyAction);
8790 m_contextMenu->addAction (pasteAction);
8891 setContextMenuPolicy (Qt::CustomContextMenu);
@@ -93,11 +96,16 @@ ExtendedTableWidget::ExtendedTableWidget(QWidget* parent) :
9396 {
9497 // Try to find out whether the current view is editable and (de)activate menu options according to that
9598 bool editable = editTriggers () != QAbstractItemView::NoEditTriggers;
99+ nullAction->setEnabled (editable);
96100 pasteAction->setEnabled (editable);
97101
98102 // Show menu
99103 m_contextMenu->popup (viewport ()->mapToGlobal (pos));
100104 });
105+ connect (nullAction, &QAction::triggered, [&]() {
106+ foreach (const QModelIndex& index, selectedIndexes ())
107+ model ()->setData (index, QVariant ());
108+ });
101109 connect (copyAction, &QAction::triggered, [&]() {
102110 copy ();
103111 });
0 commit comments