mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
refs #720, ui context menu finetuning
* renaming / formatting * const predefined subdir menus
This commit is contained in:
committed by
Mathew Sutcliffe
parent
017c593b67
commit
89ac38a072
@@ -138,12 +138,12 @@ namespace BlackGui
|
|||||||
if (!sGui->hasWebDataServices()) { this->nestedCustomMenu(menuActions); return; }
|
if (!sGui->hasWebDataServices()) { this->nestedCustomMenu(menuActions); return; }
|
||||||
|
|
||||||
menuActions.addMenuDatabase();
|
menuActions.addMenuDatabase();
|
||||||
menuActions.addMenu(CIcons::databaseEdit16(), "Consolidate with DB data", CMenuAction::pathViewDatabaseMerge());
|
menuActions.addMenu(CIcons::databaseEdit16(), "Consolidate with DB data", CMenuAction::pathViewDatabaseConsolidate());
|
||||||
|
|
||||||
this->m_consolidateAll = menuActions.addAction(this->m_consolidateAll, "All", CMenuAction::pathViewDatabaseMerge(), { this, &CConsolidateWithDbDataMenu::ps_consolidateData });
|
this->m_consolidateAll = menuActions.addAction(this->m_consolidateAll, "All", CMenuAction::pathViewDatabaseConsolidate(), { this, &CConsolidateWithDbDataMenu::ps_consolidateData });
|
||||||
if (mv->hasSelection())
|
if (mv->hasSelection())
|
||||||
{
|
{
|
||||||
this->m_consolidateSelected = menuActions.addAction(this->m_consolidateSelected, "Selected only", CMenuAction::pathViewDatabaseMerge(), { this, &CConsolidateWithDbDataMenu::ps_consolidateSelectedData });
|
this->m_consolidateSelected = menuActions.addAction(this->m_consolidateSelected, "Selected only", CMenuAction::pathViewDatabaseConsolidate(), { this, &CConsolidateWithDbDataMenu::ps_consolidateSelectedData });
|
||||||
}
|
}
|
||||||
this->nestedCustomMenu(menuActions);
|
this->nestedCustomMenu(menuActions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,18 @@ namespace BlackGui
|
|||||||
this->m_action->setEnabled(enabled);
|
this->m_action->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CMenuAction &CMenuAction::subMenuDatabase()
|
||||||
|
{
|
||||||
|
static const CMenuAction subdir(CIcons::appDatabase16(), "Database", CMenuAction::pathViewDatabase());
|
||||||
|
return subdir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CMenuAction &CMenuAction::subMenuSimulator()
|
||||||
|
{
|
||||||
|
static const CMenuAction subdir(CIcons::appSimulator16(), "Simulator", CMenuAction::pathSimulator());
|
||||||
|
return subdir;
|
||||||
|
}
|
||||||
|
|
||||||
QString CMenuAction::getLastPathPart() const
|
QString CMenuAction::getLastPathPart() const
|
||||||
{
|
{
|
||||||
if (this->m_path.contains('/'))
|
if (this->m_path.contains('/'))
|
||||||
@@ -160,6 +172,11 @@ namespace BlackGui
|
|||||||
return getMenuActions(path).size() > 0;
|
return getMenuActions(path).size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMenuAction CMenuActions::addMenu(const CMenuAction &subdirAction)
|
||||||
|
{
|
||||||
|
return this->addMenu(subdirAction.getIcon(), subdirAction.getTitle(), subdirAction.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addMenu(const QString &title, const QString &path)
|
CMenuAction CMenuActions::addMenu(const QString &title, const QString &path)
|
||||||
{
|
{
|
||||||
return this->addMenu(QIcon(), title, path);
|
return this->addMenu(QIcon(), title, path);
|
||||||
@@ -293,22 +310,19 @@ namespace BlackGui
|
|||||||
void CMenuActions::toQMenu(QMenu &menu, bool separateGroups) const
|
void CMenuActions::toQMenu(QMenu &menu, bool separateGroups) const
|
||||||
{
|
{
|
||||||
if (this->m_actions.isEmpty()) { return; }
|
if (this->m_actions.isEmpty()) { return; }
|
||||||
const QStringList keys(this->m_actions.uniqueKeys()); // Sorted ascending
|
const QStringList keys = this->m_actions.uniqueKeys(); // Sorted ascending
|
||||||
QMap<QString, QMenu *> subMenus; // all sub menus
|
|
||||||
|
|
||||||
|
QMap<QString, QMenu *> subMenus; // all sub menus
|
||||||
for (const QString &key : keys)
|
for (const QString &key : keys)
|
||||||
{
|
{
|
||||||
bool addedSeparator = false;
|
bool addedSeparator = false;
|
||||||
const int pathDepth = CMenuActions::pathDepth(key);
|
const int pathDepth = CMenuActions::pathDepth(key); // 0 based
|
||||||
|
|
||||||
QList<CMenuAction> actions;
|
QList<CMenuAction> actions;
|
||||||
QList<CMenuAction> menus;
|
QList<CMenuAction> menus;
|
||||||
this->splitSubMenus(key, actions, menus);
|
this->splitSubMenus(key, actions, menus);
|
||||||
if (actions.isEmpty())
|
if (actions.isEmpty())
|
||||||
{
|
{
|
||||||
// uncomment this if a subdir shall be displayed, even if there are no actions
|
|
||||||
// if (!menus.isEmpty()) { currentMenuForAction(menu, menus.fi, menus, subMenus, key, pathDepth); }
|
|
||||||
|
|
||||||
// No actions directly for that level
|
// No actions directly for that level
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -407,7 +421,7 @@ namespace BlackGui
|
|||||||
CMenuAction CMenuActions::addMenuDatabase()
|
CMenuAction CMenuActions::addMenuDatabase()
|
||||||
{
|
{
|
||||||
if (this->containsMenu(CMenuAction::pathViewDatabase())) { CMenuAction(); }
|
if (this->containsMenu(CMenuAction::pathViewDatabase())) { CMenuAction(); }
|
||||||
return this->addMenu(CIcons::appDatabase16(), "Database", CMenuAction::pathViewDatabase());
|
return this->addMenu(CMenuAction::subMenuDatabase());
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addMenuModelSet()
|
CMenuAction CMenuActions::addMenuModelSet()
|
||||||
@@ -416,17 +430,29 @@ namespace BlackGui
|
|||||||
return this->addMenu(CIcons::appModels16(), "Model set", CMenuAction::pathModelSet());
|
return this->addMenu(CIcons::appModels16(), "Model set", CMenuAction::pathModelSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CMenuActions &CMenuActions::predefinedSubmenus()
|
||||||
|
{
|
||||||
|
static const CMenuActions pd(
|
||||||
|
{
|
||||||
|
CMenuAction::subMenuDatabase(),
|
||||||
|
CMenuAction::subMenuSimulator()
|
||||||
|
});
|
||||||
|
return pd;
|
||||||
|
}
|
||||||
|
|
||||||
QMenu *CMenuActions::currentMenuForAction(QMenu &menu, const CMenuAction &menuAction, const QList<CMenuAction> &menus, QMap<QString, QMenu *> &subMenus, const QString &key, int pathDepth)
|
QMenu *CMenuActions::currentMenuForAction(QMenu &menu, const CMenuAction &menuAction, const QList<CMenuAction> &menus, QMap<QString, QMenu *> &subMenus, const QString &key, int pathDepth)
|
||||||
{
|
{
|
||||||
if (pathDepth < 1) { return &menu; }
|
if (pathDepth < 1) { return &menu; }
|
||||||
|
|
||||||
QMenu *parentMenu = &menu;
|
QMenu *parentMenu = &menu;
|
||||||
if (pathDepth > 1)
|
if (pathDepth > 1)
|
||||||
{
|
{
|
||||||
// find the corresponding submenu. If this is empty the next higher level will be choosen
|
// find the corresponding submenu. If this is empty the next higher level will be choosen
|
||||||
// if not found at all, use top level menu
|
// if not found at all, use top level menu
|
||||||
parentMenu = findUpwardsInMenus(key, subMenus);
|
parentMenu = findUpwardsInMenus(key, subMenus);
|
||||||
if (!parentMenu) { parentMenu = &menu; }
|
if (!parentMenu)
|
||||||
|
{
|
||||||
|
parentMenu = &menu;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// explicity menu?
|
// explicity menu?
|
||||||
@@ -471,7 +497,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (menus.contains(k))
|
if (menus.contains(k))
|
||||||
{
|
{
|
||||||
return menus[key];
|
return menus[k];
|
||||||
}
|
}
|
||||||
k = parentPath(k);
|
k = parentPath(k);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,8 +149,8 @@ namespace BlackGui
|
|||||||
//! Database
|
//! Database
|
||||||
static const QString &pathViewDatabase() { static const QString p("View.10.Database/Database"); return p; }
|
static const QString &pathViewDatabase() { static const QString p("View.10.Database/Database"); return p; }
|
||||||
|
|
||||||
//! Database merge
|
//! Database consolidation
|
||||||
static const QString &pathViewDatabaseMerge() { static const QString p("View.10.Database/Database/Merge"); return p; }
|
static const QString &pathViewDatabaseConsolidate() { static const QString p("View.10.Database/Database/Consolidate"); return p; }
|
||||||
|
|
||||||
//! Select add remove
|
//! Select add remove
|
||||||
static const QString &pathViewAddRemove() { static const QString p("View.11.AddRemove"); return p; }
|
static const QString &pathViewAddRemove() { static const QString p("View.11.AddRemove"); return p; }
|
||||||
@@ -179,6 +179,12 @@ namespace BlackGui
|
|||||||
static const QString &pathDockWidgetNested() { static const QString p("DockWidget.Nested"); return p; }
|
static const QString &pathDockWidgetNested() { static const QString p("DockWidget.Nested"); return p; }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! \name Predefined sub sub menus
|
||||||
|
//! @{
|
||||||
|
static const CMenuAction &subMenuDatabase();
|
||||||
|
static const CMenuAction &subMenuSimulator();
|
||||||
|
//! @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAction *m_action = nullptr; //!< the action
|
QAction *m_action = nullptr; //!< the action
|
||||||
QIcon m_icon; //!< icon
|
QIcon m_icon; //!< icon
|
||||||
@@ -218,6 +224,9 @@ namespace BlackGui
|
|||||||
//! Elements
|
//! Elements
|
||||||
int size() const { return m_actions.size(); }
|
int size() const { return m_actions.size(); }
|
||||||
|
|
||||||
|
//! Add a sub menu
|
||||||
|
CMenuAction addMenu(const CMenuAction &subdirAction);
|
||||||
|
|
||||||
//! Add a sub menu
|
//! Add a sub menu
|
||||||
CMenuAction addMenu(const QString &title, const QString &path);
|
CMenuAction addMenu(const QString &title, const QString &path);
|
||||||
|
|
||||||
@@ -310,6 +319,9 @@ namespace BlackGui
|
|||||||
|
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Predfefined sub menus
|
||||||
|
static const CMenuActions &predefinedSubmenus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMultiMap<QString, CMenuAction> m_actions; //!< actions sorted by path
|
QMultiMap<QString, CMenuAction> m_actions; //!< actions sorted by path
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace FsCommon
|
namespace FsCommon
|
||||||
{
|
{
|
||||||
|
|
||||||
CVPilotModelRuleSet::CVPilotModelRuleSet(const CCollection<CVPilotModelRule> &other) :
|
CVPilotModelRuleSet::CVPilotModelRuleSet(const CCollection<CVPilotModelRule> &other) :
|
||||||
CCollection<CVPilotModelRule>(other)
|
CCollection<CVPilotModelRule>(other)
|
||||||
{ }
|
{ }
|
||||||
@@ -143,7 +142,6 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ namespace BlackMisc
|
|||||||
//! Convert values to upper case
|
//! Convert values to upper case
|
||||||
static QStringList toUpper(const QStringList &stringList);
|
static QStringList toUpper(const QStringList &stringList);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} //namespace
|
} //namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user