//============================================================================
NoteBook_Table::NoteBook_Table(QWidget * parent)
:QTableWidget(parent),
- isProcessItemChangedSignal(false)
+ isProcessItemChangedSignal(false),
+ myIsModified(false)
{
setColumnCount(2);
setSelectionMode(QAbstractItemView::SingleSelection);
void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem)
{
if(isProcessItemChangedSignal) {
+ bool isModified = true;
NoteBook_TableRow* aRow = GetRowByItem(theItem);
if(aRow) {
int aCurrentColumn = column(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;
}
}
//============================================================================
void NoteBook_Table::ResetMaps()
{
+ myIsModified = false;
myVariableMapRef = myVariableMap;
myRemovedRows.clear();
}
//============================================================================
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();
}
bool IsUniqueName(const NoteBook_TableRow* theRow) const;
QList<NoteBook_TableRow*> GetRows() const;
+ const bool IsModified() const { return myIsModified; }
const QList<int>& GetRemovedRows() const { return myRemovedRows; }
const VariableMap& GetVariableMap() const { return myVariableMap; }
const VariableMap& GetVariableMapRef() const { return myVariableMapRef; }
bool isProcessItemChangedSignal;
QList<NoteBook_TableRow*> myRows;
+ bool myIsModified;
QList<int> myRemovedRows;
VariableMap myVariableMapRef;
VariableMap myVariableMap;
<source>BUT_HELP</source>
<translation>&Help</translation>
</message>
+ <message>
+ <source>CLOSE_CAPTION</source>
+ <translation>Close NoteBook</translation>
+ </message>
+ <message>
+ <source>CLOSE_DESCRIPTION</source>
+ <translation>Do you want to save changes you made to NoteBook?</translation>
+ </message>
<message>
<source>INCORRECT_DATA</source>
<translation>At least one variable has been defined incorrectly.