当前位置: 首页>>代码示例>>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;未经允许,请勿转载。