From 0d58f970a107e1f0eaf3ec5b0b75e88139048ebe Mon Sep 17 00:00:00 2001 From: nishiki Date: Fri, 26 Aug 2011 19:06:35 +0000 Subject: [PATCH] Modification of the qmessagebox during the open of project more recently than the qet's version used. The qmessagebox request if we want continue or cancel the open of project git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1314 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/qetdiagrameditor.cpp | 3 ++- sources/qetproject.cpp | 15 ++++++++++++--- sources/qetproject.h | 3 ++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 8bb0977c9..0a714f045 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -794,7 +794,7 @@ bool QETDiagramEditor::openAndAddProject(const QString &filepath, bool interacti // cree le projet a partir du fichier QETProject *project = new QETProject(filepath); if (project -> state() != QETProject::Ok) { - if (interactive) { + if (interactive && project -> state() != QETProject::FileOpenDiscard) { QET::MessageBox::warning( this, tr("\311chec de l'ouverture du projet", "message box title"), @@ -807,6 +807,7 @@ bool QETDiagramEditor::openAndAddProject(const QString &filepath, bool interacti ).arg(filepath) ); } + delete project; return(false); } diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index 7f453dfbf..572fbd6db 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -827,17 +827,26 @@ void QETProject::readProjectXml() { bool conv_ok; project_qet_version_ = root_elmt.attribute("version").toDouble(&conv_ok); if (conv_ok && QET::version.toDouble() < project_qet_version_) { - QET::MessageBox::warning( + + int ret = QET::MessageBox::warning( 0, tr("Avertissement", "message box title"), tr( "Ce document semble avoir \351t\351 enregistr\351 avec " "une version ult\351rieure de QElectroTech. Il est " "possible que l'ouverture de tout ou partie de ce " - "document \351choue.", + "document \351choue.\n" + "Que d\351sirez vous faire ?", "message box content" - ) + ), + QMessageBox::Open | QMessageBox::Cancel ); + + if (ret == QMessageBox::Cancel) { + state_ = FileOpenDiscard; + return; + } + } } diff --git a/sources/qetproject.h b/sources/qetproject.h index 48c2b8c3d..ae01486b2 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -65,7 +65,8 @@ class QETProject : public QObject { FileOpenFailed = 1, /// l'ouverture d'un fichier a echoue XmlParsingFailed = 2, /// l'analyse XML a echoue ProjectParsingRunning = 3, /// la lecture du projet est en cours - ProjectParsingFailed = 4 /// la lecture en tant que projet a echoue + ProjectParsingFailed = 4, /// la lecture en tant que projet a echoue + FileOpenDiscard = 5 /// the user cancelled the file opening }; // methodes