예제 #1
0
    def mousePressEvent(self, event):
        """Override Qt method"""
        QTableView.mousePressEvent(self, event)
        self.current_index = self.currentIndex()

        if event.button() == Qt.LeftButton:
            pos = QPoint(event.x(), event.y())
            index = self.indexAt(pos)
            self.action_pressed(index)
        elif event.button() == Qt.RightButton:
            self.context_menu_requested(event)
예제 #2
0
    def mousePressEvent(self, event):
        """Override Qt method"""
        QTableView.mousePressEvent(self, event)
        self.current_index = self.currentIndex()
        column = self.current_index.column()

        if event.button() == Qt.LeftButton and column == const.COL_ACTION:
            pos = QPoint(event.x(), event.y())
            index = self.indexAt(pos)
            self.action_pressed(index)
            self.context_menu_requested(event)
        elif event.button() == Qt.RightButton:
            self.context_menu_requested(event, right_click=True)
        self.update_visible_rows()
예제 #3
0
    def mousePressEvent(self, event):
        """Override Qt method"""
        QTableView.mousePressEvent(self, event)
        self.current_index = self.currentIndex()
        column = self.current_index.column()

        if event.button() == Qt.LeftButton and column == const.COL_ACTION:
            pos = QPoint(event.x(), event.y())
            index = self.indexAt(pos)
            self.action_pressed(index)
            self.context_menu_requested(event)
        elif event.button() == Qt.RightButton:
            self.context_menu_requested(event, right_click=True)
        self.update_visible_rows()
예제 #4
0
    def mousePressEvent(self, event):
        """Override Qt method."""
        QTableView.mousePressEvent(self, event)

        pos = QPoint(event.x(), event.y())
        index = self.indexAt(pos)
        model = self.source_model

        if self.proxy_model is None or self.source_model is None:
            return

        model_index = self.proxy_model.mapToSource(index)
        row = model_index.row()

        if row == -1:
            return

        column = model_index.column()
        row_data = self.source_model.row(row)
        remove_actions = self.source_model.count_remove_actions()
        # install_actions = self.source_model.count_install_actions()
        action = row_data[C.COL_ACTION]
        status = row_data[C.COL_STATUS]

        right_click = event.button() == Qt.RightButton
        left_click = event.button() == Qt.LeftButton

        if column == C.COL_ACTION:
            if right_click or (left_click and status != C.NOT_INSTALLED):
                self.context_menu_requested(event)
            elif left_click and status == C.NOT_INSTALLED:
                # 1-click install/uncheck if not installed
                if action == C.ACTION_NONE and not remove_actions:
                    self.set_action_status(model_index, C.ACTION_INSTALL)
                elif status:
                    self.set_action_status(model_index, C.ACTION_NONE)

        elif (column == C.COL_VERSION and model.is_upgradable(model_index)
              and left_click):
            # 1-click update
            name = row_data[C.COL_NAME]
            versions = model.get_package_versions(name)
            self.set_action_status(model_index, C.ACTION_UPGRADE, versions[-1])

        self.update_visible_rows()