LibrePCB Developers Documentation
Loading...
Searching...
No Matches
EditorToolbox Class Referencefinal

The EditorToolbox class provides some useful general purpose methods for editors (i.e. GUI stuff) More...

#include <editortoolbox.h>

+ Collaboration diagram for EditorToolbox:

Public Member Functions

 EditorToolbox ()=delete
 
 EditorToolbox (const EditorToolbox &other)=delete
 
 ~EditorToolbox ()=delete
 
EditorToolboxoperator= (const EditorToolbox &rhs)=delete
 

Static Public Member Functions

static QIcon svgIcon (const QString &file) noexcept
 Load a SVG QIcon which is properly colorized.
 
static void removeFormLayoutRow (QLabel &label) noexcept
 Remove (hide) a whole row in a QFormLayout.
 
static void deleteLayoutItemRecursively (QLayoutItem *item) noexcept
 Delete a QLayout item with all its children.
 
static bool startToolBarTabFocusCycle (QToolBar &toolBar, QWidget &returnFocusToWidget) noexcept
 Set the focus to the first widget of a toolbar and iterate through.
 
static ResourceList getComponentResources (const WorkspaceLibraryDb &db, const ComponentInstance &cmp, const std::optional< Uuid > &filterDev=std::nullopt) noexcept
 Collect all relevant resources for a given component instance.
 
static void addResourcesToMenu (const Workspace &ws, MenuBuilder &mb, const ComponentInstance &cmp, const std::optional< Uuid > &filterDev, QPointer< QWidget > editor, QMenu &root) noexcept
 Add relevant resources of a component instance to a context menu.
 

Static Private Member Functions

static bool removeFormLayoutRow (QLayout &layout, QLabel &label) noexcept
 Helper for removeFormLayoutRow(QLabel&)
 
static void hideLayoutItem (QLayoutItem &item) noexcept
 Helper for removeFormLayoutRow()
 
static void searchAndOpenDatasheet (const Workspace &ws, const QString &mpn, const QString &manufacturer, QPointer< QWidget > parent) noexcept
 Helper for addResourcesToMenu()
 

Detailed Description

The EditorToolbox class provides some useful general purpose methods for editors (i.e. GUI stuff)

Constructor & Destructor Documentation

◆ EditorToolbox() [1/2]

EditorToolbox ( )
delete

◆ EditorToolbox() [2/2]

EditorToolbox ( const EditorToolbox other)
delete

◆ ~EditorToolbox()

~EditorToolbox ( )
delete

Member Function Documentation

◆ operator=()

EditorToolbox & operator= ( const EditorToolbox rhs)
delete

◆ svgIcon()

QIcon svgIcon ( const QString &  file)
staticnoexcept

Load a SVG QIcon which is properly colorized.

Parameters
fileResource file path (e.g. ":/fa/solid/globe.svg")
Returns
A QIcon with the colorized SVG
+ Here is the caller graph for this function:

◆ removeFormLayoutRow() [1/2]

void removeFormLayoutRow ( QLabel &  label)
staticnoexcept

Remove (hide) a whole row in a QFormLayout.

Parameters
labelThe label of the row to remove.
+ Here is the caller graph for this function:

◆ deleteLayoutItemRecursively()

void deleteLayoutItemRecursively ( QLayoutItem *  item)
staticnoexcept

Delete a QLayout item with all its children.

Parameters
itemThe item to delete. Must not be nullptr!
+ Here is the caller graph for this function:

◆ startToolBarTabFocusCycle()

bool startToolBarTabFocusCycle ( QToolBar &  toolBar,
QWidget &  returnFocusToWidget 
)
staticnoexcept

Set the focus to the first widget of a toolbar and iterate through.

  • The tab order of all widgets of the passed toolbar will be configured from left to right resp. top to bottom.
  • After the last widget, the tab order is followed by a custom widget.
  • The first widget of the passed toolbar will get the focus.

Intended for the command toolbar to enter focus from the graphics view, navigate though all the toolbar widgets, and then return the focus back to the graphics view.

Parameters
toolBarThe toolbar to set the focus.
returnFocusToWidgetWidget which shall have the focus after the last widget of the toolbar.
Returns
True if there was at least one widget and the focus has been set. False if there was no widget and the focus was not set.
+ Here is the caller graph for this function:

◆ getComponentResources()

ResourceList getComponentResources ( const WorkspaceLibraryDb db,
const ComponentInstance cmp,
const std::optional< Uuid > &  filterDev = std::nullopt 
)
staticnoexcept

Collect all relevant resources for a given component instance.

Resources will be collected from both the workspace library and the project library.

Parameters
dbWorkspace library database.
cmpComponent instance
filterDevIf provided, only get resources for these devices. Otherwise, resources for all devices are returned.
Returns
List of all relevant resources.
+ Here is the call graph for this function:

◆ addResourcesToMenu()

void addResourcesToMenu ( const Workspace ws,
MenuBuilder mb,
const ComponentInstance cmp,
const std::optional< Uuid > &  filterDev,
QPointer< QWidget >  editor,
QMenu &  root 
)
staticnoexcept

Add relevant resources of a component instance to a context menu.

This calls getComponentResources() and then adds the results to a context menu.

Parameters
wsWorkspace.
mbMenu builder to add the new menu items.
cmpSee getComponentResources().
filterDevSee getComponentResources().
editorParent widget, used for asynchronously opening resources when a menu item is triggered.
rootRoot menu (for ownership).
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFormLayoutRow() [2/2]

bool removeFormLayoutRow ( QLayout &  layout,
QLabel &  label 
)
staticprivatenoexcept

Helper for removeFormLayoutRow(QLabel&)

Parameters
layoutThe layout to look for the label.
labelThe label to remove from the layout.
Return values
trueon success.
falseif the label was not found in a form layout.

◆ hideLayoutItem()

void hideLayoutItem ( QLayoutItem &  item)
staticprivatenoexcept

Helper for removeFormLayoutRow()

Parameters
itemThe item to hide.

◆ searchAndOpenDatasheet()

void searchAndOpenDatasheet ( const Workspace ws,
const QString &  mpn,
const QString &  manufacturer,
QPointer< QWidget >  parent 
)
staticprivatenoexcept

Helper for addResourcesToMenu()

Parameters
wsWorkspace.
mpnPart MPN.
manufacturerPart manufacturer name.
parentParent widget.
+ Here is the call graph for this function:

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