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

Method activate

plugins/grepview/grepoutputmodel.cpp:233–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233void GrepOutputModel::activate( const QModelIndex &idx )
234{
235 QStandardItem *stditem = itemFromIndex(idx);
236 auto *grepitem = dynamic_cast<GrepOutputItem*>(stditem);
237 if( !grepitem || !grepitem->isText() )
238 return;
239
240 QUrl url = QUrl::fromLocalFile(grepitem->filename());
241
242 int line = grepitem->lineNumber() - 1;
243 KTextEditor::Range range( line, 0, line+1, 0);
244
245 // Try to find the actual text range we found during the grep
246 IDocument* doc = ICore::self()->documentController()->documentForUrl( url );
247 if(!doc)
248 doc = ICore::self()->documentController()->openDocument( url, range );
249 if(!doc)
250 return;
251 if (KTextEditor::Document* tdoc = doc->textDocument()) {
252 KTextEditor::Range matchRange = grepitem->change()->m_range;
253 QString actualText = tdoc->text(matchRange);
254 QString expectedText = grepitem->change()->m_oldText;
255 if (actualText == expectedText) {
256 range = matchRange;
257 }
258 }
259
260 ICore::self()->documentController()->activateDocument( doc, range );
261}
262
263QModelIndex GrepOutputModel::previousItemIndex(const QModelIndex &currentIdx) const
264{

Callers 2

selectPreviousItemMethod · 0.45
selectNextItemMethod · 0.45

Calls 10

isTextMethod · 0.80
documentForUrlMethod · 0.80
documentControllerMethod · 0.80
changeMethod · 0.80
activateDocumentMethod · 0.80
filenameMethod · 0.45
lineNumberMethod · 0.45
openDocumentMethod · 0.45
textDocumentMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected