Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
CamiTK Community Edition
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
17
Issues
17
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CamiTK
CamiTK Community Edition
Commits
9fc14383
Commit
9fc14383
authored
May 30, 2019
by
Emmanuel Promayon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '84-bug-in-refreshinterfacenode-in-explorer-cpp-2' into 'develop'
Bug/
#84
Closes
#84
See merge request
!115
parents
9a47c4ed
87be8277
Changes
2
Pipelines
40
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
26 deletions
+35
-26
sdk/libraries/core/viewer/Explorer.cpp
sdk/libraries/core/viewer/Explorer.cpp
+31
-22
sdk/libraries/core/viewer/Explorer.h
sdk/libraries/core/viewer/Explorer.h
+4
-4
No files found.
sdk/libraries/core/viewer/Explorer.cpp
View file @
9fc14383
...
...
@@ -59,7 +59,7 @@ Explorer::~Explorer() {
//----------------------- getInstance ------------------------
Explorer
*
Explorer
::
getInstance
()
{
// static instan
t
iation, static method variable
// static instan
c
iation, static method variable
static
Explorer
*
explorer
=
nullptr
;
if
(
!
explorer
)
{
explorer
=
new
Explorer
();
...
...
@@ -135,18 +135,18 @@ void Explorer::refresh(Viewer* whoIsAsking) {
if
(
whoIsAsking
!=
this
)
{
//-- check the top-level component number
ComponentList
topLevelCpt
=
Application
::
getTopLevelComponents
();
ComponentList
viewedcomp
=
itemComp
Map
.
uniqueKeys
();
ComponentList
viewedcomp
=
topLevelCompItem
Map
.
uniqueKeys
();
if
(
viewedcomp
.
size
()
!=
topLevelCpt
.
size
())
{
// remove the closed/deleted top-level component
foreach
(
Component
*
comp
,
viewedcomp
)
{
if
(
!
topLevelCpt
.
contains
(
comp
))
{
remove
(
comp
);
remove
TopLevel
(
comp
);
}
}
// add the new top-level component
foreach
(
Component
*
comp
,
topLevelCpt
)
{
if
(
!
viewedcomp
.
contains
(
comp
))
{
add
(
comp
);
add
TopLevel
(
comp
);
}
}
}
...
...
@@ -217,6 +217,7 @@ QTreeWidgetItem* Explorer::getNewItem(QTreeWidgetItem* parent, Component* abstra
// add the pixmap
tw
->
setIcon
(
0
,
abstractNode
->
getIcon
());
}
// check the italic property
QFont
f
=
tw
->
font
(
0
);
f
.
setItalic
(
abstractNode
->
inItalic
());
...
...
@@ -227,6 +228,24 @@ QTreeWidgetItem* Explorer::getNewItem(QTreeWidgetItem* parent, Component* abstra
return
tw
;
}
//----------------------- addTopLevel ------------------------
void
Explorer
::
addTopLevel
(
Component
*
comp
,
int
index
)
{
if
(
!
comp
->
getParent
())
{
// create the items
QTreeWidgetItem
*
compItem
=
add
(
nullptr
,
comp
);
// add to / insert in the tree
if
(
index
<
0
)
{
explorerTree
->
addTopLevelItem
(
compItem
);
}
else
{
explorerTree
->
insertTopLevelItem
(
index
,
compItem
);
}
// insert top-level component in the map
topLevelCompItemMap
.
insert
(
comp
,
compItem
);
}
}
//----------------------- add ------------------------
QTreeWidgetItem
*
Explorer
::
add
(
QTreeWidgetItem
*
parent
,
Component
*
abstractNode
)
{
...
...
@@ -247,18 +266,6 @@ QTreeWidgetItem* Explorer::add(QTreeWidgetItem* parent, Component* abstractNode)
return
tw
;
}
//----------------------- add ------------------------
void
Explorer
::
add
(
Component
*
comp
)
{
if
(
!
comp
->
getParent
())
{
// create the items
QTreeWidgetItem
*
compItem
=
add
(
nullptr
,
comp
);
explorerTree
->
addTopLevelItem
(
compItem
);
// insert top-level component in the map
itemCompMap
.
insert
(
comp
,
compItem
);
}
}
//----------------------- refreshInterfaceNode ------------------------
void
Explorer
::
refreshInterfaceNode
(
Component
*
comp
)
{
QTreeWidgetItem
*
toDelete
=
getItem
(
comp
);
...
...
@@ -280,17 +287,19 @@ void Explorer::refreshInterfaceNode(Component* comp) {
// remove from the list and from the explorer
explorerTree
->
blockSignals
(
true
);
remove
(
toDelete
);
// recreate and add at the same place
if
(
parentTW
==
nullptr
)
// if there is no parent, then add at the correct index on the top level
{
explorerTree
->
insertTopLevelItem
(
index
,
add
(
nullptr
,
comp
));
// remove from the map
removeTopLevel
(
comp
);
addTopLevel
(
comp
,
index
);
}
else
// add where it was deleted in the parent index
{
remove
(
toDelete
);
parentTW
->
insertChild
(
index
,
add
(
nullptr
,
comp
));
}
explorerTree
->
blockSignals
(
false
);
...
...
@@ -298,16 +307,16 @@ void Explorer::refreshInterfaceNode(Component* comp) {
}
//----------------------- remove ------------------------
void
Explorer
::
remove
(
Component
*
comp
)
{
QTreeWidgetItem
*
toDelete
=
itemComp
Map
.
value
(
comp
);
//----------------------- remove
TopLevel
------------------------
void
Explorer
::
remove
TopLevel
(
Component
*
comp
)
{
QTreeWidgetItem
*
toDelete
=
topLevelCompItem
Map
.
value
(
comp
);
if
(
toDelete
!=
nullptr
)
{
explorerTree
->
blockSignals
(
true
);
// remove from the explorer
remove
(
toDelete
);
explorerTree
->
blockSignals
(
false
);
// remove from the map
itemComp
Map
.
remove
(
comp
);
topLevelCompItem
Map
.
remove
(
comp
);
}
}
...
...
sdk/libraries/core/viewer/Explorer.h
View file @
9fc14383
...
...
@@ -124,7 +124,7 @@ private:
QMap
<
QTreeWidgetItem
*
,
Component
*>
itemComponentMap
;
/// the map to get the QTreeWidgetItem corresponding to a parentComp
QMap
<
Component
*
,
QTreeWidgetItem
*>
itemComp
Map
;
QMap
<
Component
*
,
QTreeWidgetItem
*>
topLevelCompItem
Map
;
/// Return the QTreeWidgetItem of a given Component (return NULL if not found)
QTreeWidgetItem
*
getItem
(
Component
*
);
...
...
@@ -132,7 +132,7 @@ private:
/// @name QTreeWidget and QTreeWidgetItem management
///@{
/// instan
t
iate a new QTreeWidgetItem using names and properties from the InterfaceNode, and using parent
/// instan
c
iate a new QTreeWidgetItem using names and properties from the InterfaceNode, and using parent
QTreeWidgetItem
*
getNewItem
(
QTreeWidgetItem
*
parent
,
Component
*
);
/// recursively add the Component in the tree explorer and return the QTreeWidgetItem of the InterfaceNode
...
...
@@ -141,7 +141,7 @@ private:
/** Add the given Component to the explorer (at top level) and automatically create children Component items.
* @param comp The Component to add in the tree view.
*/
void
add
(
Component
*
comp
);
void
add
TopLevel
(
Component
*
comp
,
int
index
=
-
1
);
/// remove a given item from the explorer (return its index in the parent item list)
void
remove
(
QTreeWidgetItem
*
);
...
...
@@ -149,7 +149,7 @@ private:
/** Remove the Component (its Component and its sub-item) from the explorer list (if present).
* The Component itself is of course not deleted here.
*/
void
remove
(
Component
*
comp
);
void
remove
TopLevel
(
Component
*
comp
);
/// the list view
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment