HAL
hal::gui_utility Namespace Reference

Classes

class  NumeratedString
 

Enumerations

enum  mSortMechanism { lexical = 0 , natural = 1 , numerated = 2 }
 

Functions

void ensureOnScreen (QWidget *w)
 (Fully) displays the widget by moving it. More...
 
bool applyColorStyle (QString &svg_data, const QString &color_style)
 
void changeSvgColor (QString &svg_data, const QColor &from, const QColor &to)
 
void changeAllSvgColors (QString &svg_data, const QColor &to)
 
QIcon getStyledSvgIcon (const QString &from_to_colors_enabled, const QString &svg_path, QString from_to_colors_disabled=QString())
 
ModulefirstCommonAncestor (std::unordered_set< Module * > modules, const std::unordered_set< Gate * > &gates)
 
ModulefirstCommonAncestor (Module *m1, Module *m2)
 
QSet< u32parentModules (Gate *g)
 
QSet< u32parentModules (Module *m)
 
 Q_ENUM_NS (mSortMechanism)
 
bool naturalOrderCompare (const QString &a, const QString &b)
 
bool lexicalOrderCompare (const QString &a, const QString &b)
 
bool numeratedOrderCompare (const QString &a, const QString &b)
 
int numericStringCompare (QString a_num, QString b_num)
 
int compare (mSortMechanism mechanism, QString a, QString b)
 

Enumeration Type Documentation

◆ mSortMechanism

An enum for convenience purposes. Used in the compare function to determine which compare criteria should be used.

Enumerator
lexical 
natural 
numerated 

Definition at line 59 of file sort.h.

Function Documentation

◆ applyColorStyle()

bool hal::gui_utility::applyColorStyle ( QString svg_data,
const QString color_style 
)

◆ changeAllSvgColors()

void hal::gui_utility::changeAllSvgColors ( QString svg_data,
const QColor to 
)

Replaces all colors within given svg data to a new specified color.

Parameters
svg_data- The svg data as a string (e.g. read from a file)
to- The new color.

Definition at line 18 of file graphics.cpp.

References Qt::CaseInsensitive, QString::replace(), and hal::core_strings::to().

◆ changeSvgColor()

void hal::gui_utility::changeSvgColor ( QString svg_data,
const QColor from,
const QColor to 
)

Replaces a color within given svg data to a new specified color.

Parameters
svg_data- The svg data as a string (e.g. read from a file)
from- The color to replace.
to- The new color.

Definition at line 12 of file graphics.cpp.

References from, QString::replace(), and hal::core_strings::to().

◆ compare()

int hal::gui_utility::compare ( mSortMechanism  mechanism,
QString  a,
QString  b 
)

Compares two strings using a specific comparison criteria.

Parameters
mechanism- The criteria by which the 2 strings should be compared with.
a- The first string to compare.
b- The second string to compare.
Returns
True if a < b, false otherwise.

Definition at line 153 of file sort.cpp.

References lexical, lexicalOrderCompare(), natural, naturalOrderCompare(), numerated, and numeratedOrderCompare().

Referenced by hal::ContextProxyModel::lessThan(), hal::GatelibraryProxyModel::lessThan(), hal::GroupingProxyModel::lessThan(), hal::ModuleProxyModel::lessThan(), hal::SelectionTreeProxyModel::lessThan(), hal::GateSelectProxy::lessThan(), and hal::ModuleSelectProxy::lessThan().

◆ firstCommonAncestor() [1/2]

Module * hal::gui_utility::firstCommonAncestor ( Module m1,
Module m2 
)

Finds the first common ancestor of both modules by first saving every parent module of m1 until it reachs the "final" top module and then going step by step through every immediate parent of m2. The first hit that is found is returned.

Parameters
m1- The first module.
m2- The second module.
Returns
The first common ancestor. When no common ancestor is found, a nullpointer is returned.

Definition at line 15 of file netlist.cpp.

References hal::Module::get_id(), and hal::Module::get_parent_module().

◆ firstCommonAncestor() [2/2]

Module * hal::gui_utility::firstCommonAncestor ( std::unordered_set< Module * >  modules,
const std::unordered_set< Gate * > &  gates 
)

Finds the first common ancestor of a set of modules and gates. The gates are resolved to their corresponding modules and then searching pairwise (all modules with the current first common acestor at the time) for the "real" first common ancestor of all modules.

Parameters
modules- The set of modules for which the first common ancestor shall be found.
gates- The set of gates for which the first common accestor shall be found.
Returns
- The common ancestor for both the modules and the gates. If no ancestor is found, a nullpointer is returned.

Definition at line 34 of file netlist.cpp.

References test_plugin::g, and hal::Module::get_parent_module().

Referenced by hal::NetlistRelay::addToModuleDialog().

◆ getStyledSvgIcon()

QIcon hal::gui_utility::getStyledSvgIcon ( const QString from_to_colors_enabled,
const QString svg_path,
QString  from_to_colors_disabled = QString() 
)

Reads svg data from a file and styles it (replacing colors) according to a format string. When no styling is necessary, an empty string can be passed. The result is then converted into an icon and returned.

Parameters
from_to_colors- The format string in the form "from -> to" (e.g.: "all -> #E4E4E4").
svg_path- The path to the svg file.
Returns
The (perhabs styled) icon.

Definition at line 60 of file graphics.cpp.

References applyColorStyle(), file, QString::isEmpty(), QIODevice::ReadOnly, and QString::toUtf8().

Referenced by hal::GatelibraryContentWidget::activate(), hal::CommentWidget::CommentWidget(), hal::ContentFrame::ContentFrame(), hal::ContextManagerWidget::ContextManagerWidget(), hal::ModuleSelectModel::data(), hal::ContextManagerWidget::enableSearchbar(), hal::GroupingManagerWidget::enableSearchbar(), hal::MainWindow::enableUndo(), hal::FileActions::FileActions(), hal::FileSelectWidget::FileSelectWidget(), hal::GateLibrarySelection::GateLibrarySelection(), hal::GeneralInfoWizardPage::GeneralInfoWizardPage(), hal::SelectionDetailsIconProvider::getIcon(), hal::GroupingManagerWidget::GroupingManagerWidget(), hal::GroupingManagerWidget::handleCurrentChanged(), hal::PythonEditor::handleCurrentTabChanged(), hal::SelectionDetailsIconProvider::handleModuleColorChanged(), hal::PythonEditor::handleSearchbarTextEdited(), hal::SelectionDetailsWidget::handleSelectionUpdate(), hal::ImportNetlistDialog::ImportNetlistDialog(), hal::ModuleWidget::ModuleWidget(), hal::NewProjectDialog::NewProjectDialog(), hal::PluginParameterFileDialog::PluginParameterFileDialog(), hal::PluginParameterNodeDialog::PluginParameterNodeDialog(), hal::PythonEditor::PythonEditor(), hal::ExpandingListButton::repolish(), hal::GuiPluginManager::repolish(), hal::GetInTouchItem::repolish(), hal::OpenFileWidget::repolish(), hal::RecentFileItem::repolish(), hal::Searchbar::Searchbar(), hal::SelectionDetailsWidget::SelectionDetailsWidget(), hal::LoggerWidget::setupToolbar(), hal::GatelibraryContentWidget::toggleReadOnlyMode(), hal::GatelibraryContentWidget::toggleSelection(), hal::GuiPluginDelegate::updateQss(), hal::ContextManagerWidget::updateSearchIcon(), hal::ModuleWidget::updateSearchIcon(), and hal::PythonEditor::updateSearchIcon().

◆ lexicalOrderCompare()

bool hal::gui_utility::lexicalOrderCompare ( const QString a,
const QString b 
)

Compares two strings by the lexical order critera (e.g. z11 < z2).

Parameters
a- First string to compare
b- Second string to compare
Returns
True if a < b, false otherwise.

Definition at line 130 of file sort.cpp.

Referenced by compare().

◆ naturalOrderCompare()

bool hal::gui_utility::naturalOrderCompare ( const QString a,
const QString b 
)

Compares two strings by the natural order critera (e.g. z2 < z11).

Parameters
a- First string to compare.
b- Second string to compare.
Returns
True if a < b, false otherwise.

Definition at line 40 of file sort.cpp.

References QString::clear(), QString::constBegin(), QChar::isNull(), QChar::isNumber(), and numericStringCompare().

Referenced by compare().

◆ numeratedOrderCompare()

bool hal::gui_utility::numeratedOrderCompare ( const QString a,
const QString b 
)

Compares two strings firstly by their value without any digits. If these parts are the same, the numbers the strings contained are compared.

Parameters
a- The first string to compare.
b- The second string to compare.
Returns
True if a < b, false otherwise.

Definition at line 104 of file sort.cpp.

References QList::at(), hal::gui_utility::NumeratedString::mNumList, hal::gui_utility::NumeratedString::mRemainder, test::n, and QList::size().

Referenced by compare(), and hal::GraphicsModule::ModulePin::operator<().

◆ numericStringCompare()

int hal::gui_utility::numericStringCompare ( QString  a_num,
QString  b_num 
)

Compares two string by its (numerical) value. The smaller string is filled with "0"s until it matches the size of the longer string.

Parameters
a_num- First string to compare.
b_num- second string to compare.
Returns
An integer less than, equal to, or greater than zero if a_num is less than, equal to, or greater than b_num.

Definition at line 135 of file sort.cpp.

References QString::compare(), QString::rightJustified(), and QString::size().

Referenced by naturalOrderCompare().

◆ parentModules() [1/2]

QSet< u32 > hal::gui_utility::parentModules ( Gate g)

Returns all parent modules for a given gate.

Parameters
g- The gate for which all parent modules are required.
Returns
All parent modules up to the top module.

Definition at line 84 of file netlist.cpp.

References test_plugin::g, hal::Module::get_id(), and QSet::insert().

◆ parentModules() [2/2]

QSet< u32 > hal::gui_utility::parentModules ( Module m)

Retirms all parent modules for a given module by iteratively going through every immediate parent module until the top module is reached.

Parameters
m- The module for which all parent modules are required.
Returns
All parent modules up to the top module.

Definition at line 73 of file netlist.cpp.

References hal::Module::get_id(), hal::Module::get_parent_module(), and QSet::insert().

◆ Q_ENUM_NS()

hal::gui_utility::Q_ENUM_NS ( mSortMechanism  )