mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +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; }
|
||||
|
||||
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())
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,18 @@ namespace BlackGui
|
||||
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
|
||||
{
|
||||
if (this->m_path.contains('/'))
|
||||
@@ -160,6 +172,11 @@ namespace BlackGui
|
||||
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)
|
||||
{
|
||||
return this->addMenu(QIcon(), title, path);
|
||||
@@ -293,22 +310,19 @@ namespace BlackGui
|
||||
void CMenuActions::toQMenu(QMenu &menu, bool separateGroups) const
|
||||
{
|
||||
if (this->m_actions.isEmpty()) { return; }
|
||||
const QStringList keys(this->m_actions.uniqueKeys()); // Sorted ascending
|
||||
QMap<QString, QMenu *> subMenus; // all sub menus
|
||||
const QStringList keys = this->m_actions.uniqueKeys(); // Sorted ascending
|
||||
|
||||
QMap<QString, QMenu *> subMenus; // all sub menus
|
||||
for (const QString &key : keys)
|
||||
{
|
||||
bool addedSeparator = false;
|
||||
const int pathDepth = CMenuActions::pathDepth(key);
|
||||
const int pathDepth = CMenuActions::pathDepth(key); // 0 based
|
||||
|
||||
QList<CMenuAction> actions;
|
||||
QList<CMenuAction> menus;
|
||||
this->splitSubMenus(key, actions, menus);
|
||||
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
|
||||
continue;
|
||||
}
|
||||
@@ -407,7 +421,7 @@ namespace BlackGui
|
||||
CMenuAction CMenuActions::addMenuDatabase()
|
||||
{
|
||||
if (this->containsMenu(CMenuAction::pathViewDatabase())) { CMenuAction(); }
|
||||
return this->addMenu(CIcons::appDatabase16(), "Database", CMenuAction::pathViewDatabase());
|
||||
return this->addMenu(CMenuAction::subMenuDatabase());
|
||||
}
|
||||
|
||||
CMenuAction CMenuActions::addMenuModelSet()
|
||||
@@ -416,17 +430,29 @@ namespace BlackGui
|
||||
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)
|
||||
{
|
||||
if (pathDepth < 1) { return &menu; }
|
||||
|
||||
QMenu *parentMenu = &menu;
|
||||
if (pathDepth > 1)
|
||||
{
|
||||
// find the corresponding submenu. If this is empty the next higher level will be choosen
|
||||
// if not found at all, use top level menu
|
||||
parentMenu = findUpwardsInMenus(key, subMenus);
|
||||
if (!parentMenu) { parentMenu = &menu; }
|
||||
if (!parentMenu)
|
||||
{
|
||||
parentMenu = &menu;
|
||||
}
|
||||
}
|
||||
|
||||
// explicity menu?
|
||||
@@ -471,7 +497,7 @@ namespace BlackGui
|
||||
{
|
||||
if (menus.contains(k))
|
||||
{
|
||||
return menus[key];
|
||||
return menus[k];
|
||||
}
|
||||
k = parentPath(k);
|
||||
}
|
||||
|
||||
@@ -149,8 +149,8 @@ namespace BlackGui
|
||||
//! Database
|
||||
static const QString &pathViewDatabase() { static const QString p("View.10.Database/Database"); return p; }
|
||||
|
||||
//! Database merge
|
||||
static const QString &pathViewDatabaseMerge() { static const QString p("View.10.Database/Database/Merge"); return p; }
|
||||
//! Database consolidation
|
||||
static const QString &pathViewDatabaseConsolidate() { static const QString p("View.10.Database/Database/Consolidate"); return p; }
|
||||
|
||||
//! Select add remove
|
||||
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; }
|
||||
//! @}
|
||||
|
||||
//! \name Predefined sub sub menus
|
||||
//! @{
|
||||
static const CMenuAction &subMenuDatabase();
|
||||
static const CMenuAction &subMenuSimulator();
|
||||
//! @}
|
||||
|
||||
private:
|
||||
QAction *m_action = nullptr; //!< the action
|
||||
QIcon m_icon; //!< icon
|
||||
@@ -218,6 +224,9 @@ namespace BlackGui
|
||||
//! Elements
|
||||
int size() const { return m_actions.size(); }
|
||||
|
||||
//! Add a sub menu
|
||||
CMenuAction addMenu(const CMenuAction &subdirAction);
|
||||
|
||||
//! Add a sub menu
|
||||
CMenuAction addMenu(const QString &title, const QString &path);
|
||||
|
||||
@@ -310,6 +319,9 @@ namespace BlackGui
|
||||
|
||||
//! @}
|
||||
|
||||
//! Predfefined sub menus
|
||||
static const CMenuActions &predefinedSubmenus();
|
||||
|
||||
private:
|
||||
QMultiMap<QString, CMenuAction> m_actions; //!< actions sorted by path
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace FsCommon
|
||||
{
|
||||
|
||||
CVPilotModelRuleSet::CVPilotModelRuleSet(const CCollection<CVPilotModelRule> &other) :
|
||||
CCollection<CVPilotModelRule>(other)
|
||||
{ }
|
||||
@@ -143,7 +142,6 @@ namespace BlackMisc
|
||||
}
|
||||
return models;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -74,7 +74,6 @@ namespace BlackMisc
|
||||
//! Convert values to upper case
|
||||
static QStringList toUpper(const QStringList &stringList);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user