browser and dataitems - show wait cursor when loading

Signed-off-by: Tim Sutton <tim@linfiniti.com>
This commit is contained in:
Etienne Tourigny 2012-03-24 01:00:44 -03:00 committed by Tim Sutton
parent 58ebe865fb
commit ec005b29ce
3 changed files with 38 additions and 17 deletions

View File

@ -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 );

View File

@ -17,7 +17,7 @@ class QgsBrowserDockWidget : public QDockWidget
signals:
public slots:
void itemClicked( const QModelIndex& index );
void addLayerAtIndex( const QModelIndex& index );
void showContextMenu( const QPoint & );
void addFavourite();
@ -25,6 +25,7 @@ class QgsBrowserDockWidget : public QDockWidget
void refresh();
void addCurrentLayer();
void addSelectedLayers();
protected:

View File

@ -172,6 +172,13 @@ 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 )
{
@ -179,6 +186,8 @@ void QgsDataItem::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 )