22 changes: 11 additions & 11 deletions src/gui/attributetable/qgsattributetableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

QgsAttributeTableView::QgsAttributeTableView( QWidget *parent )
: QTableView( parent ),
mMasterModel( NULL ),
mFilterModel( NULL ),
mActionPopup( NULL )
mMasterModel( NULL ),
mFilterModel( NULL ),
mActionPopup( NULL )
{
QSettings settings;
restoreGeometry( settings.value( "/BetterAttributeTable/geometry" ).toByteArray() );
Expand Down Expand Up @@ -141,8 +141,8 @@ void QgsAttributeTableView::keyPressEvent( QKeyEvent *event )
switch ( event->key() )
{

// Default Qt behavior would be to change the selection.
// We don't make it that easy for the user to trash his selection.
// Default Qt behavior would be to change the selection.
// We don't make it that easy for the user to trash his selection.
case Qt::Key_Up:
case Qt::Key_Down:
case Qt::Key_Left:
Expand All @@ -166,7 +166,7 @@ void QgsAttributeTableView::onVerticalHeaderSectionClicked( int logicalIndex )

QModelIndexList selectedRows = selectionModel()->selectedRows();

foreach( QModelIndex row, selectedRows )
foreach ( QModelIndex row, selectedRows )
{
selectedFeatures.insert( mFilterModel->rowToId( row ) );
}
Expand All @@ -183,31 +183,31 @@ void QgsAttributeTableView::onFilterInvalidated()
{
QItemSelection localSelection = mFilterModel->mapSelectionFromSource( mMasterSelection->selection() );
selectionModel()->select( localSelection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection,QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );
connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );
}

void QgsAttributeTableView::onSelectionChanged( const QItemSelection& selected, const QItemSelection& deselected )
{
disconnect( mMasterSelection, SIGNAL( selectionChanged(QItemSelection,QItemSelection)), this, SLOT( onMasterSelectionChanged( QItemSelection, QItemSelection ) ) );
disconnect( mMasterSelection, SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onMasterSelectionChanged( QItemSelection, QItemSelection ) ) );
QItemSelection masterSelected = mFilterModel->mapSelectionToSource( selected );
QItemSelection masterDeselected = mFilterModel->mapSelectionToSource( deselected );

mMasterSelection->select( masterSelected, QItemSelectionModel::Select );
mMasterSelection->select( masterDeselected, QItemSelectionModel::Deselect );
connect( mMasterSelection, SIGNAL( selectionChanged(QItemSelection,QItemSelection ) ), SLOT( onMasterSelectionChanged( QItemSelection, QItemSelection ) ) );
connect( mMasterSelection, SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onMasterSelectionChanged( QItemSelection, QItemSelection ) ) );
}

void QgsAttributeTableView::onMasterSelectionChanged( const QItemSelection& selected, const QItemSelection& deselected )
{
Q_UNUSED( selected )
Q_UNUSED( deselected )
disconnect( selectionModel(), SIGNAL( selectionChanged(QItemSelection,QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );
disconnect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );

// Synchronizing the whole selection seems to work faster than using the deltas (Deselecting takes pretty long)
QItemSelection localSelection = mFilterModel->mapSelectionFromSource( mMasterSelection->selection() );
selectionModel()->select( localSelection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );

connect( selectionModel(), SIGNAL( selectionChanged(QItemSelection,QItemSelection)), this, SLOT(onSelectionChanged( QItemSelection, QItemSelection ) ) );
connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );
}

void QgsAttributeTableView::selectAll()
Expand Down
18 changes: 9 additions & 9 deletions src/gui/attributetable/qgsdualview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#include <QMenu>
#include <QProgressDialog>

QgsDualView::QgsDualView( QWidget* parent ) :
QStackedWidget( parent ),
mProgressDlg( NULL )
QgsDualView::QgsDualView( QWidget* parent )
: QStackedWidget( parent )
, mProgressDlg( NULL )
{
setupUi( this );

Expand Down Expand Up @@ -76,7 +76,7 @@ void QgsDualView::init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QgsDista
void QgsDualView::columnBoxInit()
{
QList< QAction* > previewActions = mFeatureListPreviewButton->actions();
foreach( QAction* a, previewActions )
foreach ( QAction* a, previewActions )
{
if ( a != mActionExpressionPreview )
{
Expand All @@ -90,7 +90,7 @@ void QgsDualView::columnBoxInit()

QList<QgsField> fields = mLayerCache->layer()->pendingFields().toList();

foreach( const QgsField field, fields )
foreach ( const QgsField field, fields )
{
if ( mLayerCache->layer()->editType( mLayerCache->layer()->fieldNameIndex( field.name() ) ) != QgsVectorLayer::Hidden )
{
Expand Down Expand Up @@ -121,7 +121,7 @@ void QgsDualView::columnBoxInit()
{
QStringList pkFields;

foreach( int attr, pkAttrs )
foreach ( int attr, pkAttrs )
{
pkFields.append( "\"" + fields[attr].name() + "\"" );
}
Expand All @@ -131,7 +131,7 @@ void QgsDualView::columnBoxInit()
else if ( fields.size() > 0 )
{
QStringList fieldNames;
foreach ( QgsField field, fields)
foreach ( QgsField field, fields )
{
fieldNames.append( "\"" + field.name() + "\"" );
}
Expand Down Expand Up @@ -311,11 +311,11 @@ void QgsDualView::viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex )
}
}

QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open form" ),this, -1, sourceIndex );
QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open form" ), this, -1, sourceIndex );
menu->addAction( tr( "Open form" ), a, SLOT( featureForm() ) );
}

void QgsDualView::setFilteredFeatures(QgsFeatureIds filteredFeatures)
void QgsDualView::setFilteredFeatures( QgsFeatureIds filteredFeatures )
{
mFilterModel->setFilteredFeatures( filteredFeatures );
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsdualview.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
void setCurrentEditSelection( const QgsFeatureIds& fids );

signals:

private slots:
/**
* Changes the currently visible feature within the attribute editor
Expand Down Expand Up @@ -128,7 +128,7 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
virtual void finished();

private:
void initLayerCache(QgsVectorLayer *layer);
void initLayerCache( QgsVectorLayer *layer );
void initModels( QgsMapCanvas* mapCanvas );

QgsAttributeTableModel* mMasterModel;
Expand Down
14 changes: 7 additions & 7 deletions src/gui/attributetable/qgsfeaturelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <QItemSelection>

QgsFeatureListModel::QgsFeatureListModel( QgsAttributeTableFilterModel *sourceModel, QObject *parent ) :
QAbstractProxyModel( parent )
QgsFeatureListModel::QgsFeatureListModel( QgsAttributeTableFilterModel *sourceModel, QObject *parent )
: QAbstractProxyModel( parent )
{
setSourceModel( sourceModel );
mExpression = new QgsExpression( "" );
Expand Down Expand Up @@ -40,10 +40,10 @@ QgsVectorLayerCache *QgsFeatureListModel::layerCache()

QgsFeatureId QgsFeatureListModel::idxToFid( const QModelIndex &index ) const
{
return mFilterModel->masterModel()->rowToId( mapToMaster( index).row() );
return mFilterModel->masterModel()->rowToId( mapToMaster( index ).row() );
}

QModelIndex QgsFeatureListModel::fidToIdx(const QgsFeatureId fid) const
QModelIndex QgsFeatureListModel::fidToIdx( const QgsFeatureId fid ) const
{
return mFilterModel->mapFromMaster( mFilterModel->masterModel()->idToIndex( fid ) );
}
Expand Down Expand Up @@ -175,7 +175,7 @@ QModelIndex QgsFeatureListModel::mapToMaster( const QModelIndex &proxyIndex ) co

QModelIndex QgsFeatureListModel::mapFromMaster( const QModelIndex &sourceIndex ) const
{
if( !sourceIndex.isValid() )
if ( !sourceIndex.isValid() )
return QModelIndex();

return createIndex( mFilterModel->mapFromMaster( sourceIndex ).row(), 0 );
Expand Down Expand Up @@ -203,10 +203,10 @@ QModelIndex QgsFeatureListModel::mapToSource( const QModelIndex &proxyIndex ) co

QModelIndex QgsFeatureListModel::mapFromSource( const QModelIndex &sourceIndex ) const
{
if( !sourceIndex.isValid() )
if ( !sourceIndex.isValid() )
return QModelIndex();

return createIndex( sourceIndex.row(), 0 );
return createIndex( sourceIndex.row(), 0 );
}

QModelIndex QgsFeatureListModel::index( int row, int column, const QModelIndex& parent ) const
Expand Down
15 changes: 8 additions & 7 deletions src/gui/attributetable/qgsfeaturelistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ class QgsFeatureListModel : public QAbstractProxyModel
public:
struct FeatureInfo
{
public:
FeatureInfo() :
isNew( false ),
isEdited( false ) {}

bool isNew;
bool isEdited;
public:
FeatureInfo()
: isNew( false )
, isEdited( false )
{}

bool isNew;
bool isEdited;
};

public:
Expand Down
20 changes: 10 additions & 10 deletions src/gui/attributetable/qgsfeaturelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@

QgsFeatureListView::QgsFeatureListView( QWidget *parent )
: QListView( parent ),
mCurrentEditSelectionModel( NULL ),
mItemDelegate( NULL ),
mEditSelectionDrag( false )
mCurrentEditSelectionModel( NULL ),
mItemDelegate( NULL ),
mEditSelectionDrag( false )
{
setSelectionMode( QAbstractItemView::ExtendedSelection );
}
Expand Down Expand Up @@ -123,12 +123,12 @@ void QgsFeatureListView::mouseReleaseEvent( QMouseEvent *event )

void QgsFeatureListView::editSelectionChanged( QItemSelection deselected, QItemSelection selected )
{
if (isVisible() && updatesEnabled())
if ( isVisible() && updatesEnabled() )
{
QItemSelection localDeselected = mModel->mapSelectionFromMaster( deselected );
QItemSelection localSelected = mModel->mapSelectionFromMaster( selected );
viewport()->update( visualRegionForSelection( localDeselected ) | visualRegionForSelection( localSelected ) );
}
}

QItemSelection currentSelection = mCurrentEditSelectionModel->selection();
if ( currentSelection.size() == 1 )
Expand All @@ -147,9 +147,9 @@ void QgsFeatureListView::onFilterAboutToBeInvalidated()

void QgsFeatureListView::onFilterInvalidated()
{
QItemSelection localSelection = mModel->mapSelectionFromMaster(mMasterSelection->selection() );
QItemSelection localSelection = mModel->mapSelectionFromMaster( mMasterSelection->selection() );
selectionModel()->select( localSelection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection,QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );
connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );
}

void QgsFeatureListView::onSelectionChanged( const QItemSelection& selected, const QItemSelection& deselected )
Expand All @@ -167,7 +167,7 @@ void QgsFeatureListView::onMasterSelectionChanged( const QItemSelection& selecte
{
Q_UNUSED( selected )
Q_UNUSED( deselected )
disconnect( selectionModel(), SIGNAL( selectionChanged(QItemSelection,QItemSelection)), this, SLOT(onSelectionChanged(QItemSelection,QItemSelection)) );
disconnect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );

// Synchronizing the whole selection seems to work faster than using the deltas (Deselecting takes pretty long)
QItemSelection localSelection = mModel->mapSelectionFromMaster( mMasterSelection->selection() );
Expand All @@ -178,7 +178,7 @@ void QgsFeatureListView::onMasterSelectionChanged( const QItemSelection& selecte

void QgsFeatureListView::selectAll()
{
disconnect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection,QItemSelection ) ) );
disconnect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onSelectionChanged( QItemSelection, QItemSelection ) ) );
QItemSelection selection;
selection.append( QItemSelectionRange( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, 0 ) ) );
selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
Expand All @@ -189,7 +189,7 @@ void QgsFeatureListView::setEditSelection( const QgsFeatureIds &fids )
{
QItemSelection selection;

foreach( QgsFeatureId fid, fids )
foreach ( QgsFeatureId fid, fids )
{
selection.append( QItemSelectionRange( mModel->mapToMaster( mModel->fidToIdx( fid ) ) ) );
}
Expand Down
10 changes: 5 additions & 5 deletions src/gui/attributetable/qgsfeaturelistview.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class GUI_EXPORT QgsFeatureListView : public QListView
Q_OBJECT

public:
/**
* Creates a feature list view
*
* @param parent owner
*/
/**
* Creates a feature list view
*
* @param parent owner
*/
explicit QgsFeatureListView( QWidget* parent = 0 );

/**
Expand Down
15 changes: 9 additions & 6 deletions src/gui/attributetable/qgsfeaturelistviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include <QMouseEvent>
#include <QObject>

QgsFeatureListViewDelegate::QgsFeatureListViewDelegate( QgsFeatureListModel *listModel, QObject *parent ) :
QItemDelegate( parent ),
mListModel( listModel )
QgsFeatureListViewDelegate::QgsFeatureListViewDelegate( QgsFeatureListModel *listModel, QObject *parent )
: QItemDelegate( parent )
, mListModel( listModel )
{
}

Expand All @@ -41,7 +41,7 @@ QSize QgsFeatureListViewDelegate::sizeHint( const QStyleOptionViewItem& option,
return QSize( option.rect.width(), sIconSize );
}

void QgsFeatureListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
void QgsFeatureListViewDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
QString text = index.model()->data( index, Qt::EditRole ).toString();
QgsFeatureListModel::FeatureInfo featInfo = index.model()->data( index, Qt::UserRole ).value<QgsFeatureListModel::FeatureInfo>();
Expand All @@ -54,10 +54,13 @@ void QgsFeatureListViewDelegate::paint(QPainter *painter, const QStyleOptionView
pbn1Opts.iconSize = QSize( sIconSize, sIconSize );

pbn1Opts.state |= QStyle::State_Enabled;
if (checked) {
if ( checked )
{
pbn1Opts.icon = QgsApplication::getThemeIcon( "/mIconEditableEdits.png" );
pbn1Opts.state |= QStyle::State_On;
} else {
}
else
{
pbn1Opts.icon = QgsApplication::getThemeIcon( "/mIconEditable.png" );
pbn1Opts.state |= QStyle::State_Off;
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsfeaturelistviewdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QPosition;

class QgsFeatureListViewDelegate : public QItemDelegate
{
Q_OBJECT
Q_OBJECT

public:
static int const sIconSize = 24;
Expand All @@ -29,7 +29,7 @@ class QgsFeatureListViewDelegate : public QItemDelegate
Element positionToElement( const QPoint& pos );

signals:
void editButtonClicked( QModelIndex& index);
void editButtonClicked( QModelIndex& index );

public slots:

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsattributedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
int QgsAttributeDialog::smFormCounter = 0;

QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeature, bool featureOwner, QgsDistanceArea myDa, QWidget* parent, bool showDialogButtons )
: mDialog( 0 )
: mDialog( 0 )
, mSettingsPath( "/Windows/AttributeDialog/" )
, mLayer( vl )
, mFeature( thepFeature )
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsexpressionselectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <QSettings>

QgsExpressionSelectionDialog::QgsExpressionSelectionDialog( QgsVectorLayer* layer, QString startText, QWidget* parent )
: QDialog( parent ),
mLayer( layer )
: QDialog( parent )
, mLayer( layer )
{
setupUi( this );

Expand Down Expand Up @@ -131,7 +131,7 @@ void QgsExpressionSelectionDialog::on_mActionSelectInstersect_triggered()
expression->prepare( fields );

QgsFeature feat;
foreach( const QgsFeatureId fid, oldSelection )
foreach ( const QgsFeatureId fid, oldSelection )
{
QgsFeatureIterator features = mLayer->getFeatures( QgsFeatureRequest().setFilterFid( fid ) );

Expand Down Expand Up @@ -167,7 +167,7 @@ void QgsExpressionSelectionDialog::on_mActionRemoveFromSelection_triggered()
expression->prepare( fields );

QgsFeature feat;
foreach( const QgsFeatureId fid, oldSelection )
foreach ( const QgsFeatureId fid, oldSelection )
{
QgsFeatureIterator features = mLayer->getFeatures( QgsFeatureRequest().setFilterFid( fid ) );

Expand Down