本文整理汇总了C++中QtProjectParameters::writeProFile方法的典型用法代码示例。如果您正苦于以下问题:C++ QtProjectParameters::writeProFile方法的具体用法?C++ QtProjectParameters::writeProFile怎么用?C++ QtProjectParameters::writeProFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QtProjectParameters
的用法示例。
在下文中一共展示了QtProjectParameters::writeProFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_UNUSED
Core::GeneratedFiles TestWizard::generateFiles(const QWizard *w, QString *errorMessage) const
{
Q_UNUSED(errorMessage)
const TestWizardDialog *wizardDialog = qobject_cast<const TestWizardDialog *>(w);
QTC_ASSERT(wizardDialog, return Core::GeneratedFiles());
const QtProjectParameters projectParams = wizardDialog->projectParameters();
const TestWizardParameters testParams = wizardDialog->testParameters();
const QString projectPath = projectParams.projectPath();
// Create files: Source
const QString sourceFilePath = Core::BaseFileWizardFactory::buildFileName(projectPath, testParams.fileName, sourceSuffix());
const QFileInfo sourceFileInfo(sourceFilePath);
Core::GeneratedFile source(sourceFilePath);
source.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
source.setContents(generateTestCode(testParams, sourceFileInfo.baseName()));
// Create profile with define for base dir to find test data
const QString profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, projectParams.fileName, profileSuffix());
Core::GeneratedFile profile(profileName);
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
QString contents;
{
QTextStream proStr(&contents);
QtProjectParameters::writeProFileHeader(proStr);
projectParams.writeProFile(proStr);
proStr << "\n\nSOURCES += " << Utils::FileName::fromString(sourceFilePath).fileName() << '\n'
<< "DEFINES += SRCDIR=\\\\\\\"$$PWD/\\\\\\\"\n";
}
profile.setContents(contents);
return Core::GeneratedFiles() << source << profile;
}
示例2: QLatin1String
Core::GeneratedFiles
ConsoleAppWizard::generateFiles(const QWizard *w,
QString * /*errorMessage*/) const
{
const ConsoleAppWizardDialog *wizard = qobject_cast< const ConsoleAppWizardDialog *>(w);
const QtProjectParameters params = wizard->parameters();
const QString projectPath = params.projectPath();
// Create files: Source
const QString sourceFileName = Core::BaseFileWizard::buildFileName(projectPath, QLatin1String(mainSourceFileC), sourceSuffix());
Core::GeneratedFile source(sourceFileName);
source.setContents(CppTools::AbstractEditorSupport::licenseTemplate(sourceFileName) + QLatin1String(mainCppC));
source.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
// Create files: Profile
const QString profileName = Core::BaseFileWizard::buildFileName(projectPath, params.fileName, profileSuffix());
Core::GeneratedFile profile(profileName);
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
QString contents;
{
QTextStream proStr(&contents);
QtProjectParameters::writeProFileHeader(proStr);
params.writeProFile(proStr);
proStr << "\n\nSOURCES += " << QFileInfo(sourceFileName).fileName() << '\n';
}
profile.setContents(contents);
return Core::GeneratedFiles() << source << profile;
}
示例3: Q_UNUSED
Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w,
QString *errorMessage) const
{
Q_UNUSED(errorMessage)
const LibraryWizardDialog *dialog = qobject_cast<const LibraryWizardDialog *>(w);
const QtProjectParameters projectParams = dialog->parameters();
const QString projectPath = projectParams.projectPath();
const LibraryParameters params = dialog->libraryParameters();
const QString sharedLibExportMacro = QtProjectParameters::exportMacro(projectParams.fileName);
Core::GeneratedFiles rc;
// Class header + source
const QString sourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix());
Core::GeneratedFile source(sourceFileName);
source.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
const QString headerFileFullName = buildFileName(projectPath, params.headerFileName, headerSuffix());
const QString headerFileName = Utils::FileName::fromString(headerFileFullName).fileName();
QString pluginJsonFileFullName;
QString pluginJsonFileName;
if (projectParams.type == QtProjectParameters::Qt4Plugin) {
pluginJsonFileFullName = buildFileName(projectPath, projectParams.fileName, QLatin1String("json"));
pluginJsonFileName = Utils::FileName::fromString(pluginJsonFileFullName).fileName();
}
Core::GeneratedFile header(headerFileFullName);
// Create files: global header for shared libs
QString globalHeaderFileName;
if (projectParams.type == QtProjectParameters::SharedLibrary) {
const QString globalHeaderName = buildFileName(projectPath, projectParams.fileName.toLower() + QLatin1String(sharedHeaderPostfixC), headerSuffix());
Core::GeneratedFile globalHeader(globalHeaderName);
globalHeaderFileName = Utils::FileName::fromString(globalHeader.path()).fileName();
globalHeader.setContents(CppTools::AbstractEditorSupport::licenseTemplate(globalHeaderFileName)
+ LibraryParameters::generateSharedHeader(globalHeaderFileName, projectParams.fileName, sharedLibExportMacro));
rc.push_back(globalHeader);
}
// Generate code
QString headerContents, sourceContents;
params.generateCode(projectParams.type, projectParams.fileName, headerFileName,
globalHeaderFileName, sharedLibExportMacro, pluginJsonFileName,
/* indentation*/ 4, &headerContents, &sourceContents);
source.setContents(CppTools::AbstractEditorSupport::licenseTemplate(sourceFileName, params.className)
+ sourceContents);
header.setContents(CppTools::AbstractEditorSupport::licenseTemplate(headerFileFullName, params.className)
+ headerContents);
rc.push_back(source);
rc.push_back(header);
// Create files: profile
const QString profileName = buildFileName(projectPath, projectParams.fileName, profileSuffix());
Core::GeneratedFile profile(profileName);
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
QString profileContents;
{
QTextStream proStr(&profileContents);
QtProjectParameters::writeProFileHeader(proStr);
projectParams.writeProFile(proStr);
proStr << "\nSOURCES += " << Utils::FileName::fromString(source.path()).fileName()
<< "\n\nHEADERS += " << headerFileName;
if (!globalHeaderFileName.isEmpty())
proStr << "\\\n " << globalHeaderFileName << '\n';
if (!pluginJsonFileName.isEmpty())
proStr << "\nDISTFILES += " << pluginJsonFileName << '\n';
writeLinuxProFile(proStr);
}
profile.setContents(profileContents);
rc.push_back(profile);
if (!pluginJsonFileName.isEmpty()) {
Core::GeneratedFile jsonFile(pluginJsonFileFullName);
jsonFile.setContents(QLatin1String("{\n \"Keys\" : [ ]\n}\n"));
rc.push_back(jsonFile);
}
return rc;
}
示例4: templateDir
Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
QString *errorMessage) const
{
const GuiAppWizardDialog *dialog = qobject_cast<const GuiAppWizardDialog *>(w);
const QtProjectParameters projectParams = dialog->projectParameters();
const QString projectPath = projectParams.projectPath();
const GuiAppParameters params = dialog->parameters();
// Generate file names. Note that the path for the project files is the
// newly generated project directory.
const QString templatePath = templateDir();
// Create files: main source
QString contents;
const QString mainSourceFileName = buildFileName(projectPath, QLatin1String(mainSourceFileC), sourceSuffix());
Core::GeneratedFile mainSource(mainSourceFileName);
if (!parametrizeTemplate(templatePath, QLatin1String("main.cpp"), params, &contents, errorMessage))
return Core::GeneratedFiles();
mainSource.setContents(contents);
// Create files: form source
const QString formSourceTemplate = params.designerForm ? QLatin1String("mywidget_form.cpp") : QLatin1String("mywidget.cpp");
const QString formSourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix());
Core::GeneratedFile formSource(formSourceFileName);
if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage))
return Core::GeneratedFiles();
formSource.setContents(contents);
// Create files: form header
const QString formHeaderName = buildFileName(projectPath, params.headerFileName, headerSuffix());
const QString formHeaderTemplate = params.designerForm ? QLatin1String("mywidget_form.h") : QLatin1String("mywidget.h");
Core::GeneratedFile formHeader(formHeaderName);
if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage))
return Core::GeneratedFiles();
formHeader.setContents(contents);
// Create files: form
QSharedPointer<Core::GeneratedFile> form;
if (params.designerForm) {
const QString formName = buildFileName(projectPath, params.formFileName, formSuffix());
form = QSharedPointer<Core::GeneratedFile>(new Core::GeneratedFile(formName));
if (!parametrizeTemplate(templatePath, QLatin1String("widget.ui"), params, &contents, errorMessage))
return Core::GeneratedFiles();
form->setContents(contents);
}
// Create files: profile
const QString profileName = buildFileName(projectPath, projectParams.name, profileSuffix());
Core::GeneratedFile profile(profileName);
contents.clear();
{
QTextStream proStr(&contents);
QtProjectParameters::writeProFileHeader(proStr);
projectParams.writeProFile(proStr);
proStr << "\n\nSOURCES += " << QFileInfo(mainSourceFileName).fileName()
<< "\\\n " << QFileInfo(formSource.path()).fileName()
<< "\n\nHEADERS += " << QFileInfo(formHeader.path()).fileName();
if (params.designerForm)
proStr << "\n\nFORMS += " << QFileInfo(form->path()).fileName();
proStr << '\n';
}
profile.setContents(contents);
// List
Core::GeneratedFiles rc;
rc << mainSource << formSource << formHeader;
if (params.designerForm)
rc << *form;
rc << profile;
return rc;
}