def mouseReleaseEvent( self, event ):
        """ Mouse release event to manage the layers drag """
        QTreeWidget.mouseReleaseEvent( self, event )
        self.setCursor( Qt.ArrowCursor )
        self.bMousePressedFlag = False

        if ( not self.itemBeingMoved ):
            #print "*** Legend drag: No itemBeingMoved ***"
            return

        dest = self.itemAt( event.pos() )
        origin = self.itemBeingMoved
        if ( ( not dest ) or ( not origin ) ): # Release out of the legend
            self.checkLayerOrderUpdate()
            return

        self.checkLayerOrderUpdate()
        self.itemBeingMoved = None
Ejemplo n.º 2
0
    def mouseReleaseEvent(self, event):
        """ Mouse release event to manage the layers drag """
        QTreeWidget.mouseReleaseEvent(self, event)
        self.setCursor(Qt.ArrowCursor)
        self.bMousePressedFlag = False

        if (not self.itemBeingMoved):
            #print "*** Legend drag: No itemBeingMoved ***"
            return

        dest = self.itemAt(event.pos())
        origin = self.itemBeingMoved
        if ((not dest) or (not origin)):  # Release out of the legend
            self.checkLayerOrderUpdate()
            return

        self.checkLayerOrderUpdate()
        self.itemBeingMoved = None
Ejemplo n.º 3
0
    def _filter_mouse_released(self, event):
        index = self.filterTreeWidget.indexAt(event.pos())
        if index.data(CheckableItemDelegate.CheckTypeRole) and \
                event.button() == Qt.LeftButton:
            style = QApplication.instance().style()
            radio_button_width = style.pixelMetric(
                QStyle.PM_ExclusiveIndicatorWidth)
            spacing = style.pixelMetric(QStyle.PM_RadioButtonLabelSpacing)

            item = self.filterTreeWidget.itemFromIndex(index)
            ind = 1
            while item.parent():
                ind += 1
                item = item.parent()
            indent = ind * self.filterTreeWidget.indentation()
            if indent < event.x() < indent + radio_button_width + spacing:
                self._switch_check_state(index)
                event.accept()
                # Hack to repaint the whole current item:
                self.filterTreeWidget.currentItem().setExpanded(False)
                return

        QTreeWidget.mouseReleaseEvent(self.filterTreeWidget, event)
Ejemplo n.º 4
0
 def mouseReleaseEvent(self, event):
     """ 
     Обрабатываем нажатие на иконку 'Интересно/Скучно' как нажатие на обычный чекбокс
     
     Решение достаточно грубое, но в данной ситуации вполне себе работает. Перехватывать нужно 
     отпускание мыши, потому что в QAbstractItemView редактирование запускается именно по 
     отпусканию. 
     
     """
     item = self.itemAt(event.pos())
     if self._itemIsCategory(item) and event.pos().x() < 20:
         item.setExpanded(not item.isExpanded())
     elif item is not None and event.pos().x() < settings.entryIconWidth():
         item.setSelected(True)
         rect = self.visualItemRect(item)
         iconRect = QRect(rect.left(),
                          rect.top() + (rect.height() - settings.entryIconHeight()) / 2,
                          settings.entryIconWidth(),
                          settings.entryIconHeight())
         if iconRect.contains(event.pos()):
             self._invertItemCheckState(item)
     else:
         QTreeWidget.mouseReleaseEvent(self, event)
Ejemplo n.º 5
0
    def _filter_mouse_released(self, event):
        index = self.filterTreeWidget.indexAt(event.pos())
        if index.data(CheckableItemDelegate.CheckTypeRole) and \
                event.button() == Qt.LeftButton:
            style = QApplication.instance().style()
            radio_button_width = style.pixelMetric(
                QStyle.PM_ExclusiveIndicatorWidth)
            spacing = style.pixelMetric(QStyle.PM_RadioButtonLabelSpacing)

            item = self.filterTreeWidget.itemFromIndex(index)
            ind = 1
            while item.parent():
                ind += 1
                item = item.parent()
            indent = ind * self.filterTreeWidget.indentation()
            if indent < event.x() < indent + radio_button_width + spacing:
                self._switch_check_state(index)
                event.accept()
                # Hack to repaint the whole current item:
                self.filterTreeWidget.currentItem().setExpanded(False)
                return

        QTreeWidget.mouseReleaseEvent(self.filterTreeWidget, event)