From: ouv Date: Wed, 10 Dec 2008 10:36:22 +0000 (+0000) Subject: Fixed bug IPAL20756 - DPE: non saved changes in notebook are lost - a warning should be X-Git-Tag: TG_DumpPython_Extension_4~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=812a4f6e999e9c0ab97ab6ee1fb6bbb16d3ec679;p=modules%2Fgui.git Fixed bug IPAL20756 - DPE: non saved changes in notebook are lost - a warning should be --- diff --git a/src/SalomeApp/SalomeApp_NoteBookDlg.cxx b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx index 62f1b57da..0deb518fc 100644 --- a/src/SalomeApp/SalomeApp_NoteBookDlg.cxx +++ b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx @@ -268,7 +268,8 @@ bool NoteBook_TableRow::IsIntegerValue(const QString theValue, int* theResult) //============================================================================ NoteBook_Table::NoteBook_Table(QWidget * parent) :QTableWidget(parent), - isProcessItemChangedSignal(false) + isProcessItemChangedSignal(false), + myIsModified(false) { setColumnCount(2); setSelectionMode(QAbstractItemView::SingleSelection); @@ -473,6 +474,7 @@ bool NoteBook_Table::IsLastRow(const NoteBook_TableRow* theRow) const void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem) { if(isProcessItemChangedSignal) { + bool isModified = true; NoteBook_TableRow* aRow = GetRowByItem(theItem); if(aRow) { int aCurrentColumn = column(theItem); @@ -534,13 +536,22 @@ void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem) if( myVariableMap.contains( anIndex ) ) { NoteBoox_Variable& aVariable = myVariableMap[ anIndex ]; - aVariable.Name = aRow->GetName(); - aVariable.Value = aRow->GetValue(); + if( aVariable.Name.compare( aRow->GetName() ) != 0 || + aVariable.Value.compare( aRow->GetValue() ) != 0 ) + { + aVariable.Name = aRow->GetName(); + aVariable.Value = aRow->GetValue(); + } + else + isModified = false; } if(IsCorrect && IsVariableComplited && IsLastRow(aRow)) AddEmptyRow(); } + + if( !myIsModified ) + myIsModified = isModified; } } @@ -645,6 +656,7 @@ QList NoteBook_Table::GetRows() const //============================================================================ void NoteBook_Table::ResetMaps() { + myIsModified = false; myVariableMapRef = myVariableMap; myRemovedRows.clear(); } @@ -854,6 +866,18 @@ void SalomeApp_NoteBookDlg::onApply() //============================================================================ void SalomeApp_NoteBookDlg::onCancel() { + if( myTable->IsModified() ) + { + int answer = QMessageBox::question( this, tr( "CLOSE_CAPTION" ), tr( "CLOSE_DESCRIPTION" ), + QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel ); + switch( answer ) + { + case QMessageBox::Yes : onOK(); return; + case QMessageBox::No : break; + case QMessageBox::Cancel : return; + default : break; + } + } reject(); } diff --git a/src/SalomeApp/SalomeApp_NoteBookDlg.h b/src/SalomeApp/SalomeApp_NoteBookDlg.h index 529b9245e..6afd66de5 100644 --- a/src/SalomeApp/SalomeApp_NoteBookDlg.h +++ b/src/SalomeApp/SalomeApp_NoteBookDlg.h @@ -109,6 +109,7 @@ class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget bool IsUniqueName(const NoteBook_TableRow* theRow) const; QList GetRows() const; + const bool IsModified() const { return myIsModified; } const QList& GetRemovedRows() const { return myRemovedRows; } const VariableMap& GetVariableMap() const { return myVariableMap; } const VariableMap& GetVariableMapRef() const { return myVariableMapRef; } @@ -125,6 +126,7 @@ class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget bool isProcessItemChangedSignal; QList myRows; + bool myIsModified; QList myRemovedRows; VariableMap myVariableMapRef; VariableMap myVariableMap; diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index 377ee1d73..28414a0a0 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_en.ts @@ -403,6 +403,14 @@ Do you really want to rename it? BUT_HELP &Help + + CLOSE_CAPTION + Close NoteBook + + + CLOSE_DESCRIPTION + Do you want to save changes you made to NoteBook? + INCORRECT_DATA At least one variable has been defined incorrectly.