8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 import os |
12 import os |
13 import mimetypes |
|
14 |
13 |
15 from PyQt4.QtCore import QModelIndex, pyqtSignal, QUrl, Qt, qVersion |
14 from PyQt4.QtCore import QModelIndex, pyqtSignal, QUrl, Qt, qVersion |
16 from PyQt4.QtGui import QTreeView, QDesktopServices, QItemSelectionModel, \ |
15 from PyQt4.QtGui import QTreeView, QDesktopServices, QItemSelectionModel, \ |
17 QApplication, QMenu, QAbstractItemView |
16 QApplication, QMenu, QAbstractItemView |
18 |
17 |
421 elif itm.isSvgFile(): |
421 elif itm.isSvgFile(): |
422 self.svgFile.emit(itm.fileName()) |
422 self.svgFile.emit(itm.fileName()) |
423 elif itm.isPixmapFile(): |
423 elif itm.isPixmapFile(): |
424 self.pixmapFile.emit(itm.fileName()) |
424 self.pixmapFile.emit(itm.fileName()) |
425 else: |
425 else: |
426 type_ = mimetypes.guess_type(itm.fileName())[0] |
426 if Utilities.mimetypes.isTextFile(itm.fileName()): |
427 if type_ is None or type_.split("/")[0] == "text": |
|
428 self.sourceFile[str].emit(itm.fileName()) |
427 self.sourceFile[str].emit(itm.fileName()) |
429 else: |
428 else: |
430 QDesktopServices.openUrl(QUrl(itm.fileName())) |
429 QDesktopServices.openUrl(QUrl(itm.fileName())) |
431 elif isinstance(itm, BrowserClassItem): |
430 elif isinstance(itm, BrowserClassItem): |
432 self.sourceFile[str, int].emit( |
431 self.sourceFile[str, int].emit( |