Skip to content

Commit 3ba2fe9

Browse files
committedJan 16, 2012
fix #4822
1 parent 5afa34c commit 3ba2fe9

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
lines changed
 

‎src/app/qgsattributetabledialog.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,13 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
6363
QSettings settings;
6464
restoreGeometry( settings.value( "/Windows/BetterAttributeTable/geometry" ).toByteArray() );
6565

66+
connect( mView, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
67+
connect( mView, SIGNAL( finished() ), this, SLOT( finished() ) );
6668
mView->setCanvasAndLayer( QgisApp::instance()->mapCanvas(), mLayer );
6769

6870
mFilterModel = ( QgsAttributeTableFilterModel * ) mView->model();
6971
mModel = qobject_cast<QgsAttributeTableModel * >( dynamic_cast<QgsAttributeTableFilterModel *>( mView->model() )->sourceModel() );
7072

71-
connect( mModel, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
72-
connect( mModel, SIGNAL( finished() ), this, SLOT( finished() ) );
73-
mModel->loadLayer();
74-
7573
mQuery = query;
7674
mColumnBox = columnBox;
7775
columnBoxInit();
@@ -834,7 +832,7 @@ void QgsAttributeTableDialog::progress( int i, bool &cancel )
834832

835833
mProgress->setValue( i );
836834

837-
if ( i > 0 && i % 1000 == 0 )
835+
if ( i > 0 && i % 5000 == 0 )
838836
{
839837
mProgress->setLabelText( tr( "%1 features loaded." ).arg( i ) );
840838
}

‎src/gui/attributetable/qgsattributetablememorymodel.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ void QgsAttributeTableMemoryModel::loadLayer()
6565
mIdRowMap.insert( f.id(), n );
6666
mRowIdMap.insert( n, f.id() );
6767
mFeatureMap.insert( f.id(), f );
68-
n++;
68+
69+
bool cancel = false;
70+
emit progress( n++, cancel );
71+
if ( cancel )
72+
break;
6973
}
7074

75+
emit finished();
76+
7177
mFieldCount = mAttributes.size();
7278
}
7379

‎src/gui/attributetable/qgsattributetablemodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
183183
* @parem inOperation guard insertion with beginInsertRows() / endInsertRows()
184184
*/
185185
virtual void featureAdded( QgsFeatureId fid, bool inOperation = true );
186+
186187
/**
187188
* Launched when layer has been deleted
188189
*/

‎src/gui/attributetable/qgsattributetableview.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,24 @@ void QgsAttributeTableView::setCanvasAndLayer( QgsMapCanvas *canvas, QgsVectorLa
7474
mModel = new QgsAttributeTableMemoryModel( canvas, layer );
7575
}
7676

77-
mFilterModel = new QgsAttributeTableFilterModel( layer );
78-
mFilterModel->setSourceModel( mModel );
79-
setModel( mFilterModel );
77+
connect( mModel, SIGNAL( finished() ), this, SLOT( setFilterModel() ) );
78+
79+
connect( mModel, SIGNAL( progress(int, bool&) ), this, SIGNAL( progress(int, bool&) ) );
80+
connect( mModel, SIGNAL( finished() ), this, SIGNAL( finished() ) );
81+
mModel->loadLayer();
8082

8183
delete oldModel;
8284
delete filterModel;
8385
}
8486

87+
void QgsAttributeTableView::setFilterModel()
88+
{
89+
disconnect( mModel, SIGNAL( finished() ), this, SLOT( setFilterModel() ) );
90+
mFilterModel = new QgsAttributeTableFilterModel( mModel->layer() );
91+
mFilterModel->setSourceModel( mModel );
92+
setModel( mFilterModel );
93+
}
94+
8595
QgsAttributeTableView::~QgsAttributeTableView()
8696
{
8797
delete mModel;

‎src/gui/attributetable/qgsattributetableview.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ class GUI_EXPORT QgsAttributeTableView : public QTableView
5050

5151
void contextMenuEvent( QContextMenuEvent* );
5252

53+
public slots:
54+
void setFilterModel();
55+
5356
signals:
5457
void willShowContextMenu( QMenu* menu, QModelIndex atIndex );
5558

59+
void finished();
60+
void progress( int i, bool &cancel );
61+
5662
private:
5763
QgsMapCanvas *mCanvas;
5864
QgsAttributeTableModel* mModel;

0 commit comments

Comments
 (0)
Please sign in to comment.