本文整理汇总了C++中project::Item类的典型用法代码示例。如果您正苦于以下问题:C++ Item类的具体用法?C++ Item怎么用?C++ Item使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Item类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addBrowseableCode
void LibraryModule::addBrowseableCode (ProjectExporter& exporter, const Array<File>& compiled, const File& localModuleFolder) const
{
if (sourceFiles.size() == 0)
findBrowseableFiles (localModuleFolder, sourceFiles);
Project::Item sourceGroup (Project::Item::createGroup (exporter.getProject(), getID(), "__mainsourcegroup" + getID()));
const RelativePath moduleFromProject (exporter.getModuleFolderRelativeToProject (getID()));
for (int i = 0; i < sourceFiles.size(); ++i)
{
const String pathWithinModule (FileHelpers::getRelativePathFrom (sourceFiles.getReference(i), localModuleFolder));
// (Note: in exporters like MSVC we have to avoid adding the same file twice, even if one of those instances
// is flagged as being excluded from the build, because this overrides the other and it fails to compile)
if (exporter.canCopeWithDuplicateFiles() || ! compiled.contains (sourceFiles.getReference(i)))
addFileWithGroups (sourceGroup,
moduleFromProject.getChildFile (pathWithinModule),
pathWithinModule);
}
sourceGroup.addFileAtIndex (localModuleFolder.getChildFile (FileHelpers::getRelativePathFrom (moduleInfo.manifestFile,
moduleInfo.getFolder())), -1, false);
sourceGroup.addFileAtIndex (getModuleHeaderFile (localModuleFolder), -1, false);
exporter.getModulesGroup().state.addChild (sourceGroup.state.createCopy(), -1, nullptr);
}
示例2: findAndAddCompiledUnits
void LibraryModule::findAndAddCompiledUnits (ProjectExporter& exporter, ProjectSaver* projectSaver,
const File& localModuleFolder, Array<File>& result) const
{
const var compileArray (moduleInfo.moduleInfo ["compile"]); // careful to keep this alive while the array is in use!
if (const Array<var>* const files = compileArray.getArray())
{
for (int i = 0; i < files->size(); ++i)
{
const var& file = files->getReference(i);
const String filename (file ["file"].toString());
if (filename.isNotEmpty() && fileShouldBeCompiled (exporter, file))
{
const File compiledFile (localModuleFolder.getChildFile (filename));
result.add (compiledFile);
if (projectSaver != nullptr)
{
Project::Item item (projectSaver->addFileToGeneratedGroup (compiledFile));
if (file ["warnings"].toString().equalsIgnoreCase ("disabled"))
item.getShouldInhibitWarningsValue() = true;
if (file ["stdcall"])
item.getShouldUseStdCallValue() = true;
}
}
}
}
}
示例3: findImages
static void findImages (const Project::Item& item, OwnedArray<Project::Item>& found)
{
if (item.isImageFile())
{
found.add (new Project::Item (item));
}
else if (item.isGroup())
{
for (int i = 0; i < item.getNumChildren(); ++i)
findImages (item.getChild (i), found);
}
}
示例4: addResourcesFromProjectItem
//==============================================================================
void ResourceFile::addResourcesFromProjectItem (const Project::Item& projectItem)
{
if (projectItem.isGroup())
{
for (int i = 0; i < projectItem.getNumChildren(); ++i)
addResourcesFromProjectItem (projectItem.getChild(i));
}
else
{
if (projectItem.shouldBeAddedToBinaryResources())
addFile (projectItem.getFile());
}
}
示例5: setName
void SourceFileTreeViewItem::setName (const String& newName)
{
if (newName != File::createLegalFileName (newName))
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon, "File Rename",
"That filename contained some illegal characters!");
triggerAsyncRename (item);
return;
}
File oldFile (getFile());
File newFile (oldFile.getSiblingFile (newName));
File correspondingFile (findCorrespondingHeaderOrCpp (oldFile));
if (correspondingFile.exists() && newFile.hasFileExtension (oldFile.getFileExtension()))
{
Project::Item correspondingItem (item.project.getMainGroup().findItemForFile (correspondingFile));
if (correspondingItem.isValid())
{
if (AlertWindow::showOkCancelBox (AlertWindow::NoIcon, "File Rename",
"Do you also want to rename the corresponding file \"" + correspondingFile.getFileName()
+ "\" to match?"))
{
if (! item.renameFile (newFile))
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon, "File Rename",
"Failed to rename \"" + oldFile.getFullPathName() + "\"!\n\nCheck your file permissions!");
return;
}
if (! correspondingItem.renameFile (newFile.withFileExtension (correspondingFile.getFileExtension())))
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon, "File Rename",
"Failed to rename \"" + correspondingFile.getFullPathName() + "\"!\n\nCheck your file permissions!");
}
}
}
}
if (! item.renameFile (newFile))
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon, "File Rename",
"Failed to rename the file!\n\nCheck your file permissions!");
}
}
示例6: addFileWithGroups
static void addFileWithGroups (Project::Item& group, const RelativePath& file, const String& path)
{
const int slash = path.indexOfChar (File::separator);
if (slash >= 0)
{
const String topLevelGroup (path.substring (0, slash));
const String remainingPath (path.substring (slash + 1));
Project::Item newGroup (group.getOrCreateSubGroup (topLevelGroup));
addFileWithGroups (newGroup, file, remainingPath);
}
else
{
if (! group.containsChildForFile (file))
group.addRelativeFile (file, -1, false);
}
}
示例7: addFileWithGroups
static void addFileWithGroups (Project::Item& group, const RelativePath& file, const String& path)
{
auto slash = path.indexOfChar (File::getSeparatorChar());
if (slash >= 0)
{
auto topLevelGroup = path.substring (0, slash);
auto remainingPath = path.substring (slash + 1);
auto newGroup = group.getOrCreateSubGroup (topLevelGroup);
addFileWithGroups (newGroup, file, remainingPath);
}
else
{
if (! group.containsChildForFile (file))
group.addRelativeFile (file, -1, false);
}
}
示例8: moveItems
void ProjectTreeViewBase::moveItems (OwnedArray <Project::Item>& selectedNodes,
Project::Item destNode, int insertIndex)
{
for (int i = selectedNodes.size(); --i >= 0;)
{
Project::Item* const n = selectedNodes.getUnchecked(i);
if (destNode == *n || destNode.state.isAChildOf (n->state)) // Check for recursion.
return;
if (! destNode.canContain (*n))
selectedNodes.remove (i);
}
// Don't include any nodes that are children of other selected nodes..
for (int i = selectedNodes.size(); --i >= 0;)
{
Project::Item* const n = selectedNodes.getUnchecked(i);
for (int j = selectedNodes.size(); --j >= 0;)
{
if (j != i && n->state.isAChildOf (selectedNodes.getUnchecked(j)->state))
{
selectedNodes.remove (i);
break;
}
}
}
// Remove and re-insert them one at a time..
for (int i = 0; i < selectedNodes.size(); ++i)
{
Project::Item* selectedNode = selectedNodes.getUnchecked(i);
if (selectedNode->state.getParent() == destNode.state
&& indexOfNode (destNode.state, selectedNode->state) < insertIndex)
--insertIndex;
selectedNode->removeItemFromProject();
destNode.addChild (*selectedNode, insertIndex++);
}
}
示例9: create
static bool create (Project::Item parent, const File& newFile, const char* templateName)
{
if (fillInNewCppFileTemplate (newFile, parent, templateName))
{
parent.addFile (newFile, 0, true);
return true;
}
showFailedToWriteMessage (newFile);
return false;
}
示例10: createNewFile
void createNewFile (Project::Item parent) override
{
const File newFile (askUserToChooseNewFile (String (defaultClassName) + ".h", "*.h;*.cpp", parent));
if (newFile != File::nonexistent)
{
const File headerFile (newFile.withFileExtension (".h"));
const File cppFile (newFile.withFileExtension (".cpp"));
headerFile.replaceWithText (String::empty);
cppFile.replaceWithText (String::empty);
OpenDocumentManager& odm = IntrojucerApp::getApp().openDocumentManager;
if (SourceCodeDocument* cpp = dynamic_cast <SourceCodeDocument*> (odm.openFile (nullptr, cppFile)))
{
if (SourceCodeDocument* header = dynamic_cast <SourceCodeDocument*> (odm.openFile (nullptr, headerFile)))
{
ScopedPointer<JucerDocument> jucerDoc (new ComponentDocument (cpp));
if (jucerDoc != nullptr)
{
jucerDoc->setClassName (newFile.getFileNameWithoutExtension());
jucerDoc->flushChangesToDocuments();
jucerDoc = nullptr;
cpp->save();
header->save();
odm.closeDocument (cpp, true);
odm.closeDocument (header, true);
parent.addFile (headerFile, 0, true);
parent.addFile (cppFile, 0, true);
}
}
}
}
}
示例11: createNewFile
void createNewFile (Project& project, Project::Item parent) override
{
auto newFile = askUserToChooseNewFile (String (defaultClassName) + ".h", "*.h;*.cpp", parent);
if (newFile != File())
{
auto headerFile = newFile.withFileExtension (".h");
auto cppFile = newFile.withFileExtension (".cpp");
headerFile.replaceWithText (String());
cppFile.replaceWithText (String());
auto& odm = ProjucerApplication::getApp().openDocumentManager;
if (auto* cpp = dynamic_cast<SourceCodeDocument*> (odm.openFile (nullptr, cppFile)))
{
if (auto* header = dynamic_cast<SourceCodeDocument*> (odm.openFile (nullptr, headerFile)))
{
std::unique_ptr<JucerDocument> jucerDoc (new ComponentDocument (cpp));
if (jucerDoc != nullptr)
{
jucerDoc->setClassName (newFile.getFileNameWithoutExtension());
jucerDoc->flushChangesToDocuments (&project);
jucerDoc.reset();
cpp->save();
header->save();
odm.closeDocument (cpp, true);
odm.closeDocument (header, true);
parent.addFileRetainingSortOrder (headerFile, true);
parent.addFileRetainingSortOrder (cppFile, true);
}
}
}
}
}
示例12: fc
File NewFileWizard::Type::askUserToChooseNewFile (const String& suggestedFilename, const String& wildcard,
const Project::Item& projectGroupToAddTo)
{
FileChooser fc ("Select File to Create",
projectGroupToAddTo.determineGroupFolder()
.getChildFile (suggestedFilename)
.getNonexistentSibling(),
wildcard);
if (fc.browseForFileToSave (true))
return fc.getResult();
return File::nonexistent;
}
示例13: initialiseProject
bool initialiseProject (Project& project)
{
if (! getSourceFilesFolder().createDirectory())
failedFiles.add (getSourceFilesFolder().getFullPathName());
File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp");
File mainWindowCpp = getSourceFilesFolder().getChildFile ("MainWindow.cpp");
File mainWindowH = mainWindowCpp.withFileExtension (".h");
String windowClassName = "MainAppWindow";
project.getProjectTypeValue() = ProjectType::getGUIAppTypeName();
Project::Item sourceGroup (project.getMainGroup().addNewSubGroup ("Source", 0));
setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
String initCode, shutdownCode, anotherInstanceStartedCode, privateMembers, memberInitialisers;
if (createWindow)
{
appHeaders << newLine << CodeHelpers::createIncludeStatement (mainWindowH, mainCppFile);
initCode = "mainWindow = new " + windowClassName + "();";
shutdownCode = "mainWindow = 0;";
privateMembers = "ScopedPointer <" + windowClassName + "> mainWindow;";
String windowH = project.getFileTemplate ("jucer_WindowTemplate_h")
.replace ("INCLUDES", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainWindowH), false)
.replace ("WINDOWCLASS", windowClassName, false)
.replace ("HEADERGUARD", CodeHelpers::makeHeaderGuardName (mainWindowH), false);
String windowCpp = project.getFileTemplate ("jucer_WindowTemplate_cpp")
.replace ("INCLUDES", CodeHelpers::createIncludeStatement (mainWindowH, mainWindowCpp), false)
.replace ("WINDOWCLASS", windowClassName, false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainWindowH, windowH))
failedFiles.add (mainWindowH.getFullPathName());
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainWindowCpp, windowCpp))
failedFiles.add (mainWindowCpp.getFullPathName());
sourceGroup.addFile (mainWindowCpp, -1, true);
sourceGroup.addFile (mainWindowH, -1, false);
}
if (createMainCpp)
{
String mainCpp = project.getFileTemplate ("jucer_MainTemplate_cpp")
.replace ("APPHEADERS", appHeaders, false)
.replace ("APPCLASSNAME", CodeHelpers::makeValidIdentifier (appTitle + "Application", false, true, false), false)
.replace ("MEMBERINITIALISERS", memberInitialisers, false)
.replace ("APPINITCODE", initCode, false)
.replace ("APPSHUTDOWNCODE", shutdownCode, false)
.replace ("APPNAME", CodeHelpers::addEscapeChars (appTitle), false)
.replace ("APPVERSION", "1.0", false)
.replace ("ALLOWMORETHANONEINSTANCE", "true", false)
.replace ("ANOTHERINSTANCECODE", anotherInstanceStartedCode, false)
.replace ("PRIVATEMEMBERS", privateMembers, false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
failedFiles.add (mainCppFile.getFullPathName());
sourceGroup.addFile (mainCppFile, -1, true);
}
project.createDefaultExporters();
return true;
}
示例14: initialiseProject
bool initialiseProject (Project& project)
{
if (! getSourceFilesFolder().createDirectory())
failedFiles.add (getSourceFilesFolder().getFullPathName());
File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp");
File contentCompCpp = getSourceFilesFolder().getChildFile ("MainComponent.cpp");
File contentCompH = contentCompCpp.withFileExtension (".h");
String contentCompName = "MainContentComponent";
project.getProjectTypeValue() = ProjectType::getGUIAppTypeName();
Project::Item sourceGroup (project.getMainGroup().addNewSubGroup ("Source", 0));
setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
if (createWindow)
{
appHeaders << newLine << CodeHelpers::createIncludeStatement (contentCompH, mainCppFile);
String windowH = project.getFileTemplate ("jucer_ContentCompTemplate_h")
.replace ("INCLUDE_JUCE", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompH), false)
.replace ("CONTENTCOMPCLASS", contentCompName, false)
.replace ("HEADERGUARD", CodeHelpers::makeHeaderGuardName (contentCompH), false);
String windowCpp = project.getFileTemplate ("jucer_ContentCompTemplate_cpp")
.replace ("INCLUDE_JUCE", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompCpp), false)
.replace ("INCLUDE_CORRESPONDING_HEADER", CodeHelpers::createIncludeStatement (contentCompH, contentCompCpp), false)
.replace ("CONTENTCOMPCLASS", contentCompName, false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompH, windowH))
failedFiles.add (contentCompH.getFullPathName());
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompCpp, windowCpp))
failedFiles.add (contentCompCpp.getFullPathName());
sourceGroup.addFile (contentCompCpp, -1, true);
sourceGroup.addFile (contentCompH, -1, false);
}
if (createMainCpp)
{
String mainCpp = project.getFileTemplate (createWindow ? "jucer_MainTemplate_Window_cpp"
: "jucer_MainTemplate_NoWindow_cpp")
.replace ("APPHEADERS", appHeaders, false)
.replace ("APPCLASSNAME", CodeHelpers::makeValidIdentifier (appTitle + "Application", false, true, false), false)
.replace ("APPNAME", CodeHelpers::addEscapeChars (appTitle), false)
.replace ("CONTENTCOMPCLASS", contentCompName, false)
.replace ("ALLOWMORETHANONEINSTANCE", "true", false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
failedFiles.add (mainCppFile.getFullPathName());
sourceGroup.addFile (mainCppFile, -1, true);
}
project.createExporterForCurrentPlatform();
return true;
}