prefer image if text starts with http

This commit is contained in:
Damien Elmes 2008-12-10 19:03:15 +09:00
parent 22658dea73
commit 53cb4790af

View file

@ -570,14 +570,20 @@ class FactEdit(QTextEdit):
def insertFromMimeData(self, source): def insertFromMimeData(self, source):
if source.hasText(): if source.hasText():
if not (unicode(source.text()).lower().startswith("http://") and
source.hasImage()):
# choose text unless this is a link with an image
self.insertPlainText(source.text()) self.insertPlainText(source.text())
elif source.hasImage(): return
if source.hasImage():
im = QImage(source.imageData()) im = QImage(source.imageData())
(fd, name) = tempfile.mkstemp(suffix=".jpg") (fd, name) = tempfile.mkstemp(suffix=".jpg")
im.save(name, None, 95) im.save(name, None, 95)
self.parent._addPicture(name, widget=self) self.parent._addPicture(name, widget=self)
elif source.hasHtml(): return
if source.hasHtml():
self.insertHtml(self.simplifyHTML(unicode(source.html()))) self.insertHtml(self.simplifyHTML(unicode(source.html())))
return
def simplifyHTML(self, html): def simplifyHTML(self, html):
"Remove all style information and P tags." "Remove all style information and P tags."