def create_header_menu_action(self, header):
actions = self.menu_headers.actions()
headers = [act.text() for act in actions]
if header in headers:
return
idx = bisect.bisect(headers, header)
action = QtWidgets.QAction(self)
action.setText(header)
action.setCheckable(True)
action.setChecked(True)
def set_visibility(visible):
self.view_keys.show_header(header, visible)
self.view_head.show_header(header, visible)
action.triggered.connect(set_visibility)
def visibility_set(header_, visible):
if header_ == header:
action.setChecked(visible)
for view in (self.view_keys, self.view_head):
view.header_visibility_changed.connect(visibility_set)
if idx < len(actions):
before_action = actions[idx]
self.menu_headers.insertAction(before_action, action)
else:
self.menu_headers.addAction(action)
empty = len(self.menu_headers.actions()) == 0
self.menu_headers.setDisabled(empty)
评论列表
文章目录