423 self.configListWidget = QWidget(self.configSplitter) |
423 self.configListWidget = QWidget(self.configSplitter) |
424 self.leftVBoxLayout = QVBoxLayout(self.configListWidget) |
424 self.leftVBoxLayout = QVBoxLayout(self.configListWidget) |
425 self.leftVBoxLayout.setContentsMargins(0, 0, 0, 0) |
425 self.leftVBoxLayout.setContentsMargins(0, 0, 0, 0) |
426 self.leftVBoxLayout.setSpacing(0) |
426 self.leftVBoxLayout.setSpacing(0) |
427 self.leftVBoxLayout.setObjectName("leftVBoxLayout") |
427 self.leftVBoxLayout.setObjectName("leftVBoxLayout") |
428 self.configListFilter = E5ClearableLineEdit( |
428 self.configListSearch = E5ClearableLineEdit( |
429 self, self.tr("Enter filter text...")) |
429 self, self.tr("Enter search text...")) |
430 self.configListFilter.setObjectName("configListFilter") |
430 self.configListSearch.setObjectName("configListSearch") |
431 self.leftVBoxLayout.addWidget(self.configListFilter) |
431 self.leftVBoxLayout.addWidget(self.configListSearch) |
432 self.configList = QTreeWidget() |
432 self.configList = QTreeWidget() |
433 self.configList.setObjectName("configList") |
433 self.configList.setObjectName("configList") |
434 self.leftVBoxLayout.addWidget(self.configList) |
434 self.leftVBoxLayout.addWidget(self.configList) |
435 self.configListFilter.textChanged.connect(self.__filterTextChanged) |
435 self.configListSearch.textChanged.connect(self.__searchTextChanged) |
436 |
436 |
437 self.scrollArea = QScrollArea(self.configSplitter) |
437 self.scrollArea = QScrollArea(self.configSplitter) |
438 self.scrollArea.setFrameShape(QFrame.NoFrame) |
438 self.scrollArea.setFrameShape(QFrame.NoFrame) |
439 self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) |
439 self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) |
440 self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) |
440 self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) |
501 |
501 |
502 self.configStack.setCurrentWidget(self.emptyPage) |
502 self.configStack.setCurrentWidget(self.emptyPage) |
503 |
503 |
504 self.configList.setFocus() |
504 self.configList.setFocus() |
505 |
505 |
506 def __filterTextChanged(self, filter): |
506 def __searchTextChanged(self, text): |
507 """ |
507 """ |
508 Private slot to handle a change of the filter. |
508 Private slot to handle a change of the search text. |
509 |
509 |
510 @param filter text of the filter line edit (string) |
510 @param text text to search for (string) |
511 """ |
511 """ |
512 self.__filterChildItems(self.configList.invisibleRootItem(), filter) |
512 self.__searchChildItems(self.configList.invisibleRootItem(), text) |
513 |
513 |
514 def __filterChildItems(self, parent, filter): |
514 def __searchChildItems(self, parent, text): |
515 """ |
515 """ |
516 Private method to filter child items based on a filter string. |
516 Private method to enable child items based on a search string. |
517 |
517 |
518 @param parent reference to the parent item (QTreeWidgetItem) |
518 @param parent reference to the parent item (QTreeWidgetItem) |
519 @param filter filter string (string) |
519 @param text text to search for (string) |
520 @return flag indicating a visible child item (boolean) |
520 @return flag indicating an enabled child item (boolean) |
521 """ |
521 """ |
522 childVisible = False |
522 childEnabled = False |
523 filter = filter.lower() |
523 text = text.lower() |
524 for index in range(parent.childCount()): |
524 for index in range(parent.childCount()): |
525 itm = parent.child(index) |
525 itm = parent.child(index) |
526 if itm.childCount() > 0: |
526 if itm.childCount() > 0: |
527 visible = self.__filterChildItems(itm, filter) or \ |
527 enable = self.__searchChildItems(itm, text) or \ |
528 filter == "" or filter in itm.text(0).lower() |
528 text == "" or text in itm.text(0).lower() |
529 else: |
529 else: |
530 visible = filter == "" or filter in itm.text(0).lower() |
530 enable = text == "" or text in itm.text(0).lower() |
531 if visible: |
531 if enable: |
532 childVisible = True |
532 childEnabled = True |
533 itm.setHidden(not visible) |
533 itm.setDisabled(not enable) |
534 |
534 |
535 return childVisible |
535 return childEnabled |
536 |
536 |
537 def __initLexers(self): |
537 def __initLexers(self): |
538 """ |
538 """ |
539 Private method to initialize the dictionary of preferences lexers. |
539 Private method to initialize the dictionary of preferences lexers. |
540 """ |
540 """ |