From: dish Date: Wed, 27 Nov 2024 01:35:46 +0000 (+0000) Subject: Compiles X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7a073f5ac385c1c3c5f693492aa73fedd3d59851;p=modules%2Fgui.git Compiles --- diff --git a/src/SUIT/SUIT_ShortcutMgr.cxx b/src/SUIT/SUIT_ShortcutMgr.cxx index bea9f2685..ecd6c64af 100644 --- a/src/SUIT/SUIT_ShortcutMgr.cxx +++ b/src/SUIT/SUIT_ShortcutMgr.cxx @@ -1666,7 +1666,12 @@ SUIT_ShortcutMgr::~SUIT_ShortcutMgr() /*static*/ void SUIT_ShortcutMgr::fillContainerFromPreferences(SUIT_ShortcutContainer& theContainer, bool theDefaultOnly) { - ShCutDbg() && ShCutDbg(QString("SUIT_ShortcutMgr::fillContainerFromPreferences(theContainer, theDefaultOnly = ") + (theDefaultOnly ? "true" : "false") + ") started."); + return SUIT_ShortcutMgr::fillContainerFromPreferences(theContainer, theDefaultOnly, SECTION_NAME_PREFIX); +} + +/*static*/ void SUIT_ShortcutMgr::fillContainerFromPreferences(SUIT_ShortcutContainer& theContainer, bool theDefaultOnly, const QString& theSectionNamePrefix) +{ + ShCutDbg() && ShCutDbg(QString("SUIT_ShortcutMgr::fillContainerFromPreferences(theContainer, theDefaultOnly = ") + (theDefaultOnly ? "true" : "false") + ", theSectionPrefix = \"" + theSectionNamePrefix + "\") started."); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); if (!resMgr) { @@ -1693,7 +1698,7 @@ SUIT_ShortcutMgr::~SUIT_ShortcutMgr() // And then it is not able to retrieve parametes from that subsections, // because parsed subsection names differ from the ones in resource file. // Anyway, it does not affect operability of ShortcutMgr. - QStringList moduleIDs = resMgr->subSections(SECTION_NAME_PREFIX, true); + QStringList moduleIDs = resMgr->subSections(theSectionNamePrefix, true); if (ShCutDbg()) { if (moduleIDs.isEmpty()) ShCutDbg("No discovered shortcut modules."); @@ -1710,7 +1715,7 @@ SUIT_ShortcutMgr::~SUIT_ShortcutMgr() continue; } - const QString sectionName = SECTION_NAME_PREFIX + resMgr->sectionsToken() + moduleID; + const QString sectionName = theSectionNamePrefix + resMgr->sectionsToken() + moduleID; QStringList moduleActionIDs = resMgr->parameters(sectionName); for(const QString& inModuleActionID : moduleActionIDs) { @@ -1807,7 +1812,7 @@ SUIT_ShortcutMgr::~SUIT_ShortcutMgr() resMgr->setWorkingMode(resMgrWorkingModeBefore); ShCutDbg() && ShCutDbg("theContainer holds following shortcuts:\n" + theContainer.toString()); - ShCutDbg() && ShCutDbg(QString("SUIT_ShortcutMgr::fillContainerFromPreferences(theContainer, theDefaultOnly = ") + (theDefaultOnly ? "true" : "false") + ") finished."); + ShCutDbg() && ShCutDbg(QString("SUIT_ShortcutMgr::fillContainerFromPreferences(theContainer, theDefaultOnly = ") + (theDefaultOnly ? "true" : "false") + ", theSectionPrefix = \"" + theSectionNamePrefix + "\") finished."); } /*static*/ std::pair, std::shared_ptr> @@ -3477,6 +3482,17 @@ bool SUIT_ShortcutHistorian::AIDSMutation::merge(const AIDSMutation& theOther) } +SUIT_ShortcutHistorian::SUIT_ShortcutHistorian() { + parseMutations(); + ShCutDbg("SUIT_ShortcutHistorian: parsing of old shortcut preference sections started."); + for (const auto& oldPrefixAndMutation : myOldPrefixToMutationList) { + const QString& oldPrefix = oldPrefixAndMutation.first; + auto& container = myShortcutContainers.emplace(oldPrefix, SUIT_ShortcutContainer()).first->second; + SUIT_ShortcutMgr::fillContainerFromPreferences(container, false, oldPrefix); + } + ShCutDbg("SUIT_ShortcutHistorian: parsing of old shortcut preference sections finished."); +} + std::pair SUIT_ShortcutHistorian::getOldUserDefinedKeySequence(const QString& theActionID) const { auto result = std::pair(false, QKeySequence()); @@ -3586,6 +3602,22 @@ void SUIT_ShortcutHistorian::parseMutations() std::pair SUIT_ShortcutHistorian::getUserDefinedKeySequenceInSection(const QString& theActionID, const QString& theSectionPrefix) const { auto result = std::pair(false, QKeySequence()); - // TODO + + const auto moduleIDAndInModuleActionID = SUIT_ShortcutMgr::splitIntoModuleIDAndInModuleID(theActionID); + const QString& moduleID = moduleIDAndInModuleActionID.first; + const QString& inModuleActionID = moduleIDAndInModuleActionID.second; + if (inModuleActionID.isEmpty()) + return result; // Invalid action ID. + + const auto itContainers = myShortcutContainers.find(theSectionPrefix); + if (itContainers == myShortcutContainers.end()) + return result; + + const auto& container = itContainers->second; + if (!container.hasShortcut(moduleID, inModuleActionID)) + return result; + + result.first = true; + result.second = container.getKeySequence(moduleID, inModuleActionID); return result; } \ No newline at end of file diff --git a/src/SUIT/SUIT_ShortcutMgr.h b/src/SUIT/SUIT_ShortcutMgr.h index f319dd5a1..32e59a86b 100644 --- a/src/SUIT/SUIT_ShortcutMgr.h +++ b/src/SUIT/SUIT_ShortcutMgr.h @@ -542,6 +542,9 @@ public: \param theDefaultOnly If true, user preferences are ignored and only default preferences are used. */ static void fillContainerFromPreferences(SUIT_ShortcutContainer& theContainer, bool theDefaultOnly); + /*! \param theSectionNamePrefix Prefix of section name in preference files to look in. */ + static void fillContainerFromPreferences(SUIT_ShortcutContainer& theContainer, bool theDefaultOnly, const QString& theSectionNamePrefix); + /*! \brief Returns item assets as they are in asset files. Returned module assets is necessary to keep memory ownership of theAction ancestors. The module assets contain only ancestors of theActionID. \param theLangs If empty, all languages is parsed. */ @@ -845,6 +848,8 @@ private: }; public: + SUIT_ShortcutHistorian(); + /*! \param theActionID Action ID in latest version (as elsewhere in ShortcutMgr code). \returns {false, _ }, if shortcut is not defined in any outdated shortcut section of user preference files. */ @@ -861,6 +866,9 @@ private: private: /** {sectionNamePrefixOld, mutation}[]. Sorted from the newest to the oldest. */ std::list> myOldPrefixToMutationList; + + /** {sectionNamePrefixOld, shortcutContainer}[]. */ + std::map myShortcutContainers; };