compress image, remove unneeded code, add more docstrings

This commit is contained in:
Kilian Valkhof 2010-03-31 17:44:29 +02:00
parent a3a31a7e93
commit c9126ae196
2 changed files with 7 additions and 27 deletions

View file

@ -281,6 +281,7 @@ class TriTableModel(QAbstractTableModel):
class Image:
def __init__(self, fullpath):
""" gather image information. """
self.valid = False
self.fullpath = fullpath
if path.isfile(self.fullpath):
@ -293,6 +294,7 @@ class Image:
self.valid = True
def _determinetype(self):
""" Determine the filetype of the file using imghdr. """
filetype=determinetype(self.fullpath)
if filetype in ["jpeg", "png"]:
self.filetype=filetype
@ -301,6 +303,7 @@ class Image:
return self.filetype
def compress(self):
""" Compress the image and return it to the thread. """
if not self.valid:
raise "Tried to compress invalid image (unsupported format or not file)"
runString = {
@ -361,29 +364,6 @@ class Worker(QThread):
else:
print >>sys.stderr, u"[error] %s could not be compressed" % image.fullpath
class TrimageTableView(QTableView):
"""Init the table drop event."""
def __init__(self, parent=None):
super(TrimageTableView, self).__init__(parent)
self.setAcceptDrops(True)
def dragEnterEvent(self, event):
if event.mimeData().hasFormat("text/uri-list"):
event.accept()
else:
event.ignore()
def dragMoveEvent(self, event):
event.accept()
def dropEvent(self, event):
files = str(event.mimeData().data("text/uri-list")).strip().split()
for i, file in enumerate(files):
files[i] = QUrl(QString(file)).toLocalFile()
files=[i.toUtf8().decode("utf-8") for i in files]
self.emit(SIGNAL("fileDropEvent"), (files))
if __name__ == "__main__":
app = QApplication(sys.argv)
myapp = StartQT4()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After