146 ) |
146 ) |
147 ) |
147 ) |
148 |
148 |
149 self.__project = project |
149 self.__project = project |
150 |
150 |
151 # populate the file type list |
151 self.populateFileCategories() |
|
152 |
|
153 # ensure the file type tab is the current one |
|
154 self.fileOptionsWidget.setCurrentWidget(self.fileTypeTab) |
|
155 |
|
156 self.__project.projectOpened.connect(self.__projectOpened) |
|
157 self.__project.projectClosed.connect(self.__projectClosed) |
|
158 |
|
159 self.__standardListFont = self.findList.font() |
|
160 self.findList.headerItem().setText(self.findList.columnCount(), "") |
|
161 self.findList.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder) |
|
162 self.__section0Size = self.findList.header().sectionSize(0) |
|
163 self.findList.setExpandsOnDoubleClick(False) |
|
164 |
|
165 self.__cancelSearch = False |
|
166 self.__lastFileItem = None |
|
167 self.__populating = False |
|
168 |
|
169 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
|
170 self.customContextMenuRequested.connect(self.__contextMenuRequested) |
|
171 |
|
172 self.__replaceMode = True |
|
173 self.__toggleReplaceMode() |
|
174 |
|
175 def populateFileCategories(self): |
|
176 """ |
|
177 Public method to populate the search file categories list. |
|
178 """ |
|
179 # step 1: remember checked entries categories |
|
180 checkedCategories = [] |
|
181 for row in range(self.fileTypeList.count()): |
|
182 itm = self.fileTypeList.item(row) |
|
183 if itm.checkState() == Qt.CheckState.Checked: |
|
184 checkedCategories.append(itm.data(Qt.ItemDataRole.UserRole)) |
|
185 |
|
186 # step 2: clear the list |
|
187 self.fileTypeList.clear() |
|
188 |
|
189 # step 3: populate the file type list |
152 for fileCategory in [ |
190 for fileCategory in [ |
153 c |
191 c |
154 for c in self.__project.getFileCategories() |
192 for c in self.__project.getFileCategories() |
155 if c not in ("TRANSLATIONS", "OTHERS") |
193 if c not in ("TRANSLATIONS", "OTHERS") |
156 ]: |
194 ]: |
157 itm = QListWidgetItem( |
195 itm = QListWidgetItem( |
158 self.__project.getFileCategoryType(fileCategory), self.fileTypeList |
196 self.__project.getFileCategoryType(fileCategory), self.fileTypeList |
159 ) |
197 ) |
160 itm.setData(Qt.ItemDataRole.UserRole, fileCategory) |
198 itm.setData(Qt.ItemDataRole.UserRole, fileCategory) |
161 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable) |
199 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable) |
162 itm.setCheckState( |
200 if bool(checkedCategories): |
163 Qt.CheckState.Checked |
201 itm.setCheckState( |
164 if fileCategory == "SOURCES" |
202 Qt.CheckState.Checked |
165 else Qt.CheckState.Unchecked |
203 if fileCategory in checkedCategories |
166 ) |
204 else Qt.CheckState.Unchecked |
167 |
205 ) |
168 # ensure the file type tab is the current one |
206 else: |
169 self.fileOptionsWidget.setCurrentWidget(self.fileTypeTab) |
207 # first time population |
170 |
208 itm.setCheckState( |
171 self.__project.projectOpened.connect(self.__projectOpened) |
209 Qt.CheckState.Checked |
172 self.__project.projectClosed.connect(self.__projectClosed) |
210 if fileCategory == "SOURCES" |
173 |
211 else Qt.CheckState.Unchecked |
174 self.__standardListFont = self.findList.font() |
212 ) |
175 self.findList.headerItem().setText(self.findList.columnCount(), "") |
|
176 self.findList.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder) |
|
177 self.__section0Size = self.findList.header().sectionSize(0) |
|
178 self.findList.setExpandsOnDoubleClick(False) |
|
179 |
|
180 self.__cancelSearch = False |
|
181 self.__lastFileItem = None |
|
182 self.__populating = False |
|
183 |
|
184 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
|
185 self.customContextMenuRequested.connect(self.__contextMenuRequested) |
|
186 |
|
187 self.__replaceMode = True |
|
188 self.__toggleReplaceMode() |
|
189 |
213 |
190 def __createItem(self, file, line, text, start, end, replTxt="", md5=""): |
214 def __createItem(self, file, line, text, start, end, replTxt="", md5=""): |
191 """ |
215 """ |
192 Private method to create an entry in the file list. |
216 Private method to create an entry in the file list. |
193 |
217 |
976 self.__findWidget.umlFile.connect(self.umlFile) |
1002 self.__findWidget.umlFile.connect(self.umlFile) |
977 |
1003 |
978 self.__buttonBox.accepted.connect(self.accept) |
1004 self.__buttonBox.accepted.connect(self.accept) |
979 self.__buttonBox.rejected.connect(self.reject) |
1005 self.__buttonBox.rejected.connect(self.reject) |
980 |
1006 |
|
1007 def populateFileCategories(self): |
|
1008 """ |
|
1009 Public method to populate the search file categories list. |
|
1010 """ |
|
1011 self.__findWidget.populateFileCategories() |
|
1012 |
981 def activate(self, replaceMode=False, txt="", searchDir="", openFiles=False): |
1013 def activate(self, replaceMode=False, txt="", searchDir="", openFiles=False): |
982 """ |
1014 """ |
983 Public method to activate the dialog with a given mode, a text |
1015 Public method to activate the dialog with a given mode, a text |
984 to search for and some search parameters. |
1016 to search for and some search parameters. |
985 |
1017 |