Beispiel #1
0
 def __on_textEdited(self, text):
     patt = QRegExp("(^|\W)" + text)
     patt.setCaseSensitivity(False)
     self.__suggestPage.setFilterRegExp(patt)
     self.__pages.setCurrentPage(self.__suggestPage)
     self.__selectFirstIndex()
     UsageStatistics.set_last_search_query(text)
Beispiel #2
0
 def __on_textEdited(self, text):
     patt = QRegExp("(^|\W)" + text)
     patt.setCaseSensitivity(False)
     self.__suggestPage.setFilterRegExp(patt)
     self.__pages.setCurrentPage(self.__suggestPage)
     self.__selectFirstIndex()
     UsageStatistics.set_last_search_query(text)
Beispiel #3
0
    def popup(self, pos=None, searchText=""):
        """
        Popup the menu at `pos` (in screen coordinates). 'Search' text field
        is initialized with `searchText` if provided.

        """
        if pos is None:
            pos = QPoint()

        self.__clearCurrentItems()

        self.__search.setText(searchText)
        patt = QRegExp("(^|\W)"+searchText)
        patt.setCaseSensitivity(False)
        self.__suggestPage.setFilterRegExp(patt)

        self.ensurePolished()

        if self.testAttribute(Qt.WA_Resized) and self.sizeGripEnabled():
            size = self.size()
        else:
            size = self.sizeHint()

        desktop = QApplication.desktop()
        screen_geom = desktop.availableGeometry(pos)

        # Adjust the size to fit inside the screen.
        if size.height() > screen_geom.height():
            size.setHeight(screen_geom.height())
        if size.width() > screen_geom.width():
            size.setWidth(screen_geom.width())

        geom = QRect(pos, size)

        if geom.top() < screen_geom.top():
            geom.setTop(screen_geom.top())

        if geom.left() < screen_geom.left():
            geom.setLeft(screen_geom.left())

        bottom_margin = screen_geom.bottom() - geom.bottom()
        right_margin = screen_geom.right() - geom.right()
        if bottom_margin < 0:
            # Falls over the bottom of the screen, move it up.
            geom.translate(0, bottom_margin)

        # TODO: right to left locale
        if right_margin < 0:
            # Falls over the right screen edge, move the menu to the
            # other side of pos.
            geom.translate(-size.width(), 0)

        self.setGeometry(geom)

        self.show()

        if searchText:
            self.setFocusProxy(self.__search)
        else:
            self.setFocusProxy(None)
Beispiel #4
0
    def popup(self, pos=None, searchText=""):
        """
        Popup the menu at `pos` (in screen coordinates). 'Search' text field
        is initialized with `searchText` if provided.

        """
        if pos is None:
            pos = QPoint()

        self.__clearCurrentItems()

        self.__search.setText(searchText)
        patt = QRegExp("(^|\W)" + searchText)
        patt.setCaseSensitivity(False)
        self.__suggestPage.setFilterRegExp(patt)

        self.ensurePolished()

        if self.testAttribute(Qt.WA_Resized) and self.sizeGripEnabled():
            size = self.size()
        else:
            size = self.sizeHint()

        desktop = QApplication.desktop()
        screen_geom = desktop.availableGeometry(pos)

        # Adjust the size to fit inside the screen.
        if size.height() > screen_geom.height():
            size.setHeight(screen_geom.height())
        if size.width() > screen_geom.width():
            size.setWidth(screen_geom.width())

        geom = QRect(pos, size)

        if geom.top() < screen_geom.top():
            geom.setTop(screen_geom.top())

        if geom.left() < screen_geom.left():
            geom.setLeft(screen_geom.left())

        bottom_margin = screen_geom.bottom() - geom.bottom()
        right_margin = screen_geom.right() - geom.right()
        if bottom_margin < 0:
            # Falls over the bottom of the screen, move it up.
            geom.translate(0, bottom_margin)

        # TODO: right to left locale
        if right_margin < 0:
            # Falls over the right screen edge, move the menu to the
            # other side of pos.
            geom.translate(-size.width(), 0)

        self.setGeometry(geom)

        self.show()

        if searchText:
            self.setFocusProxy(self.__search)
        else:
            self.setFocusProxy(None)
Beispiel #5
0
 def _filter_table_variables(self):
     regex = QRegExp(self.filter_string)
     # If the user explicitly types different cases, we assume they know
     # what they are searching for and account for letter case in filter
     different_case = (any(c.islower() for c in self.filter_string)
                       and any(c.isupper() for c in self.filter_string))
     if not different_case:
         regex.setCaseSensitivity(Qt.CaseInsensitive)
 def __on_textEdited(self, text):
     # type: (str) -> None
     patt = QRegExp(r"(^|\W)" + text)
     patt.setCaseSensitivity(Qt.CaseInsensitive)
     self.__suggestPage.setFilterRegExp(patt)
     self.__pages.setCurrentPage(self.__suggestPage)
     self.__selectFirstIndex()
     UsageStatistics.set_last_search_query(text)
 def _filter_table_variables(self):
     regex = QRegExp(self.filter_string)
     # If the user explicitly types different cases, we assume they know
     # what they are searching for and account for letter case in filter
     different_case = (
         any(c.islower() for c in self.filter_string) and
         any(c.isupper() for c in self.filter_string)
     )
     if not different_case:
         regex.setCaseSensitivity(Qt.CaseInsensitive)
 def __on_textEdited(self, text):
     patt = QRegExp("(^|\W)" + text)
     patt.setCaseSensitivity(False)
     self.__suggestPage.setFilterRegExp(patt)
     self.__pages.setCurrentPage(self.__suggestPage)
Beispiel #9
0
 def __on_textEdited(self, text):
     patt = QRegExp("(^|\W)" + text)
     patt.setCaseSensitivity(False)
     self.__suggestPage.setFilterRegExp(patt)
     self.__pages.setCurrentPage(self.__suggestPage)