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

Method closeView

kdevplatform/sublime/area.cpp:417–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417bool Area::closeView(View* view, bool silent)
418{
419 QPointer<Document> doc = view->document();
420
421 // We don't just delete the view, because if silent is false, we might need to ask the user.
422 if(doc && !silent)
423 {
424 // Do some counting to check whether we need to ask the user for feedback
425 qCDebug(SUBLIME) << "Closing view for" << view->document()->documentSpecifier() << "views" << view->document()->views().size() << "in area" << this;
426 int viewsInCurrentArea = 0; // Number of views for the same document in the current area
427 int viewsInOtherAreas = 0; // Number of views for the same document in other areas
428 int viewsInOtherWorkingSets = 0; // Number of views for the same document in areas with different working-set
429
430 for (View* otherView : std::as_const(doc.data()->views())) {
431 Area* area = controller()->areaForView(otherView);
432 if(area == this)
433 viewsInCurrentArea += 1;
434 if(!area || (area != this))
435 viewsInOtherAreas += 1;
436 if(area && area != this && area->workingSet() != workingSet())
437 viewsInOtherWorkingSets += 1;
438 }
439
440 if(viewsInCurrentArea == 1 && (viewsInOtherAreas == 0 || viewsInOtherWorkingSets == 0))
441 {
442 // Time to ask the user for feedback, because the document will be completely closed
443 // due to working-set synchronization
444 if( !doc.data()->askForCloseFeedback() )
445 return false;
446 }
447 }
448
449 // otherwise we can silently close the view,
450 // the document will still have an opened view somewhere
451 delete removeView(view);
452
453 return true;
454}
455
456void Area::clearViews(bool silent)
457{

Callers 1

widgetCloseRequestMethod · 0.45

Calls 9

workingSetFunction · 0.85
areaForViewMethod · 0.80
documentMethod · 0.45
documentSpecifierMethod · 0.45
sizeMethod · 0.45
viewsMethod · 0.45
dataMethod · 0.45
workingSetMethod · 0.45
askForCloseFeedbackMethod · 0.45

Tested by

no test coverage detected