Skip to content

Commit c1b631d

Browse files
committed
- fix #4732
- move contents of src/app/attributetable and src/app/spatialite up one level (there was only one class in each directory left)
1 parent 1210d35 commit c1b631d

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
lines changed

src/app/CMakeLists.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SET(QGIS_APP_SRCS
1111
qgsattributedialog.cpp
1212
qgsattributetypedialog.cpp
1313
qgsattributetypeloaddialog.cpp
14+
qgsattributetabledialog.cpp
1415
qgsbookmarkitem.cpp
1516
qgsbookmarks.cpp
1617
qgsbrowserdockwidget.cpp
@@ -96,7 +97,6 @@ SET(QGIS_APP_SRCS
9697
qgshighlight.cpp
9798
qgshandlebadlayers.cpp
9899

99-
100100
composer/qgsattributeselectiondialog.cpp
101101
composer/qgscomposer.cpp
102102
composer/qgscomposerarrowwidget.cpp
@@ -132,8 +132,6 @@ SET(QGIS_APP_SRCS
132132
ogr/qgsogrsublayersdialog.cpp
133133
ogr/qgsvectorlayersaveasdialog.cpp
134134

135-
attributetable/qgsattributetabledialog.cpp
136-
137135
gps/qgsgpsinformationwidget.cpp
138136
gps/qgsgpsmarker.cpp
139137
)
@@ -157,6 +155,7 @@ SET (QGIS_APP_MOC_HDRS
157155
qgsattributedialog.h
158156
qgsattributetypedialog.h
159157
qgsattributetypeloaddialog.h
158+
qgsattributetabledialog.h
160159
qgsbookmarks.h
161160
qgsbrowserdockwidget.h
162161
qgsconfigureshortcutsdialog.h
@@ -253,8 +252,6 @@ SET (QGIS_APP_MOC_HDRS
253252
ogr/qgsogrsublayersdialog.h
254253
ogr/qgsvectorlayersaveasdialog.h
255254

256-
attributetable/qgsattributetabledialog.h
257-
258255
gps/qgsgpsinformationwidget.h
259256
)
260257

@@ -330,10 +327,10 @@ ENDIF (POSTGRES_FOUND)
330327

331328
IF (HAVE_SPATIALITE)
332329
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS}
333-
spatialite/qgsnewspatialitelayerdialog.cpp
330+
qgsnewspatialitelayerdialog.cpp
334331
)
335332
SET (QGIS_APP_MOC_HDRS ${QGIS_APP_MOC_HDRS}
336-
spatialite/qgsnewspatialitelayerdialog.h
333+
qgsnewspatialitelayerdialog.h
337334
)
338335
ENDIF (HAVE_SPATIALITE)
339336

src/app/attributetable/qgsattributetabledialog.cpp renamed to src/app/qgsattributetabledialog.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void QgsAttributeTableDialog::on_mSelectedToTopButton_clicked()
215215
#endif
216216

217217
// just select proper rows
218-
//mModel->reload(mModel->index(0,0), mModel->index(mModel->rowCount(), mModel->columnCount()));
218+
//mModel->reload(mModel->index(0,0), mModel->index(mModel->rowCount() - 1 , mModel->columnCount() - 1));
219219
//mModel->changeLayout();
220220
mModel->resetModel();
221221
updateSelection();
@@ -677,7 +677,7 @@ void QgsAttributeTableDialog::editingToggled()
677677
mAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() && mLayer->geometryType() == QGis::NoGeometry );
678678

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

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

706706
void QgsAttributeTableDialog::on_mAddAttribute_clicked()
@@ -724,7 +724,7 @@ void QgsAttributeTableDialog::on_mAddAttribute_clicked()
724724
mLayer->destroyEditCommand();
725725
}
726726
// update model - a field has been added or updated
727-
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
727+
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) );
728728
}
729729
}
730730

@@ -765,7 +765,7 @@ void QgsAttributeTableDialog::on_mRemoveAttribute_clicked()
765765
mLayer->destroyEditCommand();
766766
}
767767
// update model - a field has been added or updated
768-
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
768+
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) );
769769
}
770770
}
771771

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

779779
if ( col >= 0 )
780780
{
781-
mModel->reload( mModel->index( 0, col ),
782-
mModel->index( mModel->rowCount(), col ) );
781+
QModelIndex idx0 = mModel->index( 0, col );
782+
QModelIndex idx1 = mModel->index( mModel->rowCount() - 1, col );
783+
784+
mModel->reload( idx0, idx1 );
783785
}
784786
}
785787
}
@@ -794,7 +796,7 @@ void QgsAttributeTableDialog::addFeature()
794796
QgsFeatureAction action( tr( "Geometryless feature added" ), f, mLayer, -1, -1, this );
795797
if ( action.addFeature() )
796798
{
797-
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
799+
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) );
798800
}
799801
}
800802

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/gui/attributetable/qgsattributetablemodel.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,6 @@ void QgsAttributeTableModel::layerDeleted()
179179

180180
void QgsAttributeTableModel::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
181181
{
182-
if ( mFeatureMap.contains( fid ) )
183-
{
184-
mFeatureMap[ fid ].changeAttribute( idx, value );
185-
}
186-
187182
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
188183
}
189184

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

477-
QgsFeatureId rowId = rowToId( index.row() );
478-
if ( mFeat.id() == rowId || featureAtId( rowId ) )
472+
QgsFeatureId fid = rowToId( index.row() );
473+
int idx = fieldIdx( index.column() );
474+
475+
if ( mFeatureMap.contains( fid ) )
479476
{
480-
mFeat.changeAttribute( mAttributes[ index.column()], value );
477+
mFeatureMap[ fid ].changeAttribute( idx, value );
478+
}
479+
480+
if ( mFeat.id() == fid || featureAtId( fid ) )
481+
{
482+
mFeat.changeAttribute( idx, value );
481483
}
482484

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

505507
void QgsAttributeTableModel::reload( const QModelIndex &index1, const QModelIndex &index2 )
506508
{
509+
for( int row = index1.row(); row < index2.row(); row++ )
510+
{
511+
QgsFeatureId fid = rowToId( row );
512+
mFeatureMap.remove( fid );
513+
mFeatureQueue.removeOne( fid );
514+
}
515+
507516
mFeat.setFeatureId( std::numeric_limits<int>::min() );
508517
emit dataChanged( index1, index2 );
509518
}

0 commit comments

Comments
 (0)