##// END OF EJS Templates
Refactoring handling of axes properties (1)...
Refactoring handling of axes properties (1) Creates helper used to determine which properties to set for the graph axes, depending on the type of the data hold (properties will be different if it's scalars/vectors or spectrograms)

File last commit:

r404:40749dfba67d
r916:b92a8e838f6e
Show More
MenuBuilder.cpp
58 lines | 1.5 KiB | text/x-c | CppLexer
Alexandre Leroux
Moves MenuBuilder in a new class
r222 #include "Visualization/operations/MenuBuilder.h"
Q_LOGGING_CATEGORY(LOG_MenuBuilder, "MenuBuilder")
MenuBuilder::MenuBuilder(QMenu *menu)
{
if (menu) {
m_Menus.push(menu);
}
else {
qCCritical(LOG_MenuBuilder()) << QObject::tr("No parent menu has been defined");
}
}
Alexandre Leroux
Disables 'plot' menu when variable data have not been loaded yet
r404 QMenu *MenuBuilder::addMenu(const QString &name, const QIcon &icon)
Alexandre Leroux
Moves MenuBuilder in a new class
r222 {
if (auto currMenu = currentMenu()) {
Alexandre Leroux
Disables 'plot' menu when variable data have not been loaded yet
r404 auto menu = currMenu->addMenu(icon, name);
m_Menus.push(menu);
return menu;
Alexandre Leroux
Moves MenuBuilder in a new class
r222 }
else {
qCCritical(LOG_MenuBuilder()) << QObject::tr("No current menu to attach the new menu");
Alexandre Leroux
Disables 'plot' menu when variable data have not been loaded yet
r404 return nullptr;
Alexandre Leroux
Moves MenuBuilder in a new class
r222 }
}
void MenuBuilder::addSeparator()
{
if (auto currMenu = currentMenu()) {
if (!currMenu->isEmpty()) {
currMenu->addSeparator();
}
}
else {
qCCritical(LOG_MenuBuilder()) << QObject::tr("No current menu to attach the separator");
}
}
void MenuBuilder::closeMenu()
{
if (!m_Menus.isEmpty()) {
if (auto closedMenu = m_Menus.pop()) {
// Purge menu : if the closed menu has no entries, we remove it from its parent (the
// current menu)
if (auto currMenu = currentMenu()) {
if (closedMenu->isEmpty()) {
currMenu->removeAction(closedMenu->menuAction());
}
}
}
}
}
QMenu *MenuBuilder::currentMenu() const
{
return !m_Menus.isEmpty() ? m_Menus.top() : nullptr;
}