pycrossword  0.4
Pure-Python implementation of a crossword puzzle generator and editor
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
pycross.forms.WordDBManager Class Reference

Manager for the inbuilt SQLite word source database. More...

Inheritance diagram for pycross.forms.WordDBManager:

Public Member Functions

def __init__ (self, settings, parent=None, flags=QtCore.Qt.WindowFlags())
 
def sizeHint (self)
 Overridden method to make the window half the screen size. More...
 
def showEvent (self, event)
 OnShow event handler: populates the dictionaries when the window is displayed. More...
 
def closeEvent (self, event)
 OnClose event handler: stops all running operations, writes changes to the DB. More...
 
def resizeEvent (self, event)
 OnResize event handler: adjusts the Preview control size. More...
 
def initUI (self)
 Creates and initializes the GUI. More...
 
def createTabs (self)
 Creates the 2 tabs of the window. More...
 
def create_tvDicPreview_menu (self)
 Creates the context menu for WordDBManager::tvDicPreview. More...
 
def repopulate_dic_model (self, refresh_from_server=True, stopcheck=None)
 Repopulates the list of available dictionaries on Tab 1. More...
 
def on_repopulate_dic_model_run_fromserver (self)
 OnRun callback for WordDBManager::dics_model_thread forcing update from server. More...
 
def on_repopulate_dic_model_run_local (self)
 OnRun callback for WordDBManager::dics_model_thread forcing update from stored data. More...
 
def on_repopulate_dic_model_start (self)
 OnStart callback for WordDBManager::dics_model_thread called when the thread starts. More...
 
def on_repopulate_dic_model_finish (self)
 OnFinish callback for WordDBManager::dics_model_thread called when the thread completes. More...
 
def on_act_refreshdics (self, checked)
 OnTriggered handler for WordDBManager::act_refreshdics: starts WordDBManager::dics_model_thread. More...
 
def on_act_refreshdics_changed (self)
 OnChanged handler for WordDBManager::act_refreshdics: adjusts the Enabled property of some actions. More...
 
def on_act_installdics (self, checked)
 OnTriggered handler for WordDBManager::act_installdics: installs / uninstalls checked / unchecked dictionaries. More...
 
def on_act_stopdics (self, checked)
 OnTriggered handler for WordDBManager::act_stopdics: interrupts the current operations waiting on the spawned threads to terminate. More...
 
def on_act_addwd (self, checked)
 OnTriggered handler for WordDBManager::act_addwd: adds a new word to the current DB. More...
 
def on_act_delwd (self, checked)
 OnTriggered handler for WordDBManager::act_delwd: deletes the selected words from the current DB. More...
 
def on_act_peekdic (self, checked)
 OnTriggered handler for WordDBManager::act_peekdic: shows or hides the dictionary preview table. More...
 
def show_dic_content (self, filepath)
 Shows the raw content of the given dictionary the in the preview panel. More...
 
def on_start_download_preview (self, id, url, lang, filepath)
 OnStart callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview. More...
 
def stopcheck_download_preview (self, id, url, lang, filepath)
 OnStopCheck callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview. More...
 
def on_getfilesize_download_preview (self, id, url, lang, filepath, total_bytes)
 OnGetFilesize callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview. More...
 
def on_run_download_preview (self, id, url, lang, filepath, bytes_written, total_bytes)
 OnProgress callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview. More...
 
def on_complete_download_preview (self, id, url, lang, filepath)
 OnComplete callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview. More...
 
def on_error_download_preview (self, id, url, lang, filepath, message)
 OnError callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview. More...
 
def download_dic (self, lang, overwrite=False)
 Downloads the dictionary for the given language from the Hunspell repo and stores it locally as pycross/assets/dic/<LANG>.dic. More...
 
def show_db (self, dic_lang, stopcheck=None)
 Refreshes and shows the DB for a given dictionary in the DB view. More...
 
def update_db_actions (self)
 Updates the Enabled property of the DB actions in the toolbar. More...
 
def on_combo_selectdb (self, index)
 Fires when a DB is selected in WordDBManager::combo_selectdb. More...
 
def on_act_refreshdb (self, checked)
 OnTriggered handler for WordDBManager::act_refreshdb: display / refresh the current database in the editor. More...
 
def on_act_stopdb (self, checked)
 OnTriggered handler for WordDBManager::act_stopdb: stops the current operation (DB view refresh). More...
 
def on_act_commit (self, checked)
 OnTriggered handler for WordDBManager::act_commit: writes the pending changes to the DB. More...
 
def check_commit_db (self, refresh=True, ignore_errors=False)
 Displays a user confirmation dialog to write the pending changes to the current DB. More...
 
def commit_db (self, refresh=True, ignore_errors=False)
 Commits (writes) the pending changes to the currently edited DB. More...
 
def on_repopulate_db_model_start (self)
 OnStart callback for WordDBManager::db_model_thread called when the thread starts. More...
 
def on_repopulate_db_model_run (self)
 OnRun callback for WordDBManager::db_model_thread: repopulates the DB model. More...
 
def on_repopulate_db_model_finish (self)
 
def on_repopulate_db_model_error (self, thread, message)
 OnError callback for WordDBManager::db_model_thread: shows error and interrupts repopulation. More...
 
def stop_operations (self)
 Stops all operations running in child threads. More...
 
def reformat_dic_model_row (self, r)
 Formats the given row in the dictionaries view changing the background color according to the dictionary status. More...
 
def locate_dic_item (self, lang)
 Returns the item in WordDBManager::dics_model corresponding to a given language. More...
 
def on_download_dics_start (self, id, url, lang, filepath)
 OnStart callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation. More...
 
def on_download_dics_getfilesize (self, id, url, lang, filepath, total_bytes)
 OnGetFilesize callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation. More...
 
def on_download_dics_run (self, id, url, lang, filepath, bytes_written, total_bytes)
 OnProgress callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation. More...
 
def on_download_dics_finish (self, id, url, lang, filepath)
 OnComplete callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation. More...
 
def on_download_dics_error (self, id, url, lang, filepath, message)
 OnError callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation. More...
 
def on_download_dics_stopcheck (self, id, url, lang, filepath)
 OnStopCheck callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation. More...
 
def execute_pending_dics (self)
 Installs the checked and uninstalls the unchecked dictionaries. More...
 
def on_install_dics_start (self, id, lang, filepath)
 OnStart callback for dbapi::HunspellImport::add_all_from_hunspell(). More...
 
def on_install_dics_commit (self, id, lang, filepath, records)
 OnCommit callback for dbapi::HunspellImport::add_all_from_hunspell(). More...
 
def on_install_dics_finish (self, id, lang, filepath, records)
 OnFinish callback for dbapi::HunspellImport::add_all_from_hunspell(). More...
 
def on_install_dics_error (self, id, lang, filepath, message)
 OnError callback for dbapi::HunspellImport::add_all_from_hunspell(). More...
 
def on_install_dics_stopcheck (self, id, lang, filepath)
 OnStopCheck callback for dbapi::HunspellImport::add_all_from_hunspell(). More...
 
def do_install_dics (self)
 Installs the downloaded dictionaries marked for installation. More...
 
def db_model_item_changed (self, item)
 OnItemChanged handler for WordDBManager::db_model: adds the changed item to WordDBManager::db_model_changed_indices. More...
 
def db_model_reset (self)
 OnModelReset handler for WordDBManager::db_model: clears WordDBManager::db_model_changed_indices. More...
 
def dics_model_item_changed (self, item)
 OnItemChanged handler for WordDBManager::dics_model: sets the item internal / displayed data according to the user changes. More...
 
def on_tvDics_activated (self, index)
 OnItemActivated handler for WordDBManager::tvDics: brings up editor dialogs to edit specific values like Replacements or Excluded POS. More...
 
def on_tvDics_selectionchanged (self, current, previous)
 OnSelectionChanged handler for WordDBManager::tvDics. More...
 
def on_tvDb_selectionchanged (self, current, previous)
 OnSelectionChanged handler for WordDBManager::tvDb. More...
 
def on_tvDicPreview_contextmenu (self, pos)
 OnCustomContextMenuRequested handler for WordDBManager::tvDicPreview. More...
 

Public Attributes

 mainwindow
 gui::MainWindow the app main window More...
 
 dics_model
 QtGui.QStandardItemModel underlying model for the dictionary collection populated from the Hunspell repo (in Tab 1) More...
 
 dics
 dict stored data for dictionaries retrieved from the Hunspell repo More...
 
 dics_model_thread
 utils::QThreadStump dedicated thread to populate dictionaries from the Hunspell repo More...
 
 hunspellmgr
 dbapi::HunspellImport HunspellImport object to import dictionaries from Hunspell More...
 
 to_install
 list list of dictionaries selected for installation More...
 
 loadermovie
 QtGui.QMovie animation shown during lengthy operations More...
 
 db_model
 QtGui.QStandardItemModel underlying model for the current database (in Tab 2) More...
 
 db_model_thread
 utils::QThreadStump dedicated thread to refresh the database table (in Tab 2) More...
 
 db_model_changed_indices
 set stored indices of the DB model to reflect user changes that must be committed More...
 
 lo_main
 QtWidgets.QVBoxLayout central widget layout More...
 
 tabw
 QtWidgets.QTabWidget tab container for the 2 tabs in the window More...
 
 statusbar
 QtWidgets.QStatusBar main status bar More...
 
 statusbar_pbar
 QtWidgets.QProgressBar progress bar inside status bar (hidden by default) More...
 
 wcentral
 QtWidgets.QWidget window central widget (root container for other controls) More...
 
 tb_dicactions
 QtWidgets.QWidget Tab 1 widget More...
 
 act_refreshdics
 QtWidgets.QAction action to repopulate dictionaries list More...
 
 act_installdics
 QtWidgets.QAction action to install selected (checked) and uninstall unchecked dictionaries More...
 
 act_stopdics
 QtWidgets.QAction action to stop the current operation (refresh / installation) More...
 
 act_peekdic
 QtWidgets.QAction action to see the raw content of the selected dictionary More...
 
 splitter_dics
 QtWidgets.QSplitter splitter between dictionaries list and preview More...
 
 tvDics
 QtWidgets.QTableView table control to view the dictionaries list More...
 
 l_gif
 QtWidgets.QLabel GIF control to display the wait animation (for dics list) More...
 
 tvDicPreview
 QtWidgets.QTableView table control to preview the dictionary content (read-only) More...
 
 l_gif2
 QtWidgets.QLabel GIF control to display the wait animation (for preview) More...
 
 combo_selectdb
 QtWidgets.QWidget Tab 2 widget More...
 
 tb_dbactions
 QtWidgets.QToolBar Tab 2 toolbar More...
 
 act_refreshdb
 QtWidgets.QAction action to display / refresh the current database in the editor More...
 
 act_stopdb
 QtWidgets.QAction action to stop the current operation (DB view refresh) More...
 
 act_addwd
 QtWidgets.QAction action to add a new word to the DB More...
 
 act_delwd
 QtWidgets.QAction action to delete the selected words from the DB More...
 
 act_commit
 QtWidgets.QAction action to write the pending changes to the DB More...
 
 l_gif3
 QtWidgets.QLabel GIF control to display the wait animation (for DB view) More...
 
 tvDB
 QtWidgets.QTableView table control to display / edit the current DB More...
 
 tvDicPreview_menu
 QtWidgets.QMenu context menu for WordDBManager::tvDicPreview More...
 
 dic_preview_item
 

Static Public Attributes

 sigEnableInstall = QtCore.pyqtSignal(bool)
 QtCore.pyqtSignal signal to notify if dictionary installation can be started. More...
 
list pos_list
 list list of localized part pf speech names More...
 

Private Member Functions

def _get_pos_index (self, pos_short)
 Gets the index of a part of speech in utils::globalvars::POS given its short name. More...
 
def _get_pos_short (self, pos_desc)
 Gets the short name of a part of speech given its full name. More...
 

Private Attributes

 _default_bgcolor
 

Detailed Description

Manager for the inbuilt SQLite word source database.

Lets the user download and import Hunspell dictionaries for any language, with flexible part-of-speech / blacklisting / replacement settings. Language dictionaries (basically, word lists) available for download are retrieved from the unofficial Hunspell repository on Github. These dictionaries can be downloaded and installed locally as SQLite databases, which in turn can be used by the application as word sources to generate crossword. Installed dictionaries are stored as *.db files in pycross/assets/dic (one *.db file for each installed language). See pycross::dbapi for details on the DB structure. The Word DB Manager provides the user with a convenient GUI to investigate the available and installed dictionaries, install / uninstall them, and manually edit the installed databases (add / remove and change entries). Most operations are performed in a multithreaded way, without blocking the GUI window, and can be interrupted by the user at any moment.

Constructor & Destructor Documentation

◆ __init__()

def pycross.forms.WordDBManager.__init__ (   self,
  settings,
  parent = None,
  flags = QtCore.Qt.WindowFlags() 
)
Parameters
settingsdict pointer to the app global settings dictionary (utils::guisettings::CWSettings::settings)
parentQtWidgets.QWidget parent widget
flagsQtCore.Qt.WindowFlags Qt window flags

Member Function Documentation

◆ _get_pos_index()

def pycross.forms.WordDBManager._get_pos_index (   self,
  pos_short 
)
private

Gets the index of a part of speech in utils::globalvars::POS given its short name.

Parameters
pos_shortstr short POS name, e.g. 'n' (noun)
Returns
int index of the POS in utils::globalvars::POS (default = 0)

◆ _get_pos_short()

def pycross.forms.WordDBManager._get_pos_short (   self,
  pos_desc 
)
private

Gets the short name of a part of speech given its full name.

Parameters
pos_descstr full POS name, e.g. 'Noun'
Returns
str | None short POS name, e.g. 'n' (None if not found in in utils::globalvars::POS)

◆ check_commit_db()

def pycross.forms.WordDBManager.check_commit_db (   self,
  refresh = True,
  ignore_errors = False 
)

Displays a user confirmation dialog to write the pending changes to the current DB.

Parameters
refreshbool whether to refresh the DB view after writing the changes
ignore_errorsbool whether to ignore any errors when writing the changes

◆ closeEvent()

def pycross.forms.WordDBManager.closeEvent (   self,
  event 
)

OnClose event handler: stops all running operations, writes changes to the DB.

◆ commit_db()

def pycross.forms.WordDBManager.commit_db (   self,
  refresh = True,
  ignore_errors = False 
)

Commits (writes) the pending changes to the currently edited DB.

Parameters
refreshbool whether to refresh the DB view after writing the changes
ignore_errorsbool whether to ignore any errors when writing the changes

◆ create_tvDicPreview_menu()

def pycross.forms.WordDBManager.create_tvDicPreview_menu (   self)

Creates the context menu for WordDBManager::tvDicPreview.

◆ createTabs()

def pycross.forms.WordDBManager.createTabs (   self)

Creates the 2 tabs of the window.

◆ db_model_item_changed()

def pycross.forms.WordDBManager.db_model_item_changed (   self,
  item 
)

OnItemChanged handler for WordDBManager::db_model: adds the changed item to WordDBManager::db_model_changed_indices.

◆ db_model_reset()

def pycross.forms.WordDBManager.db_model_reset (   self)

◆ dics_model_item_changed()

def pycross.forms.WordDBManager.dics_model_item_changed (   self,
  item 
)

OnItemChanged handler for WordDBManager::dics_model: sets the item internal / displayed data according to the user changes.

◆ do_install_dics()

def pycross.forms.WordDBManager.do_install_dics (   self)

Installs the downloaded dictionaries marked for installation.

◆ download_dic()

def pycross.forms.WordDBManager.download_dic (   self,
  lang,
  overwrite = False 
)

Downloads the dictionary for the given language from the Hunspell repo and stores it locally as pycross/assets/dic/<LANG>.dic.

Parameters
langstr short language name for the dictionary (e.g. 'en', 'de')
overwritebool whether to overwrite the existing file

◆ execute_pending_dics()

def pycross.forms.WordDBManager.execute_pending_dics (   self)

Installs the checked and uninstalls the unchecked dictionaries.

◆ initUI()

def pycross.forms.WordDBManager.initUI (   self)

Creates and initializes the GUI.

◆ locate_dic_item()

def pycross.forms.WordDBManager.locate_dic_item (   self,
  lang 
)

Returns the item in WordDBManager::dics_model corresponding to a given language.

Parameters
langstr short language name for the dictionary (e.g. 'en', 'de')
Returns
QtGui.QStandardItem | None found item in WordDBManager::dics_model or None if not found

◆ on_act_addwd()

def pycross.forms.WordDBManager.on_act_addwd (   self,
  checked 
)

OnTriggered handler for WordDBManager::act_addwd: adds a new word to the current DB.

◆ on_act_commit()

def pycross.forms.WordDBManager.on_act_commit (   self,
  checked 
)

OnTriggered handler for WordDBManager::act_commit: writes the pending changes to the DB.

◆ on_act_delwd()

def pycross.forms.WordDBManager.on_act_delwd (   self,
  checked 
)

OnTriggered handler for WordDBManager::act_delwd: deletes the selected words from the current DB.

◆ on_act_installdics()

def pycross.forms.WordDBManager.on_act_installdics (   self,
  checked 
)

OnTriggered handler for WordDBManager::act_installdics: installs / uninstalls checked / unchecked dictionaries.

◆ on_act_peekdic()

def pycross.forms.WordDBManager.on_act_peekdic (   self,
  checked 
)

OnTriggered handler for WordDBManager::act_peekdic: shows or hides the dictionary preview table.

◆ on_act_refreshdb()

def pycross.forms.WordDBManager.on_act_refreshdb (   self,
  checked 
)

OnTriggered handler for WordDBManager::act_refreshdb: display / refresh the current database in the editor.

◆ on_act_refreshdics()

def pycross.forms.WordDBManager.on_act_refreshdics (   self,
  checked 
)

◆ on_act_refreshdics_changed()

def pycross.forms.WordDBManager.on_act_refreshdics_changed (   self)

OnChanged handler for WordDBManager::act_refreshdics: adjusts the Enabled property of some actions.

◆ on_act_stopdb()

def pycross.forms.WordDBManager.on_act_stopdb (   self,
  checked 
)

OnTriggered handler for WordDBManager::act_stopdb: stops the current operation (DB view refresh).

◆ on_act_stopdics()

def pycross.forms.WordDBManager.on_act_stopdics (   self,
  checked 
)

OnTriggered handler for WordDBManager::act_stopdics: interrupts the current operations waiting on the spawned threads to terminate.

◆ on_combo_selectdb()

def pycross.forms.WordDBManager.on_combo_selectdb (   self,
  index 
)

Fires when a DB is selected in WordDBManager::combo_selectdb.

◆ on_complete_download_preview()

def pycross.forms.WordDBManager.on_complete_download_preview (   self,
  id,
  url,
  lang,
  filepath 
)

OnComplete callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)

◆ on_download_dics_error()

def pycross.forms.WordDBManager.on_download_dics_error (   self,
  id,
  url,
  lang,
  filepath,
  message 
)

OnError callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
messagestr the error message

◆ on_download_dics_finish()

def pycross.forms.WordDBManager.on_download_dics_finish (   self,
  id,
  url,
  lang,
  filepath 
)

OnComplete callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)

◆ on_download_dics_getfilesize()

def pycross.forms.WordDBManager.on_download_dics_getfilesize (   self,
  id,
  url,
  lang,
  filepath,
  total_bytes 
)

OnGetFilesize callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
total_bytesint length of file to be downloaded (in bytes)

◆ on_download_dics_run()

def pycross.forms.WordDBManager.on_download_dics_run (   self,
  id,
  url,
  lang,
  filepath,
  bytes_written,
  total_bytes 
)

OnProgress callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
bytes_writtenint number of bytes downloaded so far
total_bytesint length of file to be downloaded (in bytes)

◆ on_download_dics_start()

def pycross.forms.WordDBManager.on_download_dics_start (   self,
  id,
  url,
  lang,
  filepath 
)

OnStart callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)

◆ on_download_dics_stopcheck()

def pycross.forms.WordDBManager.on_download_dics_stopcheck (   self,
  id,
  url,
  lang,
  filepath 
)

OnStopCheck callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for installation.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
Returns
bool True to stop / False to continue download

◆ on_error_download_preview()

def pycross.forms.WordDBManager.on_error_download_preview (   self,
  id,
  url,
  lang,
  filepath,
  message 
)

OnError callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
messagestr the error message

◆ on_getfilesize_download_preview()

def pycross.forms.WordDBManager.on_getfilesize_download_preview (   self,
  id,
  url,
  lang,
  filepath,
  total_bytes 
)

OnGetFilesize callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
total_bytesint length of file to be downloaded (in bytes)

◆ on_install_dics_commit()

def pycross.forms.WordDBManager.on_install_dics_commit (   self,
  id,
  lang,
  filepath,
  records 
)

OnCommit callback for dbapi::HunspellImport::add_all_from_hunspell().

Parameters
idint ID of task in the thread pool
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
recordsint number of records (entries) written so far

◆ on_install_dics_error()

def pycross.forms.WordDBManager.on_install_dics_error (   self,
  id,
  lang,
  filepath,
  message 
)

OnError callback for dbapi::HunspellImport::add_all_from_hunspell().

Parameters
idint ID of task in the thread pool
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
messagestr error message

◆ on_install_dics_finish()

def pycross.forms.WordDBManager.on_install_dics_finish (   self,
  id,
  lang,
  filepath,
  records 
)

OnFinish callback for dbapi::HunspellImport::add_all_from_hunspell().

Parameters
idint ID of task in the thread pool
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
recordsint number of records (entries) written to the DB

◆ on_install_dics_start()

def pycross.forms.WordDBManager.on_install_dics_start (   self,
  id,
  lang,
  filepath 
)

OnStart callback for dbapi::HunspellImport::add_all_from_hunspell().

Parameters
idint ID of task in the thread pool
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)

◆ on_install_dics_stopcheck()

def pycross.forms.WordDBManager.on_install_dics_stopcheck (   self,
  id,
  lang,
  filepath 
)

OnStopCheck callback for dbapi::HunspellImport::add_all_from_hunspell().

Parameters
idint ID of task in the thread pool
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
Returns
bool True to stop / False to continue

◆ on_repopulate_db_model_error()

def pycross.forms.WordDBManager.on_repopulate_db_model_error (   self,
  thread,
  message 
)

OnError callback for WordDBManager::db_model_thread: shows error and interrupts repopulation.

Parameters
threadQtCore.QThread pointer to thread causing the error
messagestr the error message

◆ on_repopulate_db_model_finish()

def pycross.forms.WordDBManager.on_repopulate_db_model_finish (   self)

◆ on_repopulate_db_model_run()

def pycross.forms.WordDBManager.on_repopulate_db_model_run (   self)

OnRun callback for WordDBManager::db_model_thread: repopulates the DB model.

◆ on_repopulate_db_model_start()

def pycross.forms.WordDBManager.on_repopulate_db_model_start (   self)

OnStart callback for WordDBManager::db_model_thread called when the thread starts.

◆ on_repopulate_dic_model_finish()

def pycross.forms.WordDBManager.on_repopulate_dic_model_finish (   self)

OnFinish callback for WordDBManager::dics_model_thread called when the thread completes.

◆ on_repopulate_dic_model_run_fromserver()

def pycross.forms.WordDBManager.on_repopulate_dic_model_run_fromserver (   self)

OnRun callback for WordDBManager::dics_model_thread forcing update from server.

◆ on_repopulate_dic_model_run_local()

def pycross.forms.WordDBManager.on_repopulate_dic_model_run_local (   self)

OnRun callback for WordDBManager::dics_model_thread forcing update from stored data.

◆ on_repopulate_dic_model_start()

def pycross.forms.WordDBManager.on_repopulate_dic_model_start (   self)

OnStart callback for WordDBManager::dics_model_thread called when the thread starts.

◆ on_run_download_preview()

def pycross.forms.WordDBManager.on_run_download_preview (   self,
  id,
  url,
  lang,
  filepath,
  bytes_written,
  total_bytes 
)

OnProgress callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
bytes_writtenint number of bytes downloaded so far
total_bytesint length of file to be downloaded (in bytes)

◆ on_start_download_preview()

def pycross.forms.WordDBManager.on_start_download_preview (   self,
  id,
  url,
  lang,
  filepath 
)

OnStart callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)

◆ on_tvDb_selectionchanged()

def pycross.forms.WordDBManager.on_tvDb_selectionchanged (   self,
  current,
  previous 
)

OnSelectionChanged handler for WordDBManager::tvDb.

◆ on_tvDicPreview_contextmenu()

def pycross.forms.WordDBManager.on_tvDicPreview_contextmenu (   self,
  pos 
)

OnCustomContextMenuRequested handler for WordDBManager::tvDicPreview.

◆ on_tvDics_activated()

def pycross.forms.WordDBManager.on_tvDics_activated (   self,
  index 
)

OnItemActivated handler for WordDBManager::tvDics: brings up editor dialogs to edit specific values like Replacements or Excluded POS.

Parameters
indexQtCore.QModelIndex the index of the activated (e.g. double-clicked) item

◆ on_tvDics_selectionchanged()

def pycross.forms.WordDBManager.on_tvDics_selectionchanged (   self,
  current,
  previous 
)

OnSelectionChanged handler for WordDBManager::tvDics.

◆ reformat_dic_model_row()

def pycross.forms.WordDBManager.reformat_dic_model_row (   self,
  r 
)

Formats the given row in the dictionaries view changing the background color according to the dictionary status.

Parameters
rint number of row to apply formatting to

◆ repopulate_dic_model()

def pycross.forms.WordDBManager.repopulate_dic_model (   self,
  refresh_from_server = True,
  stopcheck = None 
)

Repopulates the list of available dictionaries on Tab 1.

Parameters
refresh_from_serverbool if True, the list will be retrieved from the Github repo; if False, the previously populated data in WordDBManager::dics will be used
stopcheckcallable callback function that must return True to stop the current operation, or False to continue

◆ resizeEvent()

def pycross.forms.WordDBManager.resizeEvent (   self,
  event 
)

OnResize event handler: adjusts the Preview control size.

◆ show_db()

def pycross.forms.WordDBManager.show_db (   self,
  dic_lang,
  stopcheck = None 
)

Refreshes and shows the DB for a given dictionary in the DB view.

Parameters
dic_langdict dictionary info (see dbapi::HunspellImport::list_hunspell())
stopcheckcallable callback function that must return True to stop the current operation, or False to continue

◆ show_dic_content()

def pycross.forms.WordDBManager.show_dic_content (   self,
  filepath 
)

Shows the raw content of the given dictionary the in the preview panel.

Parameters
filepathstr full path to dictionary file (*.dic)

◆ showEvent()

def pycross.forms.WordDBManager.showEvent (   self,
  event 
)

OnShow event handler: populates the dictionaries when the window is displayed.

◆ sizeHint()

def pycross.forms.WordDBManager.sizeHint (   self)

Overridden method to make the window half the screen size.

◆ stop_operations()

def pycross.forms.WordDBManager.stop_operations (   self)

Stops all operations running in child threads.

◆ stopcheck_download_preview()

def pycross.forms.WordDBManager.stopcheck_download_preview (   self,
  id,
  url,
  lang,
  filepath 
)

OnStopCheck callback for dbapi::HunspellImport::download_hunspell() downloading dictionaries for preview.

Parameters
idint ID of task in the thread pool
urlstr URL of the downloaded file (dictionary)
langstr short language name for the dictionary (e.g. 'en', 'de')
filepathstr full path to the downloaded dictionary (saved in pycross/assets/dic by default)
Returns
bool True to stop / False to continue download

◆ update_db_actions()

def pycross.forms.WordDBManager.update_db_actions (   self)

Updates the Enabled property of the DB actions in the toolbar.

Member Data Documentation

◆ _default_bgcolor

pycross.forms.WordDBManager._default_bgcolor
private

◆ act_addwd

pycross.forms.WordDBManager.act_addwd

QtWidgets.QAction action to add a new word to the DB

◆ act_commit

pycross.forms.WordDBManager.act_commit

QtWidgets.QAction action to write the pending changes to the DB

◆ act_delwd

pycross.forms.WordDBManager.act_delwd

QtWidgets.QAction action to delete the selected words from the DB

◆ act_installdics

pycross.forms.WordDBManager.act_installdics

QtWidgets.QAction action to install selected (checked) and uninstall unchecked dictionaries

◆ act_peekdic

pycross.forms.WordDBManager.act_peekdic

QtWidgets.QAction action to see the raw content of the selected dictionary

◆ act_refreshdb

pycross.forms.WordDBManager.act_refreshdb

QtWidgets.QAction action to display / refresh the current database in the editor

◆ act_refreshdics

pycross.forms.WordDBManager.act_refreshdics

QtWidgets.QAction action to repopulate dictionaries list

◆ act_stopdb

pycross.forms.WordDBManager.act_stopdb

QtWidgets.QAction action to stop the current operation (DB view refresh)

◆ act_stopdics

pycross.forms.WordDBManager.act_stopdics

QtWidgets.QAction action to stop the current operation (refresh / installation)

◆ combo_selectdb

pycross.forms.WordDBManager.combo_selectdb

QtWidgets.QWidget Tab 2 widget

QtWidgets.QVBoxLayout Tab 2 layout QtWidgets.QFormLayout Tab 2 top panel layout QtWidgets.QComboBox combo box to select the database to view / edit

◆ db_model

pycross.forms.WordDBManager.db_model

QtGui.QStandardItemModel underlying model for the current database (in Tab 2)

◆ db_model_changed_indices

pycross.forms.WordDBManager.db_model_changed_indices

set stored indices of the DB model to reflect user changes that must be committed

◆ db_model_thread

pycross.forms.WordDBManager.db_model_thread

utils::QThreadStump dedicated thread to refresh the database table (in Tab 2)

◆ dic_preview_item

pycross.forms.WordDBManager.dic_preview_item

◆ dics

pycross.forms.WordDBManager.dics

dict stored data for dictionaries retrieved from the Hunspell repo

◆ dics_model

pycross.forms.WordDBManager.dics_model

QtGui.QStandardItemModel underlying model for the dictionary collection populated from the Hunspell repo (in Tab 1)

◆ dics_model_thread

pycross.forms.WordDBManager.dics_model_thread

utils::QThreadStump dedicated thread to populate dictionaries from the Hunspell repo

◆ hunspellmgr

pycross.forms.WordDBManager.hunspellmgr

dbapi::HunspellImport HunspellImport object to import dictionaries from Hunspell

◆ l_gif

pycross.forms.WordDBManager.l_gif

QtWidgets.QLabel GIF control to display the wait animation (for dics list)

◆ l_gif2

pycross.forms.WordDBManager.l_gif2

QtWidgets.QLabel GIF control to display the wait animation (for preview)

◆ l_gif3

pycross.forms.WordDBManager.l_gif3

QtWidgets.QLabel GIF control to display the wait animation (for DB view)

◆ lo_main

pycross.forms.WordDBManager.lo_main

QtWidgets.QVBoxLayout central widget layout

◆ loadermovie

pycross.forms.WordDBManager.loadermovie

QtGui.QMovie animation shown during lengthy operations

◆ mainwindow

pycross.forms.WordDBManager.mainwindow

gui::MainWindow the app main window

◆ pos_list

list pycross.forms.WordDBManager.pos_list
static
Initial value:
= [_('Noun'), _('Verb'), _('Adverb'), _('Adjective'),
_('Participle'), _('Pronoun'), _('Interjection'), _('Conjuction'),
_('Preposition'), _('Proposition'), _('Miscellaneous / other'), _('None')]

list list of localized part pf speech names

◆ sigEnableInstall

pycross.forms.WordDBManager.sigEnableInstall = QtCore.pyqtSignal(bool)
static

QtCore.pyqtSignal signal to notify if dictionary installation can be started.

◆ splitter_dics

pycross.forms.WordDBManager.splitter_dics

QtWidgets.QSplitter splitter between dictionaries list and preview

◆ statusbar

pycross.forms.WordDBManager.statusbar

QtWidgets.QStatusBar main status bar

◆ statusbar_pbar

pycross.forms.WordDBManager.statusbar_pbar

QtWidgets.QProgressBar progress bar inside status bar (hidden by default)

◆ tabw

pycross.forms.WordDBManager.tabw

QtWidgets.QTabWidget tab container for the 2 tabs in the window

◆ tb_dbactions

pycross.forms.WordDBManager.tb_dbactions

QtWidgets.QToolBar Tab 2 toolbar

◆ tb_dicactions

pycross.forms.WordDBManager.tb_dicactions

QtWidgets.QWidget Tab 1 widget

QtWidgets.QVBoxLayout Tab 1 layout QtWidgets.QToolBar Tab 1 toolbar

◆ to_install

pycross.forms.WordDBManager.to_install

list list of dictionaries selected for installation

◆ tvDB

pycross.forms.WordDBManager.tvDB

QtWidgets.QTableView table control to display / edit the current DB

◆ tvDicPreview

pycross.forms.WordDBManager.tvDicPreview

QtWidgets.QTableView table control to preview the dictionary content (read-only)

◆ tvDicPreview_menu

pycross.forms.WordDBManager.tvDicPreview_menu

QtWidgets.QMenu context menu for WordDBManager::tvDicPreview

◆ tvDics

pycross.forms.WordDBManager.tvDics

QtWidgets.QTableView table control to view the dictionaries list

◆ wcentral

pycross.forms.WordDBManager.wcentral

QtWidgets.QWidget window central widget (root container for other controls)


The documentation for this class was generated from the following file: