CppEditor: Proliferate FilePath use a bit

Change-Id: I7e2669c3adf5de39804da2bf06d99f5ae03447dd
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-09-30 10:32:18 +02:00
parent 57b32ed773
commit 8640e00447
3 changed files with 9 additions and 9 deletions

View File

@@ -1321,7 +1321,7 @@ void CppEditorWidget::abortDeclDefLink()
void CppEditorWidget::showPreProcessorWidget() void CppEditorWidget::showPreProcessorWidget()
{ {
const QString filePath = textDocument()->filePath().toString(); const FilePath filePath = textDocument()->filePath();
CppPreProcessorDialog dialog(filePath, this); CppPreProcessorDialog dialog(filePath, this);
if (dialog.exec() == QDialog::Accepted) { if (dialog.exec() == QDialog::Accepted) {

View File

@@ -3,7 +3,6 @@
#include "cpppreprocessordialog.h" #include "cpppreprocessordialog.h"
#include "cppeditorwidget.h"
#include "cppeditorconstants.h" #include "cppeditorconstants.h"
#include "cpptoolsreuse.h" #include "cpptoolsreuse.h"
@@ -19,14 +18,14 @@ using namespace Utils;
namespace CppEditor::Internal { namespace CppEditor::Internal {
CppPreProcessorDialog::CppPreProcessorDialog(const QString &filePath, QWidget *parent) CppPreProcessorDialog::CppPreProcessorDialog(const FilePath &filePath, QWidget *parent)
: QDialog(parent) : QDialog(parent)
, m_filePath(filePath) , m_filePath(filePath)
{ {
resize(400, 300); resize(400, 300);
setWindowTitle(tr("Additional C++ Preprocessor Directives")); setWindowTitle(tr("Additional C++ Preprocessor Directives"));
const QString key = Constants::EXTRA_PREPROCESSOR_DIRECTIVES + m_filePath; const QString key = Constants::EXTRA_PREPROCESSOR_DIRECTIVES + m_filePath.toString();
const QString directives = ProjectExplorer::SessionManager::value(key).toString(); const QString directives = ProjectExplorer::SessionManager::value(key).toString();
m_editWidget = new TextEditor::SnippetEditorWidget; m_editWidget = new TextEditor::SnippetEditorWidget;
@@ -39,8 +38,7 @@ CppPreProcessorDialog::CppPreProcessorDialog(const QString &filePath, QWidget *p
using namespace Layouting; using namespace Layouting;
Column { Column {
tr("Additional C++ Preprocessor Directives for %1:") tr("Additional C++ Preprocessor Directives for %1:").arg(m_filePath.fileName()),
.arg(Utils::FilePath::fromString(m_filePath).fileName()),
m_editWidget, m_editWidget,
buttonBox, buttonBox,
}.attachTo(this); }.attachTo(this);
@@ -56,7 +54,7 @@ int CppPreProcessorDialog::exec()
if (QDialog::exec() == Rejected) if (QDialog::exec() == Rejected)
return Rejected; return Rejected;
const QString key = Constants::EXTRA_PREPROCESSOR_DIRECTIVES + m_filePath; const QString key = Constants::EXTRA_PREPROCESSOR_DIRECTIVES + m_filePath.toString();
ProjectExplorer::SessionManager::setValue(key, extraPreprocessorDirectives()); ProjectExplorer::SessionManager::setValue(key, extraPreprocessorDirectives());
return Accepted; return Accepted;

View File

@@ -3,6 +3,8 @@
#pragma once #pragma once
#include <utils/filepath.h>
#include <QDialog> #include <QDialog>
#include <QString> #include <QString>
@@ -15,7 +17,7 @@ class CppPreProcessorDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit CppPreProcessorDialog(const QString &filePath, QWidget *parent); CppPreProcessorDialog(const Utils::FilePath &filePath, QWidget *parent);
~CppPreProcessorDialog() override; ~CppPreProcessorDialog() override;
int exec() override; int exec() override;
@@ -23,7 +25,7 @@ public:
QString extraPreprocessorDirectives() const; QString extraPreprocessorDirectives() const;
private: private:
const QString m_filePath; const Utils::FilePath m_filePath;
const QString m_projectPartId; const QString m_projectPartId;
TextEditor::SnippetEditorWidget *m_editWidget; TextEditor::SnippetEditorWidget *m_editWidget;