/** * Clears all child widgets from a given QLayout * @param layout QLayout to remove children from */ void CFortEdit::ClearLayout(QLayout* layout) { QLayoutItem* Child; while ((Child = layout->takeAt(0)) != 0) { if (Child->layout()) { ClearLayout(Child->layout()); } if (Child->widget()) { layout->removeWidget(Child->widget()); } layout->removeItem(Child); } }
void LayoutStream::ClearLayout(QLayout *layout) { QLayoutItem *item; while((item = layout->takeAt(0))) { // Making sure not to delete things multiple times QLayout* layout = item->layout(); QWidget* widget = item->widget(); if (layout) { ClearLayout(layout); delete layout; } if (widget && (QLayoutItem*)widget != (QLayoutItem*)layout) delete widget; if (item != (QLayoutItem*)widget && item != (QLayoutItem*)layout) delete item; } }
void DockWindow::SerializeLayout(Stream &s, bool withsavedlayouts) { StopHighlight(false); int cnt = 0; s.Magic(); // Groups ArrayMap<String, Vector<int> > groups; if (s.IsStoring()) for (int i = 0; i < dockers.GetCount(); i++) { String g = dockers[i]->GetGroup(); if (!g.IsEmpty()) { int ix = groups.Find(g); if (ix < 0) { groups.Add(dockers[i]->GetGroup(), Vector<int>()); ix = groups.GetCount() - 1; } groups[ix].Add(i); } } s % groups; if (s.IsLoading()) { ClearLayout(); for (int i = 0; i < dockers.GetCount(); i++) dockers[i]->SetGroup(Null); for (int i = 0; i < groups.GetCount(); i++) { Vector<int> &v = groups[i]; const String &g = groups.GetKey(i); for (int j = 0; j < v.GetCount(); j++) { int ix = v[j]; if (ix >= 0 && ix < dockers.GetCount()) dockers[ix]->SetGroup(g); } } } if (s.IsStoring()) { // Write docked for (int i = 0; i < 4; i++) { DockPane &pane = dockpane[i]; int fsz = dockframe[i].IsShown() ? dockframe[i].GetSize() : 0; s / fsz % pane; DockCont *dc = dynamic_cast<DockCont *>(pane.GetFirstChild()); for (int j = 0; dc && j < pane.GetCount(); j++) { s % *dc; dc = dynamic_cast<DockCont *>(dc->GetNext()); } } cnt = 0; // Count Floating for (int i = 0; i < conts.GetCount(); i++) if (conts[i].IsFloating()) cnt++; // Write Floating s / cnt; for (int i = 0; i < conts.GetCount(); i++) { if (conts[i].IsFloating()) { conts[i].Serialize(s); conts[i].SerializePlacement(s, false); } } // Write Autohidden for (int i = 0; i < 4; i++) { cnt = hideframe[i].GetCount(); s / cnt; for (int j = 0; j < hideframe[i].GetCount(); j++) { int ix = FindDocker(&hideframe[i].GetCtrl(j)->Get(0)); if (ix >= 0) s / ix; } } } else { // Read docked for (int i = 0; i < 4; i++) { DockPane &pane = dockpane[i]; dockframe[i].Hide(); int fsz; s / fsz % pane; for (int j = 0; j < pane.GetCount(); j++) { DockCont *dc = CreateContainer(); s % *dc; dc->StateDocked(*this); pane << *dc; } if (fsz && pane.GetCount()) { dockframe[i].SetSize(fsz); dockframe[i].Show(); } else dockframe[i].SetSize(0); } // Read floating s / cnt; for (int i = 0; i < cnt; i++) { DockCont *dc = CreateContainer(); dc->Serialize(s); FloatContainer(*dc); dc->SerializePlacement(s, false); } // Read Autohidden for (int i = 0; i < 4; i++) { s / cnt; for (int j = 0; j < cnt; j++) { int ix; s / ix; if (ix >= 0 && ix < dockers.GetCount()) AutoHide(i, *dockers[ix]); } } // Clear empty containers for (int i = conts.GetCount()-1; i >= 0; i--) { if (!conts.GetCount()) CloseContainer(conts[i]); } RefreshLayout(); } bool haslay = withsavedlayouts; s % haslay; if (withsavedlayouts && (s.IsStoring() || haslay)) s % layouts; s.Magic(); }
void ScreenWidget::ClearScreen() { ClearLayout(); for (int i = 0; i < seat_list_.size(); ++i) { seat_list_[i]->hide(); } }