Skip to content
Permalink
Browse files

fix #4822

  • Loading branch information
jef-n committed Jan 16, 2012
1 parent 5afa34c commit 3ba2fe9d04cd193a54bb8165bbcb79b22977d2ec
@@ -63,15 +63,13 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
QSettings settings;
restoreGeometry( settings.value( "/Windows/BetterAttributeTable/geometry" ).toByteArray() );

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

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

connect( mModel, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
connect( mModel, SIGNAL( finished() ), this, SLOT( finished() ) );
mModel->loadLayer();

mQuery = query;
mColumnBox = columnBox;
columnBoxInit();
@@ -834,7 +832,7 @@ void QgsAttributeTableDialog::progress( int i, bool &cancel )

mProgress->setValue( i );

if ( i > 0 && i % 1000 == 0 )
if ( i > 0 && i % 5000 == 0 )
{
mProgress->setLabelText( tr( "%1 features loaded." ).arg( i ) );
}
@@ -65,9 +65,15 @@ void QgsAttributeTableMemoryModel::loadLayer()
mIdRowMap.insert( f.id(), n );
mRowIdMap.insert( n, f.id() );
mFeatureMap.insert( f.id(), f );
n++;

bool cancel = false;
emit progress( n++, cancel );
if ( cancel )
break;
}

emit finished();

mFieldCount = mAttributes.size();
}

@@ -183,6 +183,7 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
* @parem inOperation guard insertion with beginInsertRows() / endInsertRows()
*/
virtual void featureAdded( QgsFeatureId fid, bool inOperation = true );

/**
* Launched when layer has been deleted
*/
@@ -74,14 +74,24 @@ void QgsAttributeTableView::setCanvasAndLayer( QgsMapCanvas *canvas, QgsVectorLa
mModel = new QgsAttributeTableMemoryModel( canvas, layer );
}

mFilterModel = new QgsAttributeTableFilterModel( layer );
mFilterModel->setSourceModel( mModel );
setModel( mFilterModel );
connect( mModel, SIGNAL( finished() ), this, SLOT( setFilterModel() ) );

connect( mModel, SIGNAL( progress(int, bool&) ), this, SIGNAL( progress(int, bool&) ) );
connect( mModel, SIGNAL( finished() ), this, SIGNAL( finished() ) );
mModel->loadLayer();

delete oldModel;
delete filterModel;
}

void QgsAttributeTableView::setFilterModel()
{
disconnect( mModel, SIGNAL( finished() ), this, SLOT( setFilterModel() ) );
mFilterModel = new QgsAttributeTableFilterModel( mModel->layer() );
mFilterModel->setSourceModel( mModel );
setModel( mFilterModel );
}

QgsAttributeTableView::~QgsAttributeTableView()
{
delete mModel;
@@ -50,9 +50,15 @@ class GUI_EXPORT QgsAttributeTableView : public QTableView

void contextMenuEvent( QContextMenuEvent* );

public slots:
void setFilterModel();

signals:
void willShowContextMenu( QMenu* menu, QModelIndex atIndex );

void finished();
void progress( int i, bool &cancel );

private:
QgsMapCanvas *mCanvas;
QgsAttributeTableModel* mModel;

0 comments on commit 3ba2fe9

Please sign in to comment.
You can’t perform that action at this time.