예제 #1
0
 def __init__(self, parent=None):
     super().__init__("CompletionMetaInfo", ['key', 'value'],
                      constraints={'key': 'PRIMARY KEY'})
     if sql.user_version_changed():
         self._init_default_values()
         # force_rebuild is not in use anymore
         self.delete('key', 'force_rebuild', optional=True)
예제 #2
0
    def __init__(self, progress, parent=None):
        super().__init__("History", ['url', 'title', 'atime', 'redirect'],
                         constraints={
                             'url': 'NOT NULL',
                             'title': 'NOT NULL',
                             'atime': 'NOT NULL',
                             'redirect': 'NOT NULL'
                         },
                         parent=parent)
        self._progress = progress
        # Store the last saved url to avoid duplicate immediate saves.
        self._last_url = None

        self.completion = CompletionHistory(parent=self)
        self.metainfo = CompletionMetaInfo(parent=self)

        rebuild_completion = False

        if sql.user_version_changed():
            # If the DB user version changed, run a full cleanup and rebuild the
            # completion history.
            #
            # In the future, this could be improved to only be done when actually needed
            # - but version changes happen very infrequently, rebuilding everything
            # gives us less corner-cases to deal with, and we can run a VACUUM to make
            # things smaller.
            self._cleanup_history()
            rebuild_completion = True

        # Get a string of all patterns
        patterns = config.instance.get_str('completion.web_history.exclude')

        # If patterns changed, update them in database and rebuild completion
        if self.metainfo['excluded_patterns'] != patterns:
            self.metainfo['excluded_patterns'] = patterns
            rebuild_completion = True

        if rebuild_completion and self.completion:
            # If no completion history exists, we don't need to spawn a dialog for
            # cleaning it up.
            self._rebuild_completion()

        self.create_index('HistoryIndex', 'url')
        self.create_index('HistoryAtimeIndex', 'atime')
        self._contains_query = self.contains_query('url')
        self._between_query = sql.Query('SELECT * FROM History '
                                        'where not redirect '
                                        'and not url like "qute://%" '
                                        'and atime > :earliest '
                                        'and atime <= :latest '
                                        'ORDER BY atime desc')

        self._before_query = sql.Query('SELECT * FROM History '
                                       'where not redirect '
                                       'and not url like "qute://%" '
                                       'and atime <= :latest '
                                       'ORDER BY atime desc '
                                       'limit :limit offset :offset')
예제 #3
0
    def __init__(self, parent=None):
        self._fields = ['key', 'value']
        self._constraints = {'key': 'PRIMARY KEY'}
        super().__init__("CompletionMetaInfo",
                         self._fields,
                         constraints=self._constraints)

        if sql.user_version_changed():
            self._init_default_values()