Documentation BackendUpdate

From BibleTime
Jump to: navigation, search

CSwordBackend has the list of the modules. When the list is changed there are several places which must be updated. The Qt signal/slot mechanism is used for that.

CSwordBackend has the method reloadModules(CSwordBackend::SetupChangedReason). When for example a new module is installed the installer code must call that method. The backend will use the sword library to update the list of the modules. Then it sends the sigSwordSetupChanged signal with the reason as argument.

There are several places which must be updated when the module list is updated. These include the display windows, the main window Bookshelf index and the Bookshelf Manager module lists. Those classes which use the module list can catch the sigSwordSetupChanged signal by connecting it to a slot. There the necessary actions can be taken. Usually it means rebuilding some visible module list.

If the module list is changed only in BibleTime related code, not in the Sword backend, there is no need to use CSwordBackend::reloadModules(CSwordBackend::SetupChangedReason). Then the code which changes the module information can call CSwordBackend::notifyChange(CSwordBackend::SetupChangedReason). Example of this is when a module is hidden from the list. The Sword backend module list is not changed, only some BibleTime module lists. The code which hides a module calls notifyChange() and all classes which listen to the signal may update their lists unconditionally or decide if they want to update depending on the signal argument which tells the reason of the update.