當前位置: 首頁>>代碼示例>>Python>>正文


Python Qt.QMimeData類代碼示例

本文整理匯總了Python中PyQt4.Qt.QMimeData的典型用法代碼示例。如果您正苦於以下問題:Python QMimeData類的具體用法?Python QMimeData怎麽用?Python QMimeData使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QMimeData類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: selection_changed

 def selection_changed(self):
     # Workaround Qt replacing nbsp with normal spaces on copy
     clipboard = QApplication.clipboard()
     if clipboard.supportsSelection() and self.textCursor().hasSelection():
         md = QMimeData()
         md.setText(self.selected_text)
         clipboard.setMimeData(md, clipboard.Selection)
開發者ID:BatteringRam,項目名稱:calibre,代碼行數:7,代碼來源:text.py

示例2: copy

 def copy(self):
     # Workaround Qt replacing nbsp with normal spaces on copy
     c = self.textCursor()
     if not c.hasSelection():
         return
     md = QMimeData()
     md.setText(self.selected_text)
     QApplication.clipboard().setMimeData(md)
開發者ID:BatteringRam,項目名稱:calibre,代碼行數:8,代碼來源:text.py

示例3: mimeData

 def mimeData(self, itemlist):
     mimedata = QMimeData()
     urls = []
     for item in itemlist:
         dp = getattr(item, "_dp", None)
         dp and urls.append(QUrl.fromLocalFile(dp.fullpath or dp.sourcepath))
     mimedata.setUrls(urls)
     return mimedata
開發者ID:kernsuite-debian,項目名稱:purr,代碼行數:8,代碼來源:MainWindow.py

示例4: drag_data

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
開發者ID:shamray,項目名稱:calibre,代碼行數:42,代碼來源:alternate_views.py

示例5: mimeData

 def mimeData(self, indices):
     mimeData = QMimeData()
     encodedData = QByteArray()
     stream = QDataStream(encodedData, QIODevice.WriteOnly)
     for index in indices:
         if index.column() == 1:
             d = QVariant(self.data(index, Qt.DecorationRole))
         else:
             d = QVariant(self.data(index, Qt.DisplayRole).toString())
         stream << d
     mimeData.setData('application/target.tableitem.creepy', encodedData)
     return mimeData
開發者ID:andy737,項目名稱:creepy,代碼行數:12,代碼來源:ProjectWizardPossibleTargetsTable.py

示例6: drag_data

 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
開發者ID:john-peterson,項目名稱:calibre,代碼行數:13,代碼來源:views.py

示例7: mouseMoveEvent

    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()
開發者ID:alaindomissy,項目名稱:nanoengineer,代碼行數:66,代碼來源:modelTreePrototype.py

示例8: mimeData

 def mimeData(self, indexes):
     data = ','.join(str(i.row()) for i in indexes)
     md = QMimeData()
     md.setData('application/calibre_charcode_indices', data.encode('utf-8'))
     return md
開發者ID:mapopescu,項目名稱:calibre,代碼行數:5,代碼來源:char_select.py


注:本文中的PyQt4.Qt.QMimeData類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。