Example #1
0
    def set_model(self, prefix):
        """ Update the completion model when the prefix is known. Has to
        be done through an instance variable because of a bug (will not
        complete the line edit otherwise)

        CFG02

        """

        # storage in __model is required because, apparently, the value
        # returned from DatabaseLogLite.model() is deleted somehow (not stored
        # anywhere) if used directly to set the QCompleter, disabling
        # completion silently
        self.__model = database().model(prefix)
        self.__completer = QCompleter(self.__model, self)
        self.setCompleter(self.__completer)
Example #2
0
    def set_model(self, prefix):
        """ Update the completion model when the prefix is known. Has to
        be done through an instance variable because of a bug (will not
        complete the line edit otherwise)

        CFG02

        """

        # storage in __model is required because, apparently, the value
        # returned from DatabaseLogLite.model() is deleted somehow (not stored
        # anywhere) if used directly to set the QCompleter, disabling
        # completion silently
        self.__model = database().model(prefix)
        self.__completer = QCompleter(self.__model, self)
        self.setCompleter(self.__completer)
Example #3
0
        def reply_complete(reply):
            """ Prints when a request completes, handles the filter that
            chooses between successful and filtered requests

            Replies only - if the request doesn't have to go
            through the network, it will not be reported here

            AB01

            """

            qurl = reply.url()
            s_url = qurl.toString()

            status = reply.attribute(
                QNetworkRequest.HttpStatusCodeAttribute)

            if is_local(qurl) or status is None:
                return

            # 'status' will never be None from here on

            # used only once
            color_status = Fore.GREEN if reply.attribute(
                QNetworkRequest.SourceIsFromCacheAttribute) else Fore.RED

            # was it a filtered reply?
            # used only once
            color = Fore.BLUE if 200 <= status < 400 else Fore.RED

            origin = reply.request().originatingObject()

            if origin:
                # used only once
                not_same = not compare_host(
                    origin.requestedUrl().host(), qurl.host())
            else:
                print("NO ORIGINATING OBJECT", s_url)
                return

            in_iframe = origin != origin.page().mainFrame()

            # this is the response to the original .load(), not a
            # resource loaded by the page itself
            if origin.requestedUrl() == qurl and not in_iframe:
                host = sub("^www.", "", qurl.host())
                path = qurl.path().rstrip("/ ")

                if (  # AB01
                        (host not in DO_NOT_STORE) and
                        (not qurl.hasQuery()) and
                        len(path.split('/')) < 4 and
                        200 <= status < 400):
                    database().store_navigation(host, path, self.prefix)

            if not_same or in_iframe:
                info = {
                    'color_status': color_status,
                    'status': status,
                    'resource': qurl,
                    'source': origin.requestedUrl(),
                    'main_color': color,
                    'iframe': in_iframe}
                show_info(info)