Exemplo n.º 1
0
 def testArrowContact(self, indices, x, y):
     if type(indices) != list: indices = [indices]
     for index in indices:
         if index >= len(self.attributes) or index < 0:
             continue
         int_x = self.transform(xBottom, index)
         bottom = self.transform(
             yLeft,
             self.selection_conditions.get(self.attributes[index],
                                           [0, 1])[0])
         bottom_rect = QRect(int_x - self.bottom_pixmap.width() / 2, bottom,
                             self.bottom_pixmap.width(),
                             self.bottom_pixmap.height())
         if bottom_rect.contains(QPoint(x, y)):
             return 1, (index, 0)
         top = self.transform(
             yLeft,
             self.selection_conditions.get(self.attributes[index],
                                           [0, 1])[1])
         top_rect = QRect(int_x - self.top_pixmap.width() / 2,
                          top - self.top_pixmap.height(),
                          self.top_pixmap.width(), self.top_pixmap.height())
         if top_rect.contains(QPoint(x, y)):
             return 1, (index, 1)
     return 0, (0, 0)
Exemplo n.º 2
0
    def __autoScrollAdvance(self):
        """Advance the auto scroll
        """
        pos = QCursor.pos()
        pos = self.mapFromGlobal(pos)
        margin = self.__autoScrollMargin

        vvalue = self.verticalScrollBar().value()
        hvalue = self.horizontalScrollBar().value()

        vrect = QRect(0, 0, self.width(), self.height())

        # What should be the speed
        advance = 10

        # We only do auto scroll if the mouse is inside the view.
        if vrect.contains(pos):
            if pos.x() < vrect.left() + margin:
                self.horizontalScrollBar().setValue(hvalue - advance)
            if pos.y() < vrect.top() + margin:
                self.verticalScrollBar().setValue(vvalue - advance)
            if pos.x() > vrect.right() - margin:
                self.horizontalScrollBar().setValue(hvalue + advance)
            if pos.y() > vrect.bottom() - margin:
                self.verticalScrollBar().setValue(vvalue + advance)

            if self.verticalScrollBar().value() == vvalue and \
                    self.horizontalScrollBar().value() == hvalue:
                self.__stopAutoScroll()
        else:
            self.__stopAutoScroll()

        log.debug("Auto scroll advance")
Exemplo n.º 3
0
    def __autoScrollAdvance(self):
        """Advance the auto scroll
        """
        pos = QCursor.pos()
        pos = self.mapFromGlobal(pos)
        margin = self.__autoScrollMargin

        vvalue = self.verticalScrollBar().value()
        hvalue = self.horizontalScrollBar().value()

        vrect = QRect(0, 0, self.width(), self.height())

        # What should be the speed
        advance = 10

        # We only do auto scroll if the mouse is inside the view.
        if vrect.contains(pos):
            if pos.x() < vrect.left() + margin:
                self.horizontalScrollBar().setValue(hvalue - advance)
            if pos.y() < vrect.top() + margin:
                self.verticalScrollBar().setValue(vvalue - advance)
            if pos.x() > vrect.right() - margin:
                self.horizontalScrollBar().setValue(hvalue + advance)
            if pos.y() > vrect.bottom() - margin:
                self.verticalScrollBar().setValue(vvalue + advance)

            if self.verticalScrollBar().value() == vvalue and \
                    self.horizontalScrollBar().value() == hvalue:
                self.__stopAutoScroll()
        else:
            self.__stopAutoScroll()

        log.debug("Auto scroll advance")
Exemplo n.º 4
0
 def testArrowContact(self, indices, x, y):
     if type(indices) != list: indices = [indices]
     for index in indices:
         if index >= len(self.attributes) or index < 0:
             continue
         int_x = self.transform(xBottom, index)
         bottom = self.transform(yLeft,
                                 self.selection_conditions.get(self.attributes[index], [0, 1])[0])
         bottom_rect = QRect(int_x - self.bottom_pixmap.width() / 2, bottom, self.bottom_pixmap.width(),
                             self.bottom_pixmap.height())
         if bottom_rect.contains(QPoint(x, y)):
             return 1, (index, 0)
         top = self.transform(yLeft,
                              self.selection_conditions.get(self.attributes[index], [0, 1])[1])
         top_rect = QRect(int_x - self.top_pixmap.width() / 2, top - self.top_pixmap.height(),
                          self.top_pixmap.width(),
                          self.top_pixmap.height())
         if top_rect.contains(QPoint(x, y)):
             return 1, (index, 1)
     return 0, (0, 0)