properly track changed state modifications from exception list widget.

This commit is contained in:
Hugo Pereira Da Costa 2012-11-27 10:15:39 +01:00
parent 8b3457e7ed
commit 7a9e141e76
5 changed files with 55 additions and 31 deletions

View file

@ -115,7 +115,6 @@ namespace Oxygen
// exceptions
if( _configWidget->isChanged() ) modified = true;
// else if( exceptionListChanged() ) modified = true;
// emit relevant signals
if( modified ) emit changed();
@ -180,8 +179,4 @@ namespace Oxygen
}
//_______________________________________________________________________
bool Config::exceptionListChanged( void ) const
{ return true; }
}

View file

@ -87,9 +87,6 @@ namespace Oxygen {
//! load configuration
void loadConfiguration( ConfigurationPtr );
//! returns true if exception list is changed
bool exceptionListChanged( void ) const;
//! user interface
ConfigWidget* _configWidget;

View file

@ -64,12 +64,10 @@ namespace Oxygen
// connections
connect( ui.titleOutline, SIGNAL( toggled( bool ) ), ui.separatorMode, SLOT(setDisabled(bool)) );
connect( shadowConfigurations[0], SIGNAL( changed( void ) ), SLOT( updateChanged( void ) ) );
connect( shadowConfigurations[0], SIGNAL( toggled( bool ) ), SLOT( updateChanged( void ) ) );
connect( shadowConfigurations[1], SIGNAL( changed( void ) ), SLOT( updateChanged( void ) ) );
connect( shadowConfigurations[1], SIGNAL( toggled( bool ) ), SLOT( updateChanged( void ) ) );
connect( ui._expertModeButton, SIGNAL( clicked( void ) ), SLOT( toggleExpertModeInternal( void ) ) );
connect( _animationConfigWidget, SIGNAL( layoutChanged( void ) ), SLOT(updateLayout( void ) ) );
// track ui changes
connect( ui.titleAlignment, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
connect( ui.buttonSize, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
connect( ui.frameBorder, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
@ -80,14 +78,19 @@ namespace Oxygen
connect( ui.narrowButtonSpacing, SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) );
connect( ui.closeFromMenuButton, SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) );
connect( ui.separatorMode, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
connect( ui.exceptions, SIGNAL( changed( void ) ), SLOT( updateChanged( void ) ) );
connect( ui._expertModeButton, SIGNAL( clicked( void ) ), SLOT( toggleExpertModeInternal( void ) ) );
// track exception changes
connect( ui.exceptions, SIGNAL( changed( bool ) ), SLOT( updateChanged( void ) ) );
// animation config widget
// track shadow configuration changes
connect( shadowConfigurations[0], SIGNAL( changed( void ) ), SLOT( updateChanged( void ) ) );
connect( shadowConfigurations[0], SIGNAL( toggled( bool ) ), SLOT( updateChanged( void ) ) );
connect( shadowConfigurations[1], SIGNAL( changed( void ) ), SLOT( updateChanged( void ) ) );
connect( shadowConfigurations[1], SIGNAL( toggled( bool ) ), SLOT( updateChanged( void ) ) );
// track animations changes
connect( ui.animationsEnabled, SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) );
connect( _animationConfigWidget, SIGNAL( changed( bool ) ), SLOT( updateChanged( void ) ) );
connect( _animationConfigWidget, SIGNAL( layoutChanged( void ) ), SLOT(updateLayout( void ) ) );
}
@ -235,6 +238,9 @@ namespace Oxygen
else if( ui.narrowButtonSpacing->isChecked() != _configuration->useNarrowButtonSpacing() ) modified = true;
else if( ui.closeFromMenuButton->isChecked() != _configuration->closeWindowFromMenuButton() ) modified = true;
// exceptions
else if( ui.exceptions->isChanged() ) modified = true;
// shadow configurations
else if( shadowConfigurations[0]->isModified() ) modified = true;
else if( shadowConfigurations[1]->isModified() ) modified = true;

View file

@ -37,7 +37,8 @@ namespace Oxygen
//__________________________________________________________
ExceptionListWidget::ExceptionListWidget( QWidget* parent ):
QWidget( parent )
QWidget( parent ),
_changed( false )
{
//! ui
@ -79,11 +80,15 @@ namespace Oxygen
{
model().set( exceptions );
resizeColumns();
setChanged( false );
}
//__________________________________________________________
ConfigurationList ExceptionListWidget::exceptions( void ) const
{ return model().get(); }
ConfigurationList ExceptionListWidget::exceptions( void )
{
return model().get();
setChanged( false );
}
//__________________________________________________________
void ExceptionListWidget::updateButtons( void )
@ -124,6 +129,7 @@ namespace Oxygen
// create new item
model().add( exception );
setChanged( true );
// make sure item is selected
QModelIndex index( model().index( exception ) );
@ -134,7 +140,6 @@ namespace Oxygen
}
resizeColumns();
emit changed();
return;
}
@ -160,15 +165,19 @@ namespace Oxygen
return;
}
// check modifications
if( !dialog->isChanged() ) return;
// retrieve exception
dialog->save();
delete dialog;
// check new exception validity
checkException( exception );
resizeColumns();
emit changed();
setChanged( true );
return;
}
@ -184,7 +193,9 @@ namespace Oxygen
model().remove( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
resizeColumns();
updateButtons();
emit changed();
setChanged( true );
return;
}
@ -199,8 +210,7 @@ namespace Oxygen
// get matching exception
ConfigurationPtr exception( model().get( index ) );
exception->setEnabled( !exception->enabled() );
emit changed();
setChanged( true );
return;
}
@ -245,7 +255,8 @@ namespace Oxygen
for( ConfigurationList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
{ ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
emit changed();
setChanged( true );
return;
}
@ -296,7 +307,8 @@ namespace Oxygen
for( ConfigurationList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
{ ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
emit changed();
setChanged( true );
return;
}

View file

@ -47,12 +47,16 @@ namespace Oxygen
void setExceptions( const ConfigurationList& );
//! get exceptions
ConfigurationList exceptions( void ) const;
ConfigurationList exceptions( void );
//! true if changed
virtual bool isChanged( void ) const
{ return _changed; }
signals:
//! emitted when list is changed
void changed( void );
//! emitted when changed
void changed( bool );
protected:
@ -95,6 +99,13 @@ namespace Oxygen
//! check exception
bool checkException( ConfigurationPtr );
//! set changed state
virtual void setChanged( bool value )
{
_changed = value;
emit changed( value );
}
private:
//! model
@ -103,6 +114,9 @@ namespace Oxygen
//! ui
Ui_OxygenExceptionListWidget ui;
//! changed state
bool _changed;
};
}