2009-08-24 16:15:14 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-08-30 17:37:07 +00:00
|
|
|
// NitrogenExceptionListWidget.cpp
|
2009-08-24 16:15:14 +00:00
|
|
|
// -------------------
|
2009-09-09 00:55:55 +00:00
|
|
|
//
|
2009-08-24 16:15:14 +00:00
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
2009-09-09 00:55:55 +00:00
|
|
|
// IN THE SOFTWARE.
|
2009-08-24 16:15:14 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#include <QLayout>
|
|
|
|
#include <KLocale>
|
|
|
|
#include <KMessageBox>
|
|
|
|
|
|
|
|
#include "nitrogenexceptiondialog.h"
|
2009-08-30 17:37:07 +00:00
|
|
|
#include "nitrogenexceptionlistwidget.h"
|
|
|
|
#include "nitrogenexceptionlistwidget.moc"
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
//__________________________________________________________
|
|
|
|
namespace Nitrogen
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//__________________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
NitrogenExceptionListWidget::NitrogenExceptionListWidget( QWidget* parent, NitrogenConfiguration default_configuration ):
|
|
|
|
QWidget( parent ),
|
2009-08-22 08:24:06 +00:00
|
|
|
default_configuration_( default_configuration )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// layout
|
|
|
|
QHBoxLayout* h_layout = new QHBoxLayout();
|
2009-08-30 19:43:21 +00:00
|
|
|
h_layout->setMargin(6);
|
|
|
|
h_layout->setSpacing(6);
|
2009-08-30 17:37:07 +00:00
|
|
|
setLayout( h_layout );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// list
|
2009-08-30 17:37:07 +00:00
|
|
|
h_layout->addWidget( list_ = new QTreeView( this ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
_list().setAllColumnsShowFocus( true );
|
|
|
|
_list().setRootIsDecorated( false );
|
|
|
|
_list().setSortingEnabled( false );
|
|
|
|
_list().setModel( &_model() );
|
|
|
|
_list().sortByColumn( NitrogenExceptionModel::TYPE );
|
2009-08-30 19:43:21 +00:00
|
|
|
_list().setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Ignored ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// button layout
|
|
|
|
QVBoxLayout* v_layout = new QVBoxLayout();
|
|
|
|
v_layout->setMargin(0);
|
|
|
|
v_layout->setSpacing(5);
|
|
|
|
h_layout->addLayout( v_layout );
|
|
|
|
KIconLoader* icon_loader = KIconLoader::global();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
v_layout->addWidget( up_button_ = new KPushButton(
|
2009-08-22 08:24:06 +00:00
|
|
|
KIcon( "arrow-up", icon_loader ),
|
2009-08-30 17:37:07 +00:00
|
|
|
i18n("Move &Up"), this ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
v_layout->addWidget( down_button_ = new KPushButton(
|
2009-08-22 08:24:06 +00:00
|
|
|
KIcon( "arrow-down", icon_loader ),
|
2009-08-30 17:37:07 +00:00
|
|
|
i18n("Move &Down"), this ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
v_layout->addWidget( add_button_ = new KPushButton(
|
|
|
|
KIcon( "list-add", icon_loader ),
|
2009-08-30 17:37:07 +00:00
|
|
|
i18n("&Add"), this ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
v_layout->addWidget( remove_button_ = new KPushButton(
|
|
|
|
KIcon( "list-remove", icon_loader ),
|
2009-08-30 17:37:07 +00:00
|
|
|
i18n("&Remove"), this ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
v_layout->addWidget( edit_button_ = new KPushButton(
|
2009-08-22 08:24:06 +00:00
|
|
|
KIcon( "edit-rename", icon_loader ),
|
2009-08-30 17:37:07 +00:00
|
|
|
i18n("&Edit"), this ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
v_layout->addStretch();
|
|
|
|
|
|
|
|
connect( add_button_, SIGNAL( clicked() ), SLOT( _add() ) );
|
|
|
|
connect( edit_button_, SIGNAL( clicked() ), SLOT( _edit() ) );
|
|
|
|
connect( remove_button_, SIGNAL( clicked() ), SLOT( _remove() ) );
|
|
|
|
connect( up_button_, SIGNAL( clicked() ), SLOT( _up() ) );
|
|
|
|
connect( down_button_, SIGNAL( clicked() ), SLOT( _down() ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
connect( &_list(), SIGNAL( activated( const QModelIndex& ) ), SLOT( _edit() ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
connect( &_list(), SIGNAL( clicked( const QModelIndex& ) ), SLOT( _toggle( const QModelIndex& ) ) );
|
|
|
|
connect( _list().selectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), SLOT( _updateButtons() ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
_updateButtons();
|
|
|
|
_resizeColumns();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//__________________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
void NitrogenExceptionListWidget::setExceptions( const NitrogenExceptionList& exceptions )
|
2009-09-09 00:55:55 +00:00
|
|
|
{
|
|
|
|
_model().set( NitrogenExceptionModel::List( exceptions.begin(), exceptions.end() ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
_resizeColumns();
|
|
|
|
}
|
|
|
|
|
|
|
|
//__________________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
NitrogenExceptionList NitrogenExceptionListWidget::exceptions( void ) const
|
2009-09-09 00:55:55 +00:00
|
|
|
{
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
NitrogenExceptionModel::List exceptions( _model().get() );
|
|
|
|
NitrogenExceptionList out;
|
|
|
|
for( NitrogenExceptionModel::List::const_iterator iter = exceptions.begin(); iter != exceptions.end(); iter++ )
|
|
|
|
{ out.push_back( *iter ); }
|
|
|
|
return out;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//__________________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
void NitrogenExceptionListWidget::_updateButtons( void )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
bool has_selection( !_list().selectionModel()->selectedRows().empty() );
|
|
|
|
remove_button_->setEnabled( has_selection );
|
|
|
|
edit_button_->setEnabled( has_selection );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
up_button_->setEnabled( has_selection && !_list().selectionModel()->isRowSelected( 0, QModelIndex() ) );
|
|
|
|
down_button_->setEnabled( has_selection && !_list().selectionModel()->isRowSelected( _model().rowCount()-1, QModelIndex() ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
void NitrogenExceptionListWidget::_add( void )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// map dialog
|
|
|
|
NitrogenExceptionDialog dialog( this );
|
|
|
|
dialog.setException( default_configuration_ );
|
|
|
|
if( dialog.exec() == QDialog::Rejected ) return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// retrieve exception and check
|
|
|
|
NitrogenException exception( dialog.exception() );
|
|
|
|
if( !_checkException( exception ) ) return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// create new item
|
|
|
|
_model().add( exception );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// make sure item is selected
|
|
|
|
QModelIndex index( _model().index( exception ) );
|
|
|
|
if( index != _list().selectionModel()->currentIndex() )
|
|
|
|
{
|
|
|
|
_list().selectionModel()->select( index, QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
|
|
|
|
_list().selectionModel()->setCurrentIndex( index, QItemSelectionModel::Current|QItemSelectionModel::Rows );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
_resizeColumns();
|
2009-08-30 17:37:07 +00:00
|
|
|
emit changed();
|
2009-08-22 08:24:06 +00:00
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
void NitrogenExceptionListWidget::_edit( void )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// retrieve selection
|
|
|
|
QModelIndex current( _list().selectionModel()->currentIndex() );
|
|
|
|
if( !current.isValid() ) return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
NitrogenException& exception( _model().get( current ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// create dialog
|
|
|
|
NitrogenExceptionDialog dialog( this );
|
|
|
|
dialog.setException( exception );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// map dialog
|
|
|
|
if( dialog.exec() == QDialog::Rejected ) return;
|
|
|
|
NitrogenException new_exception = dialog.exception();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:37:07 +00:00
|
|
|
// check if exception was changed
|
|
|
|
if( exception == new_exception ) return;
|
|
|
|
|
|
|
|
// check new exception validity
|
2009-08-22 08:24:06 +00:00
|
|
|
if( !_checkException( new_exception ) ) return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:37:07 +00:00
|
|
|
// asign new exception
|
2009-09-09 00:55:55 +00:00
|
|
|
*&exception = new_exception;
|
2009-08-22 08:24:06 +00:00
|
|
|
_resizeColumns();
|
2009-08-30 17:37:07 +00:00
|
|
|
emit changed();
|
2009-08-22 08:24:06 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
void NitrogenExceptionListWidget::_remove( void )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
|
|
|
|
2009-08-30 17:37:07 +00:00
|
|
|
// shoud use a konfirmation dialog
|
|
|
|
if( KMessageBox::questionYesNo( this, i18n("Remove selected exception ?") ) == KMessageBox::No ) return;
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// remove
|
|
|
|
_model().remove( _model().get( _list().selectionModel()->selectedRows() ) );
|
|
|
|
_resizeColumns();
|
2009-08-30 17:37:07 +00:00
|
|
|
emit changed();
|
2009-08-22 08:24:06 +00:00
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
void NitrogenExceptionListWidget::_toggle( const QModelIndex& index )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
if( !index.isValid() ) return;
|
|
|
|
if( index.column() != NitrogenExceptionModel::ENABLED ) return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// get matching exception
|
|
|
|
NitrogenException& exception( _model().get( index ) );
|
|
|
|
exception.setEnabled( !exception.enabled() );
|
|
|
|
_model().add( exception );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:37:07 +00:00
|
|
|
emit changed();
|
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
void NitrogenExceptionListWidget::_up( void )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
NitrogenExceptionModel::List selection( _model().get( _list().selectionModel()->selectedRows() ) );
|
|
|
|
if( selection.empty() ) { return; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// retrieve selected indexes in list and store in model
|
|
|
|
QModelIndexList selected_indexes( _list().selectionModel()->selectedRows() );
|
|
|
|
NitrogenExceptionModel::List selected_exceptions( _model().get( selected_indexes ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
NitrogenExceptionModel::List current_exceptions( _model().get() );
|
|
|
|
NitrogenExceptionModel::List new_exceptions;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
for( NitrogenExceptionModel::List::const_iterator iter = current_exceptions.begin(); iter != current_exceptions.end(); iter++ )
|
|
|
|
{
|
|
|
|
|
|
|
|
// check if new list is not empty, current index is selected and last index is not.
|
|
|
|
// if yes, move.
|
2009-09-09 00:55:55 +00:00
|
|
|
if(
|
|
|
|
!( new_exceptions.empty() ||
|
2009-08-22 08:24:06 +00:00
|
|
|
selected_indexes.indexOf( _model().index( *iter ) ) == -1 ||
|
2009-09-09 00:55:55 +00:00
|
|
|
selected_indexes.indexOf( _model().index( new_exceptions.back() ) ) != -1
|
2009-08-22 08:24:06 +00:00
|
|
|
) )
|
2009-09-09 00:55:55 +00:00
|
|
|
{
|
2009-08-22 08:24:06 +00:00
|
|
|
NitrogenException last( new_exceptions.back() );
|
|
|
|
new_exceptions.pop_back();
|
|
|
|
new_exceptions.push_back( *iter );
|
|
|
|
new_exceptions.push_back( last );
|
|
|
|
} else new_exceptions.push_back( *iter );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
_model().set( new_exceptions );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// restore selection
|
|
|
|
_list().selectionModel()->select( _model().index( selected_exceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
|
|
|
|
for( NitrogenExceptionModel::List::const_iterator iter = selected_exceptions.begin(); iter != selected_exceptions.end(); iter++ )
|
|
|
|
{ _list().selectionModel()->select( _model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:37:07 +00:00
|
|
|
emit changed();
|
2009-08-22 08:24:06 +00:00
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
void NitrogenExceptionListWidget::_down( void )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
NitrogenExceptionModel::List selection( _model().get( _list().selectionModel()->selectedRows() ) );
|
|
|
|
if( selection.empty() )
|
|
|
|
{ return; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// retrieve selected indexes in list and store in model
|
|
|
|
QModelIndexList selected_indexes( _list().selectionModel()->selectedIndexes() );
|
|
|
|
NitrogenExceptionModel::List selected_exceptions( _model().get( selected_indexes ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
NitrogenExceptionModel::List current_exceptions( _model().get() );
|
|
|
|
NitrogenExceptionModel::List new_exceptions;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
for( NitrogenExceptionModel::List::reverse_iterator iter = current_exceptions.rbegin(); iter != current_exceptions.rend(); iter++ )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// check if new list is not empty, current index is selected and last index is not.
|
|
|
|
// if yes, move.
|
2009-09-09 00:55:55 +00:00
|
|
|
if(
|
|
|
|
!( new_exceptions.empty() ||
|
2009-08-22 08:24:06 +00:00
|
|
|
selected_indexes.indexOf( _model().index( *iter ) ) == -1 ||
|
2009-09-09 00:55:55 +00:00
|
|
|
selected_indexes.indexOf( _model().index( new_exceptions.back() ) ) != -1
|
2009-08-22 08:24:06 +00:00
|
|
|
) )
|
2009-09-09 00:55:55 +00:00
|
|
|
{
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
NitrogenException last( new_exceptions.back() );
|
|
|
|
new_exceptions.pop_back();
|
|
|
|
new_exceptions.push_back( *iter );
|
|
|
|
new_exceptions.push_back( last );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
} else new_exceptions.push_back( *iter );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
_model().set( NitrogenExceptionModel::List( new_exceptions.rbegin(), new_exceptions.rend() ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// restore selection
|
|
|
|
_list().selectionModel()->select( _model().index( selected_exceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
|
|
|
|
for( NitrogenExceptionModel::List::const_iterator iter = selected_exceptions.begin(); iter != selected_exceptions.end(); iter++ )
|
|
|
|
{ _list().selectionModel()->select( _model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:37:07 +00:00
|
|
|
emit changed();
|
2009-08-22 08:24:06 +00:00
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
void NitrogenExceptionListWidget::_resizeColumns( void ) const
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
|
|
|
_list().resizeColumnToContents( NitrogenExceptionModel::ENABLED );
|
|
|
|
_list().resizeColumnToContents( NitrogenExceptionModel::TYPE );
|
|
|
|
_list().resizeColumnToContents( NitrogenExceptionModel::REGEXP );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________
|
2009-08-30 17:37:07 +00:00
|
|
|
bool NitrogenExceptionListWidget::_checkException( NitrogenException& exception )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
while( !exception.regExp().isValid() )
|
|
|
|
{
|
|
|
|
|
2009-08-24 07:29:46 +00:00
|
|
|
KMessageBox::error( this, i18n("Regular Expression syntax is incorrect") );
|
2009-08-22 08:24:06 +00:00
|
|
|
NitrogenExceptionDialog dialog( this );
|
|
|
|
dialog.setException( exception );
|
|
|
|
if( dialog.exec() == QDialog::Rejected ) return false;
|
|
|
|
exception = dialog.exception();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-24 06:27:49 +00:00
|
|
|
}
|