13 import re |
13 import re |
14 |
14 |
15 from PyQt6.QtCore import QFile, QIODevice, Qt, QCoreApplication |
15 from PyQt6.QtCore import QFile, QIODevice, Qt, QCoreApplication |
16 from PyQt6.QtWidgets import QTreeWidget, QDialog, QApplication, QMenu, QTreeWidgetItem |
16 from PyQt6.QtWidgets import QTreeWidget, QDialog, QApplication, QMenu, QTreeWidgetItem |
17 |
17 |
18 from EricWidgets.EricApplication import ericApp |
18 from eric7.EricWidgets.EricApplication import ericApp |
19 from EricWidgets import EricMessageBox, EricFileDialog |
19 from eric7.EricWidgets import EricMessageBox, EricFileDialog |
20 |
20 |
21 import Preferences |
21 from eric7.EricGui import EricPixmapCache |
22 |
22 from eric7 import Preferences, Utilities |
23 import UI.PixmapCache |
|
24 import Utilities |
|
25 |
23 |
26 from .TemplatesFile import TemplatesFile |
24 from .TemplatesFile import TemplatesFile |
27 |
25 |
28 |
26 |
29 class TemplateGroup(QTreeWidgetItem): |
27 class TemplateGroup(QTreeWidgetItem): |
435 |
433 |
436 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
434 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
437 self.customContextMenuRequested.connect(self.__showContextMenu) |
435 self.customContextMenuRequested.connect(self.__showContextMenu) |
438 self.itemActivated.connect(self.__templateItemActivated) |
436 self.itemActivated.connect(self.__templateItemActivated) |
439 |
437 |
440 self.setWindowIcon(UI.PixmapCache.getIcon("eric")) |
438 self.setWindowIcon(EricPixmapCache.getIcon("eric")) |
441 |
439 |
442 def __resort(self): |
440 def __resort(self): |
443 """ |
441 """ |
444 Private method to resort the tree. |
442 Private method to resort the tree. |
445 """ |
443 """ |
1004 if filename.endswith(".ecj"): |
1002 if filename.endswith(".ecj"): |
1005 self.__templatesFile.readFile(filename) |
1003 self.__templatesFile.readFile(filename) |
1006 else: |
1004 else: |
1007 f = QFile(filename) |
1005 f = QFile(filename) |
1008 if f.open(QIODevice.OpenModeFlag.ReadOnly): |
1006 if f.open(QIODevice.OpenModeFlag.ReadOnly): |
1009 from EricXML.TemplatesReader import TemplatesReader |
1007 from eric7.EricXML.TemplatesReader import TemplatesReader |
1010 |
1008 |
1011 reader = TemplatesReader(f, viewer=self) |
1009 reader = TemplatesReader(f, viewer=self) |
1012 reader.readXML() |
1010 reader.readXML() |
1013 f.close() |
1011 f.close() |
1014 else: |
1012 else: |