MCPcopy Create free account
hub / github.com/KDE/kdevelop / saveFromAreaPrivate

Function saveFromAreaPrivate

kdevplatform/shell/workingsets/workingset.cpp:213–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213QSplitter* saveFromAreaPrivate(Sublime::AreaIndex *area, KConfigGroup setGroup, const Sublime::View *activeView)
214{
215 QSplitter *parentSplitter = nullptr;
216
217 if (area->isSplit()) {
218 if (!area->first()) {
219 parentSplitter = saveFromAreaPrivate(area->second(), setGroup, activeView);
220 } else if (!area->second()) {
221 parentSplitter = saveFromAreaPrivate(area->first(), setGroup, activeView);
222 } else {
223 parentSplitter = saveFromAreaPrivate(area->first(), KConfigGroup(&setGroup, QStringLiteral("0")), activeView);
224 if (!parentSplitter) {
225 parentSplitter = saveFromAreaPrivate(area->second(), setGroup, activeView);
226 } else if (saveFromAreaPrivate(area->second(), KConfigGroup(&setGroup, QStringLiteral("1")), activeView)) {
227 setGroup.writeEntry("Orientation", area->orientation() == Qt::Horizontal ? "Horizontal" : "Vertical");
228 setGroup.writeEntry("Sizes", parentSplitter->sizes());
229 } else {
230 // move up settings of group "0"
231 KConfigGroup(&setGroup, QStringLiteral("0")).copyTo(&setGroup);
232 setGroup.deleteGroup(QStringLiteral("0"));
233 }
234 }
235 } else {
236 int index = 0;
237 int activeIndex = -1;
238 const auto views = area->views();
239 for (Sublime::View *view : views) {
240 //The working set config gets an updated list of files
241 QString docSpec = view->document()->documentSpecifier();
242
243 if (view == activeView) {
244 activeIndex = index;
245 }
246
247 //only save the documents from protocols KIO understands
248 //otherwise we try to load kdev:// too early
249 if (!KProtocolInfo::isKnownProtocol(QUrl(docSpec))) {
250 continue;
251 }
252
253 setGroup.writeEntry(QStringLiteral("View %1").arg(index), docSpec);
254 KConfigGroup viewGroup(&setGroup, QStringLiteral("View %1 Config").arg(index));
255 view->writeSessionConfig(viewGroup);
256 if (auto textView = qobject_cast<TextView*>(view)) {
257 if (auto kateView = textView->textView()) {
258 auto range = kateView->selectionRange();
259 if (range.isValid()) {
260 viewGroup.writeEntry("Selection", QList<int>({range.start().line(), range.start().column(),
261 range.end().line(), range.end().column()}));
262 }
263 }
264 }
265 ++index;
266
267 if (!parentSplitter) {
268 if (const auto* const widget = view->widget()) {
269 auto* p = widget->parentWidget();
270 while (p && !(parentSplitter = qobject_cast<QSplitter*>(p))) {

Callers 1

saveFromAreaMethod · 0.85

Calls 15

secondMethod · 0.80
writeEntryMethod · 0.80
textViewMethod · 0.80
KConfigGroupClass · 0.50
QUrlClass · 0.50
isSplitMethod · 0.45
firstMethod · 0.45
orientationMethod · 0.45
copyToMethod · 0.45
viewsMethod · 0.45
documentSpecifierMethod · 0.45
documentMethod · 0.45

Tested by

no test coverage detected