29 @param parent reference to the parent widget (QWidget) |
29 @param parent reference to the parent widget (QWidget) |
30 """ |
30 """ |
31 super(LexerAssociationDialog, self).__init__(parent) |
31 super(LexerAssociationDialog, self).__init__(parent) |
32 self.setupUi(self) |
32 self.setupUi(self) |
33 |
33 |
34 self.editorLexerList.headerItem().setText(self.editorLexerList.columnCount(), "") |
34 self.editorLexerList.headerItem().setText( |
|
35 self.editorLexerList.columnCount(), "") |
35 header = self.editorLexerList.header() |
36 header = self.editorLexerList.header() |
36 if qVersion() >= "5.0.0": |
37 if qVersion() >= "5.0.0": |
37 header.setSectionResizeMode(QHeaderView.ResizeToContents) |
38 header.setSectionResizeMode(QHeaderView.ResizeToContents) |
38 else: |
39 else: |
39 header.setResizeMode(QHeaderView.ResizeToContents) |
40 header.setResizeMode(QHeaderView.ResizeToContents) |
45 self.extsep = "." |
46 self.extsep = "." |
46 |
47 |
47 self.extras = ["-----------", self.trUtf8("Alternative")] |
48 self.extras = ["-----------", self.trUtf8("Alternative")] |
48 |
49 |
49 import QScintilla.Lexers |
50 import QScintilla.Lexers |
50 languages = \ |
51 languages = [''] + \ |
51 [''] + sorted(QScintilla.Lexers.getSupportedLanguages().keys()) + self.extras |
52 sorted(QScintilla.Lexers.getSupportedLanguages().keys()) + \ |
|
53 self.extras |
52 self.editorLexerCombo.addItems(languages) |
54 self.editorLexerCombo.addItems(languages) |
53 |
55 |
54 from pygments.lexers import get_all_lexers |
56 from pygments.lexers import get_all_lexers |
55 pygmentsLexers = [''] + sorted([l[0] for l in get_all_lexers()]) |
57 pygmentsLexers = [''] + sorted([l[0] for l in get_all_lexers()]) |
56 self.pygmentsLexerCombo.addItems(pygmentsLexers) |
58 self.pygmentsLexerCombo.addItems(pygmentsLexers) |
91 self.editorLexerList.header().sortIndicatorOrder()) |
93 self.editorLexerList.header().sortIndicatorOrder()) |
92 |
94 |
93 @pyqtSlot() |
95 @pyqtSlot() |
94 def on_deleteLexerButton_clicked(self): |
96 def on_deleteLexerButton_clicked(self): |
95 """ |
97 """ |
96 Private slot to delete the currently selected lexer association of the list. |
98 Private slot to delete the currently selected lexer association of the |
|
99 list. |
97 """ |
100 """ |
98 itmList = self.editorLexerList.selectedItems() |
101 itmList = self.editorLexerList.selectedItems() |
99 if itmList: |
102 if itmList: |
100 index = self.editorLexerList.indexOfTopLevelItem(itmList[0]) |
103 index = self.editorLexerList.indexOfTopLevelItem(itmList[0]) |
101 itm = self.editorLexerList.takeTopLevelItem(index) |
104 itm = self.editorLexerList.takeTopLevelItem(index) |
105 self.editorFileExtEdit.clear() |
108 self.editorFileExtEdit.clear() |
106 self.editorLexerCombo.setCurrentIndex(0) |
109 self.editorLexerCombo.setCurrentIndex(0) |
107 |
110 |
108 def on_editorLexerList_itemClicked(self, itm, column): |
111 def on_editorLexerList_itemClicked(self, itm, column): |
109 """ |
112 """ |
110 Private slot to handle the clicked signal of the lexer association list. |
113 Private slot to handle the clicked signal of the lexer association |
|
114 list. |
111 |
115 |
112 @param itm reference to the selecte item (QTreeWidgetItem) |
116 @param itm reference to the selecte item (QTreeWidgetItem) |
113 @param column column the item was clicked or activated (integer) (ignored) |
117 @param column column the item was clicked or activated (integer) |
|
118 (ignored) |
114 """ |
119 """ |
115 if itm is None: |
120 if itm is None: |
116 self.editorFileExtEdit.clear() |
121 self.editorFileExtEdit.clear() |
117 self.editorLexerCombo.setCurrentIndex(0) |
122 self.editorLexerCombo.setCurrentIndex(0) |
118 self.pygmentsLexerCombo.setCurrentIndex(0) |
123 self.pygmentsLexerCombo.setCurrentIndex(0) |
129 self.editorLexerCombo.setCurrentIndex(index) |
134 self.editorLexerCombo.setCurrentIndex(index) |
130 self.pygmentsLexerCombo.setCurrentIndex(pygmentsIndex) |
135 self.pygmentsLexerCombo.setCurrentIndex(pygmentsIndex) |
131 |
136 |
132 def on_editorLexerList_itemActivated(self, itm, column): |
137 def on_editorLexerList_itemActivated(self, itm, column): |
133 """ |
138 """ |
134 Private slot to handle the activated signal of the lexer association list. |
139 Private slot to handle the activated signal of the lexer association |
|
140 list. |
135 |
141 |
136 @param itm reference to the selecte item (QTreeWidgetItem) |
142 @param itm reference to the selecte item (QTreeWidgetItem) |
137 @param column column the item was clicked or activated (integer) (ignored) |
143 @param column column the item was clicked or activated (integer) |
|
144 (ignored) |
138 """ |
145 """ |
139 self.on_editorLexerList_itemClicked(itm, column) |
146 self.on_editorLexerList_itemClicked(itm, column) |
140 |
147 |
141 @pyqtSlot(str) |
148 @pyqtSlot(str) |
142 def on_editorLexerCombo_currentIndexChanged(self, text): |
149 def on_editorLexerCombo_currentIndexChanged(self, text): |
152 self.pygmentsLexerCombo.setEnabled(False) |
159 self.pygmentsLexerCombo.setEnabled(False) |
153 self.pygmentsLabel.setEnabled(False) |
160 self.pygmentsLabel.setEnabled(False) |
154 |
161 |
155 def transferData(self): |
162 def transferData(self): |
156 """ |
163 """ |
157 Public slot to transfer the associations into the projects data structure. |
164 Public slot to transfer the associations into the projects data |
|
165 structure. |
158 """ |
166 """ |
159 self.project.pdata["LEXERASSOCS"] = {} |
167 self.project.pdata["LEXERASSOCS"] = {} |
160 for index in range(self.editorLexerList.topLevelItemCount()): |
168 for index in range(self.editorLexerList.topLevelItemCount()): |
161 itm = self.editorLexerList.topLevelItem(index) |
169 itm = self.editorLexerList.topLevelItem(index) |
162 pattern = itm.text(0) |
170 pattern = itm.text(0) |