Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::AppModuleInterface Class Referenceabstract

Base/Interface class for application modules. More...

#include <AppModuleInterface.h>

Inheritance diagram for sf::AppModuleInterface:
Collaboration diagram for sf::AppModuleInterface:

Classes

struct  Parameters
 Structure for passing parameters to derived classes loaded and created at run-time. More...
 

Public Types

enum  InitializeStage { Uninitialize = 0 , Initialize , Finalize }
 
enum  MenuType { Settings , View , Tools }
 
typedef QMap< QString, AppModuleInterface * > Map
 
typedef QList< QDockWidget * > DockWidgetList
 Type definition for containing dock widgets.
 
typedef TClosure< MultiDocInterface *, const QString &, AppModuleInterface * > OpenFileClosure
 Type definition for the callback closure.
 

Public Member Functions

 AppModuleInterface (const Parameters &)
 Constructor for passing general structure for derived classes.
 
 ~AppModuleInterface () override
 Virtual destructor for derived classes.
 
virtual void initialize (InitializeStage stage)=0
 Called when al modules are loaded or when a module added.
 
virtual QString getName () const =0
 Gets the description of this instance.
 
virtual QString getDescription () const =0
 Gets the description of this instance.
 
virtual QString getLibraryFilename () const =0
 Gets the library filename.
 
virtual QString getSvgIconResource () const
 Gets svg icon resource name and can be overridden to change the default.
 
virtual void addPropertyPages (PropertySheetDialog *sheet)=0
 Adds module property pages to the passed sheet.
 
virtual void addMenuItems (MenuType menuType, QMenu *menu)
 Adds menu items for the passed type of menu.
 
virtual DockWidgetList createDockingWidgets (QWidget *parent)
 Creates docking widgets having the passed parent.
 
virtual void addToolBars (QMainWindow *mainWindow)
 Adds toolbars to the passed main window.
 
bool hasFileTypes () const
 
void addFileType (const QString &name, const QString &suffix)
 Adds a file type handled by this instance.
 
void addFileType (const QString &mime)
 Adds a file type handled by this instance.
 
void addFileType (const QMimeType &mime)
 Adds a file type using the passed QMimeType instance.
 
QString getFileTypeFilters () const
 Gets the filter string for a file dialog.
 
MultiDocInterfacecreateChild (QWidget *parent) const
 Calls createChild() and assigns this creating instance for reference.
 
QSettings * getSettings () const
 Gets the settings class passed on creation.
 
MultiDocInterfaceopenFile (const QString &filename, AppModuleInterface *ami=nullptr) const
 Makes the application open a file.
 
virtual void documentActivated (MultiDocInterface *iface, bool yn) const
 Called from main window when a document is activated or deactivated.
 

Static Public Member Functions

static void instantiate (QSettings *settings, QObject *parent)
 Creates instances of all available/loaded interface implementations.
 
static size_t initializeInstances (InitializeStage stage)
 Initializes all uninitialized instances or visa versa.
 
static void addAllPropertyPages (PropertySheetDialog *sheet)
 Adds property pages from all modules to the passed sheet.
 
static void addAllMenuItems (MenuType menuType, QMenu *menu)
 Adds items from all modules to this menu.
 
static const MapgetMap ()
 Gets the named module map.
 
static DockWidgetList createAllDockingWidgets (QWidget *parent)
 Creates all docking widgets of the loaded modules by calling createDockingWidgets().
 
static void addAllToolBars (QMainWindow *mainWindow)
 Creates all toolbars of the loaded modules by calling addToolBars().
 
static AppModuleInterfacefindByFile (const QString &filename)
 Find the instance handling the file using the file suffix.
 
static QString getFileTypeFilters (bool all_files)
 Gets the filter string for the open file dialog.
 
static AppModuleInterfaceselectDialog (const QString &title, QSettings *settings, QWidget *parent=nullptr)
 Determined if this module handles this mime type.
 
static QAbstractItemModel * getListModel (bool file_only, QObject *parent)
 Gets a list model from the available instances.
 

Static Public Attributes

static OpenFileClosure callbackOpenFile
 Holds a callback to open a file in the application.
 

Protected Member Functions

virtual MultiDocInterfacecreateWidget (QWidget *parent) const
 Creates child of the passed parent (i.e. QMdiArea).
 

Detailed Description

Base/Interface class for application modules.

This class should provide functionality for loading libraries dynamically and creating implementations

Member Typedef Documentation

◆ DockWidgetList

typedef QList<QDockWidget*> sf::AppModuleInterface::DockWidgetList

Type definition for containing dock widgets.

◆ Map

Map type for the application modules to their names.

◆ OpenFileClosure

Type definition for the callback closure.

Member Enumeration Documentation

◆ InitializeStage

Stages for a module.

Enumerator
Uninitialize 

Application is going to shutdown.

Initialize 

Application is starting up and module can configure.

Finalize 

All modules are done initializing and processing can start.

◆ MenuType

Type of menu items to collect.

Enumerator
Settings 
View 
Tools 

Constructor & Destructor Documentation

◆ AppModuleInterface()

sf::AppModuleInterface::AppModuleInterface ( const Parameters )
explicit

Constructor for passing general structure for derived classes.

◆ ~AppModuleInterface()

sf::AppModuleInterface::~AppModuleInterface ( )
override

Virtual destructor for derived classes.

Member Function Documentation

◆ addAllMenuItems()

static void sf::AppModuleInterface::addAllMenuItems ( MenuType  menuType,
QMenu *  menu 
)
static

Adds items from all modules to this menu.

Parameters
menuTypeType of menu items to add.
menuMenu to add the actions/menus to.

◆ addAllPropertyPages()

static void sf::AppModuleInterface::addAllPropertyPages ( PropertySheetDialog sheet)
static

Adds property pages from all modules to the passed sheet.

◆ addAllToolBars()

static void sf::AppModuleInterface::addAllToolBars ( QMainWindow *  mainWindow)
static

Creates all toolbars of the loaded modules by calling addToolBars().

See also
addToolBars()

◆ addFileType() [1/3]

void sf::AppModuleInterface::addFileType ( const QMimeType &  mime)

Adds a file type using the passed QMimeType instance.

Parameters
mimeMime as a string like 'text/plain'.

◆ addFileType() [2/3]

void sf::AppModuleInterface::addFileType ( const QString &  mime)

Adds a file type handled by this instance.

Parameters
mimeMime as a string like 'text/plain'.

◆ addFileType() [3/3]

void sf::AppModuleInterface::addFileType ( const QString &  name,
const QString &  suffix 
)

Adds a file type handled by this instance.

Parameters
nameName of this file type.
suffixFile suffix like 'txt'

◆ addMenuItems()

virtual void sf::AppModuleInterface::addMenuItems ( MenuType  menuType,
QMenu *  menu 
)
virtual

Adds menu items for the passed type of menu.

Reimplemented in sf::ProjectAppModule.

◆ addPropertyPages()

virtual void sf::AppModuleInterface::addPropertyPages ( PropertySheetDialog sheet)
pure virtual

◆ addToolBars()

virtual void sf::AppModuleInterface::addToolBars ( QMainWindow *  mainWindow)
virtual

Adds toolbars to the passed main window.

Reimplemented in sf::ProjectAppModule.

◆ createAllDockingWidgets()

static DockWidgetList sf::AppModuleInterface::createAllDockingWidgets ( QWidget *  parent)
static

Creates all docking widgets of the loaded modules by calling createDockingWidgets().

See also
createDockingWidgets()

◆ createChild()

MultiDocInterface * sf::AppModuleInterface::createChild ( QWidget *  parent) const

Calls createChild() and assigns this creating instance for reference.

Parameters
parentParent and owner of the new child.
Returns

◆ createDockingWidgets()

virtual DockWidgetList sf::AppModuleInterface::createDockingWidgets ( QWidget *  parent)
virtual

Creates docking widgets having the passed parent.

Reimplemented in sf::LayoutEditorAppModule.

◆ createWidget()

virtual MultiDocInterface * sf::AppModuleInterface::createWidget ( QWidget *  parent) const
protectedvirtual

Creates child of the passed parent (i.e. QMdiArea).

Parameters
parentParent widget of the returned object.
Returns
MDI child.

Reimplemented in sf::CodeEditorAppModule, sf::TextEditorAppModule, sf::LayoutEditorAppModule, and sf::ScriptAppModule.

◆ documentActivated()

virtual void sf::AppModuleInterface::documentActivated ( MultiDocInterface iface,
bool  yn 
) const
virtual

Called from main window when a document is activated or deactivated.

Parameters
ifaceMDI interface which can be dynamically cast to the actual document.
yn

Reimplemented in sf::LayoutEditorAppModule.

◆ findByFile()

static AppModuleInterface * sf::AppModuleInterface::findByFile ( const QString &  filename)
static

Find the instance handling the file using the file suffix.

Returns
nullptr when not found.

◆ getDescription()

virtual QString sf::AppModuleInterface::getDescription ( ) const
pure virtual

◆ getFileTypeFilters() [1/2]

QString sf::AppModuleInterface::getFileTypeFilters ( ) const

Gets the filter string for a file dialog.

The order of creation using addFileType determines which of the duplicate entries get into open file dialog filter list. Duplicates can appear when an entry is created using a mime type.

Returns
Filter string

◆ getFileTypeFilters() [2/2]

static QString sf::AppModuleInterface::getFileTypeFilters ( bool  all_files)
static

Gets the filter string for the open file dialog.

The order of creation using addFileType determines which of the duplicate entries get into open file dialog filter list. Duplicates can appear when an entry is created using a mime type.

Returns
Filter string

◆ getLibraryFilename()

virtual QString sf::AppModuleInterface::getLibraryFilename ( ) const
pure virtual

◆ getListModel()

static QAbstractItemModel * sf::AppModuleInterface::getListModel ( bool  file_only,
QObject *  parent 
)
static

Gets a list model from the available instances.

Parameters
file_onlyTrue when only Modules handling files are to listed.
parentOwning object.
Returns
The list model.

◆ getMap()

static const Map & sf::AppModuleInterface::getMap ( )
static

Gets the named module map.

◆ getName()

virtual QString sf::AppModuleInterface::getName ( ) const
pure virtual

◆ getSettings()

QSettings * sf::AppModuleInterface::getSettings ( ) const

Gets the settings class passed on creation.

◆ getSvgIconResource()

virtual QString sf::AppModuleInterface::getSvgIconResource ( ) const
virtual

Gets svg icon resource name and can be overridden to change the default.

Reimplemented in sf::CodeEditorAppModule, sf::TextEditorAppModule, sf::LayoutEditorAppModule, sf::ProjectAppModule, sf::ScriptAppModule, sf::ServiceAppModule, and sf::UnitConversionAppModule.

◆ hasFileTypes()

bool sf::AppModuleInterface::hasFileTypes ( ) const

Gets if the instance has file handling types.

Returns
True when handling file types.

◆ initialize()

virtual void sf::AppModuleInterface::initialize ( InitializeStage  stage)
pure virtual

Called when al modules are loaded or when a module added.

Parameters
stageDetermines initialization or uninitialization.

Implemented in sf::CodeEditorAppModule, sf::TextEditorAppModule, sf::LayoutEditorAppModule, sf::ProjectAppModule, sf::ScriptAppModule, sf::ServiceAppModule, and sf::UnitConversionAppModule.

◆ initializeInstances()

static size_t sf::AppModuleInterface::initializeInstances ( InitializeStage  stage)
static

Initializes all uninitialized instances or visa versa.

Parameters
stageDetermines what is done.
Returns
Amount of initialized instances.

◆ instantiate()

static void sf::AppModuleInterface::instantiate ( QSettings *  settings,
QObject *  parent 
)
static

Creates instances of all available/loaded interface implementations.

◆ openFile()

MultiDocInterface * sf::AppModuleInterface::openFile ( const QString &  filename,
AppModuleInterface ami = nullptr 
) const

Makes the application open a file.

Parameters
filenameName of file to open.
amiForce file, even when empty to open using this module.
Returns
Not null when the type of document was handled.

◆ selectDialog()

static AppModuleInterface * sf::AppModuleInterface::selectDialog ( const QString &  title,
QSettings *  settings,
QWidget *  parent = nullptr 
)
static

Determined if this module handles this mime type.

Returns
nullptr when cancelled

Member Data Documentation

◆ callbackOpenFile

OpenFileClosure sf::AppModuleInterface::callbackOpenFile
static

Holds a callback to open a file in the application.


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