Changeset 833

Show
Ignore:
Timestamp:
08/18/08 01:48:20 (3 months ago)
Author:
liamstask
Message:

- clean the source files if a new project's config info is different from the previous one

Location:
mcbuilder/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • mcbuilder/trunk/include/ProjectInfo.h

    r801 r833  
    8080    int tcpServers() { return tcpServerEdit->text().toInt(); } 
    8181    bool load(); 
     82    bool diffProjects( QString newProjectPath, bool saveUiToFile = false ); 
    8283     
    8384  public slots: 
     
    9091    MainWindow *mainWindow; 
    9192    ProjectManager projectManager; 
    92     QString projectFilePath( ); 
     93    QString projectFilePath( QString projectPath ); 
    9394    bool configChanged; 
    9495    void setNetworkSectionEnabled(bool state); 
  • mcbuilder/trunk/src/MainWindow.cpp

    r807 r833  
    7777  connect(editor->document(), SIGNAL(contentsChanged()),this, SLOT(onDocumentModified())); 
    7878  connect(outputConsole, SIGNAL(itemDoubleClicked(QListWidgetItem*)),this, SLOT(onConsoleDoubleClick(QListWidgetItem*))); 
    79   connect(projInfo, SIGNAL(projectInfoUpdated()), builder, SLOT(onProjectUpdated())); 
    8079   
    8180  // menu actions  
     
    529528    setWindowTitle( projectName + "[*] - mcbuilder"); 
    530529    updateRecentProjects(projectPath); 
     530    if(projInfo->diffProjects(projectPath)) 
     531      builder->clean(projectPath); 
    531532    projInfo->load(); 
    532533    buildLog->clear(); 
  • mcbuilder/trunk/src/ProjectInfo.cpp

    r801 r833  
    8585   
    8686  // read the ProjectInfo file 
    87   QFile file(projectFilePath()); 
     87  QFile file(projectFilePath(proj)); 
    8888  if(file.open(QIODevice::ReadOnly|QFile::Text)) 
    8989  { 
     
    160160void ProjectInfo::applyChanges( ) 
    161161{ 
    162   QFile file(projectFilePath()); 
     162  if( diffProjects( projectFilePath(mainWindow->currentProjectPath()), true ) ) 
     163    emit projectInfoUpdated(); 
     164  accept(); 
     165} 
     166 
     167/* 
     168  Determine whether the ProjectInfo for a new project is 
     169  different than the existing project, optionally saving the 
     170  values currently in the UI to the project file. 
     171*/ 
     172bool ProjectInfo::diffProjects( QString newProjectPath, bool saveUiToFile ) 
     173{ 
     174  if(versionEdit->text().isEmpty()) // check the version box as a sample...if this is empty, we don't have anything loaded so don't bother checking 
     175    return false; 
     176  bool changed = false; 
     177  QFile file(projectFilePath(newProjectPath)); 
    163178  if(file.open(QIODevice::ReadWrite|QFile::Text)) 
    164179  { 
     
    166181    if(projectFile.setContent(&file)) 
    167182    { 
    168       bool changed = false; 
    169183      // to get at the actual text of an element, you need to grab its child, 
    170184      // which will be a QDomText node 
     
    243257      } 
    244258       
    245       if(changed) 
    246         emit projectInfoUpdated(); 
    247        
    248       file.resize(0); // clear out the current contents so we can update them, since we opened as read/write 
    249       file.write(projectFile.toByteArray(2)); 
     259      if(saveUiToFile) 
     260      { 
     261        file.resize(0); // clear out the current contents so we can update them, since we opened as read/write 
     262        file.write(projectFile.toByteArray(2)); 
     263      } 
    250264    } 
    251265    file.close(); 
    252266  } 
    253   accept(); 
     267  return changed; 
    254268} 
    255269 
     
    258272  for the current project. 
    259273*/ 
    260 QString ProjectInfo::projectFilePath( ) 
    261 { 
    262   QDir projectDir(mainWindow->currentProjectPath()); 
    263   QString projectName = projectDir.dirName(); 
    264   // filename should not have spaces 
    265   return projectDir.filePath(projectName.remove(" ") + ".xml");  
     274QString ProjectInfo::projectFilePath( QString projectPath ) 
     275{ 
     276  QDir projectDir(projectPath); 
     277  return projectDir.filePath(projectDir.dirName() + ".xml");  
    266278} 
    267279 
     
    357369void ProjectInfo::onRemoveFileRequest(QString filename) 
    358370{ 
    359   QFile projectFile(projectFilePath( )); 
     371  QFile projectFile(projectFilePath(mainWindow->currentProjectPath())); 
    360372  QDir projectDir(mainWindow->currentProjectPath()); 
    361373  if(projectManager.removeFromProjectFile(projectDir.path(), filename))