mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-18 03:54:14 +02:00
Offer a damaged project's previous version, or what can be read of it
A project file that could not be read showed "The file ... does not appear to be a QElectroTech project file", for a .qetz missing one picture as for a picture file renamed .qet: wrong, and no way out. Now the message says what is damaged (QETProject::openError()) and offers, when there are any: - the newest previous version kept beside it (PreviousVersions); - for a .qetz, what can be read of it (QetContainer::recover()), then a list of what was left out. Either opens as a new project, "<name> (recovered)" beside the file, numbered if that is taken, not saved yet. The damaged file is never moved or written. Checked in the program (scripts/qet-gui-dialog.sh, File > Open on a .qetz whose picture is missing, a previous version beside it): the dialog says which picture; "Recover what can be read" opens plant (recovered).qetz without the picture, saved with Ctrl+S it opens again; "Open the version saved ..." opens plant (recovered 2).qetz with its picture; plant.qetz unchanged (same sha256). ctest 107/107. Stacked on "Keep the previous versions of a project when saving it" and "Add recovering what can be read of a damaged .qetz". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -515,6 +515,7 @@ QETProject::ProjectState QETProject::openFile(QFile *file)
|
||||
if (!read)
|
||||
{
|
||||
qWarning().noquote() << "Unable to read" << fi.fileName() << ":" << read_error;
|
||||
m_open_error = read_error;
|
||||
m_container_pictures.clear();
|
||||
m_folio_parts.clear();
|
||||
if(opened_here) {
|
||||
@@ -603,6 +604,16 @@ QETProject::ProjectState QETProject::state() const
|
||||
return(m_state);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::openError
|
||||
@return why the file could not be read, when state() is
|
||||
XmlParsingFailed: "picture ... is missing", say; empty otherwise
|
||||
*/
|
||||
QString QETProject::openError() const
|
||||
{
|
||||
return m_open_error;
|
||||
}
|
||||
|
||||
/**
|
||||
@return la liste des schemas de ce projet
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user