Esempio n. 1
0
/*
  Save a copy of a project.
  Any files in the project with the name of the project should be changed,
  others are simply copied over.
*/
QString ProjectManager::saveCurrentProjectAs(QString currentProjectPath, QString newProjectPath)
{
  QDir currentProjectDir(currentProjectPath);
  QString currentProjectName = currentProjectDir.dirName();
  confirmValidProjectName(&newProjectPath);
  if(newProjectPath.contains(" ")) // if there are still spaces elsewhere in the path, we have problems
    return "";
    
  QDir newProjectDir;
  newProjectDir.mkpath(newProjectPath);
  newProjectDir.setPath(newProjectPath);
  QString newProjectName = newProjectDir.dirName();
  
  QFileInfoList fileList = currentProjectDir.entryInfoList();
  foreach(QFileInfo fi, fileList)
  {
    // give any project-specific files the new project's name
    if(fi.baseName() == currentProjectName)
    {
      if(fi.suffix() != "o") // don't need to copy obj files
      {
        QFile tocopy(fi.filePath());
        tocopy.copy(newProjectDir.filePath(newProjectName + "." + fi.suffix()));
      }
    }
    else // just copy the file over
    {
      QFile tocopy(fi.filePath());
      tocopy.copy(newProjectDir.filePath(fi.fileName()));
    }
  }
  
  // update the contents of the project file
  QDomDocument projectDoc;
  QFile projFile(newProjectDir.filePath(newProjectName + ".xml"));
  if(projectDoc.setContent(&projFile))
  {
    projFile.close();
    QDomNodeList allFiles = projectDoc.elementsByTagName("files").at(0).childNodes();
    for(int i = 0; i < allFiles.count(); i++)
    {
      if(!allFiles.at(i).toElement().text().startsWith("resources/cores"))
      {
        QFileInfo fi(allFiles.at(i).toElement().text());
        if(fi.baseName() == currentProjectName)
        {
          fi.setFile(fi.path() + "/" + newProjectName + "." + fi.suffix());
          allFiles.at(i).firstChild().setNodeValue(QDir::cleanPath(fi.filePath()));
        }
      }
    }
    // reopen with WriteOnly
    if(projFile.open(QIODevice::WriteOnly|QFile::Text))
    {
      projFile.write(projectDoc.toByteArray(2));
      projFile.close();
    }
  }
  return newProjectDir.path();
}
Esempio n. 2
0
bool EditFiles::checkDebugger()
    {
    bool ok = false;

    NameValueFile projFile(Project::getProjectFilePath());
    OovStatus status = projFile.readFile();
    if(!status.ok())
        {
        OovString str = "Unable to get project file to get debugger: ";
        str += Project::getProjectFilePath();
        status.report(ET_Error, str);
        }
    getDebugger().setDebuggerFilePath(projFile.getValue(OptToolDebuggerPath));
    getDebugger().setDebuggee(mEditOptions.getValue(OptEditDebuggee));
    getDebugger().setDebuggeeArgs(mEditOptions.getValue(OptEditDebuggeeArgs));
    getDebugger().setWorkingDir(mEditOptions.getValue(OptEditDebuggerWorkingDir));
//Gui::messageBox("Debugging is not recommended. It is very unstable.");
    std::string debugger = getDebugger().getDebuggerFilePath();
    std::string debuggee = getDebugger().getDebuggeeFilePath();
    if(debugger.length() > 0)
        {
        if(debuggee.length() > 0)
            {
// The debugger could be on the path.
//          if(fileExists(debugger))
                {
                if(FileIsFileOnDisk(debuggee, status))
                    {
                    ok = true;
                    }
                else
                    {
                    Gui::messageBox("Component to debug in Edit/Preferences does not exist");
                    }
                if(status.needReport())
                    {
                    status.report(ET_Error, "Unable to check debuggee status");
                    }
                }
//          else
//                {
//                Gui::messageBox("Debugger in Oovaide Analysis/Settings does not exist");
//                }
            }
        else
            {
            Gui::messageBox("Component to debug must be set in Edit/Preferences");
            }
        }
    else
        {
        Gui::messageBox("Debugger tool path must be set in Oovaide Analysis/Settings");
        }
    return ok;
    }
Esempio n. 3
0
/*
  Open an existing project.
  Read the project file and load the appropriate files into the UI.
*/
void MainWindow::openProject(QString projectPath)
{
  QDir projectDir(projectPath);
  QString projectName = projectDir.dirName();
  if(!projectDir.exists())
    return statusBar()->showMessage( QString("Couldn't find %1.").arg(projectName), 3500 );

  QString pathname = projectName; // filename should not have spaces
  QFile projFile(projectDir.filePath(pathname + ".xml"));
  QDomDocument doc;
  if(doc.setContent(&projFile))
  {
    currentProject = projectPath;
    currentFileDropDown->clear();
    QDomNodeList allFiles = doc.elementsByTagName("files").at(0).childNodes();
    for(int i = 0; i < allFiles.count(); i++)
    {
      QFileInfo fi(allFiles.at(i).toElement().text());
      if(fi.fileName().isEmpty())
        continue;
      // load the file name into the file dropdown
      if(projectDir.exists(fi.fileName()))
      {
        if(QDir::isAbsolutePath(fi.filePath()))
          currentFileDropDown->addItem(fi.fileName(), fi.filePath());
        else
          currentFileDropDown->addItem(fi.fileName(), projectDir.filePath(fi.filePath()));
          
        // if this is the main project file, load it into the editor
        if(fi.baseName() == pathname)
        {
          editorLoadFile(projectDir.filePath(fi.filePath()));
          currentFileDropDown->setCurrentIndex(currentFileDropDown->findText(fi.fileName()));
        }
      }
    }
    setWindowTitle( projectName + "[*] - mcbuilder");
    updateRecentProjects(projectPath);
    builder->onProjectUpdated();
    projInfo->load();
    buildLog->clear();
	}
	else
    return statusBar()->showMessage( QString("Couldn't find main file for %1.").arg(projectName), 3500 );
}