int MakeCommand::execute() { const QString projectPathParameter = projectPath().isEmpty() ? QString() : QLatin1String(" -p ") + QLatin1String("'") + projectPath() + QLatin1String("'"); QString command = QLatin1String("mb2") + projectPathParameter + QLatin1String(" -t ") + targetName() + QLatin1Char(' ') + arguments().join(QLatin1String(" ")) + QLatin1Char(' '); MerRemoteProcess process; process.setSshParameters(sshParameters()); process.setCommand(remotePathMapping(command)); return process.executeAndWait(); }
/** * @brief Project::save */ void Project::save() { Q_ASSERT(!!m_Database); m_Errors.clear(); if (!m_Path.isEmpty()) { QDir dir(m_Path); if (!dir.exists()) if (!dir.mkpath(m_Path)) { m_Errors << tr("Cannot create project directory."); emit errors(tr("Make path error%1").arg(m_Errors.count() <= 1 ? "" : "s"), m_Errors); return; } if (!utility::writeToFile(*this, projectPath(m_Path))) m_Errors << tr("Cannot save project to file."); m_Database->setName(databaseFileName()); m_Database->setPath(m_Path); if (!m_Database->save()) m_Errors << tr("Cannot save database to file."); } else { m_Errors << "Project path is empty."; } setSaveStatus(m_Errors.isEmpty()); if (!m_Errors.isEmpty()) emit errors(tr("Project save error%1").arg(m_Errors.count() <= 1 ? "" : "s"), m_Errors); }
CProject* ProjectManager::projectObject(const QString &projectName) { if (!hasProject(projectName)) return 0; CProject *project = 0; if (projectObjectMap.contains(projectName)) { project = projectObjectMap[projectName]; if (!project->isValid()) project->update(); return project; } else { CProject *project = new CProject(projectPath(projectName)); connect(project, SIGNAL(updated(const QString &)), this, SIGNAL(projectUpdated(const QString &))); projectObjectMap[projectName] = project; return project; } }
Project* Project::open(const QString& path, QObject* parent) { if (!_serializerActivated) { Serializer::getActivator()->registerClass("gameplay::Project", &Project::createInstance); _serializerActivated = true; } QString projectPath(path + QString("/") + QString(QLatin1String(PROJECT_FILE))); if (!QFile(projectPath).exists()) return nullptr; QByteArray ba = projectPath.toLatin1(); const char* str = ba.data(); Serializer* projectReader = Serializer::createReader(str); Project* project = nullptr; if (projectReader) { project = static_cast<Project*>(projectReader->readObject(nullptr)); projectReader->close(); SAFE_DELETE(projectReader); } return project; }
/** * Returns absolute path of folder where model will be saved. */ QString BaseModel::path() const{ Q_ASSERT(prj != NULL); return projectPath() + "/" + folder(); }
bool cxProjectInfo::Load(const wxFileName& rootPath, const wxString& path, bool onlyFilters) { wxFileName projectPath(path, wxEmptyString); this->path = path; this->isRoot = (projectPath == rootPath); projectPath.SetFullName(wxT(".eprj")); if (!projectPath.FileExists()) return false; // Load plist file TiXmlDocument doc; wxFFile docffile(projectPath.GetFullPath(), _T("rb")); wxCHECK(docffile.IsOpened() && doc.LoadFile(docffile.fp()), false); // Get top dict const TiXmlHandle docHandle(&doc); const TiXmlElement* topDict = docHandle.FirstChildElement("plist").FirstChildElement().Element(); if (!topDict || strcmp(topDict->Value(), "dict") != 0) return false; // empty plist // Parse entries const TiXmlElement* entry = topDict->FirstChildElement(); for(; entry; entry = entry->NextSiblingElement() ) { if (strcmp(entry->Value(), "key") != 0) return false; // invalid dict const TiXmlElement* const value = entry->NextSiblingElement(); if (strcmp(entry->GetText(), "filters") == 0) { // Load all filters const TiXmlElement* filter = value->FirstChildElement(); for(; filter; filter = filter->NextSiblingElement() ) { if (strcmp(filter->Value(), "key") != 0) return false; // invalid dict // Set target array wxArrayString* filterArray = NULL; const char* filterName = filter->GetText(); if (strcmp(filterName, "includeDirs") == 0) filterArray = &this->includeDirs; else if (strcmp(filterName, "excludeDirs") == 0) filterArray = &this->excludeDirs; else if (strcmp(filterName, "includeFiles") == 0) filterArray = &this->includeFiles; else if (strcmp(filterName, "excludeFiles") == 0) filterArray = &this->excludeFiles; else { wxASSERT(false); break; } const TiXmlElement* const array = filter->NextSiblingElement(); if (strcmp(array->Value(), "array") != 0) return false; // invalid dict const TiXmlElement* child = array->FirstChildElement(); for(; child; child = child->NextSiblingElement() ) { const char* valType = child->Value(); if (strcmp(valType, "string") == 0) { const char* pattern = child->GetText(); if (pattern) filterArray->Add(wxString(pattern, wxConvUTF8)); } else { wxASSERT(false); } } filter = array; // jump over value } this->hasFilters = true; if (onlyFilters) return true; } else if (strcmp(entry->GetText(), "environment") == 0) { // Load all env variables const TiXmlElement* env = value->FirstChildElement(); for(; env; env = env->NextSiblingElement() ) { // Get Key if (strcmp(env->Value(), "key") != 0) return false; // invalid dict const char* key = env->GetText(); const TiXmlElement* const val = env->NextSiblingElement(); if (strcmp(val->Value(), "string") != 0) return false; // invalid dict const char* value = val->GetText(); if (key) { this->env[wxString(key, wxConvUTF8)] = value ? wxString(value, wxConvUTF8) : *wxEmptyString; } env = val; // jump over value } } else if (strcmp(entry->GetText(), "fileTriggers") == 0) { // Load all env variables const TiXmlElement* trigger = value->FirstChildElement(); for(; trigger; trigger = trigger->NextSiblingElement() ) { // Get Key if (strcmp(trigger->Value(), "key") != 0) return false; // invalid dict const char* key = trigger->GetText(); const TiXmlElement* const val = trigger->NextSiblingElement(); if (strcmp(val->Value(), "string") != 0) return false; // invalid dict const char* value = val->GetText(); if (key && value) { wxFileName path(wxString(value, wxConvUTF8)); path.MakeAbsolute(rootPath.GetPath()); this->triggers[wxString(key, wxConvUTF8)] = path.GetFullPath(); } trigger = val; // jump over value } } entry = value; // jump over value } if (onlyFilters && !this->hasFilters) return false; return true; }
// WriteProjectListings //------------------------------------------------------------------------------ void SLNGenerator::WriteProjectListings( const AString& solutionBasePath, const AString& solutionBuildProject, const Array< VCXProjectNode * > & projects, const Array< SLNSolutionFolder > & folders, const Array< SLNDependency > & slnDeps, AString & solutionBuildProjectGuid, Array< AString > & projectGuids, Array< AString > & solutionProjectsToFolder ) { // Project Listings VCXProjectNode ** const projectsEnd = projects.End(); for( VCXProjectNode ** it = projects.Begin() ; it != projectsEnd ; ++it ) { // check if this project is the master project const bool projectIsActive = ( solutionBuildProject.CompareI( (*it)->GetName() ) == 0 ); AStackString<> projectPath( (*it)->GetName() ); // get project base name only const char * lastSlash = projectPath.FindLast( NATIVE_SLASH ); const char * lastPeriod = projectPath.FindLast( '.' ); AStackString<> projectName( lastSlash ? lastSlash + 1 : projectPath.Get(), lastPeriod ? lastPeriod : projectPath.GetEnd() ); // retrieve projectGuid AStackString<> projectGuid; if ( (*it)->GetProjectGuid().GetLength() == 0 ) { // For backward compatibility, keep the preceding slash and .vcxproj extension for GUID generation AStackString<> projectNameForGuid( lastSlash ? lastSlash : projectPath.Get() ); VSProjectGenerator::FormatDeterministicProjectGUID( projectGuid, projectNameForGuid ); } else { projectGuid = (*it)->GetProjectGuid(); } // make project path relative projectPath.Replace( solutionBasePath.Get(), "" ); // projectGuid must be uppercase (visual does that, it changes the .sln otherwise) projectGuid.ToUpper(); if ( projectIsActive ) { ASSERT( solutionBuildProjectGuid.GetLength() == 0 ); solutionBuildProjectGuid = projectGuid; } Write( "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"%s\", \"%s\", \"%s\"\r\n", projectName.Get(), projectPath.Get(), projectGuid.Get() ); // Manage dependencies Array< AString > dependencyGUIDs( 64, true ); const AString & fullProjectPath = (*it)->GetName(); for ( const SLNDependency & deps : slnDeps ) { // is the set of deps relevant to this project? if ( deps.m_Projects.Find( fullProjectPath ) ) { // get all the projects this project depends on for ( const AString & dependency : deps.m_Dependencies ) { // For backward compatibility, keep the preceding slash and .vcxproj extension for GUID generation const char * projNameFromSlash = dependency.FindLast( NATIVE_SLASH ); AStackString<> projectNameForGuid( projNameFromSlash ? projNameFromSlash : dependency.Get() ); AStackString<> newGUID; VSProjectGenerator::FormatDeterministicProjectGUID( newGUID, projectNameForGuid ); dependencyGUIDs.Append( newGUID ); } } } if ( !dependencyGUIDs.IsEmpty() ) { Write( "\tProjectSection(ProjectDependencies) = postProject\r\n" ); for ( const AString & guid : dependencyGUIDs ) { Write( "\t\t%s = %s\r\n", guid.Get(), guid.Get() ); } Write( "\tEndProjectSection\r\n" ); } Write( "EndProject\r\n" ); projectGuids.Append( projectGuid ); // check if this project is in a solution folder const SLNSolutionFolder * const foldersEnd = folders.End(); for ( const SLNSolutionFolder * it2 = folders.Begin() ; it2 != foldersEnd ; ++it2 ) { // this has to be done here to have the same order of declaration (like visual) if ( it2->m_ProjectNames.Find( (*it)->GetName() ) ) { // generate a guid for the solution folder AStackString<> solutionFolderGuid; VSProjectGenerator::FormatDeterministicProjectGUID( solutionFolderGuid, it2->m_Path ); solutionFolderGuid.ToUpper(); AStackString<> projectToFolder; projectToFolder.Format( "\t\t%s = %s\r\n", projectGuid.Get(), solutionFolderGuid.Get() ); solutionProjectsToFolder.Append( projectToFolder ); } } } }
// 修改项目名称 bool ProjectManager::renameProject(const QString &oldName, const QString &newName, bool changePath) { // 如果项目列表中没有oldName项目, 则返回false if (!allProjectMap.contains(oldName)) return false; // 如果项目列表中有项目newName项目, 新项目名称重名了, 则返回false if (allProjectMap.contains(newName)) return false; if (changePath) { // 如果选择重命名文件夹 QString oldPath = allProjectMap[oldName]; QDir dir(oldPath); if(dir.cdUp() && dir.rename(oldName, newName)) { // 如果重命名文件夹成功 QString newPath = dir.path() + "/" + newName; allProjectMap.remove(oldName); allProjectMap[newName] = newPath; pathList.removeAll(oldPath); pathList << newPath; if (openedProjectList.contains(oldName)) { openedProjectList.removeAll(oldName); openedProjectList << newName; } if (closedProjectList.contains(oldName)) { closedProjectList.removeAll(oldName); closedProjectList << newName; } deleteProjectObject(oldName); // 暂存historySettings中项目oldName配置 historySettings->beginGroup(oldName); QString status = historySettings->value("Status", "On").toString(); QString isCurrent = historySettings->value("IsCurrent", "False").toString(); historySettings->endGroup(); // 移除 historySettings中的oldName配置, 加入newName的配置 historySettings->remove(oldName); historySettings->setValue(newName + "/Status", status); historySettings->setValue(newName + "/IsCurrent", isCurrent); historySettings->setValue(newName + "/RootPath", newPath); historySettings->sync(); // 更新项目配置文件 QSettings *projectSettings = new QSettings(newPath + "/project.small", QSettings::IniFormat); projectSettings->setValue("Name", newName); projectSettings->sync(); delete projectSettings; emit projectRenamed(oldName, newName); return true; } else { // 如果重命名文件夹不成功 return false; } } else { // 如果不重命名文件夹 allProjectMap[newName] = allProjectMap[oldName]; allProjectMap.remove(oldName); if (openedProjectList.contains(oldName)) { openedProjectList.removeAll(oldName); openedProjectList << newName; } if (closedProjectList.contains(oldName)) { closedProjectList.removeAll(oldName); closedProjectList << newName; } if (projectObjectMap.contains(oldName)) { projectObjectMap[newName] = projectObjectMap[oldName]; projectObjectMap[newName]->setName(newName); } else { // 更新项目配置文件 QSettings *projectSettings = new QSettings( projectPath(newName) + "/project.small", QSettings::IniFormat); projectSettings->setValue("Name", newName); projectSettings->sync(); delete projectSettings; } // 暂存historySettings中项目oldName配置 historySettings->beginGroup(oldName); QString status = historySettings->value("Status", "On").toString(); QString isCurrent = historySettings->value("IsCurrent", "False").toString(); QString path = historySettings->value("RootPath").toString(); historySettings->endGroup(); // 移除 historySettings中的oldName配置, 加入newName的配置 historySettings->remove(oldName); historySettings->setValue(newName + "/Status", status); historySettings->setValue(newName + "/IsCurrent", isCurrent); historySettings->setValue(newName + "/RootPath", path); historySettings->sync(); return true; } }
int MyApp::OnRun() { // Using a space so the initial 'w' will not be capitalized in wxLogGUI dialogs wxApp::SetAppName( wxT( " wxFormBuilder" ) ); // Creating the wxConfig manually so there will be no space // The old config (if any) is returned, delete it delete wxConfigBase::Set( new wxConfig( wxT("wxFormBuilder") ) ); // Get the data directory wxStandardPathsBase& stdPaths = wxStandardPaths::Get(); wxString dataDir = stdPaths.GetDataDir(); dataDir.Replace( GetAppName().c_str(), wxT("wxformbuilder") ); // Log to stderr while working on the command line delete wxLog::SetActiveTarget( new wxLogStderr ); // Message output to the same as the log target delete wxMessageOutput::Set( new wxMessageOutputLog ); // Parse command line wxCmdLineParser parser( s_cmdLineDesc, argc, argv ); if ( 0 != parser.Parse() ) { return 1; } // Get project to load wxString projectToLoad = wxEmptyString; if ( parser.GetParamCount() > 0 ) { projectToLoad = parser.GetParam(); } bool justGenerate = false; wxString language; bool hasLanguage = parser.Found( wxT("l"), &language ); if ( parser.Found( wxT("g") ) ) { if ( projectToLoad.empty() ) { wxLogError( _("You must pass a path to a project file. Nothing to generate.") ); return 2; } if ( hasLanguage ) { if ( language.empty() ) { wxLogError( _("Empty language option. Nothing generated.") ); return 3; } language.Replace( wxT(","), wxT("|"), true ); } // generate code justGenerate = true; } else { delete wxLog::SetActiveTarget( new wxLogGui ); } // Create singleton AppData - wait to initialize until sure that this is not the second // instance of a project file. AppDataCreate( dataDir ); // Make passed project name absolute try { if ( !projectToLoad.empty() ) { wxFileName projectPath( projectToLoad ); if ( !projectPath.IsOk() ) { THROW_WXFBEX( wxT("This path is invalid: ") << projectToLoad ); } if ( !projectPath.IsAbsolute() ) { if ( !projectPath.MakeAbsolute() ) { THROW_WXFBEX( wxT("Could not make path absolute: ") << projectToLoad ); } } projectToLoad = projectPath.GetFullPath(); } } catch ( wxFBException& ex ) { wxLogError( ex.what() ); } // If the project is already loaded in another instance, switch to that instance and quit if ( !projectToLoad.empty() && !justGenerate ) { if ( ::wxFileExists( projectToLoad ) ) { if ( !AppData()->VerifySingleInstance( projectToLoad ) ) { return 4; } } } // Init handlers wxInitAllImageHandlers(); wxXmlResource::Get()->InitAllHandlers(); #if wxVERSION_NUMBER >= 2905 wxXmlResource::Get()->AddHandler(new wxAuiNotebookXmlHandler); #endif // Init AppData try { AppDataInit(); } catch( wxFBException& ex ) { wxLogError( _("Error loading application: %s\nwxFormBuilder cannot continue."), ex.what() ); wxLog::FlushActive(); return 5; } wxSystemOptions::SetOption( wxT( "msw.remap" ), 0 ); wxSystemOptions::SetOption( wxT( "msw.staticbox.optimized-paint" ), 0 ); m_frame = NULL; #ifndef __WXFB_DEBUG__ wxBitmap bitmap; std::unique_ptr< cbSplashScreen > splash; if ( !justGenerate ) { if ( bitmap.LoadFile( dataDir + wxFILE_SEP_PATH + wxT( "resources" ) + wxFILE_SEP_PATH + wxT( "splash.png" ), wxBITMAP_TYPE_PNG ) ) { splash = std::unique_ptr< cbSplashScreen >( new cbSplashScreen( bitmap, -1, 0, wxNewId() ) ); } } #endif wxYield(); // Read size and position from config file wxConfigBase *config = wxConfigBase::Get(); config->SetPath( wxT("/mainframe") ); int x, y, w, h; x = y = w = h = -1; config->Read( wxT( "PosX" ), &x ); config->Read( wxT( "PosY" ), &y ); config->Read( wxT( "SizeW" ), &w ); config->Read( wxT( "SizeH" ), &h ); long style = config->Read( wxT("style"), wxFB_WIDE_GUI ); if ( style != wxFB_CLASSIC_GUI ) { style = wxFB_WIDE_GUI; } config->SetPath( wxT("/") ); m_frame = new MainFrame( NULL ,-1, (int)style, wxPoint( x, y ), wxSize( w, h ) ); if ( !justGenerate ) { m_frame->Show( TRUE ); SetTopWindow( m_frame ); #ifndef __WXFB_DEBUG__ // turn off the splash screen delete splash.release(); #endif #ifdef __WXFB_DEBUG__ wxLogWindow* log = dynamic_cast< wxLogWindow* >( AppData()->GetDebugLogTarget() ); if ( log ) { m_frame->AddChild( log->GetFrame() ); } #endif //__WXFB_DEBUG__ } // This is not necessary for wxFB to work. However, Windows sets the Current Working Directory // to the directory from which a .fbp file was opened, if opened from Windows Explorer. // This puts an unneccessary lock on the directory. // This changes the CWD to the already locked app directory as a workaround #ifdef __WXMSW__ ::wxSetWorkingDirectory( dataDir ); #endif if ( !projectToLoad.empty() ) { if ( AppData()->LoadProject( projectToLoad, justGenerate ) ) { if ( justGenerate ) { if ( hasLanguage ) { PObjectBase project = AppData()->GetProjectData(); PProperty codeGen = project->GetProperty( _("code_generation") ); if ( codeGen ) { codeGen->SetValue( language ); } } AppData()->GenerateCode( false, true ); return 0; } else { m_frame->InsertRecentProject( projectToLoad ); return wxApp::OnRun(); } } else { wxLogError( wxT("Unable to load project: %s"), projectToLoad.c_str() ); } } if ( justGenerate ) { return 6; } AppData()->NewProject(); #ifdef __WXMAC__ // document to open on startup if(!m_mac_file_name.IsEmpty()) { if ( AppData()->LoadProject( m_mac_file_name ) ) m_frame->InsertRecentProject( m_mac_file_name ); } #endif return wxApp::OnRun(); }
void NewQtProjDlg::OnOKUI(wxUpdateUIEvent& event) { wxString projectName = m_textCtrlProjName->GetValue().Trim(); wxFileName projectPath ( m_dirPicker4->GetPath(), "" ); event.Enable( !projectName.IsEmpty() && projectPath.Exists() ); }