Skip to content

Commit

Permalink
[oracle] Fix missing items in oracle connections in browser
Browse files Browse the repository at this point in the history
On behalf of Faunalia, sponsored by ENEL
  • Loading branch information
nyalldawson committed Jul 6, 2016
1 parent a31a1d3 commit f1a15e3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/core/qgsdataitem.cpp
Expand Up @@ -668,6 +668,8 @@ void QgsDataItem::setState( State state )
mPopulated = state == Populated;

emit stateChanged( this, oldState );
if ( state == Populated )
emitDataChanged();
}

// ---------------------------------------------------------------------
Expand Down
31 changes: 24 additions & 7 deletions src/providers/oracle/qgsoracledataitems.cpp
Expand Up @@ -30,7 +30,7 @@ QGISEXTERN bool deleteLayer( const QString& uri, QString& errCause );
// ---------------------------------------------------------------------------
QgsOracleConnectionItem::QgsOracleConnectionItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
, mColumnTypeThread( 0 )
, mColumnTypeThread( nullptr )
{
mIconName = "mIconConnect.png";
}
Expand All @@ -47,14 +47,12 @@ void QgsOracleConnectionItem::stop()
mColumnTypeThread->stop();
mColumnTypeThread->wait();
delete mColumnTypeThread;
mColumnTypeThread = 0;
mColumnTypeThread = nullptr;
}
}

void QgsOracleConnectionItem::refresh()
{
QApplication::setOverrideCursor( Qt::WaitCursor );

stop();

Q_FOREACH ( QgsDataItem *child, mChildren )
Expand All @@ -66,17 +64,28 @@ void QgsOracleConnectionItem::refresh()
{
addChildItem( item, true );
}
}

QApplication::restoreOverrideCursor();
void QgsOracleConnectionItem::setAllAsPopulated()
{
Q_FOREACH ( QgsDataItem *child, mChildren )
{
child->setState( Populated );
}
setState( Populated );
}

QVector<QgsDataItem*> QgsOracleConnectionItem::createChildren()
{
setState( Populating );

mOwnerMap.clear();

stop();

if ( deferredDelete() )
return QVector<QgsDataItem*>();

if ( !mColumnTypeThread )
{
mColumnTypeThread = new QgsOracleColumnTypeThread( mName,
Expand All @@ -98,21 +107,26 @@ QVector<QgsDataItem*> QgsOracleConnectionItem::createChildren()
}

if ( mColumnTypeThread )
{
mColumnTypeThread->start();
}
else
{
setAllAsPopulated();
}

return QVector<QgsDataItem*>();
}

void QgsOracleConnectionItem::threadStarted()
{
QgsDebugMsgLevel( "Entering.", 3 );
qApp->setOverrideCursor( Qt::BusyCursor );
}

void QgsOracleConnectionItem::threadFinished()
{
QgsDebugMsgLevel( "Entering.", 3 );
qApp->restoreOverrideCursor();
setAllAsPopulated();
}

void QgsOracleConnectionItem::setLayerType( QgsOracleLayerProperty layerProperty )
Expand All @@ -132,6 +146,7 @@ void QgsOracleConnectionItem::setLayerType( QgsOracleLayerProperty layerProperty
if ( !ownerItem )
{
ownerItem = new QgsOracleOwnerItem( this, layerProperty.ownerName, mPath + "/" + layerProperty.ownerName );
ownerItem->setState( Populating );
QgsDebugMsgLevel( "add owner item: " + layerProperty.ownerName, 3 );
addChildItem( ownerItem, true );
mOwnerMap[ layerProperty.ownerName ] = ownerItem;
Expand Down Expand Up @@ -370,6 +385,8 @@ QgsOracleOwnerItem::QgsOracleOwnerItem( QgsDataItem* parent, QString name, QStri
: QgsDataCollectionItem( parent, name, path )
{
mIconName = "mIconDbOwner.png";
//not fertile, since children are created by QgsOracleConnectionItem
mCapabilities &= ~( Fertile );
}

QVector<QgsDataItem*> QgsOracleOwnerItem::createChildren()
Expand Down
1 change: 1 addition & 0 deletions src/providers/oracle/qgsoracledataitems.h
Expand Up @@ -85,6 +85,7 @@ class QgsOracleConnectionItem : public QgsDataCollectionItem
void stop();
QMap<QString, QgsOracleOwnerItem * > mOwnerMap;
QgsOracleColumnTypeThread *mColumnTypeThread;
void setAllAsPopulated();
};

class QgsOracleOwnerItem : public QgsDataCollectionItem
Expand Down

0 comments on commit f1a15e3

Please sign in to comment.