From 7c483f89cd7cb367ffeecde6b0ae3756b6d88310 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 8 Mar 2025 17:08:33 +0200 Subject: [PATCH] chore: Replace deprecated FilePath::toString() with toFSPathString() (#116) This solves a number of deprecation warnings during build. FilePath::toFSPathString() has been available since couple of years ago. --- ChatView/ChatRootView.cpp | 18 ++++++++++-------- ChatView/ClientInterface.cpp | 4 ++-- context/ContextManager.cpp | 2 +- settings/ProjectSettings.cpp | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChatView/ChatRootView.cpp b/ChatView/ChatRootView.cpp index e7da539..f82e6ac 100644 --- a/ChatView/ChatRootView.cpp +++ b/ChatView/ChatRootView.cpp @@ -164,9 +164,10 @@ QString ChatRootView::getChatsHistoryDir() const if (auto project = ProjectExplorer::ProjectManager::startupProject()) { Settings::ProjectSettings projectSettings(project); - path = projectSettings.chatHistoryPath().toString(); + path = projectSettings.chatHistoryPath().toFSPathString(); } else { - path = QString("%1/qodeassist/chat_history").arg(Core::ICore::userResourcePath().toString()); + path = QString("%1/qodeassist/chat_history") + .arg(Core::ICore::userResourcePath().toFSPathString()); } QDir dir(path); @@ -350,7 +351,7 @@ void ChatRootView::showAttachFilesDialog() dialog.setFileMode(QFileDialog::ExistingFiles); if (auto project = ProjectExplorer::ProjectManager::startupProject()) { - dialog.setDirectory(project->projectDirectory().toString()); + dialog.setDirectory(project->projectDirectory().toFSPathString()); } if (dialog.exec() == QDialog::Accepted) { @@ -384,7 +385,7 @@ void ChatRootView::showLinkFilesDialog() dialog.setFileMode(QFileDialog::ExistingFiles); if (auto project = ProjectExplorer::ProjectManager::startupProject()) { - dialog.setDirectory(project->projectDirectory().toString()); + dialog.setDirectory(project->projectDirectory().toFSPathString()); } if (dialog.exec() == QDialog::Accepted) { @@ -437,9 +438,10 @@ void ChatRootView::openChatHistoryFolder() QString path; if (auto project = ProjectExplorer::ProjectManager::startupProject()) { Settings::ProjectSettings projectSettings(project); - path = projectSettings.chatHistoryPath().toString(); + path = projectSettings.chatHistoryPath().toFSPathString(); } else { - path = QString("%1/qodeassist/chat_history").arg(Core::ICore::userResourcePath().toString()); + path = QString("%1/qodeassist/chat_history") + .arg(Core::ICore::userResourcePath().toFSPathString()); } QDir dir(path); @@ -493,7 +495,7 @@ bool ChatRootView::isSyncOpenFiles() const void ChatRootView::onEditorAboutToClose(Core::IEditor *editor) { if (auto document = editor->document(); document && isSyncOpenFiles()) { - QString filePath = document->filePath().toString(); + QString filePath = document->filePath().toFSPathString(); m_linkedFiles.removeOne(filePath); emit linkedFilesChanged(); } @@ -506,7 +508,7 @@ void ChatRootView::onEditorAboutToClose(Core::IEditor *editor) void ChatRootView::onAppendLinkFileFromEditor(Core::IEditor *editor) { if (auto document = editor->document(); document && isSyncOpenFiles()) { - QString filePath = document->filePath().toString(); + QString filePath = document->filePath().toFSPathString(); if (!m_linkedFiles.contains(filePath)) { m_linkedFiles.append(filePath); emit linkedFilesChanged(); diff --git a/ChatView/ClientInterface.cpp b/ChatView/ClientInterface.cpp index 4a0b921..f0f2846 100644 --- a/ChatView/ClientInterface.cpp +++ b/ChatView/ClientInterface.cpp @@ -183,11 +183,11 @@ QString ClientInterface::getCurrentFileContext() const } QString fileInfo = QString("Language: %1\nFile: %2\n\n") - .arg(textDocument->mimeType(), textDocument->filePath().toString()); + .arg(textDocument->mimeType(), textDocument->filePath().toFSPathString()); QString content = textDocument->document()->toPlainText(); - LOG_MESSAGE(QString("Got context from file: %1").arg(textDocument->filePath().toString())); + LOG_MESSAGE(QString("Got context from file: %1").arg(textDocument->filePath().toFSPathString())); return QString("Current file context:\n%1\nFile content:\n%2").arg(fileInfo, content); } diff --git a/context/ContextManager.cpp b/context/ContextManager.cpp index 893ed14..0e94b94 100644 --- a/context/ContextManager.cpp +++ b/context/ContextManager.cpp @@ -81,7 +81,7 @@ ProgrammingLanguage ContextManager::getDocumentLanguage(const QJsonObject &reque filePath); if (!textDocument) { - LOG_MESSAGE("Error: Document is not available for" + filePath.toString()); + LOG_MESSAGE("Error: Document is not available for" + filePath.toFSPathString()); return Context::ProgrammingLanguage::Unknown; } diff --git a/settings/ProjectSettings.cpp b/settings/ProjectSettings.cpp index 4be7392..b910705 100644 --- a/settings/ProjectSettings.cpp +++ b/settings/ProjectSettings.cpp @@ -43,8 +43,8 @@ ProjectSettings::ProjectSettings(ProjectExplorer::Project *project) chatHistoryPath.setExpectedKind(Utils::PathChooser::ExistingDirectory); chatHistoryPath.setLabelText(Tr::tr("Chat History Path:")); - QString projectChatHistoryPath - = QString("%1/qodeassist/chat_history").arg(Core::ICore::userResourcePath().toString()); + QString projectChatHistoryPath = QString("%1/qodeassist/chat_history") + .arg(Core::ICore::userResourcePath().toFSPathString()); chatHistoryPath.setDefaultValue(projectChatHistoryPath);