def startDrag(self, dropAction):
        """
        Start drag

        @param dropAction:
        @type dropAction:
        """
        if self.datasetView:
            return

        # check indexes
        indexes = self.selectedIndexes()
        if not indexes:
            return
        for index in indexes:
            if not index.isValid():
                return

        rowVal = self.model.getValueRow(indexes[0])
        if len(rowVal) > 1:
            meta = QByteArray()
            meta.append("description('%s')" % rowVal['key'])

            # create mime data object
            mime = QMimeData()
            m = 'application/x-%s-description-item' % Settings.instance(
            ).readValue(key='Common/acronym').lower()
            mime.setData(m, meta)
            # start drag
            drag = QDrag(self)
            drag.setMimeData(mime)

            drag.exec_(Qt.CopyAction)
示例#2
0
文件: explorer.py 项目: koll00/Gui_SM
 def startDrag(self, dropActions):
     """Reimplement Qt Method - handle drag event"""
     data = QMimeData()
     data.setUrls([QUrl(fname) for fname in self.get_selected_filenames()])
     drag = QDrag(self)
     drag.setMimeData(data)
     drag.exec_()
示例#3
0
    def startDrag(self, dropAction):
        """
        Start drag

        @param dropAction:
        @type dropAction:
        """
        indexes = self.selectedIndexes()
        if not indexes:
            return
        for index in indexes:
            if not index.isValid():
                return
        rowVal = self.model.getValueRow(indexes[0])
        if len(rowVal) > 1:
            meta = QByteArray()
            if self.datasetView:
                meta.append("__%s__" % rowVal['name'])
            else:
                meta.append("agent('%s')" % rowVal['name'])

            # create mime data object
            mime = QMimeData()
            mime.setData('application/x-%s-agent-item' % self.__acronym, meta)

            # start drag
            drag = QDrag(self)
            drag.setMimeData(mime)

            drag.exec_(Qt.CopyAction)
示例#4
0
    def startDrag(self, dropAction):
        """
        Start drag

        @param dropAction:
        @type dropAction:
        """
        indexes = self.selectedIndexes()
        if not indexes:
            return
        for index in indexes:
            if not index.isValid():
                return
        rowVal = self.model.getValueRow( indexes[0] )
        if len(rowVal) > 1 :
            if self.datasetView:
                meta = "__%s__" % rowVal['name']
            else:
                meta = "agent('%s')" % rowVal['name']
            # create mime data object
            mime = QMimeData()
            mime.setData('application/x-%s-agent-item' % Settings.instance().readValue( key='Common/acronym' ).lower() , meta )
            # start drag )
            drag = QDrag(self)
            drag.setMimeData(mime) 
            
            drag.exec_(Qt.CopyAction)
示例#5
0
    def mousePressEvent(self, event):
        # handle an internal move

        # start a drag event
        if event.button() == Qt.LeftButton and self.dragDropRect().contains(
                event.pos()):
            # create the pixmap
            pixmap = QPixmap.grabWidget(self, self.rect())

            # create the mimedata
            mimeData = QMimeData()
            mimeData.setText('ItemTitle::%s' % (self.title()))

            # create the drag
            drag = QDrag(self)
            drag.setMimeData(mimeData)
            drag.setPixmap(pixmap)
            drag.setHotSpot(event.pos())

            if not drag.exec_():
                self._accordianWidget.emitItemDragFailed(self)

            event.accept()

        # determine if the expand/collapse should occur
        elif event.button() == Qt.LeftButton and self.expandCollapseRect(
        ).contains(event.pos()):
            self._clicked = True
            event.accept()

        else:
            event.ignore()
示例#6
0
 def eventFilter( self, object, event ):
     if event.type() == event.MouseButtonPress:
         if self.isLocked():
             return False
             
         if event.button() == Qt.MidButton or \
            (event.button() == Qt.LeftButton and \
             event.modifiers() == Qt.ShiftModifier):
             index = self.tabBar().tabAt(event.pos())
             view  = self.widget(index)
             pixmap = QPixmap.grabWidget(view)
             drag = QDrag(self)
             data = QMimeData()
             data.setText('move view:{}'.format(index))
             drag.setMimeData(data)
             drag.setPixmap(pixmap)
             drag.exec_()
             
             return True
         return False
         
     elif event.type() == event.DragEnter:
         if ( str(event.mimeData().text()).startswith('move view:') and
              event.source() != self ):
             event.acceptProposedAction()
         return True
     
     elif event.type() == event.Drop:
         text = str(event.mimeData().text())
         splt = text.split(':')
         self.snagViewFromPanel(event.source(), int(splt[1]))
         return True
     
     return False
示例#7
0
    def __onDragStarted(self, index):
        desc = index.data(QtWidgetRegistry.WIDGET_DESC_ROLE)
        icon = index.data(Qt.DecorationRole)

        drag_data = QMimeData()
        drag_data.setData(
            "application/vnv.orange-canvas.registry.qualified-name",
            desc.qualified_name.encode('utf-8'))
        drag = QDrag(self)
        drag.setPixmap(icon.pixmap(38))
        drag.setMimeData(drag_data)

        # TODO: Should animate (accept) hide.
        self.hide()

        # When a drag is started and the menu hidden the item's tool tip
        # can still show for a short time UNDER the cursor preventing a
        # drop.
        viewport = self.__menu.view().viewport()
        filter = ToolTipEventFilter()
        viewport.installEventFilter(filter)

        drag.exec_(Qt.CopyAction)

        viewport.removeEventFilter(filter)
示例#8
0
 def startDrag(self, dropActions):
     """Reimplement Qt Method - handle drag event"""
     mimeData = QMimeData()
     mimeData.setText(self.get_filename())
     drag = QDrag(self)
     drag.setMimeData(mimeData)
     drag.exec_()
示例#9
0
 def startDrag(self, supportedActions):
     drag = QDrag(self)
     mimeData = self.model().mimeData(self.selectedIndexes())
     # mimeData.setText(str(t))
     drag.setMimeData(mimeData)
     if drag.start(Qt.MoveAction) == Qt.MoveAction:
         for item in self.selectedItems():
             self.takeItem(self.row(item))
示例#10
0
    def mouseMoveEvent(self, event):
        if '_selected' in self.__dict__:
            mimeData = QMimeData()
            byteArray = QByteArray(self._label.text())
            mimeData.setData(CoordinateButton.MIME_TYPE, byteArray)

            drag = QDrag(self)
            drag.setMimeData(mimeData)
            drag.start(Qt.CopyAction)
示例#11
0
def dragFile(widget, filename, icon=None, dropactions=Qt.CopyAction):
    """Starts dragging the given local file from the widget."""
    if icon is None or icon.isNull():
        icon = QFileIconProvider().icon(QFileInfo(filename))
    drag = QDrag(widget)
    data = QMimeData()
    data.setUrls([QUrl.fromLocalFile(filename)])
    drag.setMimeData(data)
    drag.setPixmap(icon.pixmap(32))
    drag.exec_(dropactions)
示例#12
0
 def mouseMoveEvent(self, event):
     if event.buttons() != Qt.RightButton:
         return
     mimeData = QMimeData()
     drag = QDrag(self)
     drag.setMimeData(mimeData)
     drag.setHotSpot(event.pos() - self.rect().topLeft())
     dropAction = drag.start(Qt.MoveAction)
     if dropAction == Qt.MoveAction:
         self.close()
示例#13
0
    def startDrag(self, data):
        """
        Starts dragging information from this chart widget based on the
        dragData associated with this item.
        """
        if not data:
            return

        widget = self.scene().chartWidget()
        drag = QDrag(widget)
        drag.setMimeData(data)
        drag.exec_()
示例#14
0
    def mousePressEvent(self, e):
        """
		Start a drag operation

		Arguments:
		e -- a QMouseEvent
		"""

        if e.button() == Qt.RightButton:
            item = self.itemAt(e.pos())
            if item == None:
                return
            note = item.zoteroItem.get_note()
            if note != None:
                self.qnotero.previewNote(note)
            return

        QListWidget.mousePressEvent(self, e)
        qnoteroItem = self.currentItem()
        if qnoteroItem == None:
            return
        if not hasattr(qnoteroItem, "zoteroItem"):
            return
        zoteroItem = qnoteroItem.zoteroItem
        if zoteroItem.fulltext == None:
            return

        path = zoteroItem.fulltext.encode("latin-1")
        tmpName = '%s.pdf' % zoteroItem.filename_format()
        tmpFile = os.path.join(tempfile.gettempdir(), tmpName)
        suffix = 1
        while os.path.exists(tmpFile):
            tmpName = '%s-%d.pdf' % (zoteroItem.filename_format(), suffix)
            tmpFile = os.path.join(tempfile.gettempdir(), tmpName)
            suffix += 1
        try:
            shutil.copy(path, tmpFile)
        except:
            print(
                "qnoteroResults.mousePressEvent(): failed to copy file, sorry..."
            )
            return

        print("qnoteroResults.mousePressEvent(): prepare to copy %s" % path)
        print("qnoteroResults.mousePressEvent(): prepare to copy (tmp) %s" \
         % tmpFile)
        mimeData = QMimeData()
        mimeData.setUrls([QUrl.fromLocalFile(tmpFile)])
        mimeData.setData("text/plain", tmpFile)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.exec_(Qt.CopyAction)
 def mouseMoveEvent(self,event):
     #if the left mouse button is used
     if event.buttons() == Qt.LeftButton:
         data = QByteArray()
         mime_data = QMimeData()
         mime_data.setData(self.mimetext,data)
         drag = QDrag(self)
         drag.setMimeData(mime_data)
         drag.setHotSpot(self.rect().topLeft()) #where do we drag from
         if QT_VERSION_STR < '5':
             drop_action = drag.start(Qt.MoveAction) #drag starts
         else:
             drop_action = drag.exec(Qt.MoveAction) #drag starts
示例#16
0
 def drag(self, tile=None, meld=None):
     """returns a drag object"""
     drag = QDrag(self)
     mimeData = MimeData(tile, meld)
     drag.setMimeData(mimeData)
     tile = tile or meld[0]
     graphics = tile.graphics
     tRect = graphics.boundingRect()
     tRect = self.viewportTransform().mapRect(tRect)
     pmapSize = QSize(tRect.width() * graphics.scale(), tRect.height() * graphics.scale())
     pMap = graphics.pixmapFromSvg(pmapSize)
     drag.setPixmap(pMap)
     drag.setHotSpot(QPoint(pMap.width()/2, pMap.height()/2))
     return drag
示例#17
0
 def __startDrag(self, button):
     """
     Start a drag from button
     """
     action = button.defaultAction()
     desc = action.data()  # Widget Description
     icon = action.icon()
     drag_data = QMimeData()
     drag_data.setData(
         "application/vnv.orange-canvas.registry.qualified-name",
         desc.qualified_name.encode("utf-8"))
     drag = QDrag(button)
     drag.setPixmap(icon.pixmap(self.iconSize()))
     drag.setMimeData(drag_data)
     drag.exec_(Qt.CopyAction)
示例#18
0
 def mouseMoveEvent(self, event):
     # Chequear que se esté presionando el botón derecho
     if not (event.buttons() and Qt.LeftButton):
         return
     # Verificar que sea una posición válida
     if ((event.pos() - self.drag_start_position).manhattanLength()
             < QApplication.startDragDistance()):
         return
     drag = QDrag(self)
     mime_data = QMimeData()
     # Establecer el contenido del widget como dato
     drag.setMimeData(mime_data)
     mime_data.setText(self.label2.text())
     # Ejecutar la acción
     self.drop_action = drag.exec_(Qt.CopyAction | Qt.MoveAction)
示例#19
0
    def startDrag(self, dragData):
        """
        Starts a new drag with the inputed data.
        
        :param      dragData | <dict>
        """
        # create the mime data
        mimeData = QMimeData()
        for key, value in dragData.items():
            mimeData.setData('application/x-%s' % key, wrapVariant(value))

        # create the drag instance
        drag = QDrag(self.scene().chart())
        drag.setMimeData(mimeData)
        drag.exec_()
示例#20
0
    def mouseMoveEvent(self, event):
        if not (event.buttons() and Qt.LeftButton):
            return

        if ((event.pos() - self.drag_start_position).manhattanLength() <
                QApplication.startDragDistance()):
            return
        drag = QDrag(self)
        pix = QPixmap.grabWidget(self)
        drag.setPixmap(pix)
        mime_data = QMimeData()
        mime_data.setText(self.map.text())
        # mime_data.setImageData(self.currentmap)
        drag.setMimeData(mime_data)

        self.drop_action = drag.exec_(Qt.CopyAction | Qt.MoveAction)
示例#21
0
 def startDrag(self, mainwin, ev):
     d = mainwin.currentDocument()
     if not d:
         return
     url = d.url()
     if url.isEmpty():
         return
     drag = QDrag(mainwin)
     data = QMimeData()
     data.setUrls([url])
     drag.setMimeData(data)
     pixmap = mainwin.style().standardPixmap(QStyle.SP_FileIcon, 0, mainwin)
     hotspot = QPoint(pixmap.width() - 5, 5)
     drag.setPixmap(pixmap)
     drag.setHotSpot(hotspot)
     drag.start(Qt.LinkAction | Qt.CopyAction)
示例#22
0
 def mouseMoveEvent(self, event):
     """Override Qt method"""
     if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
        (event.pos() - self.__drag_start_pos).manhattanLength() > \
             QApplication.startDragDistance():
         drag = QDrag(self)
         mimeData = QMimeData()
         mimeData.setData("parent-id", QByteArray.number(id(self.ancestor)))
         mimeData.setData("tabwidget-id",
                          QByteArray.number(id(self.parentWidget())))
         mimeData.setData("tabbar-id", QByteArray.number(id(self)))
         mimeData.setData(
             "source-index",
             QByteArray.number(self.tabAt(self.__drag_start_pos)))
         drag.setMimeData(mimeData)
         drag.exec_()
     QTabBar.mouseMoveEvent(self, event)
示例#23
0
 def startDrag(self):
     image = self.image()
     data = QMimeData()
     data.setImageData(image)
     drag = QDrag(self)
     drag.setMimeData(data)
     if max(image.width(), image.height()) > 256:
         image = image.scaled(QSize(256, 256), Qt.KeepAspectRatio,
                              Qt.SmoothTransformation)
     p = QPainter()
     p.begin(image)
     p.setCompositionMode(QPainter.CompositionMode_DestinationIn)
     p.fillRect(image.rect(), QColor(0, 0, 0, 160))
     p.end()
     pixmap = QPixmap.fromImage(image)
     drag.setPixmap(pixmap)
     drag.setHotSpot(pixmap.rect().center())
     drag.exec_(Qt.CopyAction)
    def start_drag(self, info_id):
        # pixmap = QPixmap()
        # painter = QPainter( pixmap )
        # painter.setFont( QFont("Arial") );
        # painter.drawText( QPoint(100, 100), info_id );
        mimeData = QMimeData()
        mimeData.data =("/" + info_id.partition("/")[2].partition("/")[0], moose.element(info_id))
        mimeData.setText(info_id)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        pixmap = QPixmap("")

        drag.setPixmap(pixmap)
        # drag.setHotSpot(e.pos() - self.rect().topLeft())
        dropAction = drag.start(QtCore.Qt.MoveAction)
        print(" => ", dropAction)
        self.select_info.set_event_type(0)
        self._timer.start(0)
        return
示例#25
0
文件: tabs.py 项目: koll00/Gui_SM
 def mouseMoveEvent(self, event):
     """Override Qt method"""
     if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
        (event.pos() - self.__drag_start_pos).manhattanLength() > \
             QApplication.startDragDistance():
         drag = QDrag(self)
         mimeData = QMimeData()
         # Converting id's to long to avoid an OverflowError with PySide
         ancestor_id = long(id(self.ancestor))
         parent_widget_id = long(id(self.parentWidget()))
         self_id = long(id(self))
         mimeData.setData("parent-id", QByteArray.number(ancestor_id))
         mimeData.setData("tabwidget-id",
                          QByteArray.number(parent_widget_id))
         mimeData.setData("tabbar-id", QByteArray.number(self_id))
         mimeData.setData("source-index", 
                      QByteArray.number(self.tabAt(self.__drag_start_pos)))
         drag.setMimeData(mimeData)
         drag.exec_()
     QTabBar.mouseMoveEvent(self, event)
    def startDrag(self, dropAction):
        """
        Start drag
        """
        if self.itemCurrent.type() == QTreeWidgetItem.UserType+0: # file
            pathFile = self.itemCurrent.getPath(withFileName = False)
            if len(pathFile) > 1 :
                meta = {}
                meta['repotype'] = UCI.REPO_TESTS_LOCAL
                meta['pathfile'] = pathFile
                meta['filename'] = self.itemCurrent.fileName
                meta['ext'] = self.itemCurrent.fileExtension

                # create mime data object
                mime = QMimeData()
                mime.setData('application/x-%s-repo-openfile' % Settings.instance().readValue( key = 'Common/acronym' ).lower() , pickle.dumps(meta) )
                # start drag 
                drag = QDrag(self)
                drag.setMimeData(mime)    
                
                drag.exec_(Qt.CopyAction)
 def startDrag(self, supportedActions):
     """ Overwritten function of QTreeWidget.
     
     This function creates a QDrag object representing the selected element of this TreeWidget.
     """
     logging.debug(self.__class__.__name__ + ": startDrag()")
     indexes = self.selectedIndexes()
     if len(indexes) > 0:
         data = self.model().mimeData(indexes)
         if not data:
             return
         drag = QDrag(self)
         drag.setMimeData(data)
         if self.model().data(indexes[0],
                              Qt.DecorationRole).type() == QVariant.Icon:
             icon = QIcon(self.model().data(indexes[0], Qt.DecorationRole))
             drag.setPixmap(icon.pixmap(QSize(50, 50)))
             drag.setHotSpot(
                 QPoint(drag.pixmap().width() / 2,
                        drag.pixmap().height() /
                        2))  # center icon in respect to cursor
         defaultDropAction = Qt.IgnoreAction
         drag.exec_(supportedActions, defaultDropAction)