# Standard imports import sqlite3 from typing import Callable # Qt imports from PySide2.QtCore import QRunnable, QObject, Signal, QThread # Custom imports from cutevariant.core.sql import get_sql_connection from cutevariant.commons import logger LOGGER = logger() class SqlRunnable(QObject, QRunnable): """Used to execute SQL/VQL queries in a separated thread Attributes: - db_file (str): File path of the database. - async_conn (sqlite3.Connection): sqlite3 Connection - function (Callable): Function to be executed - query_number (int): (default: 0) Used to identify the finished query in a pool via the finished signal (see section Signals below). - results: Contain the result of the threaded function. `None`, as long as the function has not finished its execution done. Class attributes: - sql_connections_pool (dict): Mapping of thread ids as keys and sqlite3 Connections as values. It allows to reuse sql connections accros calls of run() method and benefit from their cache methods.
import os import glob from abc import abstractmethod from logging import DEBUG # Qt imports from PySide2.QtWidgets import * from PySide2.QtCore import * # QApplication.instance() from PySide2.QtGui import * # QIcon, QPalette # Custom imports import cutevariant.commons as cm from cutevariant.gui.ficon import FIcon from cutevariant.gui import network, style, widgets LOGGER = cm.logger() class AbstractSettingsWidget(QWidget): """Abstract class for settings widgets User must reimplement load() and save() """ def __init__(self): super().__init__() self.setWindowTitle("base") self.setWindowIcon(FIcon(0xF5CA)) self.section_widget = None