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

Method updateKompareModel

plugins/patchreview/patchreview.cpp:218–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void PatchReviewPlugin::updateKompareModel() {
219 if ( !m_patch ) {
220 ///TODO: this method should be cleaned up, it can be called by the timer and
221 /// e.g. https://bugs.kde.org/show_bug.cgi?id=267187 shows how it could
222 /// lead to asserts before...
223 return;
224 }
225
226 qCDebug(PLUGIN_PATCHREVIEW) << "updating model";
227 removeHighlighting();
228 m_modelList.reset( nullptr );
229 m_depth = 0;
230 m_diffSettings.reset(nullptr);
231 {
232 IDocument* patchDoc = ICore::self()->documentController()->documentForUrl( m_patch->file() );
233 if( patchDoc )
234 patchDoc->reload();
235 }
236
237 QString patchFile;
238 if( m_patch->file().isLocalFile() )
239 patchFile = m_patch->file().toLocalFile();
240 else if( m_patch->file().isValid() && !m_patch->file().isEmpty() ) {
241 patchFile = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
242 bool ret = KIO::copy(m_patch->file(), QUrl::fromLocalFile(patchFile), KIO::HideProgressInfo)->exec();
243 if( !ret ) {
244 qCWarning(PLUGIN_PATCHREVIEW) << "Problem while downloading: " << m_patch->file() << "to" << patchFile;
245 patchFile.clear();
246 }
247 }
248
249 if (!patchFile.isEmpty()) //only try to construct the model if we have a patch to load
250 try {
251 m_diffSettings.reset(new KompareDiff2::DiffSettings());
252 m_kompareInfo.reset(new KompareDiff2::Info());
253 m_kompareInfo->localDestination = patchFile;
254 m_kompareInfo->localSource = m_patch->baseDir().toLocalFile();
255 m_kompareInfo->depth = m_patch->depth();
256 m_kompareInfo->applied = m_patch->isAlreadyApplied();
257
258 m_modelList.reset(new KompareDiff2::ModelList(m_diffSettings.data(), this));
259 m_modelList->slotKompareInfo( m_kompareInfo.data() );
260
261 try {
262 m_modelList->openDirAndDiff();
263 } catch ( const QString & /*str*/ ) {
264 throw;
265 } catch ( ... ) {
266 throw QStringLiteral( "lib/libdiff2 crashed, memory may be corrupted. Please restart kdevelop." );
267 }
268
269 for (m_depth = 0; m_depth < 10; ++m_depth) {
270 bool allFound = true;
271 for( int i = 0; i < m_modelList->modelCount(); i++ ) {
272 if (!QFile::exists(urlForFileModel(m_modelList->modelAt(i)).toLocalFile())) {
273 allFound = false;
274 }
275 }

Callers

nothing calls this directly

Calls 15

documentForUrlMethod · 0.80
documentControllerMethod · 0.80
isLocalFileMethod · 0.80
toLocalFileMethod · 0.80
execMethod · 0.80
resetMethod · 0.45
fileMethod · 0.45
reloadMethod · 0.45
isValidMethod · 0.45
isEmptyMethod · 0.45
clearMethod · 0.45
baseDirMethod · 0.45

Tested by

no test coverage detected