code: def contextMenuEvent(self, event):
          
          if self.model.showndata:
              self.refresh_menu()
              self.menu.popup(event.globalPos())
              event.accept()
          else:
              self.empty_ws_menu.popup(event.globalPos())
              event.accept()
docs: Reimplement Qt method