14bbbdcb |
1 | // Created on: 2017-06-16 |
2 | // Created by: Natalia ERMOLAEVA |
3 | // Copyright (c) 2017 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
0cb512c0 |
16 | #include <inspector/DFBrowserPane_AttributePaneSelector.hxx> |
14bbbdcb |
17 | |
18 | #include <QItemSelectionModel> |
19 | |
20 | // ======================================================================= |
21 | // function : Constructor |
22 | // purpose : |
23 | // ======================================================================= |
24 | DFBrowserPane_AttributePaneSelector::DFBrowserPane_AttributePaneSelector (QObject* theParent) |
25 | : QObject (theParent), mySendSelectionChangeBlocked (false) |
26 | { |
27 | } |
28 | |
29 | // ======================================================================= |
30 | // function : Destructor |
31 | // purpose : |
32 | // ======================================================================= |
33 | DFBrowserPane_AttributePaneSelector::~DFBrowserPane_AttributePaneSelector() |
34 | { |
35 | SetCurrentSelectionModels (std::list<QItemSelectionModel*>()); |
36 | } |
37 | |
38 | // ======================================================================= |
39 | // function : SetCurrentSelectionModels |
40 | // purpose : |
41 | // ======================================================================= |
42 | void DFBrowserPane_AttributePaneSelector::SetCurrentSelectionModels (const std::list<QItemSelectionModel*>& theModels) |
43 | { |
44 | for (std::list<QItemSelectionModel*>::const_iterator anModelsIt = mySelectionModels.begin(), |
45 | aLast = mySelectionModels.end(); anModelsIt != aLast; anModelsIt++) |
46 | disconnect (*anModelsIt, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), |
47 | this, SLOT (onTableSelectionChanged (const QItemSelection&, const QItemSelection&))); |
48 | |
49 | mySelectionModels = theModels; |
50 | for (std::list<QItemSelectionModel*>::const_iterator anModelsIt = mySelectionModels.begin(), |
51 | aLast = mySelectionModels.end(); anModelsIt != aLast; anModelsIt++) |
52 | connect (*anModelsIt, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), |
53 | this, SLOT (onTableSelectionChanged (const QItemSelection&, const QItemSelection&))); |
54 | } |
55 | |
56 | // ======================================================================= |
57 | // function : ClearSelected |
58 | // purpose : |
59 | // ======================================================================= |
60 | void DFBrowserPane_AttributePaneSelector::ClearSelected() |
61 | { |
62 | mySendSelectionChangeBlocked = true; |
63 | for (std::list<QItemSelectionModel*>::const_iterator anModelsIt = mySelectionModels.begin(), |
64 | aLast = mySelectionModels.end(); anModelsIt != aLast; anModelsIt++) |
65 | (*anModelsIt)->clearSelection(); |
66 | mySendSelectionChangeBlocked = false; |
67 | } |
68 | |
69 | // ======================================================================= |
70 | // function : |
71 | // purpose : |
72 | // ======================================================================= |
73 | void DFBrowserPane_AttributePaneSelector::onTableSelectionChanged (const QItemSelection& theSelected, |
74 | const QItemSelection& theDeselected) |
75 | { |
76 | if (mySendSelectionChangeBlocked) |
77 | return; |
78 | |
79 | QItemSelectionModel* aModel = (QItemSelectionModel*)sender(); |
80 | emit tableSelectionChanged (theSelected, theDeselected, aModel); |
81 | } |