Skip to content
Permalink
Browse files
browser and dataitems - show wait cursor when loading
Signed-off-by: Tim Sutton <tim@linfiniti.com>
  • Loading branch information
etiennesky authored and timlinux committed Mar 31, 2012
1 parent 58ebe86 commit ec005b29ce74508f06aef276554417353c61bf16
Showing with 38 additions and 17 deletions.
  1. +23 −16 src/app/qgsbrowserdockwidget.cpp
  2. +2 −1 src/app/qgsbrowserdockwidget.h
  3. +13 −0 src/core/qgsdataitem.cpp
@@ -104,8 +104,7 @@ QgsBrowserDockWidget::QgsBrowserDockWidget( QWidget * parent ) :
setWidget( innerWidget );

connect( mBrowserView, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( showContextMenu( const QPoint & ) ) );
//connect( mBrowserView, SIGNAL( clicked( const QModelIndex& ) ), this, SLOT( itemClicked( const QModelIndex& ) ) );
connect( mBrowserView, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( itemClicked( const QModelIndex& ) ) );
connect( mBrowserView, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( addLayerAtIndex( const QModelIndex& ) ) );

}

@@ -126,19 +125,6 @@ void QgsBrowserDockWidget::showEvent( QShowEvent * e )
QDockWidget::showEvent( e );
}


void QgsBrowserDockWidget::itemClicked( const QModelIndex& index )
{
QgsDataItem *dataItem = mModel->dataItem( index );

if ( dataItem != NULL && dataItem->type() == QgsDataItem::Layer )
{
QgsLayerItem *layerItem = qobject_cast<QgsLayerItem*>( dataItem );
if ( layerItem != NULL )
addLayer( layerItem );
}
}

void QgsBrowserDockWidget::showContextMenu( const QPoint & pt )
{
QModelIndex idx = mBrowserView->indexAt( pt );
@@ -168,7 +154,7 @@ void QgsBrowserDockWidget::showContextMenu( const QPoint & pt )

else if ( item->type() == QgsDataItem::Layer )
{
menu->addAction( tr( "Add Layer" ), this, SLOT( itemClicked( idx ) ) );
menu->addAction( tr( "Add Layer" ), this, SLOT( addCurrentLayer( ) ) );
menu->addAction( tr( "Add Selected Layers" ), this, SLOT( addSelectedLayers() ) );
}

@@ -312,6 +298,27 @@ void QgsBrowserDockWidget::addLayer( QgsLayerItem *layerItem )
}
}

void QgsBrowserDockWidget::addLayerAtIndex( const QModelIndex& index )
{
QgsDataItem *dataItem = mModel->dataItem( index );

if ( dataItem != NULL && dataItem->type() == QgsDataItem::Layer )
{
QgsLayerItem *layerItem = qobject_cast<QgsLayerItem*>( dataItem );
if ( layerItem != NULL )
{
QApplication::setOverrideCursor( Qt::WaitCursor );
addLayer( layerItem );
QApplication::restoreOverrideCursor();
}
}
}

void QgsBrowserDockWidget::addCurrentLayer( )
{
addLayerAtIndex( mBrowserView->currentIndex() );
}

void QgsBrowserDockWidget::addSelectedLayers()
{
QApplication::setOverrideCursor( Qt::WaitCursor );
@@ -17,14 +17,15 @@ class QgsBrowserDockWidget : public QDockWidget
signals:

public slots:
void itemClicked( const QModelIndex& index );
void addLayerAtIndex( const QModelIndex& index );
void showContextMenu( const QPoint & );

void addFavourite();
void removeFavourite();

void refresh();

void addCurrentLayer();
void addSelectedLayers();

protected:
@@ -172,13 +172,22 @@ QVector<QgsDataItem*> QgsDataItem::createChildren( )

void QgsDataItem::populate()
{
if ( mPopulated )
return;

QgsDebugMsg( "mPath = " + mPath );

QApplication::setOverrideCursor( Qt::WaitCursor );

QVector<QgsDataItem*> children = createChildren( );
foreach( QgsDataItem *child, children )
{
// initialization, do not refresh! That would result in infinite loop (beginInsertItems->rowCount->populate)
addChildItem( child );
}
mPopulated = true;

QApplication::restoreOverrideCursor();
}

int QgsDataItem::rowCount()
@@ -246,6 +255,8 @@ void QgsDataItem::refresh()
{
QgsDebugMsg( "mPath = " + mPath );

QApplication::setOverrideCursor( Qt::WaitCursor );

QVector<QgsDataItem*> items = createChildren( );

// Remove no more present items
@@ -272,6 +283,8 @@ void QgsDataItem::refresh()
}
addChildItem( item, true );
}

QApplication::restoreOverrideCursor();
}

bool QgsDataItem::equal( const QgsDataItem *other )

0 comments on commit ec005b2

Please sign in to comment.