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 04dc5cc commit 91c86bd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/core/qgsdataitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ void QgsDataItem::setState( State state )
mPopulated = state == Populated;

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

// ---------------------------------------------------------------------
Expand Down
32 changes: 24 additions & 8 deletions src/providers/oracle/qgsoracledataitems.cpp
Original file line number Diff line number Diff line change
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,18 +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()
{
QgsDebugMsg( "Entered" );
setState( Populating );

mOwnerMap.clear();

stop();

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

if ( !mColumnTypeThread )
{
mColumnTypeThread = new QgsOracleColumnTypeThread( mName,
Expand All @@ -99,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 @@ -133,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 @@ -371,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
Original file line number Diff line number Diff line change
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 91c86bd

Please sign in to comment.