@@ -106,6 +106,49 @@ SectionWidget* ContainerWidget::addSectionContent(const SectionContent::RefPtr&
106
106
return dropContent (data, sw, area, false );
107
107
}
108
108
109
+ bool ContainerWidget::removeSectionContent (const SectionContent::RefPtr& sc)
110
+ {
111
+ // Hide the content.
112
+ // The hideSectionContent() automatically deletes no longer required SectionWidget objects.
113
+ if (!hideSectionContent (sc))
114
+ return false ;
115
+
116
+ // Begin of ugly work arround.
117
+ // TODO The hideSectionContent() method should take care of deleting FloatingWidgets and SectionWidgets,
118
+ // but only cares about SectionWidgets right now. So we need to check whether it was a FloatingWidget
119
+ // and delete it.
120
+ bool found = false ;
121
+ for (int i = 0 ; i < _floatings.count (); ++i)
122
+ {
123
+ FloatingWidget* fw = _floatings.at (i);
124
+ InternalContentData data;
125
+ if (!(found = fw->takeContent (data)))
126
+ continue ;
127
+ _floatings.removeAll (fw);
128
+ delete fw;
129
+ delete data.titleWidget ;
130
+ delete data.contentWidget ;
131
+ break ;
132
+ } // End of ugly work arround.
133
+
134
+ // Get from hidden contents and delete associated internal stuff.
135
+ if (!_hiddenSectionContents.contains (sc->uid ()))
136
+ {
137
+ qFatal (" Something went wrong... The content should have been there :-/" );
138
+ return false ;
139
+ }
140
+
141
+ // Delete internal objects.
142
+ HiddenSectionItem hsi = _hiddenSectionContents.take (sc->uid ());
143
+ delete hsi.data .titleWidget ;
144
+ delete hsi.data .contentWidget ;
145
+
146
+ // Hide the custom widgets of SectionContent.
147
+ // ... should we? ...
148
+
149
+ return true ;
150
+ }
151
+
109
152
bool ContainerWidget::showSectionContent (const SectionContent::RefPtr& sc)
110
153
{
111
154
// Search SC in floatings
@@ -603,6 +646,19 @@ QRect ContainerWidget::outerLeftDropRect() const
603
646
return QRect (r.left (), r.top (), w, r.height ());
604
647
}
605
648
649
+ QList<SectionContent::RefPtr> ContainerWidget::contents () const
650
+ {
651
+ QList<SectionContent::WeakPtr> wl = _scLookupMapById.values ();
652
+ QList<SectionContent::RefPtr> sl;
653
+ for (int i = 0 ; i < wl.count (); ++i)
654
+ {
655
+ const SectionContent::RefPtr sc = wl.at (i).toStrongRef ();
656
+ if (sc)
657
+ sl.append (sc);
658
+ }
659
+ return sl;
660
+ }
661
+
606
662
// /////////////////////////////////////////////////////////////////////
607
663
// PRIVATE API BEGINS HERE
608
664
// /////////////////////////////////////////////////////////////////////
0 commit comments