当前位置: 首页>>代码示例>>Python>>正文


Python Qt.QMimeData类代码示例

本文整理汇总了Python中PyQt5.Qt.QMimeData的典型用法代码示例。如果您正苦于以下问题:Python QMimeData类的具体用法?Python QMimeData怎么用?Python QMimeData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QMimeData类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createMimeDataFromSelection

    def createMimeDataFromSelection(self):
        result = QMimeData()
        cursor = self.textCursor()
        selection = cursor.selectedText()
        selection = selection.replace('\u2029', '\n')
        selection = selection.replace('\u2028', '\n')
        result.setText(selection)

        # create an xml representation of the selected document structure 
        traversal = TextDocumentSelectionTraversal()
        frame = traversal.traverse(self.textCursor(), self.document())

        print('\n-----------------------------------------------')
        printer = StructurePrinter(frame, self.outPut)
        printer.traverse()
        print('-----------------------------------------------')

        return

        sp = AppXmlPrinter(frame, None)
        sp.traverse()

        blafasel = '''<?xml version="1.0" encoding="utf-8"?>
<article version="5.0" xml:lang="en"
         xmlns="http://docbook.org/ns/docbook"
         xmlns:xlink="http://www.w3.org/1999/xlink">
  <title></title></article>'''
        result.setData("application/xml", blafasel)
        return result
开发者ID:afester,项目名称:CodeSamples,代码行数:29,代码来源:StylableTextEdit.py

示例2: 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:Coi-l,项目名称:calibre,代码行数:7,代码来源:widgets.py

示例3: copy_all

def copy_all(web_view):
    web_view = getattr(web_view, 'details', web_view)
    mf = web_view.page().mainFrame()
    c = QApplication.clipboard()
    md = QMimeData()
    md.setText(mf.toPlainText())
    md.setHtml(mf.toHtml())
    c.setMimeData(md)
开发者ID:bwhitenb5e,项目名称:calibre,代码行数:8,代码来源:book_details.py

示例4: 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:Coi-l,项目名称:calibre,代码行数:8,代码来源:widgets.py

示例5: 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", b"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:mihailim,项目名称:calibre,代码行数:13,代码来源:views.py

示例6: copy_metadata

 def copy_metadata(self):
     rows = self.gui.library_view.selectionModel().selectedRows()
     if not rows or len(rows) == 0:
         return error_dialog(self.gui, _('Cannot copy metadata'),
                             _('No books selected'), show=True)
     if len(rows) > 1:
         return error_dialog(self.gui, _('Cannot copy metadata'),
                             _('Multiple books selected, can only copy from one book at a time.'), show=True)
     db = self.gui.current_db
     book_id = db.id(rows[0].row())
     mi = db.new_api.get_metadata(book_id)
     md = QMimeData()
     md.setText(unicode(mi))
     md.setData('application/calibre-book-metadata', bytearray(metadata_to_opf(mi, default_lang='und')))
     img = db.new_api.cover(book_id, as_image=True)
     if img:
         md.setImageData(img)
     c = QApplication.clipboard()
     c.setMimeData(md)
开发者ID:artbycrunk,项目名称:calibre,代码行数:19,代码来源:edit_metadata.py

示例7: 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.encode('utf-8'))
    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:JimmXinu,项目名称:calibre,代码行数:42,代码来源:alternate_views.py

示例8: mousePressEvent

	def mousePressEvent(self, event):
		self.parentWidget().mousePressEvent(event)
		if not self.parentWidget().isDraging():
			super(WebView, self).mousePressEvent(event)
			if event.buttons() == Qt.LeftButton:
				mimeData = QMimeData()
				hitTestResult = self.mainFrame.hitTestContent(event.pos())
				# print(hitTestResult.linkUrl())
				# dragging the scrollbar
				if hitTestResult.isNull():
					self.draging = True
				if hitTestResult.isContentSelected():
					mimeData.setText(self.selectedText())
					mimeData.setHtml(self.selectedHtml())
				elif not hitTestResult.linkUrl().isEmpty():
					mimeData.setUrls([hitTestResult.linkUrl()])
					mimeData.setHtml(hitTestResult.element().toOuterXml())
				elif not hitTestResult.pixmap().isNull():
					mimeData.setImageData(hitTestResult.pixmap())
					mimeData.setUrls([hitTestResult.imageUrl()])
					mimeData.setHtml(hitTestResult.element().toOuterXml())
					# mimeData.setData('application/x-qt-windows-mime;value="FileContents"', QVariant(hitTestResult.pixmap()).toByteArray())
				# elif not hitTestResult.mediaUrl().isEmpty():
				# 	mimeData.setUrls([hitTestResult.mediaUrl()])
				# 	mimeData.setHtml(hitTestResult.element().toOuterXml())
				else:
					return
				# pixmap = hitTestResult.pixmap()
				# pixmap.setMask(QBitmap.fromImage(pixmap.toImage()))
				self.drag.setMimeData(mimeData)
开发者ID:andriodartisan,项目名称:hae,代码行数:30,代码来源:webview.py

示例9: 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:artbycrunk,项目名称:calibre,代码行数:5,代码来源:char_select.py


注:本文中的PyQt5.Qt.QMimeData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。