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

Method close

plugins/okteta/oktetadocument.cpp:112–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112bool OktetaDocument::close( IDocument::DocumentSaveMode mode )
113{
114 bool isCanceled = false;
115 if( !(mode & Discard) )
116 {
117 if (mode & Silent)
118 {
119 if (!save(mode))
120 isCanceled = true;
121
122 }
123 else
124 {
125 if( state() == IDocument::Modified )
126 {
127 // TODO: use Kasten::*Manager
128 int code = KMessageBox::warningTwoActionsCancel(
129 qApp->activeWindow(),
130 i18n("The document \"%1\" has unsaved changes. Would you like to save them?", url().toLocalFile()),
131 i18nc("@title:window", "Close Document"), KStandardGuiItem::save(), KStandardGuiItem::cancel());
132
133 if (code == KMessageBox::PrimaryAction) {
134 if (!save(mode))
135 isCanceled = true;
136
137 } else if (code == KMessageBox::Cancel)
138 isCanceled = true;
139
140 }
141 else if( state() == IDocument::DirtyAndModified )
142 {
143 if( !save(mode) )
144 isCanceled = true;
145 }
146 }
147 }
148
149 if( isCanceled )
150 return false;
151
152 //close all views and then delete ourself
153 ///@todo test this
154 const QList<Sublime::Area*>& allAreas =
155 ICore::self()->uiController()->controller()->allAreas();
156 for (Sublime::Area* area : allAreas ) {
157 const QList<Sublime::View*> areaViews = area->views();
158 for (Sublime::View* view : areaViews) {
159 if (views().contains(view))
160 {
161 area->removeView(view);
162 delete view;
163 }
164 }
165 }
166
167 // The document is deleted automatically when there are no views left
168
169 return true;

Callers 15

helpEventMethod · 0.45
addFilesMethod · 0.45
commitFilesMethod · 0.45
testAnnotationMethod · 0.45
generateMakefileMethod · 0.45
showStashMethod · 0.45
updatePatchFileMethod · 0.45
~DiffViewsCtrlMethod · 0.45

Calls 8

urlFunction · 0.85
toLocalFileMethod · 0.80
allAreasMethod · 0.80
uiControllerMethod · 0.80
controllerMethod · 0.45
viewsMethod · 0.45
containsMethod · 0.45
removeViewMethod · 0.45

Tested by 15

addFilesMethod · 0.36
commitFilesMethod · 0.36
testAnnotationMethod · 0.36
commitFilesMethod · 0.36
testStashMethod · 0.36
textForDocumentFunction · 0.36
operator()Method · 0.36
createFileMethod · 0.36