Skip to content

Commit

Permalink
- fix #4732
Browse files Browse the repository at this point in the history
- move contents of src/app/attributetable and src/app/spatialite up one level
  (there was only one class in each directory left)
  • Loading branch information
jef-n committed Jan 2, 2012
1 parent 1210d35 commit c1b631d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
11 changes: 4 additions & 7 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SET(QGIS_APP_SRCS
qgsattributedialog.cpp
qgsattributetypedialog.cpp
qgsattributetypeloaddialog.cpp
qgsattributetabledialog.cpp
qgsbookmarkitem.cpp
qgsbookmarks.cpp
qgsbrowserdockwidget.cpp
Expand Down Expand Up @@ -96,7 +97,6 @@ SET(QGIS_APP_SRCS
qgshighlight.cpp
qgshandlebadlayers.cpp


composer/qgsattributeselectiondialog.cpp
composer/qgscomposer.cpp
composer/qgscomposerarrowwidget.cpp
Expand Down Expand Up @@ -132,8 +132,6 @@ SET(QGIS_APP_SRCS
ogr/qgsogrsublayersdialog.cpp
ogr/qgsvectorlayersaveasdialog.cpp

attributetable/qgsattributetabledialog.cpp

gps/qgsgpsinformationwidget.cpp
gps/qgsgpsmarker.cpp
)
Expand All @@ -157,6 +155,7 @@ SET (QGIS_APP_MOC_HDRS
qgsattributedialog.h
qgsattributetypedialog.h
qgsattributetypeloaddialog.h
qgsattributetabledialog.h
qgsbookmarks.h
qgsbrowserdockwidget.h
qgsconfigureshortcutsdialog.h
Expand Down Expand Up @@ -253,8 +252,6 @@ SET (QGIS_APP_MOC_HDRS
ogr/qgsogrsublayersdialog.h
ogr/qgsvectorlayersaveasdialog.h

attributetable/qgsattributetabledialog.h

gps/qgsgpsinformationwidget.h
)

Expand Down Expand Up @@ -330,10 +327,10 @@ ENDIF (POSTGRES_FOUND)

IF (HAVE_SPATIALITE)
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS}
spatialite/qgsnewspatialitelayerdialog.cpp
qgsnewspatialitelayerdialog.cpp
)
SET (QGIS_APP_MOC_HDRS ${QGIS_APP_MOC_HDRS}
spatialite/qgsnewspatialitelayerdialog.h
qgsnewspatialitelayerdialog.h
)
ENDIF (HAVE_SPATIALITE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void QgsAttributeTableDialog::on_mSelectedToTopButton_clicked()
#endif

// just select proper rows
//mModel->reload(mModel->index(0,0), mModel->index(mModel->rowCount(), mModel->columnCount()));
//mModel->reload(mModel->index(0,0), mModel->index(mModel->rowCount() - 1 , mModel->columnCount() - 1));
//mModel->changeLayout();
mModel->resetModel();
updateSelection();
Expand Down Expand Up @@ -677,7 +677,7 @@ void QgsAttributeTableDialog::editingToggled()
mAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() && mLayer->geometryType() == QGis::NoGeometry );

// (probably reload data if user stopped editing - possible revert)
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) );

// not necessary to set table read only if layer is not editable
// because model always reflects actual state when returning item flags
Expand All @@ -700,7 +700,7 @@ void QgsAttributeTableDialog::revert()
{
mLayer->rollBack();
mModel->revert();
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) );
}

void QgsAttributeTableDialog::on_mAddAttribute_clicked()
Expand All @@ -724,7 +724,7 @@ void QgsAttributeTableDialog::on_mAddAttribute_clicked()
mLayer->destroyEditCommand();
}
// update model - a field has been added or updated
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) );
}
}

Expand Down Expand Up @@ -765,7 +765,7 @@ void QgsAttributeTableDialog::on_mRemoveAttribute_clicked()
mLayer->destroyEditCommand();
}
// update model - a field has been added or updated
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) );
}
}

Expand All @@ -778,8 +778,10 @@ void QgsAttributeTableDialog::on_mOpenFieldCalculator_clicked()

if ( col >= 0 )
{
mModel->reload( mModel->index( 0, col ),
mModel->index( mModel->rowCount(), col ) );
QModelIndex idx0 = mModel->index( 0, col );
QModelIndex idx1 = mModel->index( mModel->rowCount() - 1, col );

mModel->reload( idx0, idx1 );
}
}
}
Expand All @@ -794,7 +796,7 @@ void QgsAttributeTableDialog::addFeature()
QgsFeatureAction action( tr( "Geometryless feature added" ), f, mLayer, -1, -1, this );
if ( action.addFeature() )
{
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) );
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 17 additions & 8 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ void QgsAttributeTableModel::layerDeleted()

void QgsAttributeTableModel::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
{
if ( mFeatureMap.contains( fid ) )
{
mFeatureMap[ fid ].changeAttribute( idx, value );
}

setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
}

Expand Down Expand Up @@ -474,10 +469,17 @@ bool QgsAttributeTableModel::setData( const QModelIndex &index, const QVariant &
if ( !index.isValid() || role != Qt::EditRole || !mLayer->isEditable() )
return false;

QgsFeatureId rowId = rowToId( index.row() );
if ( mFeat.id() == rowId || featureAtId( rowId ) )
QgsFeatureId fid = rowToId( index.row() );
int idx = fieldIdx( index.column() );

if ( mFeatureMap.contains( fid ) )
{
mFeat.changeAttribute( mAttributes[ index.column()], value );
mFeatureMap[ fid ].changeAttribute( idx, value );
}

if ( mFeat.id() == fid || featureAtId( fid ) )
{
mFeat.changeAttribute( idx, value );
}

if ( !mLayer->isModified() )
Expand All @@ -504,6 +506,13 @@ Qt::ItemFlags QgsAttributeTableModel::flags( const QModelIndex &index ) const

void QgsAttributeTableModel::reload( const QModelIndex &index1, const QModelIndex &index2 )
{
for( int row = index1.row(); row < index2.row(); row++ )
{
QgsFeatureId fid = rowToId( row );
mFeatureMap.remove( fid );
mFeatureQueue.removeOne( fid );
}

mFeat.setFeatureId( std::numeric_limits<int>::min() );
emit dataChanged( index1, index2 );
}
Expand Down

0 comments on commit c1b631d

Please sign in to comment.