29 super(FiletypeAssociationDialog, self).__init__(parent) |
29 super(FiletypeAssociationDialog, self).__init__(parent) |
30 self.setupUi(self) |
30 self.setupUi(self) |
31 |
31 |
32 self.filetypeAssociationList.headerItem().setText( |
32 self.filetypeAssociationList.headerItem().setText( |
33 self.filetypeAssociationList.columnCount(), "") |
33 self.filetypeAssociationList.columnCount(), "") |
34 self.filetypeAssociationList.header().setSortIndicator(0, Qt.AscendingOrder) |
34 self.filetypeAssociationList.header().setSortIndicator( |
|
35 0, Qt.AscendingOrder) |
35 |
36 |
36 # keep these lists in sync |
37 # keep these lists in sync |
37 self.filetypes = ["SOURCES", "FORMS", "TRANSLATIONS", "RESOURCES", "INTERFACES", |
38 self.filetypes = ["SOURCES", "FORMS", "TRANSLATIONS", "RESOURCES", |
38 "OTHERS", "__IGNORE__"] |
39 "INTERFACES", "OTHERS", "__IGNORE__"] |
39 self.filetypeStrings = [self.trUtf8("Sources"), self.trUtf8("Forms"), |
40 self.filetypeStrings = [self.trUtf8("Sources"), self.trUtf8("Forms"), |
40 self.trUtf8("Translations"), self.trUtf8("Resources"), |
41 self.trUtf8("Translations"), |
41 self.trUtf8("Interfaces"), self.trUtf8("Others"), |
42 self.trUtf8("Resources"), |
|
43 self.trUtf8("Interfaces"), |
|
44 self.trUtf8("Others"), |
42 self.trUtf8("Ignore")] |
45 self.trUtf8("Ignore")] |
43 self.filetypeCombo.addItems(self.filetypeStrings) |
46 self.filetypeCombo.addItems(self.filetypeStrings) |
44 |
47 |
45 self.project = project |
48 self.project = project |
46 for pattern, filetype in list(self.project.pdata["FILETYPES"].items()): |
49 for pattern, filetype in list(self.project.pdata["FILETYPES"].items()): |
55 |
58 |
56 def __resort(self): |
59 def __resort(self): |
57 """ |
60 """ |
58 Private method to resort the tree. |
61 Private method to resort the tree. |
59 """ |
62 """ |
60 self.filetypeAssociationList.sortItems(self.filetypeAssociationList.sortColumn(), |
63 self.filetypeAssociationList.sortItems( |
|
64 self.filetypeAssociationList.sortColumn(), |
61 self.filetypeAssociationList.header().sortIndicatorOrder()) |
65 self.filetypeAssociationList.header().sortIndicatorOrder()) |
62 |
66 |
63 def __reformat(self): |
67 def __reformat(self): |
64 """ |
68 """ |
65 Private method to reformat the tree. |
69 Private method to reformat the tree. |
66 """ |
70 """ |
67 self.filetypeAssociationList.header().resizeSections(QHeaderView.ResizeToContents) |
71 self.filetypeAssociationList.header().resizeSections( |
|
72 QHeaderView.ResizeToContents) |
68 self.filetypeAssociationList.header().setStretchLastSection(True) |
73 self.filetypeAssociationList.header().setStretchLastSection(True) |
69 |
74 |
70 def __createItem(self, pattern, filetype): |
75 def __createItem(self, pattern, filetype): |
71 """ |
76 """ |
72 Private slot to create a new entry in the association list. |
77 Private slot to create a new entry in the association list. |
73 |
78 |
74 @param pattern pattern of the entry (string) |
79 @param pattern pattern of the entry (string) |
75 @param filetype file type of the entry (string) |
80 @param filetype file type of the entry (string) |
76 @return reference to the newly generated entry (QTreeWidgetItem) |
81 @return reference to the newly generated entry (QTreeWidgetItem) |
77 """ |
82 """ |
78 itm = QTreeWidgetItem(self.filetypeAssociationList, [pattern, filetype]) |
83 itm = QTreeWidgetItem( |
|
84 self.filetypeAssociationList, [pattern, filetype]) |
79 return itm |
85 return itm |
80 |
86 |
81 def on_filetypeAssociationList_currentItemChanged(self, itm, prevItm): |
87 def on_filetypeAssociationList_currentItemChanged(self, itm, prevItm): |
82 """ |
88 """ |
83 Private slot to handle the currentItemChanged signal of the association list. |
89 Private slot to handle the currentItemChanged signal of the |
|
90 association list. |
84 |
91 |
85 @param itm reference to the new current item (QTreeWidgetItem) |
92 @param itm reference to the new current item (QTreeWidgetItem) |
86 @param prevItm reference to the previous current item (QTreeWidgetItem) |
93 @param prevItm reference to the previous current item (QTreeWidgetItem) |
87 """ |
94 """ |
88 if itm is None: |
95 if itm is None: |
89 self.filePatternEdit.clear() |
96 self.filePatternEdit.clear() |
90 self.filetypeCombo.setCurrentIndex(0) |
97 self.filetypeCombo.setCurrentIndex(0) |
91 self.deleteAssociationButton.setEnabled(False) |
98 self.deleteAssociationButton.setEnabled(False) |
92 else: |
99 else: |
93 self.filePatternEdit.setText(itm.text(0)) |
100 self.filePatternEdit.setText(itm.text(0)) |
94 self.filetypeCombo.setCurrentIndex(self.filetypeCombo.findText(itm.text(1))) |
101 self.filetypeCombo.setCurrentIndex( |
|
102 self.filetypeCombo.findText(itm.text(1))) |
95 self.deleteAssociationButton.setEnabled(True) |
103 self.deleteAssociationButton.setEnabled(True) |
96 |
104 |
97 @pyqtSlot() |
105 @pyqtSlot() |
98 def on_addAssociationButton_clicked(self): |
106 def on_addAssociationButton_clicked(self): |
99 """ |
107 """ |
116 self.filetypeAssociationList.setCurrentItem(itm) |
124 self.filetypeAssociationList.setCurrentItem(itm) |
117 |
125 |
118 @pyqtSlot() |
126 @pyqtSlot() |
119 def on_deleteAssociationButton_clicked(self): |
127 def on_deleteAssociationButton_clicked(self): |
120 """ |
128 """ |
121 Private slot to delete the currently selected association of the listbox. |
129 Private slot to delete the currently selected association of the |
|
130 listbox. |
122 """ |
131 """ |
123 for itm in self.filetypeAssociationList.selectedItems(): |
132 for itm in self.filetypeAssociationList.selectedItems(): |
124 itm = self.filetypeAssociationList.takeTopLevelItem( |
133 itm = self.filetypeAssociationList.takeTopLevelItem( |
125 self.filetypeAssociationList.indexOfTopLevelItem(itm)) |
134 self.filetypeAssociationList.indexOfTopLevelItem(itm)) |
126 del itm |
135 del itm |
142 self.addAssociationButton.setEnabled(True) |
151 self.addAssociationButton.setEnabled(True) |
143 if len(self.filetypeAssociationList.selectedItems()) == 0: |
152 if len(self.filetypeAssociationList.selectedItems()) == 0: |
144 self.deleteAssociationButton.setEnabled(False) |
153 self.deleteAssociationButton.setEnabled(False) |
145 else: |
154 else: |
146 self.deleteAssociationButton.setEnabled( |
155 self.deleteAssociationButton.setEnabled( |
147 self.filetypeAssociationList.selectedItems()[0].text(0) == txt) |
156 self.filetypeAssociationList.selectedItems()[0].text(0) \ |
|
157 == txt) |
148 |
158 |
149 def transferData(self): |
159 def transferData(self): |
150 """ |
160 """ |
151 Public slot to transfer the associations into the projects data structure. |
161 Public slot to transfer the associations into the projects data |
|
162 structure. |
152 """ |
163 """ |
153 self.project.pdata["FILETYPES"] = {} |
164 self.project.pdata["FILETYPES"] = {} |
154 for index in range(self.filetypeAssociationList.topLevelItemCount()): |
165 for index in range(self.filetypeAssociationList.topLevelItemCount()): |
155 itm = self.filetypeAssociationList.topLevelItem(index) |
166 itm = self.filetypeAssociationList.topLevelItem(index) |
156 pattern = itm.text(0) |
167 pattern = itm.text(0) |