forked from qt-creator/qt-creator
CppEditor: Convert AbstractEditorSupport interface to FilePath
Change-Id: I47439e154bc28d40e112b7eef46fa1f57a8b3fce Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
#include <utils/macroexpander.h>
|
#include <utils/macroexpander.h>
|
||||||
#include <utils/templateengine.h>
|
#include <utils/templateengine.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
|
|
||||||
AbstractEditorSupport::AbstractEditorSupport(CppModelManager *modelmanager, QObject *parent) :
|
AbstractEditorSupport::AbstractEditorSupport(CppModelManager *modelmanager, QObject *parent) :
|
||||||
@@ -27,22 +29,23 @@ AbstractEditorSupport::~AbstractEditorSupport()
|
|||||||
void AbstractEditorSupport::updateDocument()
|
void AbstractEditorSupport::updateDocument()
|
||||||
{
|
{
|
||||||
++m_revision;
|
++m_revision;
|
||||||
m_modelmanager->updateSourceFiles(QSet<QString>{fileName()});
|
m_modelmanager->updateSourceFiles(QSet<QString>{filePath().toString()});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractEditorSupport::notifyAboutUpdatedContents() const
|
void AbstractEditorSupport::notifyAboutUpdatedContents() const
|
||||||
{
|
{
|
||||||
m_modelmanager->emitAbstractEditorSupportContentsUpdated(fileName(), sourceFileName(), contents());
|
m_modelmanager->emitAbstractEditorSupportContentsUpdated(
|
||||||
|
filePath().toString(), sourceFilePath().toString(), contents());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AbstractEditorSupport::licenseTemplate(const QString &file, const QString &className)
|
QString AbstractEditorSupport::licenseTemplate(const FilePath &filePath, const QString &className)
|
||||||
{
|
{
|
||||||
const QString license = Internal::CppFileSettings::licenseTemplate();
|
const QString license = Internal::CppFileSettings::licenseTemplate();
|
||||||
Utils::MacroExpander expander;
|
Utils::MacroExpander expander;
|
||||||
expander.registerVariable("Cpp:License:FileName", tr("The file name."),
|
expander.registerVariable("Cpp:License:FileName", tr("The file name."),
|
||||||
[file]() { return Utils::FilePath::fromString(file).fileName(); });
|
[filePath] { return filePath.fileName(); });
|
||||||
expander.registerVariable("Cpp:License:ClassName", tr("The class name."),
|
expander.registerVariable("Cpp:License:ClassName", tr("The class name."),
|
||||||
[className]() { return className; });
|
[className] { return className; });
|
||||||
|
|
||||||
return Utils::TemplateEngine::processText(&expander, license, nullptr);
|
return Utils::TemplateEngine::processText(&expander, license, nullptr);
|
||||||
}
|
}
|
||||||
@@ -52,5 +55,4 @@ bool AbstractEditorSupport::usePragmaOnce()
|
|||||||
return Internal::CppEditorPlugin::usePragmaOnce();
|
return Internal::CppEditorPlugin::usePragmaOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CppEditor
|
} // CppEditor
|
||||||
|
|
||||||
|
@@ -5,29 +5,32 @@
|
|||||||
|
|
||||||
#include "cppeditor_global.h"
|
#include "cppeditor_global.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
|
|
||||||
class CppModelManager;
|
class CppModelManager;
|
||||||
|
|
||||||
class CPPEDITOR_EXPORT AbstractEditorSupport : public QObject
|
class CPPEDITOR_EXPORT AbstractEditorSupport : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AbstractEditorSupport(CppModelManager *modelmanager, QObject *parent = nullptr);
|
explicit AbstractEditorSupport(CppModelManager *modelmanager, QObject *parent = nullptr);
|
||||||
~AbstractEditorSupport() override;
|
~AbstractEditorSupport() override;
|
||||||
|
|
||||||
/// \returns the contents, encoded as UTF-8
|
/// \returns the contents, encoded as UTF-8
|
||||||
virtual QByteArray contents() const = 0;
|
virtual QByteArray contents() const = 0;
|
||||||
virtual QString fileName() const = 0;
|
virtual Utils::FilePath filePath() const = 0;
|
||||||
virtual QString sourceFileName() const = 0;
|
virtual Utils::FilePath sourceFilePath() const = 0;
|
||||||
|
|
||||||
void updateDocument();
|
void updateDocument();
|
||||||
void notifyAboutUpdatedContents() const;
|
void notifyAboutUpdatedContents() const;
|
||||||
unsigned revision() const { return m_revision; }
|
unsigned revision() const { return m_revision; }
|
||||||
|
|
||||||
static QString licenseTemplate(const QString &file = QString(), const QString &className = QString());
|
static QString licenseTemplate(const Utils::FilePath &filePath = {}, const QString &className = {});
|
||||||
static bool usePragmaOnce();
|
static bool usePragmaOnce();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -35,4 +38,4 @@ private:
|
|||||||
unsigned m_revision;
|
unsigned m_revision;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppEditor
|
} // CppEditor
|
||||||
|
@@ -63,7 +63,7 @@ public:
|
|||||||
mm()->unregisterCppEditorDocument(m_registrationFilePath);
|
mm()->unregisterCppEditorDocument(m_registrationFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString filePath() const override { return m_cppEditorDocument->filePath().toString(); }
|
FilePath filePath() const override { return m_cppEditorDocument->filePath(); }
|
||||||
QByteArray contents() const override { return m_cppEditorDocument->contentsText(); }
|
QByteArray contents() const override { return m_cppEditorDocument->contentsText(); }
|
||||||
unsigned revision() const override { return m_cppEditorDocument->contentsRevision(); }
|
unsigned revision() const override { return m_cppEditorDocument->contentsRevision(); }
|
||||||
|
|
||||||
|
@@ -1128,12 +1128,12 @@ BaseEditorDocumentProcessor *CppModelManager::cppEditorDocumentProcessor(const Q
|
|||||||
void CppModelManager::registerCppEditorDocument(CppEditorDocumentHandle *editorDocument)
|
void CppModelManager::registerCppEditorDocument(CppEditorDocumentHandle *editorDocument)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(editorDocument, return);
|
QTC_ASSERT(editorDocument, return);
|
||||||
const QString filePath = editorDocument->filePath();
|
const FilePath filePath = editorDocument->filePath();
|
||||||
QTC_ASSERT(!filePath.isEmpty(), return);
|
QTC_ASSERT(!filePath.isEmpty(), return);
|
||||||
|
|
||||||
QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
|
QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
|
||||||
QTC_ASSERT(d->m_cppEditorDocuments.value(filePath, 0) == 0, return);
|
QTC_ASSERT(d->m_cppEditorDocuments.value(filePath.toString(), 0) == 0, return);
|
||||||
d->m_cppEditorDocuments.insert(filePath, editorDocument);
|
d->m_cppEditorDocuments.insert(filePath.toString(), editorDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppModelManager::unregisterCppEditorDocument(const QString &filePath)
|
void CppModelManager::unregisterCppEditorDocument(const QString &filePath)
|
||||||
@@ -1204,7 +1204,7 @@ WorkingCopy CppModelManager::buildWorkingCopyList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEditorSupport *es : std::as_const(d->m_extraEditorSupports))
|
for (AbstractEditorSupport *es : std::as_const(d->m_extraEditorSupports))
|
||||||
workingCopy.insert(es->fileName(), es->contents(), es->revision());
|
workingCopy.insert(es->filePath(), es->contents(), es->revision());
|
||||||
|
|
||||||
// Add the project configuration file
|
// Add the project configuration file
|
||||||
QByteArray conf = codeModelConfiguration();
|
QByteArray conf = codeModelConfiguration();
|
||||||
@@ -1922,21 +1922,22 @@ void CppModelManager::GC()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Collect files of opened editors and editor supports (e.g. ui code model)
|
// Collect files of opened editors and editor supports (e.g. ui code model)
|
||||||
QStringList filesInEditorSupports;
|
FilePaths filesInEditorSupports;
|
||||||
const QList<CppEditorDocumentHandle *> editorDocuments = cppEditorDocuments();
|
const QList<CppEditorDocumentHandle *> editorDocuments = cppEditorDocuments();
|
||||||
for (const CppEditorDocumentHandle *editorDocument : editorDocuments)
|
for (const CppEditorDocumentHandle *editorDocument : editorDocuments)
|
||||||
filesInEditorSupports << editorDocument->filePath();
|
filesInEditorSupports << editorDocument->filePath();
|
||||||
|
|
||||||
const QSet<AbstractEditorSupport *> abstractEditorSupportList = abstractEditorSupports();
|
const QSet<AbstractEditorSupport *> abstractEditorSupportList = abstractEditorSupports();
|
||||||
for (AbstractEditorSupport *abstractEditorSupport : abstractEditorSupportList)
|
for (AbstractEditorSupport *abstractEditorSupport : abstractEditorSupportList)
|
||||||
filesInEditorSupports << abstractEditorSupport->fileName();
|
filesInEditorSupports << abstractEditorSupport->filePath();
|
||||||
|
|
||||||
Snapshot currentSnapshot = snapshot();
|
Snapshot currentSnapshot = snapshot();
|
||||||
QSet<Utils::FilePath> reachableFiles;
|
QSet<Utils::FilePath> reachableFiles;
|
||||||
// The configuration file is part of the project files, which is just fine.
|
// The configuration file is part of the project files, which is just fine.
|
||||||
// If single files are open, without any project, then there is no need to
|
// If single files are open, without any project, then there is no need to
|
||||||
// keep the configuration file around.
|
// keep the configuration file around.
|
||||||
FilePaths todo = transform(filesInEditorSupports + projectFiles(), &FilePath::fromString);
|
FilePaths todo = filesInEditorSupports;
|
||||||
|
todo += transform(projectFiles(), &FilePath::fromString);
|
||||||
|
|
||||||
// Collect all files that are reachable from the project files
|
// Collect all files that are reachable from the project files
|
||||||
while (!todo.isEmpty()) {
|
while (!todo.isEmpty()) {
|
||||||
|
@@ -6,9 +6,10 @@
|
|||||||
#include "cppeditor_global.h"
|
#include "cppeditor_global.h"
|
||||||
#include "senddocumenttracker.h"
|
#include "senddocumenttracker.h"
|
||||||
|
|
||||||
#include <QString>
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
|
|
||||||
class BaseEditorDocumentProcessor;
|
class BaseEditorDocumentProcessor;
|
||||||
|
|
||||||
class CPPEDITOR_EXPORT CppEditorDocumentHandle
|
class CPPEDITOR_EXPORT CppEditorDocumentHandle
|
||||||
@@ -25,7 +26,7 @@ public:
|
|||||||
void setRefreshReason(const RefreshReason &refreshReason);
|
void setRefreshReason(const RefreshReason &refreshReason);
|
||||||
|
|
||||||
// For the Working Copy
|
// For the Working Copy
|
||||||
virtual QString filePath() const = 0;
|
virtual Utils::FilePath filePath() const = 0;
|
||||||
virtual QByteArray contents() const = 0;
|
virtual QByteArray contents() const = 0;
|
||||||
virtual unsigned revision() const = 0;
|
virtual unsigned revision() const = 0;
|
||||||
|
|
||||||
@@ -41,4 +42,4 @@ private:
|
|||||||
RefreshReason m_refreshReason = None;
|
RefreshReason m_refreshReason = None;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppEditor
|
} // CppEditor
|
||||||
|
@@ -7,12 +7,15 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/buildmanager.h>
|
#include <projectexplorer/buildmanager.h>
|
||||||
|
#include <projectexplorer/extracompiler.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -22,6 +25,7 @@
|
|||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
|
|
||||||
@@ -46,16 +50,16 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
GeneratedCodeModelSupport::GeneratedCodeModelSupport(CppModelManager *modelmanager,
|
GeneratedCodeModelSupport::GeneratedCodeModelSupport(CppModelManager *modelmanager,
|
||||||
ProjectExplorer::ExtraCompiler *generator,
|
ExtraCompiler *generator,
|
||||||
const Utils::FilePath &generatedFile) :
|
const FilePath &generatedFile) :
|
||||||
AbstractEditorSupport(modelmanager, generator), m_generatedFileName(generatedFile),
|
AbstractEditorSupport(modelmanager, generator), m_generatedFilePath(generatedFile),
|
||||||
m_generator(generator)
|
m_generator(generator)
|
||||||
{
|
{
|
||||||
QLoggingCategory log("qtc.cppeditor.generatedcodemodelsupport", QtWarningMsg);
|
QLoggingCategory log("qtc.cppeditor.generatedcodemodelsupport", QtWarningMsg);
|
||||||
qCDebug(log) << "ctor GeneratedCodeModelSupport for" << m_generator->source()
|
qCDebug(log) << "ctor GeneratedCodeModelSupport for" << m_generator->source()
|
||||||
<< generatedFile;
|
<< generatedFile;
|
||||||
|
|
||||||
connect(m_generator, &ProjectExplorer::ExtraCompiler::contentsChanged,
|
connect(m_generator, &ExtraCompiler::contentsChanged,
|
||||||
this, &GeneratedCodeModelSupport::onContentsChanged, Qt::QueuedConnection);
|
this, &GeneratedCodeModelSupport::onContentsChanged, Qt::QueuedConnection);
|
||||||
onContentsChanged(generatedFile);
|
onContentsChanged(generatedFile);
|
||||||
}
|
}
|
||||||
@@ -63,14 +67,14 @@ GeneratedCodeModelSupport::GeneratedCodeModelSupport(CppModelManager *modelmanag
|
|||||||
GeneratedCodeModelSupport::~GeneratedCodeModelSupport()
|
GeneratedCodeModelSupport::~GeneratedCodeModelSupport()
|
||||||
{
|
{
|
||||||
CppModelManager::instance()->emitAbstractEditorSupportRemoved(
|
CppModelManager::instance()->emitAbstractEditorSupportRemoved(
|
||||||
m_generatedFileName.toString());
|
m_generatedFilePath.toString());
|
||||||
QLoggingCategory log("qtc.cppeditor.generatedcodemodelsupport", QtWarningMsg);
|
QLoggingCategory log("qtc.cppeditor.generatedcodemodelsupport", QtWarningMsg);
|
||||||
qCDebug(log) << "dtor ~generatedcodemodelsupport for" << m_generatedFileName;
|
qCDebug(log) << "dtor ~generatedcodemodelsupport for" << m_generatedFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneratedCodeModelSupport::onContentsChanged(const Utils::FilePath &file)
|
void GeneratedCodeModelSupport::onContentsChanged(const FilePath &file)
|
||||||
{
|
{
|
||||||
if (file == m_generatedFileName) {
|
if (file == m_generatedFilePath) {
|
||||||
notifyAboutUpdatedContents();
|
notifyAboutUpdatedContents();
|
||||||
updateDocument();
|
updateDocument();
|
||||||
}
|
}
|
||||||
@@ -78,20 +82,20 @@ void GeneratedCodeModelSupport::onContentsChanged(const Utils::FilePath &file)
|
|||||||
|
|
||||||
QByteArray GeneratedCodeModelSupport::contents() const
|
QByteArray GeneratedCodeModelSupport::contents() const
|
||||||
{
|
{
|
||||||
return m_generator->content(m_generatedFileName);
|
return m_generator->content(m_generatedFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GeneratedCodeModelSupport::fileName() const
|
FilePath GeneratedCodeModelSupport::filePath() const
|
||||||
{
|
{
|
||||||
return m_generatedFileName.toString();
|
return m_generatedFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GeneratedCodeModelSupport::sourceFileName() const
|
FilePath GeneratedCodeModelSupport::sourceFilePath() const
|
||||||
{
|
{
|
||||||
return m_generator->source().toString();
|
return m_generator->source();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneratedCodeModelSupport::update(const QList<ProjectExplorer::ExtraCompiler *> &generators)
|
void GeneratedCodeModelSupport::update(const QList<ExtraCompiler *> &generators)
|
||||||
{
|
{
|
||||||
static QObjectCache extraCompilerCache;
|
static QObjectCache extraCompilerCache;
|
||||||
|
|
||||||
@@ -102,10 +106,10 @@ void GeneratedCodeModelSupport::update(const QList<ProjectExplorer::ExtraCompile
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
extraCompilerCache.insert(generator);
|
extraCompilerCache.insert(generator);
|
||||||
generator->forEachTarget([mm, generator](const Utils::FilePath &generatedFile) {
|
generator->forEachTarget([mm, generator](const FilePath &generatedFile) {
|
||||||
new GeneratedCodeModelSupport(mm, generator, generatedFile);
|
new GeneratedCodeModelSupport(mm, generator, generatedFile);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CppEditor
|
} // CppEditor
|
||||||
|
@@ -6,15 +6,7 @@
|
|||||||
#include "cppeditor_global.h"
|
#include "cppeditor_global.h"
|
||||||
#include "abstracteditorsupport.h"
|
#include "abstracteditorsupport.h"
|
||||||
|
|
||||||
#include <projectexplorer/projectnodes.h>
|
namespace ProjectExplorer { class ExtraCompiler; }
|
||||||
#include <projectexplorer/extracompiler.h>
|
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QHash>
|
|
||||||
#include <QSet>
|
|
||||||
|
|
||||||
namespace Core { class IEditor; }
|
|
||||||
namespace ProjectExplorer { class Project; }
|
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
|
|
||||||
@@ -30,14 +22,14 @@ public:
|
|||||||
|
|
||||||
/// \returns the contents encoded in UTF-8.
|
/// \returns the contents encoded in UTF-8.
|
||||||
QByteArray contents() const override;
|
QByteArray contents() const override;
|
||||||
QString fileName() const override; // The generated file
|
Utils::FilePath filePath() const override; // The generated file
|
||||||
QString sourceFileName() const override;
|
Utils::FilePath sourceFilePath() const override;
|
||||||
|
|
||||||
static void update(const QList<ProjectExplorer::ExtraCompiler *> &generators);
|
static void update(const QList<ProjectExplorer::ExtraCompiler *> &generators);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onContentsChanged(const Utils::FilePath &file);
|
void onContentsChanged(const Utils::FilePath &file);
|
||||||
Utils::FilePath m_generatedFileName;
|
Utils::FilePath m_generatedFilePath;
|
||||||
ProjectExplorer::ExtraCompiler *m_generator;
|
ProjectExplorer::ExtraCompiler *m_generator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -17,16 +17,17 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
static const char uiMemberC[] = "ui";
|
static const char uiMemberC[] = "ui";
|
||||||
static const char uiNamespaceC[] = "Ui";
|
static const char uiNamespaceC[] = "Ui";
|
||||||
|
|
||||||
namespace Designer {
|
namespace Designer {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
// Generation code
|
// Generation code
|
||||||
|
|
||||||
// Write out how to access the Ui class in the source code.
|
// Write out how to access the Ui class in the source code.
|
||||||
static inline void writeUiMemberAccess(const QtSupport::CodeGenSettings &fp, QTextStream &str)
|
static void writeUiMemberAccess(const QtSupport::CodeGenSettings &fp, QTextStream &str)
|
||||||
{
|
{
|
||||||
switch (fp.embedding) {
|
switch (fp.embedding) {
|
||||||
case QtSupport::CodeGenSettings::PointerAggregatedUiClass:
|
case QtSupport::CodeGenSettings::PointerAggregatedUiClass:
|
||||||
@@ -40,8 +41,6 @@ static inline void writeUiMemberAccess(const QtSupport::CodeGenSettings &fp, QTe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
|
|
||||||
bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParameters ¶meters,
|
bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParameters ¶meters,
|
||||||
QString *header, QString *source, int indentation)
|
QString *header, QString *source, int indentation)
|
||||||
{
|
{
|
||||||
@@ -72,9 +71,11 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete
|
|||||||
const QString unqualifiedClassName = namespaceList.takeLast();
|
const QString unqualifiedClassName = namespaceList.takeLast();
|
||||||
|
|
||||||
const QString headerLicense =
|
const QString headerLicense =
|
||||||
CppEditor::AbstractEditorSupport::licenseTemplate(parameters.headerFile, parameters.className);
|
CppEditor::AbstractEditorSupport::licenseTemplate(
|
||||||
|
FilePath::fromString(parameters.headerFile), parameters.className);
|
||||||
const QString sourceLicense =
|
const QString sourceLicense =
|
||||||
CppEditor::AbstractEditorSupport::licenseTemplate(parameters.sourceFile, parameters.className);
|
CppEditor::AbstractEditorSupport::licenseTemplate(
|
||||||
|
FilePath::fromString(parameters.sourceFile), parameters.className);
|
||||||
// Include guards
|
// Include guards
|
||||||
const QString guard = Utils::headerGuard(parameters.headerFile, namespaceList);
|
const QString guard = Utils::headerGuard(parameters.headerFile, namespaceList);
|
||||||
|
|
||||||
@@ -165,7 +166,7 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete
|
|||||||
if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass)
|
if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass)
|
||||||
sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")";
|
sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")";
|
||||||
sourceStr << '\n' << namespaceIndent << "{\n" << namespaceIndent << indent;
|
sourceStr << '\n' << namespaceIndent << "{\n" << namespaceIndent << indent;
|
||||||
Internal::writeUiMemberAccess(generationParameters, sourceStr);
|
writeUiMemberAccess(generationParameters, sourceStr);
|
||||||
sourceStr << "setupUi(this);\n" << namespaceIndent << "}\n";
|
sourceStr << "setupUi(this);\n" << namespaceIndent << "}\n";
|
||||||
// Deleting destructor for ptr
|
// Deleting destructor for ptr
|
||||||
if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass) {
|
if (generationParameters.embedding == QtSupport::CodeGenSettings::PointerAggregatedUiClass) {
|
||||||
@@ -181,7 +182,7 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete
|
|||||||
<< namespaceIndent << indent << formBaseClass << "::changeEvent(e);\n"
|
<< namespaceIndent << indent << formBaseClass << "::changeEvent(e);\n"
|
||||||
<< namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n"
|
<< namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n"
|
||||||
<< namespaceIndent << indent << indent;
|
<< namespaceIndent << indent << indent;
|
||||||
Internal::writeUiMemberAccess(generationParameters, sourceStr);
|
writeUiMemberAccess(generationParameters, sourceStr);
|
||||||
sourceStr << "retranslateUi(this);\n"
|
sourceStr << "retranslateUi(this);\n"
|
||||||
<< namespaceIndent << indent << indent << "break;\n"
|
<< namespaceIndent << indent << indent << "break;\n"
|
||||||
<< namespaceIndent << indent << "default:\n"
|
<< namespaceIndent << indent << "default:\n"
|
||||||
|
@@ -18,14 +18,15 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
|
namespace QmakeProjectManager::Internal {
|
||||||
|
|
||||||
static QString headerGuard(const QString &header)
|
static QString headerGuard(const QString &header)
|
||||||
{
|
{
|
||||||
return header.toUpper().replace(QRegularExpression("[^A-Z0-9]+"), QString("_"));
|
return header.toUpper().replace(QRegularExpression("[^A-Z0-9]+"), QString("_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmakeProjectManager {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
struct ProjectContents {
|
struct ProjectContents {
|
||||||
QString tmpl;
|
QString tmpl;
|
||||||
QString library;
|
QString library;
|
||||||
@@ -100,7 +101,8 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
|||||||
if (pluginHeaderContents.isEmpty())
|
if (pluginHeaderContents.isEmpty())
|
||||||
return QList<Core::GeneratedFile>();
|
return QList<Core::GeneratedFile>();
|
||||||
Core::GeneratedFile pluginHeader(baseDir + wo.pluginHeaderFile);
|
Core::GeneratedFile pluginHeader(baseDir + wo.pluginHeaderFile);
|
||||||
pluginHeader.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(wo.pluginHeaderFile, wo.pluginClassName)
|
pluginHeader.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(
|
||||||
|
FilePath::fromString(wo.pluginHeaderFile), wo.pluginClassName)
|
||||||
+ pluginHeaderContents);
|
+ pluginHeaderContents);
|
||||||
rc.push_back(pluginHeader);
|
rc.push_back(pluginHeader);
|
||||||
|
|
||||||
@@ -128,7 +130,8 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
|||||||
if (pluginSourceContents.isEmpty())
|
if (pluginSourceContents.isEmpty())
|
||||||
return QList<Core::GeneratedFile>();
|
return QList<Core::GeneratedFile>();
|
||||||
Core::GeneratedFile pluginSource(baseDir + wo.pluginSourceFile);
|
Core::GeneratedFile pluginSource(baseDir + wo.pluginSourceFile);
|
||||||
pluginSource.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(wo.pluginSourceFile, wo.pluginClassName)
|
pluginSource.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(
|
||||||
|
FilePath::fromString(wo.pluginSourceFile), wo.pluginClassName)
|
||||||
+ pluginSourceContents);
|
+ pluginSourceContents);
|
||||||
if (i == 0 && widgetCount == 1) // Open first widget unless collection
|
if (i == 0 && widgetCount == 1) // Open first widget unless collection
|
||||||
pluginSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
pluginSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||||
@@ -174,7 +177,9 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
|||||||
if (widgetHeaderContents.isEmpty())
|
if (widgetHeaderContents.isEmpty())
|
||||||
return QList<Core::GeneratedFile>();
|
return QList<Core::GeneratedFile>();
|
||||||
Core::GeneratedFile widgetHeader(baseDir + wo.widgetHeaderFile);
|
Core::GeneratedFile widgetHeader(baseDir + wo.widgetHeaderFile);
|
||||||
widgetHeader.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(wo.widgetHeaderFile, wo.widgetClassName)
|
widgetHeader.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(
|
||||||
|
FilePath::fromString(wo.widgetHeaderFile),
|
||||||
|
wo.widgetClassName)
|
||||||
+ widgetHeaderContents);
|
+ widgetHeaderContents);
|
||||||
rc.push_back(widgetHeader);
|
rc.push_back(widgetHeader);
|
||||||
|
|
||||||
@@ -184,7 +189,9 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
|||||||
if (widgetSourceContents.isEmpty())
|
if (widgetSourceContents.isEmpty())
|
||||||
return QList<Core::GeneratedFile>();
|
return QList<Core::GeneratedFile>();
|
||||||
Core::GeneratedFile widgetSource(baseDir + wo.widgetSourceFile);
|
Core::GeneratedFile widgetSource(baseDir + wo.widgetSourceFile);
|
||||||
widgetSource.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(wo.widgetSourceFile, wo.widgetClassName)
|
widgetSource.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(
|
||||||
|
FilePath::fromString(wo.widgetSourceFile),
|
||||||
|
wo.widgetClassName)
|
||||||
+ widgetSourceContents);
|
+ widgetSourceContents);
|
||||||
rc.push_back(widgetSource);
|
rc.push_back(widgetSource);
|
||||||
}
|
}
|
||||||
@@ -219,7 +226,9 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
|||||||
if (collectionHeaderContents.isEmpty())
|
if (collectionHeaderContents.isEmpty())
|
||||||
return QList<Core::GeneratedFile>();
|
return QList<Core::GeneratedFile>();
|
||||||
Core::GeneratedFile collectionHeader(baseDir + options.collectionHeaderFile);
|
Core::GeneratedFile collectionHeader(baseDir + options.collectionHeaderFile);
|
||||||
collectionHeader.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(options.collectionHeaderFile, options.collectionClassName)
|
collectionHeader.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(
|
||||||
|
FilePath::fromString(options.collectionHeaderFile),
|
||||||
|
options.collectionClassName)
|
||||||
+ collectionHeaderContents);
|
+ collectionHeaderContents);
|
||||||
rc.push_back(collectionHeader);
|
rc.push_back(collectionHeader);
|
||||||
|
|
||||||
@@ -235,7 +244,9 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
|||||||
if (collectionSourceFileContents.isEmpty())
|
if (collectionSourceFileContents.isEmpty())
|
||||||
return QList<Core::GeneratedFile>();
|
return QList<Core::GeneratedFile>();
|
||||||
Core::GeneratedFile collectionSource(baseDir + options.collectionSourceFile);
|
Core::GeneratedFile collectionSource(baseDir + options.collectionSourceFile);
|
||||||
collectionSource.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(options.collectionSourceFile, options.collectionClassName)
|
collectionSource.setContents(CppEditor::AbstractEditorSupport::licenseTemplate(
|
||||||
|
FilePath::fromString(options.collectionSourceFile),
|
||||||
|
options.collectionClassName)
|
||||||
+ collectionSourceFileContents);
|
+ collectionSourceFileContents);
|
||||||
collectionSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
collectionSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||||
rc.push_back(collectionSource);
|
rc.push_back(collectionSource);
|
||||||
@@ -336,5 +347,4 @@ QString PluginGenerator::cStringQuote(QString s)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // QmakeProjectManager::Internal
|
||||||
}
|
|
||||||
|
@@ -6,10 +6,13 @@
|
|||||||
#include "qmakeproject.h"
|
#include "qmakeproject.h"
|
||||||
#include "qmakeprojectmanagertr.h"
|
#include "qmakeprojectmanagertr.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/extracompiler.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
#include <resourceeditor/resourcenode.h>
|
#include <resourceeditor/resourcenode.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include <cppeditor/cppeditorconstants.h>
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
|
|
||||||
#include <projectexplorer/editorconfiguration.h>
|
#include <projectexplorer/editorconfiguration.h>
|
||||||
|
#include <projectexplorer/extracompiler.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
@@ -31,7 +32,6 @@
|
|||||||
#include <utils/QtConcurrentTools>
|
#include <utils/QtConcurrentTools>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/filesystemwatcher.h>
|
#include <utils/filesystemwatcher.h>
|
||||||
#include <utils/fileutils.h>
|
|
||||||
#include <utils/mimeutils.h>
|
#include <utils/mimeutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
#include <cppeditor/generatedcodemodelsupport.h>
|
#include <cppeditor/generatedcodemodelsupport.h>
|
||||||
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <utils/textfileformat.h>
|
#include <utils/textfileformat.h>
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
@@ -20,12 +21,15 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace ProjectExplorer { class BuildConfiguration; }
|
namespace ProjectExplorer {
|
||||||
|
class BuildConfiguration;
|
||||||
|
class ExtraCompilerFactory;
|
||||||
|
} // ProjectExplorer
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
class FilePath;
|
class FilePath;
|
||||||
class FileSystemWatcher;
|
class FileSystemWatcher;
|
||||||
} // namespace Utils;
|
} // Utils;
|
||||||
|
|
||||||
namespace QtSupport { class ProFileReader; }
|
namespace QtSupport { class ProFileReader; }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user