browser

class jukeboxcore.gui.widgets.browser.AbstractLevel(*args, **kwargs)[source]

Bases: object

Mixin for QtGui.QWidget for a level of a browser

A level is a widget that should display data of a specific root index of its model. So it can be just a regular view, but it can also be a combobox. It can also emit a signal to state that the level below this one should have a new root index. You are free to emit the signal in whatever case you want.

When subclassing implement AbstractLevel.model_changed(), AbstractLevel.set_root(), AbstractLevel.selected_indexes().

Constructs a new level. All arguments will be passed on.

Raises:None
new_root = <PySide.QtCore.Signal object at 0x0000000004056030>

This signal says that the level under this one should update its root index to the one of the signal.

set_model(m)[source]

Set the model for the level

Parameters:m (QtCore.QAbstractItemModel) – the model that the level should use
Returns:None
Return type:None
Raises:None
get_model()[source]

Return the model that the level uses

Returns:the model
Return type:QtCore.QAbstractItemModel|None
Raises:None
model_changed(model)[source]

Abstract method that should handle the case that someone set the model

When a level instance is created, the model is None. So it has to be set afterwards. Then this method will be called and your level should somehow use the model

Parameters:model (QtCore.QAbstractItemModel) – the model that the level should use | None
Returns:None
Return type:None
Raises:NotImplementedError
set_root(index)[source]

Abstract method that should make the level use the given index as root

The index might also be invalid! In that case show an empty level. The index might also be from a different model. In that case change the model of the level:

if self.get_model() != index.model():
    self.set_model(index.model())
Parameters:index (QtCore.QModelIndex) – the new root index
Returns:None
Return type:None
Raises:NotImplementedError
selected_indexes()[source]

Abstract method that should return the “selected” indexes.

Selected does not mean, selected like Qt refers to the term. It just means that this level has some indexes that seam to be of importance right now. E.g. your level is a combobox, then the selected indexes would just consit of the current index. If your level is a regular view, then you could indeed return the selected indexes.

Returns:the ‘selected’ indexes of the level
Return type:list of QtCore.QModelIndex
Raises:NotImplementedError
set_index(index)[source]

Set the current index of the level to the given one

The given index should be the new root for levels below. You should make sure that the new_root signal will be emitted.

Parameters:index (QtCore.QModelIndex) – the new index
Returns:None
Return type:None
Raises:NotImplementedError
class jukeboxcore.gui.widgets.browser.AbstractTreeBrowser(depth, parent=None, flags=0)[source]

Bases: PySide.QtGui.QWidget

A abstract class for a treebrowser

A tree browser can be compared to a column view. The browser uses a tree model and on initialisation creates levels up to a certain depth. Each level displays on level of hierarchy of the model.

When subclassing implement AbstractTreeBrowser.create_level(), AbstractTreeBrowser.add_lvl_to_ui(), AbstractTreeBrowser.create_level() and for headers reimplement AbstractTreeBrowser.create_header()

Constructs an AbstractTreeBrowser

Parameters:
  • depth (int) – the depth of the browser
  • parent (QtGui.QWidget) – the parent of the widget
  • flags (QtCore.Qt.WindowFlags) – the flags for the widget
Raises:

None

build_browser()[source]

Creates all levels and adds them to the ui

Returns:None
Return type:None
Raises:None
create_level(depth)[source]

Create and return a level for the given depth

The model and root of the level will be automatically set by the browser.

Parameters:depth (int) – the depth level that the level should handle
Returns:a new level for the given depth
Return type:jukeboxcore.gui.widgets.browser.AbstractLevel
Raises:NotImplementedError
create_header(depth)[source]

Create and return a widget that will be used as a header for the given depth

Override this method if you want to have header widgets. The default implementation returns None. You can return None if you do not want a header for the given depth

Parameters:depth (int) – the depth level
Returns:a Widget that is used for the header or None
Return type:QtGui.QWidget|None
Raises:None
add_lvl_to_ui(level, header)[source]

Abstract method that is responsible for inserting the level and header into the ui.

Parameters:
Returns:

None

Return type:

None

Raises:

NotImplementedError

set_model(model)[source]

Set all levels’ model to the given one

Parameters:m (QtCore.QAbstractItemModel) – the model that the levels should use
Returns:None
Return type:None
Raises:None
set_root(depth, index)[source]

Set the level’s root of the given depth to index

Parameters:
  • depth (int) – the depth level
  • index (QtCore.QModelIndex) – the new root index
Returns:

None

Return type:

None

Raises:

None

get_level(depth)[source]

Return the level for the given depth

Parameters:depth (int) – the hierarchy level
Returns:the level widget
Return type:AbstractLevel
Raises:None
get_depth()[source]

Return the current depth of the browser

Returns:the hierarchy depth of the browser
Return type:int
Raises:None
selected_indexes(depth)[source]

Get the selected indexes of a certain depth level

Parameters:depth (int) – the depth level
Returns:the selected indexes of the given depth level
Return type:list of QtCore.QModelIndex
Raises:None
set_index(depth, index)[source]

Set the level at the given depth to the given index

Parameters:
  • depth (int) – addresses the level at the given depth
  • index (QtCore.QModelIndex) – the index to set the level to
Returns:

None

Return type:

None

Raises:

None

staticMetaObject = <PySide.QtCore.QMetaObject object at 0x000000000505EE48>
class jukeboxcore.gui.widgets.browser.CBLevel(parent=None)[source]

Bases: jukeboxcore.gui.widgets.browser.AbstractLevel, PySide.QtGui.QComboBox

A level that consists of a simple combobox to be used in a TreeBrowser

Constructs a new cblevel with the given parent

Parameters:parent (QtGui.QWidget) – the parent widget
Raises:None
model_changed(model)[source]

Apply the model to the combobox

When a level instance is created, the model is None. So it has to be set afterwards. Then this method will be called and your level should somehow use the model

Parameters:model (QtCore.QAbstractItemModel) – the model that the level should use
Returns:None
Return type:None
Raises:None
set_root(index)[source]

Set the given index as root index of the combobox

Parameters:index (QtCore.QModelIndex) – the new root index
Returns:None
Return type:None
Raises:None
selected_indexes()[source]

Return the current index

Returns:the current index in a list
Return type:list of QtCore.QModelIndex
Raises:None
current_changed(i)[source]

Slot for when the current index changes. Emits the AbstractLevel.new_root signal.

Parameters:index (int) – the new current index
Returns:None
Return type:None
Raises:None
set_index(index)[source]

Set the current index to the row of the given index

Parameters:index (QtCore.QModelIndex) – the index to set the level to
Returns:None
Return type:None
Raises:None
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x000000000505EA48>
class jukeboxcore.gui.widgets.browser.ComboBoxBrowser(depth, parent=None, flags=0, headers=None)[source]

Bases: jukeboxcore.gui.widgets.browser.AbstractTreeBrowser

A tree browser that has a combo box for every level and a label for every header. The header labels will be next to each combobox.

Constructs a new ComboBoxBrowser with the given depth

Parameters:
  • depth (int) – the depth of the browser
  • parent (QtGui.QWidget) – the parent of the widget
  • flags (QtCore.Qt.WindowFlags) – the flags for the widget
  • headers (list of str|None) – a list of label texts to put for the labels next to the comboboxes the list does not need to have the length of depth. If the list is None, no headers will be created.
Raises:

None

setup_ui()[source]

Create the layouts and set some attributes of the ui

Returns:None
Return type:None
Raises:None
create_level(depth)[source]

Create and return a level for the given depth

The model and root of the level will be automatically set by the browser.

Parameters:depth (int) – the depth level that the level should handle
Returns:a new level for the given depth
Return type:CBLevel
Raises:None
create_header(depth)[source]

Create and return a widget that will be used as a header for the given depth

Override this method if you want to have header widgets. The default implementation returns None. You can return None if you do not want a header for the given depth

Parameters:depth (int) – the depth level
Returns:a Widget that is used for the header or None
Return type:QtGui.QWidget|None
Raises:None
add_lvl_to_ui(level, header)[source]

Insert the level and header into the ui.

Parameters:
Returns:

None

Return type:

None

Raises:

None

staticMetaObject = <PySide.QtCore.QMetaObject object at 0x000000000505EAC8>
class jukeboxcore.gui.widgets.browser.ListLevel(parent=None)[source]

Bases: jukeboxcore.gui.widgets.browser.AbstractLevel, PySide.QtGui.QListView

A level that consists of a listview to be used in a TreeBrowser

Constructs a new listlevel with the given parent

Parameters:parent (QtGui.QWidget) – the parent widget
Raises:None
model_changed(model)[source]

Apply the model to the combobox

When a level instance is created, the model is None. So it has to be set afterwards. Then this method will be called and your level should somehow use the model

Parameters:model (QtCore.QAbstractItemModel) – the model that the level should use
Returns:None
Return type:None
Raises:None
set_root(index)[source]

Set the given index as root index of list

Parameters:index (QtCore.QModelIndex) – the new root index
Returns:None
Return type:None
Raises:None
selected_indexes()[source]

Return the current index

Returns:the current index in a list
Return type:list of QtCore.QModelIndex
Raises:None
currentChanged(current, prev)[source]

Slot for when the current index changes. Emits the AbstractLevel.new_root signal.

Parameters:
  • current (QtGui.QModelIndex) – the new current index
  • current – the previous current index
Returns:

None

Return type:

None

Raises:

None

set_index(index)[source]

Set the current index to the row of the given index

Parameters:index (QtCore.QModelIndex) – the index to set the level to
Returns:None
Return type:None
Raises:None
resizeEvent(event)[source]

Schedules an item layout if resize mode is “adjust”. Somehow this is needed for correctly scaling down items.

The reason this was reimplemented was the CommentDelegate.

Parameters:event (QtCore.QEvent) – the resize event
Returns:None
Return type:None
Raises:None
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x000000000505E8C8>
class jukeboxcore.gui.widgets.browser.ListBrowser(depth, parent=None, flags=0, headers=None)[source]

Bases: jukeboxcore.gui.widgets.browser.AbstractTreeBrowser

A tree browser that has a list view for every level and a label for every header. The header labels will be above each list.

Constructs a new ListBrowser with the given depth

Parameters:
  • depth (int) – the depth of the browser
  • parent (QtGui.QWidget) – the parent of the widget
  • flags (QtCore.Qt.WindowFlags) – the flags for the widget
  • headers (list of str|None) – a list of label texts to put for the labels above the lists the list does not need to have the length of depth. If the list is None or an element is None, no headers will be created.
Raises:

None

setup_ui()[source]

Create the layouts and set some attributes of the ui

Returns:None
Return type:None
Raises:None
create_level(depth)[source]

Create and return a level for the given depth

The model and root of the level will be automatically set by the browser.

Parameters:depth (int) – the depth level that the level should handle
Returns:a new level for the given depth
Return type:jukeboxcore.gui.widgets.browser.AbstractLevel
Raises:None
create_header(depth)[source]

Create and return a widget that will be used as a header for the given depth

Override this method if you want to have header widgets. The default implementation returns None. You can return None if you do not want a header for the given depth

Parameters:depth (int) – the depth level
Returns:a Widget that is used for the header or None
Return type:QtGui.QWidget|None
Raises:None
add_lvl_to_ui(level, header)[source]

Insert the level and header into the ui.

Parameters:
Returns:

None

Return type:

None

Raises:

None

staticMetaObject = <PySide.QtCore.QMetaObject object at 0x000000000505E888>
class jukeboxcore.gui.widgets.browser.CommentBrowser(depth, parent=None, flags=0, headers=None)[source]

Bases: jukeboxcore.gui.widgets.browser.ListBrowser

A list browser that has a list view for every level and a label for every header. The header labels will be above each list. The lists are designed to display jukeboxcore.gui.djitemdata.NoteItemData.

Constructs a new ListBrowser with the given depth

Parameters:
  • depth (int) – the depth of the browser
  • parent (QtGui.QWidget) – the parent of the widget
  • flags (QtCore.Qt.WindowFlags) – the flags for the widget
  • headers (list of str|None) – a list of label texts to put for the labels above the lists the list does not need to have the length of depth. If the list is None or an element is None, no headers will be created.
Raises:

None

create_level(depth)[source]

Create and return a level for the given depth

The model and root of the level will be automatically set by the browser.

Parameters:depth (int) – the depth level that the level should handle
Returns:a new level for the given depth
Return type:jukeboxcore.gui.widgets.browser.AbstractLevel
Raises:None
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x000000000505EB48>