def _slot_context_menu(self, point): context_menu = MMenu(parent=self) logical_column = self.logicalIndexAt(point) model = utils.real_model(self.model()) if logical_column >= 0 and model.header_list[logical_column].get('checkable', False): action_select_all = context_menu.addAction(self.tr('Select All')) action_select_none = context_menu.addAction(self.tr('Select None')) action_select_invert = context_menu.addAction(self.tr('Select Invert')) self.connect(action_select_all, SIGNAL('triggered()'), functools.partial(self._slot_set_select, logical_column, Qt.Checked)) self.connect(action_select_none, SIGNAL('triggered()'), functools.partial(self._slot_set_select, logical_column, Qt.Unchecked)) self.connect(action_select_invert, SIGNAL('triggered()'), functools.partial(self._slot_set_select, logical_column, None)) context_menu.addSeparator() fit_action = context_menu.addAction(self.tr('Fit Size')) fit_action.triggered.connect(functools.partial(self._slot_set_resize_mode, True)) context_menu.addSeparator() for column in range(self.count()): action = context_menu.addAction(model.headerData(column, Qt.Horizontal, Qt.DisplayRole)) action.setCheckable(True) action.setChecked(not self.isSectionHidden(column)) action.toggled.connect(functools.partial(self._slot_set_section_visible, column)) context_menu.exec_(QCursor.pos() + QPoint(10, 10))
def _slot_context_menu(self, point): context_menu = MMenu(parent=self) action_select_all = context_menu.addAction('Select All') action_select_none = context_menu.addAction('Select None') action_select_invert = context_menu.addAction('Select Invert') action_select_all.triggered.connect(functools.partial(self._slot_set_select, True)) action_select_none.triggered.connect(functools.partial(self._slot_set_select, False)) action_select_invert.triggered.connect(functools.partial(self._slot_set_select, None)) context_menu.exec_(QCursor.pos() + QPoint(10, 10))