Opened 13 years ago

Closed 13 years ago

#3297 closed patch (worksforme)

Add projectSaved() signal to the QgisInterface

Reported by: ccrook Owned by: nobody
Priority: major: does not work as expected Milestone: Version 1.7.0
Component: Project Loading / Saving Version: Trunk
Keywords: Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

Description

Creates a projectSaved() signal that can be used by plugins to take actions when a project is saved.

This matches the projectRead() signal emitted when a project is read, allowing a plugin to carry out corresponding activities when a project is saved and read.

Attachments (1)

projectSaved_signal.patch (2.3 KB ) - added by ccrook 13 years ago.

Download all attachments as: .zip

Change History (6)

by ccrook, 13 years ago

Attachment: projectSaved_signal.patch added

comment:1 by ccrook, 13 years ago

Patch attached

comment:2 by wonder, 13 years ago

The patch looks OK, but I'm wondering whether the plugins wouldn't profit more from a signal e.g. "projectWillBeSaved" which would be called before saving the project file, so that plugins could alter the project file somehow (given they receive project's QDomDocument with the signal).

in reply to:  2 comment:3 by ccrook, 13 years ago

In this case I'm thinking that I need a signal after the project is successfully saved. I'm not doing anything with the DOM, I'm saving other data external to the project file. I want to be sure that the project file is successfully saved (and the filename is defined), before I do this.

I agree that a projectWillBeSaved(QDom), or maybe savingProject(QDom), would also be a useful signal.

comment:4 by jef, 13 years ago

Am I missing something? Shouldn't connecting to QgsProject.writeProject( QDomDocument & ) (possibly in a projectRead() slot) already work?

in reply to:  4 comment:5 by ccrook, 13 years ago

Resolution: worksforme
Status: newclosed

Good point .. it does indeed seem to work.

I hadn't realised that the QgsProject was a singleton, so I can just attach to the .instance() signals. Although the timing of the event doesn't fit perfectly (the file is not completely written) I think this is works for me!

It may be worth putting a bit more source code documentation on the QgsInterface readProject signal to point users to the QgsProject signals?

Note: See TracTickets for help on using tickets.