Add the feature to merge projects#122
Conversation
sanny32
left a comment
There was a problem hiding this comment.
In AppProject::loadProject(), every loaded file ends with _mainWindow->applyConnections(defs, conns) at src/appproject.cpp:1968, and applyConnections() does _mbMultiServer.setModbusDefinitions(defs) plus replaces the connect menu with only conns at src/mainwindow.cpp:1675.
So when MainWindow::loadProject(filename, replace=false) is used for the second/next project, forms are appended, but Modbus definitions and saved connections are overwritten by the last merged file. That makes “merge projects” lossy and order-dependent.
c65d09c to
f42e183
Compare
Thank you, that's a correct point. 👍 I've made the necessary changes to the patch; now the register descriptions are merged correctly, and project-wide settings are ignored for subsequent files being merged. |
sanny32
left a comment
There was a problem hiding this comment.
Thanks for the update. This is definitely safer now: the merged project no longer overwrites the current project's ModbusDefinitions and connection list, which addresses the main data-loss concern I had.
I still think the merge semantics should be clarified before merging. As currently implemented, additional projects contribute forms and address-space data, but their ModbusDefinitions, connections, global view settings, tab order, and active-window state are ignored. That may be a valid design, but then the UI/PR description should make it clear that this is more like importing forms/data into the current project rather than a full project merge.
A couple of smaller code issues remain:
MainWindow::dragEnterEvent()andMainWindow::dropEvent()are missing the required Doxygen blocks (\brief, and\paramwhere applicable).- Drag-and-drop currently accepts any existing file, not just
.omsimfiles. SinceAppProject::loadProject()returnsvoid,MainWindow::loadProject()cannot tell whether loading actually succeeded, so dropping an invalid file may result in confusing behavior.
f42e183 to
5eb23fc
Compare
|
Added an explanatory label for the user, added documentation comments, and added the ability to select project files from the list of dropped files in the window. Also added the ability to drag and drop entire directories containing files. The project has been rebased to the top of the P.S. The |
MainWindow::on_actionOpenProject_triggered().MainWindow::on_mdiSubWindowActivated().Changes to the codebase:
AppProject::filePath()method, which returns the file path to the project, replacing the removedMainWindow::_projectFilePathclass member that duplicated this functionality.AppProject::loadProject()method to theAppProject::closeProject()method.AppProject::saveProject()method now remembers the save directory on its own; previously, all calls tosaveProject()were paired withsetSavePath().MainWindow::closeProject()method—removed duplicate code for closing the project and prompting to save changes.MainWindow::dragEnterEvent()andMainWindow::dropEvent()methods have been added to implement file dragging.MainWindow::loadProject()function has been extended to support adding multiple files to a single project and handling user-initiated cancellation of the operation.MainWindow::saveProject()method now maintains its own list of recent files usingaddRecentProject().Fixes #121.