Changeset 833
- Timestamp:
- 08/18/08 01:48:20 (3 months ago)
- Location:
- mcbuilder/trunk
- Files:
-
- 3 modified
-
include/ProjectInfo.h (modified) (2 diffs)
-
src/MainWindow.cpp (modified) (2 diffs)
-
src/ProjectInfo.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mcbuilder/trunk/include/ProjectInfo.h
r801 r833 80 80 int tcpServers() { return tcpServerEdit->text().toInt(); } 81 81 bool load(); 82 bool diffProjects( QString newProjectPath, bool saveUiToFile = false ); 82 83 83 84 public slots: … … 90 91 MainWindow *mainWindow; 91 92 ProjectManager projectManager; 92 QString projectFilePath( );93 QString projectFilePath( QString projectPath ); 93 94 bool configChanged; 94 95 void setNetworkSectionEnabled(bool state); -
mcbuilder/trunk/src/MainWindow.cpp
r807 r833 77 77 connect(editor->document(), SIGNAL(contentsChanged()),this, SLOT(onDocumentModified())); 78 78 connect(outputConsole, SIGNAL(itemDoubleClicked(QListWidgetItem*)),this, SLOT(onConsoleDoubleClick(QListWidgetItem*))); 79 connect(projInfo, SIGNAL(projectInfoUpdated()), builder, SLOT(onProjectUpdated()));80 79 81 80 // menu actions … … 529 528 setWindowTitle( projectName + "[*] - mcbuilder"); 530 529 updateRecentProjects(projectPath); 530 if(projInfo->diffProjects(projectPath)) 531 builder->clean(projectPath); 531 532 projInfo->load(); 532 533 buildLog->clear(); -
mcbuilder/trunk/src/ProjectInfo.cpp
r801 r833 85 85 86 86 // read the ProjectInfo file 87 QFile file(projectFilePath( ));87 QFile file(projectFilePath(proj)); 88 88 if(file.open(QIODevice::ReadOnly|QFile::Text)) 89 89 { … … 160 160 void ProjectInfo::applyChanges( ) 161 161 { 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 */ 172 bool 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)); 163 178 if(file.open(QIODevice::ReadWrite|QFile::Text)) 164 179 { … … 166 181 if(projectFile.setContent(&file)) 167 182 { 168 bool changed = false;169 183 // to get at the actual text of an element, you need to grab its child, 170 184 // which will be a QDomText node … … 243 257 } 244 258 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/write249 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 } 250 264 } 251 265 file.close(); 252 266 } 253 accept();267 return changed; 254 268 } 255 269 … … 258 272 for the current project. 259 273 */ 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"); 274 QString ProjectInfo::projectFilePath( QString projectPath ) 275 { 276 QDir projectDir(projectPath); 277 return projectDir.filePath(projectDir.dirName() + ".xml"); 266 278 } 267 279 … … 357 369 void ProjectInfo::onRemoveFileRequest(QString filename) 358 370 { 359 QFile projectFile(projectFilePath( ));371 QFile projectFile(projectFilePath(mainWindow->currentProjectPath())); 360 372 QDir projectDir(mainWindow->currentProjectPath()); 361 373 if(projectManager.removeFromProjectFile(projectDir.path(), filename))
