2009-08-24 16:15:14 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2010-05-02 18:34:08 +00:00
|
|
|
// oxygenexceptionlistwidget.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
|
|
|
|
2009-09-16 06:09:31 +00:00
|
|
|
#include "oxygenexceptionlistwidget.h"
|
|
|
|
#include "oxygenexceptionlistwidget.moc"
|
|
|
|
#include "oxygenexceptiondialog.h"
|
|
|
|
|
2013-08-01 17:30:54 +00:00
|
|
|
#include <QMessageBox>
|
2013-02-26 08:00:51 +00:00
|
|
|
#include <QPointer>
|
2013-08-01 15:21:26 +00:00
|
|
|
#include <QIcon>
|
2013-03-07 11:55:39 +00:00
|
|
|
#include <KLocalizedString>
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
//__________________________________________________________
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//__________________________________________________________
|
2012-11-23 09:09:39 +00:00
|
|
|
ExceptionListWidget::ExceptionListWidget( QWidget* parent ):
|
2012-11-27 09:15:39 +00:00
|
|
|
QWidget( parent ),
|
|
|
|
_changed( false )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
//! ui
|
|
|
|
ui.setupUi( this );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// list
|
|
|
|
ui.exceptionListView->setAllColumnsShowFocus( true );
|
|
|
|
ui.exceptionListView->setRootIsDecorated( false );
|
|
|
|
ui.exceptionListView->setSortingEnabled( false );
|
2011-02-24 16:47:38 +00:00
|
|
|
ui.exceptionListView->setModel( &model() );
|
2010-05-02 18:34:08 +00:00
|
|
|
ui.exceptionListView->sortByColumn( ExceptionModel::TYPE );
|
|
|
|
ui.exceptionListView->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Ignored ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2013-08-01 15:21:26 +00:00
|
|
|
ui.moveUpButton->setIcon( QIcon::fromTheme( QStringLiteral( "arrow-up" ) ) );
|
|
|
|
ui.moveDownButton->setIcon( QIcon::fromTheme( QStringLiteral( "arrow-down" ) ) );
|
|
|
|
ui.addButton->setIcon( QIcon::fromTheme( QStringLiteral( "list-add" ) ) );
|
|
|
|
ui.removeButton->setIcon( QIcon::fromTheme( QStringLiteral( "list-remove" ) ) );
|
|
|
|
ui.editButton->setIcon( QIcon::fromTheme( QStringLiteral( "edit-rename" ) ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2011-08-17 21:51:55 +00:00
|
|
|
connect( ui.addButton, SIGNAL(clicked()), SLOT(add()) );
|
|
|
|
connect( ui.editButton, SIGNAL(clicked()), SLOT(edit()) );
|
|
|
|
connect( ui.removeButton, SIGNAL(clicked()), SLOT(remove()) );
|
|
|
|
connect( ui.moveUpButton, SIGNAL(clicked()), SLOT(up()) );
|
|
|
|
connect( ui.moveDownButton, SIGNAL(clicked()), SLOT(down()) );
|
2009-10-31 03:54:11 +00:00
|
|
|
|
2011-08-17 21:51:55 +00:00
|
|
|
connect( ui.exceptionListView, SIGNAL(activated(QModelIndex)), SLOT(edit()) );
|
|
|
|
connect( ui.exceptionListView, SIGNAL(clicked(QModelIndex)), SLOT(toggle(QModelIndex)) );
|
|
|
|
connect( ui.exceptionListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(updateButtons()) );
|
2009-10-31 03:54:11 +00:00
|
|
|
|
2011-02-24 16:47:38 +00:00
|
|
|
updateButtons();
|
|
|
|
resizeColumns();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//__________________________________________________________
|
2012-11-23 09:09:39 +00:00
|
|
|
void ExceptionListWidget::setExceptions( const ConfigurationList& exceptions )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2012-11-04 19:54:22 +00:00
|
|
|
model().set( exceptions );
|
2011-02-24 16:47:38 +00:00
|
|
|
resizeColumns();
|
2012-11-27 09:15:39 +00:00
|
|
|
setChanged( false );
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//__________________________________________________________
|
2012-11-27 09:15:39 +00:00
|
|
|
ConfigurationList ExceptionListWidget::exceptions( void )
|
|
|
|
{
|
|
|
|
return model().get();
|
|
|
|
setChanged( false );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//__________________________________________________________
|
2011-02-24 16:47:38 +00:00
|
|
|
void ExceptionListWidget::updateButtons( void )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2011-02-24 16:47:38 +00:00
|
|
|
bool hasSelection( !ui.exceptionListView->selectionModel()->selectedRows().empty() );
|
|
|
|
ui.removeButton->setEnabled( hasSelection );
|
|
|
|
ui.editButton->setEnabled( hasSelection );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2011-02-24 16:47:38 +00:00
|
|
|
ui.moveUpButton->setEnabled( hasSelection && !ui.exceptionListView->selectionModel()->isRowSelected( 0, QModelIndex() ) );
|
|
|
|
ui.moveDownButton->setEnabled( hasSelection && !ui.exceptionListView->selectionModel()->isRowSelected( model().rowCount()-1, QModelIndex() ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________
|
2011-02-24 16:47:38 +00:00
|
|
|
void ExceptionListWidget::add( void )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
|
2012-01-09 08:42:37 +00:00
|
|
|
QPointer<ExceptionDialog> dialog = new ExceptionDialog( this );
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr exception( new Configuration() );
|
|
|
|
exception->readConfig();
|
|
|
|
dialog->setException( exception );
|
2012-01-09 08:42:37 +00:00
|
|
|
|
|
|
|
// run dialog and check existence
|
2012-11-23 09:09:39 +00:00
|
|
|
if( !dialog->exec() )
|
2012-01-09 08:49:44 +00:00
|
|
|
{
|
|
|
|
delete dialog;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
dialog->save();
|
2012-01-09 08:49:44 +00:00
|
|
|
delete dialog;
|
|
|
|
|
|
|
|
// check exceptions
|
2011-02-24 16:47:38 +00:00
|
|
|
if( !checkException( exception ) ) return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// create new item
|
2011-02-24 16:47:38 +00:00
|
|
|
model().add( exception );
|
2012-11-27 09:15:39 +00:00
|
|
|
setChanged( true );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// make sure item is selected
|
2011-02-24 16:47:38 +00:00
|
|
|
QModelIndex index( model().index( exception ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( index != ui.exceptionListView->selectionModel()->currentIndex() )
|
|
|
|
{
|
|
|
|
ui.exceptionListView->selectionModel()->select( index, QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
|
|
|
|
ui.exceptionListView->selectionModel()->setCurrentIndex( index, QItemSelectionModel::Current|QItemSelectionModel::Rows );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2011-02-24 16:47:38 +00:00
|
|
|
resizeColumns();
|
2010-05-02 18:34:08 +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
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________
|
2011-02-24 16:47:38 +00:00
|
|
|
void ExceptionListWidget::edit( void )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// retrieve selection
|
|
|
|
QModelIndex current( ui.exceptionListView->selectionModel()->currentIndex() );
|
2012-11-01 18:09:09 +00:00
|
|
|
if( ! model().contains( current ) ) return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr exception( model().get( current ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// create dialog
|
2012-01-09 08:49:44 +00:00
|
|
|
QPointer<ExceptionDialog> dialog( new ExceptionDialog( this ) );
|
2011-07-25 15:04:28 +00:00
|
|
|
dialog->setException( exception );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// map dialog
|
2012-11-23 09:09:39 +00:00
|
|
|
if( !dialog->exec() )
|
2012-01-09 08:49:44 +00:00
|
|
|
{
|
|
|
|
delete dialog;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-27 09:15:39 +00:00
|
|
|
// check modifications
|
|
|
|
if( !dialog->isChanged() ) return;
|
|
|
|
|
2012-01-09 08:49:44 +00:00
|
|
|
// retrieve exception
|
2012-11-23 09:09:39 +00:00
|
|
|
dialog->save();
|
2012-01-09 08:49:44 +00:00
|
|
|
delete dialog;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// check new exception validity
|
2012-11-23 09:09:39 +00:00
|
|
|
checkException( exception );
|
2011-02-24 16:47:38 +00:00
|
|
|
resizeColumns();
|
2012-11-27 09:15:39 +00:00
|
|
|
|
|
|
|
setChanged( true );
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________
|
2011-02-24 16:47:38 +00:00
|
|
|
void ExceptionListWidget::remove( void )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// should use a konfirmation dialog
|
2013-08-01 17:30:54 +00:00
|
|
|
if( QMessageBox::question( this, i18n("Question - Oxygen Settings" ), i18n("Remove selected exception?") ) == QMessageBox::No ) return;
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// remove
|
2011-02-24 16:47:38 +00:00
|
|
|
model().remove( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
|
|
|
|
resizeColumns();
|
2012-11-01 18:09:09 +00:00
|
|
|
updateButtons();
|
2012-11-27 09:15:39 +00:00
|
|
|
|
|
|
|
setChanged( true );
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return;
|
2009-08-30 17:37:07 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________
|
2011-02-24 16:47:38 +00:00
|
|
|
void ExceptionListWidget::toggle( const QModelIndex& index )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-01 18:09:09 +00:00
|
|
|
if( !model().contains( index ) ) return;
|
2010-05-02 18:34:08 +00:00
|
|
|
if( index.column() != ExceptionModel::ENABLED ) return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// get matching exception
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr exception( model().get( index ) );
|
|
|
|
exception->setEnabled( !exception->enabled() );
|
2012-11-27 09:15:39 +00:00
|
|
|
setChanged( true );
|
2010-05-02 18:34:08 +00:00
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________
|
2011-02-24 16:47:38 +00:00
|
|
|
void ExceptionListWidget::up( void )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationList selection( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( selection.empty() ) { return; }
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// retrieve selected indexes in list and store in model
|
2011-02-24 16:47:38 +00:00
|
|
|
QModelIndexList selectedIndices( ui.exceptionListView->selectionModel()->selectedRows() );
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationList selectedExceptions( model().get( selectedIndices ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationList currentException( model().get() );
|
|
|
|
ConfigurationList newExceptions;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
for( ConfigurationList::const_iterator iter = currentException.constBegin(); iter != currentException.constEnd(); ++iter )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// check if new list is not empty, current index is selected and last index is not.
|
|
|
|
// if yes, move.
|
|
|
|
if(
|
2011-02-24 16:47:38 +00:00
|
|
|
!( newExceptions.empty() ||
|
|
|
|
selectedIndices.indexOf( model().index( *iter ) ) == -1 ||
|
|
|
|
selectedIndices.indexOf( model().index( newExceptions.back() ) ) != -1
|
2010-05-02 18:34:08 +00:00
|
|
|
) )
|
|
|
|
{
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr last( newExceptions.back() );
|
2012-11-04 19:54:22 +00:00
|
|
|
newExceptions.removeLast();
|
|
|
|
newExceptions.append( *iter );
|
|
|
|
newExceptions.append( last );
|
|
|
|
} else newExceptions.append( *iter );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2011-02-24 16:47:38 +00:00
|
|
|
model().set( newExceptions );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// restore selection
|
2011-02-24 16:47:38 +00:00
|
|
|
ui.exceptionListView->selectionModel()->select( model().index( selectedExceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
|
2012-11-23 09:09:39 +00:00
|
|
|
for( ConfigurationList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
|
2011-02-24 16:47:38 +00:00
|
|
|
{ ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-27 09:15:39 +00:00
|
|
|
setChanged( true );
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________
|
2011-02-24 16:47:38 +00:00
|
|
|
void ExceptionListWidget::down( void )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationList selection( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( selection.empty() )
|
|
|
|
{ return; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// retrieve selected indexes in list and store in model
|
2011-02-24 16:47:38 +00:00
|
|
|
QModelIndexList selectedIndices( ui.exceptionListView->selectionModel()->selectedIndexes() );
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationList selectedExceptions( model().get( selectedIndices ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationList currentExceptions( model().get() );
|
|
|
|
ConfigurationList newExceptions;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationListIterator iter( currentExceptions );
|
2012-11-04 19:54:22 +00:00
|
|
|
iter.toBack();
|
|
|
|
while( iter.hasPrevious() )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr current( iter.previous() );
|
2012-11-04 19:54:22 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// check if new list is not empty, current index is selected and last index is not.
|
|
|
|
// if yes, move.
|
|
|
|
if(
|
2011-02-24 16:47:38 +00:00
|
|
|
!( newExceptions.empty() ||
|
2012-11-04 19:54:22 +00:00
|
|
|
selectedIndices.indexOf( model().index( current ) ) == -1 ||
|
|
|
|
selectedIndices.indexOf( model().index( newExceptions.front() ) ) != -1
|
2010-05-02 18:34:08 +00:00
|
|
|
) )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr first( newExceptions.front() );
|
2012-11-04 19:54:22 +00:00
|
|
|
newExceptions.removeFirst();
|
|
|
|
newExceptions.prepend( current );
|
|
|
|
newExceptions.prepend( first );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-04 19:54:22 +00:00
|
|
|
} else newExceptions.prepend( current );
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-04 19:54:22 +00:00
|
|
|
model().set( newExceptions );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// restore selection
|
2011-02-24 16:47:38 +00:00
|
|
|
ui.exceptionListView->selectionModel()->select( model().index( selectedExceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
|
2012-11-23 09:09:39 +00:00
|
|
|
for( ConfigurationList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
|
2011-02-24 16:47:38 +00:00
|
|
|
{ ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-27 09:15:39 +00:00
|
|
|
setChanged( true );
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________
|
2011-02-24 16:47:38 +00:00
|
|
|
void ExceptionListWidget::resizeColumns( void ) const
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
|
|
|
ui.exceptionListView->resizeColumnToContents( ExceptionModel::ENABLED );
|
|
|
|
ui.exceptionListView->resizeColumnToContents( ExceptionModel::TYPE );
|
|
|
|
ui.exceptionListView->resizeColumnToContents( ExceptionModel::REGEXP );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________
|
2012-11-23 09:09:39 +00:00
|
|
|
bool ExceptionListWidget::checkException( ConfigurationPtr exception )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
while( exception->exceptionPattern().isEmpty() || !QRegExp( exception->exceptionPattern() ).isValid() )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2013-08-01 17:30:54 +00:00
|
|
|
QMessageBox::warning( this, i18n( "Warning - Oxygen Settings" ), i18n("Regular Expression syntax is incorrect") );
|
2012-01-09 08:49:44 +00:00
|
|
|
QPointer<ExceptionDialog> dialog( new ExceptionDialog( this ) );
|
2011-07-25 15:04:28 +00:00
|
|
|
dialog->setException( exception );
|
2012-01-09 08:49:44 +00:00
|
|
|
if( dialog->exec() == QDialog::Rejected )
|
|
|
|
{
|
|
|
|
delete dialog;
|
|
|
|
return false;
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
dialog->save();
|
2012-01-09 08:49:44 +00:00
|
|
|
delete dialog;
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-24 06:27:49 +00:00
|
|
|
}
|