diff --git a/kate/katequickopen.cpp b/kate/katequickopen.cpp --- a/kate/katequickopen.cpp +++ b/kate/katequickopen.cpp @@ -159,7 +159,7 @@ void KateQuickOpen::slotReturnPressed() { const auto index = m_listView->model()->index(m_listView->currentIndex().row(), KateQuickOpenModel::Columns::FilePath); - auto url = QUrl(index.data(Qt::DisplayRole).toString()); + auto url = index.data(Qt::UserRole).toUrl(); m_mainWindow->wrapper()->openUrl(url); m_mainWindow->slotWindowActivated(); m_inputLine->clear(); diff --git a/kate/katequickopenmodel.h b/kate/katequickopenmodel.h --- a/kate/katequickopenmodel.h +++ b/kate/katequickopenmodel.h @@ -28,9 +28,10 @@ #include "katemainwindow.h" struct ModelEntry { - QString fileName; - QString filePath; - bool bold; + QUrl url; // used for actually opening a selected file (local or remote) + QString fileName; // display string for left column + QString filePath; // display string for right column + bool bold; // format line in bold text or not }; class KateQuickOpenModel : public QAbstractTableModel { diff --git a/kate/katequickopenmodel.cpp b/kate/katequickopenmodel.cpp --- a/kate/katequickopenmodel.cpp +++ b/kate/katequickopenmodel.cpp @@ -51,7 +51,7 @@ return {}; } - if (role != Qt::DisplayRole && role != Qt::FontRole) { + if (role != Qt::DisplayRole && role != Qt::FontRole && role != Qt::UserRole) { return {}; } @@ -67,6 +67,8 @@ font.setBold(true); return font; } + } else if (role == Qt::UserRole) { + return entry.url; } return {}; @@ -84,21 +86,21 @@ for (auto *view : qAsConst(sortedViews)) { auto doc = view->document(); - allDocuments.push_back({ doc->documentName(), doc->url().toDisplayString(QUrl::NormalizePathSegments | QUrl::PreferLocalFile), false }); + allDocuments.push_back({ doc->url(), doc->documentName(), doc->url().toDisplayString(QUrl::NormalizePathSegments | QUrl::PreferLocalFile), false }); } QStringList openedUrls; openedUrls.reserve(openDocs.size()); for (auto *doc : qAsConst(openDocs)) { const auto normalizedUrl = doc->url().toString(QUrl::NormalizePathSegments | QUrl::PreferLocalFile); - allDocuments.push_back({ doc->documentName(), normalizedUrl, false }); + allDocuments.push_back({ doc->url(), doc->documentName(), normalizedUrl, false }); openedUrls.push_back(normalizedUrl); } for (const auto& file : qAsConst(projectDocs)) { QFileInfo fi(file); // example of file: "/home/user/projects/myfile.txt" which is consistent with QUrl::toDisplayString(QUrl::PreferLocalFile) - allDocuments.push_back({ fi.fileName(), file, false }); + allDocuments.push_back({ QUrl::fromLocalFile(fi.absoluteFilePath()), fi.fileName(), file, false }); } /** Sort the arrays by filePath. */