templates#

The module used to create job and asset items based on zip template files.

The template files usually contain a folder structure used to define the skeleton of a project file structure.

The list of template files are read from/and saved to the folder returned by get_template_folder().

The template mode can be any arbitrary string - we’re defining them as JobTemplateMode and AssetTemplateMode.

Classes:

TemplateContextMenu(index[, parent])

Context menu associated with the TemplatesWidget.

TemplateListDelegate([parent])

Delegate associated with TemplateListWidget.

TemplateListWidget([mode, parent])

Widget used to display a list of zip template files associated with the given mode.

TemplatesPreviewWidget([parent])

List widget used to peak into the contents of a zip template file.

TemplatesWidget(mode[, parent])

Main template list with a template content preview widget.

Functions:

get_template_folder(mode)

Returns the path where the ZIP template files are stored, associated with the given mode.

class bookmarks.templates.TemplateContextMenu(index, parent=None)[source]#

Bases: BaseContextMenu

Context menu associated with the TemplatesWidget.

Methods:

add_menu()

Add action menu.

refresh_menu()

Refresh action menu.

remove_menu()

Remove action menu.

reveal_menu()

Reveal action menu.

setup()

Creates the context menu.

add_menu()[source]#

Add action menu.

refresh_menu()[source]#

Refresh action menu.

remove_menu()[source]#

Remove action menu.

reveal_menu()[source]#

Reveal action menu.

setup()[source]#

Creates the context menu.

class bookmarks.templates.TemplateListDelegate(parent=None)[source]#

Bases: ListWidgetDelegate

Delegate associated with TemplateListWidget.

Methods:

createEditor(parent, option, index)

Custom editor for editing the template's name.

createEditor(parent, option, index)[source]#

Custom editor for editing the template’s name.

class bookmarks.templates.TemplateListWidget(mode=JobTemplateMode, parent=None)[source]#

Bases: ListWidget

Widget used to display a list of zip template files associated with the given mode.

Methods:

contextMenuEvent(event)

Event handler.

create(name, destination)

The main method used to expand the selected zip template into a destination folder.

dropMimeData(index, data, action)

Returns the drop mime data.

eventFilter(widget, event)

Event filter handler.

init_data()

Loads the available zip template files from the template directory.

mode()

The TemplateWidget's current mode.

showEvent(event)

Event handler.

sizeHint()

Returns a size hint.

supportedDropActions()

Returns the supported drop actions.

update_name(index)

Updates the model data when a template's name has been edited.

contextMenuEvent(event)[source]#

Event handler.

create(name, destination)[source]#

The main method used to expand the selected zip template into a destination folder.

Parameters
  • name (str) – The name of the folder the contents of the zip archive will be saved to.

  • destination (str) – The destination folder where the new asset will be expanded to.

dropMimeData(index, data, action)[source]#

Returns the drop mime data.

eventFilter(widget, event)[source]#

Event filter handler.

init_data()[source]#

Loads the available zip template files from the template directory.

mode()[source]#

The TemplateWidget’s current mode.

Returns

A template mode, e.g. AssetTable or JobTemplateMode.

Return type

str

showEvent(event)[source]#

Event handler.

sizeHint()[source]#

Returns a size hint.

supportedDropActions()[source]#

Returns the supported drop actions.

update_name(index)[source]#

Updates the model data when a template’s name has been edited.

class bookmarks.templates.TemplatesPreviewWidget(parent=None)[source]#

Bases: QListWidget

List widget used to peak into the contents of a zip template file.

Methods:

eventFilter(widget, event)

Event filter handler.

init_data(files)

Slot responsible for displaying a list of file names.

sizeHint()

Returns a size hint.

eventFilter(widget, event)[source]#

Event filter handler.

init_data(files)[source]#

Slot responsible for displaying a list of file names.

Parameters

files (tuple) – A list of file names.

sizeHint()[source]#

Returns a size hint.

class bookmarks.templates.TemplatesWidget(mode, parent=None)[source]#

Bases: QSplitter

Main template list with a template content preview widget.

Methods:

itemActivated(selectionList)

Slot called when a template was selected by the user.

mode()

The current template mode.

sizeHint()

Returns a size hint.

itemActivated(selectionList)[source]#

Slot called when a template was selected by the user.

It will load and display the contents of the zip file in the template_contents_widget.

Parameters

selectionList (QItemSelection) – A QItemSelection instance of QModelIndexes.

mode()[source]#

The current template mode.

sizeHint()[source]#

Returns a size hint.

bookmarks.templates.get_template_folder(mode)[source]#

Returns the path where the ZIP template files are stored, associated with the given mode.

Parameters

mode (str) – A template mode, e.g. JobTemplateMode.

Returns

Path to the folder where the template zip files are stored.

Return type

str