items.views#

Base views used to show bookmark, asset, and file items.

The view uses ItemModel for getting the item data, ItemDelegate to paint the items.

BaseItemView is a customised QListView widget augmented by InlineIconView (adds inline icon functionality), and ThreadedItemView that implement threading related functionality.

Classes:

BaseItemView([icon, parent])

The base view of all subsequent item views.

DragPixmapFactory(pixmap, text[, parent])

Widget used to define the appearance of an item being dragged.

DropIndicatorWidget([parent])

Widgets responsible for drawing an overlay.

FilterOnOverlayWidget([parent])

An indicator widget drawn on top of the list widgets to signal if a model has filters set or if it requires a refresh.

InlineIconView([icon, parent])

Adds multi-toggle and clickable in-line icons to BaseItemView.

ItemDrag(index, widget)

A utility class used to start a drag operation.

ListsWidget([parent])

This stacked widget contains the main bookmark, asset, file and favourite item views.

ProgressWidget([parent])

Widget responsible for indicating files are being loaded.

ThreadedItemView([icon, parent])

Extends the InlineIconView with the methods used to interface with threads.

ThumbnailsContextMenu(index[, parent])

Context menu associated with thumbnail actions.

class bookmarks.items.views.BaseItemView(icon='icon_bw', parent=None)[source]#

Bases: QTableView

The base view of all subsequent item views.

Miscellaneous:

ContextMenu

alias of NotImplementedError

Delegate

alias of NotImplementedError

Classes:

Methods:

activate(index)

This method is called in response to a user action and is used to mark an item active.

buttons_hidden()

Returns the visibility of the inline icon buttons.

contextMenuEvent(event)

Custom context menu event.

delay_restore_selection()

Delays getting the saved selection from the user settings file.

delay_save_selection()

Delays saving the current item selection to the user settings file to reduce the number of file writes.

dragMoveEvent(event)

Drag move events checks source validity against available drop actions.

dropEvent(event)

Event handler.

eventFilter(widget, event)

Event filter handler.

get_hint_string()

Returns an informative hint text.

get_source_model()

Returns the model class associated with this view.

get_status_string()

Returns an informative string to indicate if the list has hidden items.

init_buttons_hidden()

Restore the previous state of the inline icon buttons.

init_model()

Add a model to the view.

keyPressEvent(event)

Key press event handler.

key_down()

Custom action on down arrow key-press.

key_enter()

Custom key action

key_space()

Custom key action.

key_tab()

Custom key action

key_up()

Custom action to perform when the up arrow is pressed on the keyboard.

mouseDoubleClickEvent(event)

Custom doubleclick event.

mousePressEvent(event)

Deselect the current index when clicked on an empty space.

mouseReleaseEvent(event)

Event handler.

paint_hint(widget, event)

Paints the hint message.

paint_loading(widget, event)

Paints the hint message.

paint_status_message(widget, event)

Displays a visual hint for the user to indicate if the list has hidden items.

repaint_visible_rows()

Slot used to repaint all currently visible items.

reset_row_layout(*args, **kwargs)

Re-initializes the rows to apply size and row height changes.

resizeEvent(event)

Event handler.

restore_selection()

Slot called to reselect a previously saved selection.

save_selection()

Saves the current selection to the user settings file.

select_item(v[, role])

Select an item in the viewer.

set_buttons_hidden(val)

Sets the visibility of the inline icon buttons.

set_row_size(v)

Sets the row size.

showEvent(event)

Show event handler.

show_item(v[, role, update, limit])

Show an item in the viewer.

startDrag(supported_actions)

Drag action start.

toggle_item_flag(index, flag[, state, ...])

Sets the index's filter flag value based on the passed state.

update(index)

This slot is used by all threads to repaint/update the given index after it's thumbnail or file information has been loaded.

wheelEvent(event)

Custom wheel event responsible for scrolling the list.

Attributes:

customContextMenuRequested(*args, **kwargs)

Emitted when the user shift+right-clicks on the view.

interruptRequested(*args, **kwargs)

Called when the user requests model data load by pressing the ESC key.

resized(*args, **kwargs)

Signals window size change

ContextMenu#

alias of NotImplementedError

Delegate#

alias of NotImplementedError

ThumbnailContextMenu#

alias of ThumbnailsContextMenu Methods:

setup()

Creates the context menu.

activate(index)[source]#

This method is called in response to a user action and is used to mark an item active.

buttons_hidden()[source]#

Returns the visibility of the inline icon buttons.

contextMenuEvent(event)[source]#

Custom context menu event.

delay_restore_selection()[source]#

Delays getting the saved selection from the user settings file.

delay_save_selection()[source]#

Delays saving the current item selection to the user settings file to reduce the number of file writes.

dragMoveEvent(event)[source]#

Drag move events checks source validity against available drop actions.

dropEvent(event)[source]#

Event handler.

eventFilter(widget, event)[source]#

Event filter handler.

get_hint_string()[source]#

Returns an informative hint text.

get_source_model()[source]#

Returns the model class associated with this view.

get_status_string()[source]#

Returns an informative string to indicate if the list has hidden items.

init_buttons_hidden()[source]#

Restore the previous state of the inline icon buttons.

init_model()[source]#

Add a model to the view.

The ItemModel subclasses are wrapped in a QSortFilterProxyModel. All the necessary internal signal-slot connections needed for the proxy, model and the view to communicate are made here.

keyPressEvent(event)[source]#

Key press event handler.

We’re defining the default behaviour of the list-items here, including defining the actions needed to navigate the list using keyboard presses.

key_down()[source]#

Custom action on down arrow key-press.

We’re implementing a continuous scroll: when reaching the last item in the list, we’ll jump to the beginning, and vice-versa.

key_enter()[source]#

Custom key action

key_space()[source]#

Custom key action.

key_tab()[source]#

Custom key action

key_up()[source]#

Custom action to perform when the up arrow is pressed on the keyboard.

We’re implementing a continuous scroll: when reaching the last item in the list, we’ll jump to the beginning, and vice-versa.

mouseDoubleClickEvent(event)[source]#

Custom doubleclick event.

A double click can activate an item, or it can trigger an edit event. As each item is associated with multiple editors we have to inspect the double click location before deciding what action to take.

mousePressEvent(event)[source]#

Deselect the current index when clicked on an empty space.

mouseReleaseEvent(event)[source]#

Event handler.

paint_hint(widget, event)[source]#

Paints the hint message.

paint_loading(widget, event)[source]#

Paints the hint message.

paint_status_message(widget, event)[source]#

Displays a visual hint for the user to indicate if the list has hidden items.

repaint_visible_rows()[source]#

Slot used to repaint all currently visible items.

reset_row_layout(*args, **kwargs)[source]#

Re-initializes the rows to apply size and row height changes.

resizeEvent(event)[source]#

Event handler.

restore_selection()[source]#

Slot called to reselect a previously saved selection.

save_selection()[source]#

Saves the current selection to the user settings file.

select_item(v, role=QtCore.Qt.DisplayRole)[source]#

Select an item in the viewer.

set_buttons_hidden(val)[source]#

Sets the visibility of the inline icon buttons.

set_row_size(v)[source]#

Sets the row size.

Parameters:

v (int) – The new row size

showEvent(event)[source]#

Show event handler.

show_item(v, role=QtCore.Qt.DisplayRole, update=True, limit=10000)[source]#

Show an item in the viewer.

Parameters:
  • v (any) – A value to match.

  • role (QtCore.Qt.ItemRole) – An item data role.

  • update (bool) – Refreshes the model if True (the default).

  • limit (int) – Maximum item search number.

startDrag(supported_actions)[source]#

Drag action start.

toggle_item_flag(index, flag, state=None, commit_now=True)[source]#

Sets the index’s filter flag value based on the passed state.

We’re using the method to mark items archived, or favourite and save the changes to the database and the user settings file.

Parameters:
  • index (QModelIndex) – Model index.

  • flag (int) – A filter flag, e.g. MarkedAsArchived.

  • state (bool) – Pass an explicit state value. Defaults to None.

  • commit_now (bool) – When True, commits database values immediately.

Returns:

The key used to find and match items.

Return type:

str

update(index)[source]#

This slot is used by all threads to repaint/update the given index after it’s thumbnail or file information has been loaded.

An actual repaint event will only trigger if the index is visible in the view.

wheelEvent(event)[source]#

Custom wheel event responsible for scrolling the list.

customContextMenuRequested(*args, **kwargs)#

Emitted when the user shift+right-clicks on the view. Use this to show DCC specific context menus.

interruptRequested(*args, **kwargs)#

Called when the user requests model data load by pressing the ESC key.

resized(*args, **kwargs)#

Signals window size change

class bookmarks.items.views.DragPixmapFactory(pixmap, text, parent=None)[source]#

Bases: QWidget

Widget used to define the appearance of an item being dragged.

Methods:

paintEvent(event)

Event handler.

pixmap(pixmap, text)

Returns the widget as a rendered pixmap.

paintEvent(event)[source]#

Event handler.

classmethod pixmap(pixmap, text)[source]#

Returns the widget as a rendered pixmap.

class bookmarks.items.views.DropIndicatorWidget(parent=None)[source]#

Bases: QWidget

Widgets responsible for drawing an overlay.

Methods:

paintEvent(event)

Event handler.

show()

Shows and sets the size of the widget.

paintEvent(event)[source]#

Event handler.

show()[source]#

Shows and sets the size of the widget.

class bookmarks.items.views.FilterOnOverlayWidget(parent=None)[source]#

Bases: ProgressWidget

An indicator widget drawn on top of the list widgets to signal if a model has filters set or if it requires a refresh.

Methods:

paintEvent(event)

Event handler.

paint_filter_indicator(painter)

Paints the filter indicator.

paint_needs_refresh(painter)

Paints the data status indicator.

showEvent(event)

Event handler.

paintEvent(event)[source]#

Event handler.

paint_filter_indicator(painter)[source]#

Paints the filter indicator.

paint_needs_refresh(painter)[source]#

Paints the data status indicator.

showEvent(event)[source]#

Event handler.

class bookmarks.items.views.InlineIconView(icon='bw_icon', parent=None)[source]#

Bases: BaseItemView

Adds multi-toggle and clickable in-line icons to BaseItemView.

Methods:

add_item_action(index)

Action to execute when the add item icon is clicked.

clickable_rectangle_event(event)

Handle mouse press & release events on an item's interactive rectangle.

edit_item_action(index)

Action to execute when the edit item icon is clicked.

enterEvent(event)

Event handler.

inline_icons_count()

Inline buttons count.

leaveEvent(event)

Event handler.

mouseMoveEvent(event)

InlineIconView's mouse move event is responsible for handling the multi-toggle operations and repainting the current index under the mouse.

mousePressEvent(event)

The InlineIconView's mousePressEvent initiates multi-row flag toggling.

mouseReleaseEvent(event)

Concludes InlineIconView's multi-item toggle operation, and resets the associated variables.

reset_multi_toggle()

Resets the multi-toggle state.

add_item_action(index)[source]#

Action to execute when the add item icon is clicked.

clickable_rectangle_event(event)[source]#

Handle mouse press & release events on an item’s interactive rectangle.

The clickable rectangles are defined by and stored by the item delegate. See get_clickable_rectangles().

We’re implementing filtering by reacting to clicks on item labels: shift modifier will add a _positive_ filter and hide all items not containing the clicked rectangle’s text content.

The alt and control modifiers will add a negative filter and hide all items containing the clicked rectangle’s text content.

edit_item_action(index)[source]#

Action to execute when the edit item icon is clicked.

enterEvent(event)[source]#

Event handler.

inline_icons_count()[source]#

Inline buttons count.

leaveEvent(event)[source]#

Event handler.

mouseMoveEvent(event)[source]#

InlineIconView’s mouse move event is responsible for handling the multi-toggle operations and repainting the current index under the mouse.

mousePressEvent(event)[source]#

The InlineIconView’s mousePressEvent initiates multi-row flag toggling.

This event is responsible for setting multi_toggle_pos, the start position of the toggle, multi_toggle_state & multi_toggle_flag the modes of the toggle, based on the state of the state and location of the clicked item.

mouseReleaseEvent(event)[source]#

Concludes InlineIconView’s multi-item toggle operation, and resets the associated variables.

The inline icon buttons are also triggered here. We’re using the delegate’s get_rectangles function to determine which icon was clicked.

reset_multi_toggle()[source]#

Resets the multi-toggle state.

class bookmarks.items.views.ItemDrag(index, widget)[source]#

Bases: QDrag

A utility class used to start a drag operation.

class bookmarks.items.views.ListsWidget(parent=None)[source]#

Bases: QStackedWidget

This stacked widget contains the main bookmark, asset, file and favourite item views.

Methods:

setCurrentIndex(idx)

Sets the current index of the ListsWidget.

showEvent(event)

Event handler.

setCurrentIndex(idx)[source]#

Sets the current index of the ListsWidget.

Parameters:

idx (int) – The index of the widget to set.

showEvent(event)[source]#

Event handler.

class bookmarks.items.views.ProgressWidget(parent=None)[source]#

Bases: QWidget

Widget responsible for indicating files are being loaded.

Methods:

mousePressEvent(event)

Event handler.

paintEvent(event)

Event handler.

set_message(text)

Sets the message to be displayed when saving the widget.

showEvent(event)

Event handler.

mousePressEvent(event)[source]#

Event handler.

paintEvent(event)[source]#

Event handler.

set_message(text)[source]#

Sets the message to be displayed when saving the widget.

showEvent(event)[source]#

Event handler.

class bookmarks.items.views.ThreadedItemView(icon='bw_icon', parent=None)[source]#

Bases: InlineIconView

Extends the InlineIconView with the methods used to interface with threads.

Methods:

init_model(*args, **kwargs)

The methods responsible for connecting the associated item model with the view.

init_threads()

Starts and connects the threads.

queue_visible_indexes(**kwargs)

Function wrapper.

queued_row_repaint()

Process a repaint request.

save_visible_rows(*args, **kwargs)

Cache the currently visible rows.

start_delayed_queue_timer(*args, **kwargs)

Starts the delayed queue timer.

update_row(ref)

Queues an update request by the threads for later processing.

init_model(*args, **kwargs)[source]#

The methods responsible for connecting the associated item model with the view.

init_threads()[source]#

Starts and connects the threads.

queue_visible_indexes(**kwargs)#

Function wrapper.

queued_row_repaint()[source]#

Process a repaint request.

save_visible_rows(*args, **kwargs)[source]#

Cache the currently visible rows.

start_delayed_queue_timer(*args, **kwargs)[source]#

Starts the delayed queue timer.

update_row(ref)[source]#

Queues an update request by the threads for later processing.

class bookmarks.items.views.ThumbnailsContextMenu(index, parent=None)[source]#

Bases: BaseContextMenu

Context menu associated with thumbnail actions.

Methods:

setup()

Creates the context menu.

setup()[source]#

Creates the context menu.