def drawScaleContents(self, painter, center, radius):
        dir = 90  #360 - int(roud(self.origin() - self.value()))
        arc = 90  #+ int(round(self.gradient * 90))
        skyColor = QColor(38, 151, 221)
        painter.save()
        painter.setBrush(skyColor)
        painter.drawChord(self.scaleContentsRect(), (dir - arc) * 16,
                          2 * arc * 16)
        direction1 = self.value() * M_PI / 180.0
        direction2 = self.value() * M_PI / 180.0 + M_PI_2

        triangleSize = qRound(radius * 0.15)
        p0 = (QPoint(center.x() + 0, center.y() + 0))
        p1 = qwtPolar2Pos(p0, 2, direction2)
        pa = QPolygon(3)
        pa.setPoint(0, qwtPolar2Pos(p1, 2 * triangleSize, direction2))
        pa.setPoint(1, qwtPolar2Pos(p1, triangleSize, direction2 + M_PI_2))
        pa.setPoint(2, qwtPolar2Pos(p1, triangleSize, direction2 - M_PI_2))
        color = self.palette().color(QPalette.Text)
        painter.setBrush(color)
        painter.drawPolygon(pa)

        p0 = (QPoint(center.x() + 0, center.y() + 0))
        color = self.palette().color(QPalette.Text)
        painter.setBrush(color)
        painter.setPen(QPen(color, 3))
        painter.drawLine(qwtPolar2Pos(p0, radius - 3, direction1),
                         qwtPolar2Pos(p0, radius - 3, direction1 - M_PI))

        painter.restore()
Beispiel #2
0
    def penMoveEvent(self, pos, pressure, liftedDeque):
        pen_x = pos[0]
        pen_y = pos[1]
        pen_pressure = pressure

        # print(liftedDeque)
        # print(self.__lastPos)

        if self.__lastPos is None:
            self.__lastPos = QPoint(pen_x, pen_y)

        self.__currentPos = QPoint(pen_x, pen_y)
        self.__painter.begin(self.__board)

        if self.EraserMode == False:
            #Non-Eraser mode
            self.__penColor = QColor("blue")
            self.__painter.setPen(QPen(
                self.__penColor, self.__thickness))  #Set pen color, thickness
        else:
            #Eraser mode: pen color is white, thickness is 6
            self.__painter.setPen(QPen(Qt.white, 6))

        self.__painter.drawLine(self.__lastPos, self.__currentPos)
        self.__painter.end()
        self.__lastPos = self.__currentPos

        self.update()  #Show updates

        # If ever detected the pen is lifted, reset the __lastPos variable in order to reposition the pen
        if (True in liftedDeque):
            self.__lastPos = None
Beispiel #3
0
    def penMoveEvent(self, pos, pressure):
        pen_x = pos[0]
        pen_y = pos[1]
        pen_pressure = pressure

        if self.__lastPos is None:
            self.__lastPos = QPoint(pen_x, pen_y)
        elif (abs(pen_x - self.__lastPos.x()) > 21
              or abs(pen_y - self.__lastPos.y()) > 21):
            self.__lastPos = QPoint(pen_x, pen_y)

        self.__currentPos = QPoint(pen_x, pen_y)
        self.__painter.begin(self.__board)

        if self.EraserMode == False:
            #Non-Eraser mode
            self.__painter.setPen(QPen(
                self.__penColor, self.__thickness))  #Set pen color, thickness
        else:
            #Eraser mode: pen color is white, thickness is 6
            self.__painter.setPen(QPen(Qt.white, 6))

        self.__painter.drawLine(self.__lastPos, self.__currentPos)
        self.__painter.end()
        self.__lastPos = self.__currentPos

        self.update()  #Show updates
Beispiel #4
0
 def compute_path(self):
     p1 = self.p1 if self.p1.x() < self.p2.x() else self.p2
     p2 = self.p2 if self.p1.x() < self.p2.x() else self.p1
     path = QPainterPath()
     path.moveTo(p1)
     dx = p2.x() - p1.x()
     path.cubicTo(QPoint(p1.x() + dx / 3, p1.y()), QPoint(p2.x() - dx / 3, p2.y()), p2)
     self.__path = path
Beispiel #5
0
 def mousePressEvent(self, event):
     self.drag_is_not_DND = False  # don't know yet
     qp = event.globalPos()  # clone the point to keep it constant
     self.mouse_press_qpoint = QPoint(qp.x(), qp.y())
     self.mouse_press_event = QMouseEvent(event.type(),
                                          QPoint(event.x(), event.y()),
                                          event.button(), event.buttons(),
                                          event.modifiers())
Beispiel #6
0
    def paintPolyg(self, x1, y1, x2, y2, x3, y3, x4, y4):
        self.__painter.begin(self.__board)
        self.__penColor = QColor("black")
        self.__painter.setPen(QPen(self.__penColor, self.__thickness))
        self.__painter.drawPolygon(QPoint(x1, y1), QPoint(x2, y2),
                                   QPoint(x3, y3), QPoint(x4, y4))
        self.__painter.end()

        self.update()  #Show updates
Beispiel #7
0
    def paintLine(self, P1_x, P1_y, P2_x, P2_y):
        P1 = QPoint(P1_x, P1_y)
        P2 = QPoint(P2_x, P2_y)

        self.__painter.begin(self.__board)
        self.__painter.setPen(QPen(self.__penColor, self.__thickness))
        self.__painter.drawLine(P1, P2)
        self.__painter.end()

        self.update()  #Show updates
Beispiel #8
0
 def first_visible_row(self):
     geom = self.viewport().geometry()
     for y in xrange(geom.top(), (self.spacing()*2) + geom.top(), 5):
         for x in xrange(geom.left(), (self.spacing()*2) + geom.left(), 5):
             ans = self.indexAt(QPoint(x, y)).row()
             if ans > -1:
                 return ans
Beispiel #9
0
    def mouseMoveEvent(self, e: QMouseEvent):
        if self.__action == Action.DRAG:
            dx = e.x() - self.__origin.x()
            dy = e.y() - self.__origin.y()
            self.set_pos(self.x() + dx, self.y() + dy)
        elif self.__action == Action.RESIZE:
            self.set_size(e.x(), e.y())
        elif self.__action == Action.CONNECTING and self.__line is not None:
            p = QPoint(e.x() + self.x(), e.y() + self.y())

            n = self.parent().get_node(p)
            if n is not None and n.compatible(self.__line.n1):
                self.__line.status(True)
            else:
                self.__line.status(False)

            self.__line.update(p)

        else:
            n = self.node(e.pos())
            if self.__label is None and n is not None:
                self.__label = self.parent().create_label(self.node_name(n), n)
            elif self.__label is not None and self.__label.node() is not n and n is not None:
                self.parent().delete_label(self.__label)
                self.__label = self.parent().create_label(self.node_name(n), n)
            elif n is None:
                self.parent().delete_label(self.__label)
                self.__label = None
Beispiel #10
0
 def _paint_widget(self, p):
     if self._widget is not None and (self.mode() == Mode.DEBUG or self.mode() == Mode.EDIT_LOGIC):
         p.setClipRect(Block.padding + 5, 5 + Block.padding, self.width() - 2 * Block.padding - 10,
                       25)
         p.translate(self.padding + 5, 5 + self.padding)
         self._widget.render(p, QPoint(), QRegion(0, 0, self.width(), 25),
                             QWidget.IgnoreMask)
Beispiel #11
0
    def virtual_library_clicked(self):
        m = self.virtual_library_menu
        m.clear()

        a = m.addAction(_('Create Virtual Library'))
        a.triggered.connect(partial(self.do_create_edit, name=None))

        a = self.edit_menu
        self.build_virtual_library_list(a, self.do_create_edit)
        m.addMenu(a)

        a = self.rm_menu
        self.build_virtual_library_list(a, self.remove_vl_triggered)
        m.addMenu(a)

        m.addSeparator()

        db = self.library_view.model().db

        a = self.ar_menu
        a.clear()
        a.setIcon(self.checked if db.data.get_search_restriction_name(
        ) else self.empty)
        self.build_search_restriction_list()
        m.addMenu(a)

        m.addSeparator()

        current_lib = db.data.get_base_restriction_name()

        if current_lib == '':
            a = m.addAction(self.checked, self.no_restriction)
        else:
            a = m.addAction(self.empty, self.no_restriction)
        a.triggered.connect(partial(self.apply_virtual_library, library=''))

        a = m.addAction(self.empty, _('*current search'))
        a.triggered.connect(partial(self.apply_virtual_library, library='*'))

        if self.search_based_vl_name:
            a = m.addAction(
                self.checked
                if db.data.get_base_restriction_name().startswith('*') else
                self.empty, self.search_based_vl_name)
            a.triggered.connect(
                partial(self.apply_virtual_library,
                        library=self.search_based_vl_name))

        m.addSeparator()

        virt_libs = db.prefs.get('virtual_libraries', {})
        for vl in sorted(virt_libs.keys(), key=sort_key):
            a = m.addAction(self.checked if vl == current_lib else self.empty,
                            vl)
            a.triggered.connect(partial(self.apply_virtual_library,
                                        library=vl))

        p = QPoint(0, self.virtual_library.height())
        self.virtual_library_menu.popup(self.virtual_library.mapToGlobal(p))
Beispiel #12
0
 def get_node(self, p):
     for b in self.blocks:
         if b.geometry().contains(p):
             p1 = QPoint(p.x() - b.x(), p.y() - b.y())
             n = b.node(p1)
             if n is not None:
                 return n
     return None
Beispiel #13
0
 def last_visible_row(self):
     geom = self.viewport().geometry()
     for y in xrange(geom.bottom(), geom.bottom() - 2 * self.spacing(), -5):
         for x in xrange(geom.left(), (self.spacing()*2) + geom.left(), 5):
             ans = self.indexAt(QPoint(x, y)).row()
             if ans > -1:
                 item_width = self.delegate.item_size.width() + 2*self.spacing()
                 return ans + (geom.width() // item_width)
Beispiel #14
0
    def paintEllipse(self, center_x, center_y, radias1, radias2):
        self.__painter.begin(self.__board)
        self.__penColor = QColor("black")
        self.__painter.setPen(QPen(self.__penColor, self.__thickness))
        self.__painter.drawEllipse(QPoint(center_x, center_y), radias1,
                                   radias2)

        self.__painter.end()

        self.update()  #Show updates
Beispiel #15
0
    def paintBezierSpline(self, pointListX, pointListY):
        P1 = QPoint(int(pointListX[0]), int(pointListY[0]))
        path = QtGui.QPainterPath()
        path.moveTo(P1)

        self.__painter.begin(self.__board)
        self.__painter.setPen(QPen(self.__penColor, self.__thickness))

        i = 0
        while i < len(pointListX) - 3:
            P2 = QPoint(int(pointListX[i + 1]), int(pointListY[i + 1]))
            P3 = QPoint(int(pointListX[i + 2]), int(pointListY[i + 2]))
            P4 = QPoint(int(pointListX[i + 3]), int(pointListY[i + 3]))
            path.cubicTo(P2, P3, P4)
            self.__painter.drawPath(path)
            i += 3

        self.__painter.end()

        self.update()  #Show updates
Beispiel #16
0
 def check_line(self, line):
     p = line.p2
     for b in self.blocks:
         if b.geometry().contains(p):
             p1 = QPoint(p.x() - b.x(), p.y() - b.y())
             n = b.node(p1)
             if n is not None and n.compatible(
                     line.n1) and line.n1.compatible(n):
                 line.connect(n)
                 return
     line.remove()
 def drawScale(self, painter, center, radius, origin, minArc, maxArc):
     direction1 = M_PI_2
     triangleSize = qRound(radius * 0.15)
     p0 = (QPoint(center.x() + 0, center.y() + 0))
     p1 = qwtPolar2Pos(p0, radius - 2 * triangleSize + 20, direction1)
     pa = QPolygon(3)
     pa.setPoint(0, qwtPolar2Pos(p1, -1.6 * triangleSize, direction1))
     pa.setPoint(1, qwtPolar2Pos(p1, triangleSize, direction1 + M_PI_2))
     pa.setPoint(2, qwtPolar2Pos(p1, triangleSize, direction1 - M_PI_2))
     color = self.palette().color(QPalette.Text)
     painter.setBrush(color)
     painter.drawPolygon(pa)
Beispiel #18
0
 def drag_data(self):
     m = self.model()
     rows = self.selectionModel().selectedRows()
     paths = [force_unicode(p, enc=filesystem_encoding) for p in m.paths(rows) if p]
     md = QMimeData()
     md.setData('application/calibre+from_device', 'dummy')
     md.setUrls([QUrl.fromLocalFile(p) for p in paths])
     drag = QDrag(self)
     drag.setMimeData(md)
     cover = self.drag_icon(m.cover(self.currentIndex().row()), len(paths) >
             1)
     drag.setHotSpot(QPoint(-15, -15))
     drag.setPixmap(cover)
     return drag
Beispiel #19
0
    def popup(self, select_first=True):
        if self.disable_popup:
            return
        p = self
        m = p.model()
        widget = self.completer_widget()
        if widget is None:
            return
        screen = QApplication.desktop().availableGeometry(widget)
        h = (p.sizeHintForRow(0) * min(self.max_visible_items, m.rowCount()) +
             3) + 3
        hsb = p.horizontalScrollBar()
        if hsb and hsb.isVisible():
            h += hsb.sizeHint().height()

        rh = widget.height()
        pos = widget.mapToGlobal(QPoint(0, widget.height() - 2))
        w = min(widget.width(), screen.width())

        if (pos.x() + w) > (screen.x() + screen.width()):
            pos.setX(screen.x() + screen.width() - w)
        if pos.x() < screen.x():
            pos.setX(screen.x())

        top = pos.y() - rh - screen.top() + 2
        bottom = screen.bottom() - pos.y()
        h = max(h, p.minimumHeight())
        if h > bottom:
            h = min(max(top, bottom), h)

            if top > bottom:
                pos.setY(pos.y() - h - rh + 2)

        p.setGeometry(pos.x(), pos.y(), w, h)

        if (tweaks['preselect_first_completion'] and select_first
                and not self.currentIndex().isValid()
                and self.model().rowCount() > 0):
            self.setCurrentIndex(self.model().index(0))

        if not p.isVisible():
            if isosx and get_osx_version() >= (10, 9, 0):
                # On mavericks the popup menu seems to use a font smaller than
                # the widgets font, see for example:
                # https://bugs.launchpad.net/bugs/1243761
                fp = QFontInfo(widget.font())
                f = QFont()
                f.setPixelSize(fp.pixelSize())
                self.setFont(f)
            p.show()
Beispiel #20
0
    def paintEvent(self, ev):
        offset = QPoint(0, 0)
        p = QPainter(self)
        p.setClipRect(ev.rect())
        bottom = self.rect().bottom()

        if self.results:
            for i, (prefix, full, text) in enumerate(self.results):
                size = prefix.size()
                if offset.y() + size.height() > bottom:
                    break
                self.max_result = i
                offset.setX(0)
                if i in (self.current_result, self.mouse_hover_result):
                    p.save()
                    if i != self.current_result:
                        p.setPen(Qt.DotLine)
                    p.drawLine(offset, QPoint(self.width(), offset.y()))
                    p.restore()
                offset.setY(offset.y() + self.MARGIN // 2)
                p.drawStaticText(offset, prefix)
                offset.setX(self.maxwidth + 5)
                p.drawStaticText(offset, self.divider)
                offset.setX(offset.x() + self.divider.size().width())
                p.drawStaticText(offset, full)
                offset.setY(offset.y() + size.height() + self.MARGIN // 2)
                if i in (self.current_result, self.mouse_hover_result):
                    offset.setX(0)
                    p.save()
                    if i != self.current_result:
                        p.setPen(Qt.DotLine)
                    p.drawLine(offset, QPoint(self.width(), offset.y()))
                    p.restore()
        else:
            p.drawText(self.rect(), Qt.AlignCenter, _('No results found'))

        p.end()
 def draw(self, painter, center, length, direction, cg):
     direction1 = direction * M_PI / 180.0
     triangleSize = qRound(length * 0.1)
     painter.save()
     p0 = (QPoint(center.x() + 0, center.y() + 0))
     p1 = qwtPolar2Pos(p0, length - 2 * triangleSize - 2, direction1)
     pa = QPolygon(3)
     pa.setPoint(0, qwtPolar2Pos(p1, 2 * triangleSize, direction1))
     pa.setPoint(1, qwtPolar2Pos(p1, triangleSize, direction1 + M_PI_2))
     pa.setPoint(2, qwtPolar2Pos(p1, triangleSize, direction1 - M_PI_2))
     color = self.palette().color(cg, QPalette.Text)
     painter.setBrush(color)
     painter.drawPolygon(pa)
     painter.setPen(QPen(color, 3))
     painter.drawLine(qwtPolar2Pos(p0, length - 2, direction1 + M_PI_2),
                      qwtPolar2Pos(p0, length - 2, direction1 - M_PI_2))
     painter.restore()
Beispiel #22
0
    def __InitData(self, sizeX, sizeY):
        self.__size = QSize(sizeX, sizeY)

        self.__board = QPixmap(
            self.__size)  # Make a new QPixmap as paint board,350px * 250px
        self.__board.fill(Qt.white)  #Fill the paint board with white

        self.__IsEmpty = True  #board is empty by default
        self.EraserMode = False  #eraser mode is disabled by default

        self.__lastPos = None
        self.__currentPos = QPoint(0, 0)

        self.__painter = QPainter()

        self.__thickness = 1  #default pen thickness is 1
        self.__penColor = QColor("black")  #default color is black
        self.__colorList = QColor.colorNames()  #get the list of colors
Beispiel #23
0
def full(p, xmax, ymax):
    p.drawRect(0, 0, xmax, ymax)
    p.drawPolyline(QPoint(0, 0), QPoint(xmax, 0), QPoint(xmax, ymax),
                   QPoint(0, ymax), QPoint(0, 0))
    pp = QPainterPath()
    pp.addRect(0, 0, xmax, ymax)
    p.drawPath(pp)
    p.save()
    for i in xrange(3):
        col = [0, 0, 0, 200]
        col[i] = 255
        p.setOpacity(0.3)
        p.fillRect(0, 0, xmax / 10, xmax / 10, QBrush(QColor(*col)))
        p.setOpacity(1)
        p.drawRect(0, 0, xmax / 10, xmax / 10)
        p.translate(xmax / 10, xmax / 10)
        p.scale(1, 1.5)
    p.restore()

    # p.scale(2, 2)
    # p.rotate(45)
    p.drawPixmap(0, 0, xmax / 4, xmax / 4, QPixmap(I('library.png')))
    p.drawRect(0, 0, xmax / 4, xmax / 4)

    f = p.font()
    f.setPointSize(20)
    # f.setLetterSpacing(f.PercentageSpacing, 200)
    f.setUnderline(True)
    # f.setOverline(True)
    # f.setStrikeOut(True)
    f.setFamily('Calibri')
    p.setFont(f)
    # p.setPen(QColor(0, 0, 255))
    # p.scale(2, 2)
    # p.rotate(45)
    p.drawText(QPoint(xmax / 3.9, 30), 'Some—text not By’s ū --- Д AV ff ff')

    b = QBrush(Qt.HorPattern)
    b.setColor(QColor(Qt.blue))
    pix = QPixmap(I('console.png'))
    w = xmax / 4
    p.fillRect(0, ymax / 3, w, w, b)
    p.fillRect(xmax / 3, ymax / 3, w, w, QBrush(pix))
    x, y = 2 * xmax / 3, ymax / 3
    p.drawTiledPixmap(QRectF(x, y, w, w), pix, QPointF(10, 10))

    x, y = 1, ymax / 1.9
    g = QLinearGradient(QPointF(x, y), QPointF(x + w, y + w))
    g.setColorAt(0, QColor('#00f'))
    g.setColorAt(1, QColor('#fff'))
    p.fillRect(x, y, w, w, QBrush(g))
Beispiel #24
0
 def __init__(self, type_name: str, name: str, parent: QWidget=None):
     QWidget.__init__(self, parent)
     self.settings = {"Name": Setting("Name", StringValue(name), parent=self)}
     self.outputs = {}
     self.inputs = {}
     self.__type_name = type_name
     self._bg_color = QColor(159, 160, 144, 255)
     self._fg_color = QColor(255, 255, 255)
     self._resizable = True
     self.setMinimumSize(90, 120)
     self.__origin = QPoint(0, 0)
     self.__action = Action.NONE
     self.__status = Mode.EDIT_LOGIC
     self.__selected = False
     self.__line = None
     self.__label = None
     self.setMouseTracking(True)
     if self._resizable:
         self.__init_corner()
Beispiel #25
0
def drag_data(self):
    m = self.model()
    db = m.db
    selected = self.get_selected_ids()
    ids = ' '.join(map(str, selected))
    md = QMimeData()
    md.setData('application/calibre+from_library', ids)
    fmt = prefs['output_format']

    def url_for_id(i):
        try:
            ans = db.format_path(i, fmt, index_is_id=True)
        except:
            ans = None
        if ans is None:
            fmts = db.formats(i, index_is_id=True)
            if fmts:
                fmts = fmts.split(',')
            else:
                fmts = []
            for f in fmts:
                try:
                    ans = db.format_path(i, f, index_is_id=True)
                except:
                    ans = None
        if ans is None:
            ans = db.abspath(i, index_is_id=True)
        return QUrl.fromLocalFile(ans)

    md.setUrls([url_for_id(i) for i in selected])
    drag = QDrag(self)
    col = self.selectionModel().currentIndex().column()
    try:
        md.column_name = self.column_map[col]
    except AttributeError:
        md.column_name = 'title'
    drag.setMimeData(md)
    cover = self.drag_icon(m.cover(self.currentIndex().row()),
                           len(selected) > 1)
    drag.setHotSpot(QPoint(-15, -15))
    drag.setPixmap(cover)
    return drag
Beispiel #26
0
 def recount(self, *args):
     '''
     Rebuild the category tree, expand any categories that were expanded,
     reset the search states, and reselect the current node.
     '''
     if self.disable_recounting or not self.pane_is_visible:
         return
     self.refresh_signal_processed = True
     ci = self.currentIndex()
     if not ci.isValid():
         ci = self.indexAt(QPoint(10, 10))
     path = self.model().path_for_index(ci) if self.is_visible(ci) else None
     expanded_categories, state_map = self.get_state()
     self._model.rebuild_node_tree(state_map=state_map)
     self.blockSignals(True)
     for category in expanded_categories:
         idx = self._model.index_for_category(category)
         if idx is not None and idx.isValid():
             self.expand(idx)
     self.show_item_at_path(path)
     self.blockSignals(False)
Beispiel #27
0
    def popup(self, select_first=True):
        p = self
        m = p.model()
        widget = self.completer_widget()
        if widget is None:
            return
        screen = QApplication.desktop().availableGeometry(widget)
        h = (p.sizeHintForRow(0) * min(self.max_visible_items, m.rowCount()) +
             3) + 3
        hsb = p.horizontalScrollBar()
        if hsb and hsb.isVisible():
            h += hsb.sizeHint().height()

        rh = widget.height()
        pos = widget.mapToGlobal(QPoint(0, widget.height() - 2))
        w = min(widget.width(), screen.width())

        if (pos.x() + w) > (screen.x() + screen.width()):
            pos.setX(screen.x() + screen.width() - w)
        if pos.x() < screen.x():
            pos.setX(screen.x())

        top = pos.y() - rh - screen.top() + 2
        bottom = screen.bottom() - pos.y()
        h = max(h, p.minimumHeight())
        if h > bottom:
            h = min(max(top, bottom), h)

            if top > bottom:
                pos.setY(pos.y() - h - rh + 2)

        p.setGeometry(pos.x(), pos.y(), w, h)

        if (tweaks['preselect_first_completion'] and select_first
                and not self.currentIndex().isValid()
                and self.model().rowCount() > 0):
            self.setCurrentIndex(self.model().index(0))

        if not p.isVisible():
            p.show()
Beispiel #28
0
    def mouseMoveEvent(self, event):
        if self.drag is not None:
            QTreeView.mouseMoveEvent(self, event)
            return
        if ((event.globalPos() - self.mouse_press_qpoint).manhattanLength() <
                QApplication.startDragDistance()):
            return
        #
        # starting a drag
        # [logic bug, after bruce change 070507: should not do this
        #  if we already started dragging out a selection. How can we tell?
        #  Only by whether the initial press had eventInRect, I think
        #  (not yet recorded), or at least, the initial move (#e could record here).]
        #
        index = self.indexAt(event.pos())

        sellst = self.selectedList()  # bruce 070507 move earlier

        DEBUG2 = True

        if index.isValid():
            thisnode = index.internalPointer().node

            #bruce 070507 bring in some code from modelTreeGui.py
            alreadySelected = (thisnode in sellst)

            item = index.internalPointer()
            rect = self.visualRect(index)
            if DEBUG2:
                print "visualRect coords", rect.left(), rect.right(), rect.top(
                ), rect.bottom()
            qfm = QFontMetrics(QLineEdit(self).font())
            rect.setWidth(qfm.width(item.node.name) + _ICONSIZE[0] + 4)
            if DEBUG2:
                print "visualRect coords, modified:", rect.left(), rect.right(
                ), rect.top(), rect.bottom()
                # looks like icon and text, a bit taller than text (guesses)
            eventInRect = rect.contains(event.pos())
            if DEBUG2:
                print "valid index: eventInRect = %r, item = %r, index = %r, alreadySelected = %r" % \
                      (eventInRect, item, index, alreadySelected)#######
        else:
            thisnode = item = None
            alreadySelected = eventInRect = False

        if not eventInRect:
            # nothing to drag, but [bruce 070507] let super handle it (for dragging over nodes to select)
            self.drag_is_not_DND = True  ### not yet used
            QTreeView.mouseMoveEvent(self, event)
            return

        if thisnode in sellst:
            # if dragging something selected, drag along all other selected ones
            dragged_nodes = sellst
        else:
            # if dragging something unselected, ignore any selected ones
            dragged_nodes = [thisnode]
        qdrag = QDrag(self)
        drag_type = 'move'  # how do I decide between 'move' and 'copy'?
        self.drag = (dragged_nodes, drag_type, qdrag)
        mimedata = QMimeData()
        mimedata.setText("need a string here for a valid mimetype")
        qdrag.setMimeData(mimedata)
        display_prefs = {}
        pixmap = dragged_nodes[0].node_icon(display_prefs)
        qdrag.setPixmap(pixmap)
        qdrag.setHotSpot(QPoint(-8, 8))
        qdrag.start()
Beispiel #29
0
def text(p, xmax, ymax):
    f = p.font()
    f.setPixelSize(24)
    f.setFamily('Candara')
    p.setFont(f)
    p.drawText(QPoint(0, 100), 'Test intra glyph spacing ffagain imceo')
Beispiel #30
0
 def scroll_to(self, x=0, y=0):
     self.mainFrame().setScrollPosition(QPoint(x, y))