Salome HOME
[bos #40644][CEA](2024-T1) Feature search.
[modules/gui.git] / src / SUIT / SUIT_PagePrefShortcutTreeItem.h
1 // Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef SUIT_PAGEPREFSHORTCUTTREEITEM_H
24 #define SUIT_PAGEPREFSHORTCUTTREEITEM_H
25
26 #include "SUIT.h"
27 #include <QtxPagePrefMgr.h>
28
29 #include <map>
30 #include <memory>
31
32
33 class SUIT_ShortcutTree;
34 class SUIT_ShortcutContainer;
35
36
37 class SUIT_EXPORT SUIT_PagePrefShortcutTreeItem : public QtxPagePrefItem
38 {
39 public:
40   SUIT_PagePrefShortcutTreeItem(QtxPreferenceItem* theParent);
41   virtual ~SUIT_PagePrefShortcutTreeItem() = default;
42
43   virtual void     retrieve();
44   virtual void     retrieveDefault();
45   virtual void     store();
46
47 private:
48   SUIT_ShortcutTree* myShortcutTree;
49
50   // { root item (preference window), shortcut container of synchronized trees (widgets within the same window) }
51   static std::map<QtxPreferenceItem*, std::weak_ptr<SUIT_ShortcutContainer>> shortcutContainers;
52   /** Why is this?
53    * Every QtxPagePrefMgr is eventually a preference window. Each preference window has button "Apply".
54    * When the button is pressed, all descendants of the QtxPagePrefMgr store changes they carry into preferences.
55    * The pitfall with shortcut trees is as follows: made in independent shortcut trees, changes may conflict,
56    * and merge of such changes is ambiguous. And the solution is to keep shortcut trees within the same window
57    * synchronized - all changes being made in a tree of a synchronized bundle are projected to other trees from the bundle
58    * without interacting with SUIT_ShortcutMgr.
59    *
60    * Every time shortcut preferences stored to the ShortcutMgr, all instances of SUIT_ShortcutTree are updated.
61   */
62 };
63
64 #endif // SUIT_PAGEPREFSHORTCUTTREEITEM_H