Permalink
Browse files

OWS meta provider; represents all OWS services under single connectio…

…n in browser
  • Loading branch information...
1 parent ff8b451 commit b6193dbb07ada75a2f0fd840093fc742a3bd602c @blazek committed May 1, 2012
View
@@ -134,10 +134,16 @@ const QIcon &QgsFavouritesItem::iconFavourites()
}
QgsDataItem::QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, QString name, QString path )
- : QObject( parent ), mType( type ), mParent( parent ), mPopulated( false ), mName( name ), mPath( path )
+ // Do not pass parent to QObject, Qt would delete this when parent is deleted
+ : QObject(), mType( type ), mParent( parent ), mPopulated( false ), mName( name ), mPath( path )
{
}
+QgsDataItem::~QgsDataItem()
+{
+ QgsDebugMsg( "mName = " + mName + " mPath = " + mPath);
+}
+
// TODO: This is copy from QgisApp, bad
// TODO: add some caching mechanism ?
QPixmap QgsDataItem::getThemePixmap( const QString theName )
@@ -215,6 +221,7 @@ bool QgsDataItem::hasChildren()
void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
{
QgsDebugMsg( QString( "add child #%1 - %2" ).arg( mChildren.size() ).arg( child->mName ) );
+ QgsDebugMsg( QString("child = 0x%0").arg((qlonglong)child,8,16,QLatin1Char('0')) );
int i;
if ( type() == Directory )
@@ -264,6 +271,26 @@ void QgsDataItem::deleteChildItem( QgsDataItem * child )
emit endRemoveItems();
}
+QgsDataItem * QgsDataItem::removeChildItem( QgsDataItem * child )
+{
+ QgsDebugMsg( "mName = " + child->mName );
+ int i = mChildren.indexOf( child );
+ Q_ASSERT( i >= 0 );
+ emit beginRemoveItems( this, i, i );
+ mChildren.remove( i );
+ emit endRemoveItems();
+ disconnect( child, SIGNAL( beginInsertItems( QgsDataItem*, int, int ) ),
+ this, SLOT( emitBeginInsertItems( QgsDataItem*, int, int ) ) );
+ disconnect( child, SIGNAL( endInsertItems() ),
+ this, SLOT( emitEndInsertItems() ) );
+ disconnect( child, SIGNAL( beginRemoveItems( QgsDataItem*, int, int ) ),
+ this, SLOT( emitBeginRemoveItems( QgsDataItem*, int, int ) ) );
+ disconnect( child, SIGNAL( endRemoveItems() ),
+ this, SLOT( emitEndRemoveItems() ) );
+ child->setParent(0);
+ return child;
+}
+
int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )
{
for ( int i = 0; i < items.size(); i++ )
@@ -368,8 +395,12 @@ QgsDataCollectionItem::QgsDataCollectionItem( QgsDataItem* parent, QString name,
QgsDataCollectionItem::~QgsDataCollectionItem()
{
+ QgsDebugMsg( "Entered");
foreach( QgsDataItem* i, mChildren )
- delete i;
+ {
+ QgsDebugMsg( QString("delete child = 0x%0").arg((qlonglong)i,8,16,QLatin1Char('0')) );
+ delete i;
+ }
}
//-----------------------------------------------------------------------
View
@@ -52,7 +52,7 @@ class CORE_EXPORT QgsDataItem : public QObject
};
QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, QString name, QString path );
- virtual ~QgsDataItem() {}
+ virtual ~QgsDataItem();
bool hasChildren();
@@ -75,6 +75,10 @@ class CORE_EXPORT QgsDataItem : public QObject
// remove and delete child item, signals to browser are emited
virtual void deleteChildItem( QgsDataItem * child );
+ // remove child item but don't delete it, signals to browser are emited
+ // returns pointer to the removed item or null if no such item was found
+ virtual QgsDataItem * removeChildItem( QgsDataItem * child );
+
virtual bool equal( const QgsDataItem *other );
virtual QWidget * paramWidget() { return 0; }
@@ -113,6 +117,7 @@ class CORE_EXPORT QgsDataItem : public QObject
Type type() const { return mType; }
QgsDataItem* parent() const { return mParent; }
+ void setParent( QgsDataItem* parent ) { mParent = parent; }
QVector<QgsDataItem*> children() const { return mChildren; }
QIcon icon() const { return mIcon; }
QString name() const { return mName; }
@@ -10,6 +10,7 @@ ADD_SUBDIRECTORY(osm)
ADD_SUBDIRECTORY(sqlanywhere)
ADD_SUBDIRECTORY(gdal)
ADD_SUBDIRECTORY(mssql)
+ADD_SUBDIRECTORY(ows)
IF (POSTGRES_FOUND)
ADD_SUBDIRECTORY(postgres)
@@ -60,28 +60,31 @@ bool QgsGdalLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
QgsWCSConnectionItem::QgsWCSConnectionItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
- mIcon = QIcon( getThemePixmap( "mIconConnect.png" ) );
+ mIcon = QIcon( getThemePixmap( "mIconWcs.png" ) );
}
QgsWCSConnectionItem::~QgsWCSConnectionItem()
{
+ QgsDebugMsg( "Entered");
}
QVector<QgsDataItem*> QgsWCSConnectionItem::createChildren()
{
QgsDebugMsg( "Entered" );
QVector<QgsDataItem*> children;
- QgsOWSConnection connection( "WCS", mName );
+ QString encodedUri = mPath;
+ QgsDataSourceURI uri;
+ uri.setEncodedUri ( encodedUri );
+ QgsDebugMsg( "encodedUri = " + encodedUri );
- QgsDataSourceURI uri = connection.uri();
- QgsDebugMsg( "uri = " + uri.encodedUri() );
mCapabilities.setUri( uri );
// Attention: supportedLayers() gives tree leafes, not top level
if ( !mCapabilities.lastError().isEmpty() )
{
- children.append( new QgsErrorItem( this, tr( "Failed to retrieve layers" ), mPath + "/error" ) );
+ //children.append( new QgsErrorItem( this, tr( "Failed to retrieve layers" ), mPath + "/error" ) );
+ // TODO: show the error without adding child
return children;
}
@@ -105,9 +108,12 @@ bool QgsWCSConnectionItem::equal( const QgsDataItem *other )
return false;
}
const QgsWCSConnectionItem *o = dynamic_cast<const QgsWCSConnectionItem *>( other );
- //TODO
- //return ( mPath == o->mPath && mName == o->mName && mConnInfo == o->mConnInfo );
- return false;
+ if ( !o )
+ {
+ return false;
+ }
+
+ return ( mPath == o->mPath && mName == o->mName );
}
QList<QAction*> QgsWCSConnectionItem::actions()
@@ -166,7 +172,8 @@ QgsWCSLayerItem::QgsWCSLayerItem( QgsDataItem* parent, QString name, QString pat
if ( mChildren.size() == 0 )
{
- mIcon = iconRaster();
+ //mIcon = iconRaster();
+ mIcon = QIcon( getThemePixmap( "mIconWcs.png" ) );
}
mPopulated = true;
}
@@ -246,7 +253,11 @@ QVector<QgsDataItem*>QgsWCSRootItem::createChildren()
QVector<QgsDataItem*> connections;
foreach( QString connName, QgsOWSConnection::connectionList( "WCS" ) )
{
- QgsDataItem * conn = new QgsWCSConnectionItem( this, connName, mPath + "/" + connName );
+ //QgsDataItem * conn = new QgsWCSConnectionItem( this, connName, mPath + "/" + connName );
+ QgsOWSConnection connection( "WCS", connName );
+ QgsDataItem * conn = new QgsWCSConnectionItem( this, connName, connection.uri().encodedUri() );
+
+ conn->setIcon ( QIcon( getThemePixmap( "mIconConnect.png" ) ) );
connections.append( conn );
}
return connections;
@@ -294,17 +305,25 @@ static QStringList wildcards = QStringList();
QGISEXTERN int dataCapabilities()
{
- return QgsDataProvider::File | QgsDataProvider::Dir;
+ return QgsDataProvider::File | QgsDataProvider::Dir | QgsDataProvider::Net;
}
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
{
+ QgsDebugMsg( "thePath = " + thePath );
if ( thePath.isEmpty() )
{
// Top level WCS
return new QgsWCSRootItem( parentItem, "WCS", "wcs:" );
}
+ if ( thePath.contains ( "url=" ) )
+ {
+ // OWS server
+ QgsDebugMsg( "connection found in uri" );
+ return new QgsWCSConnectionItem( parentItem, "WCS", thePath );
+ }
+
QFileInfo info( thePath );
if ( info.isFile() )
{
@@ -30,8 +30,6 @@ class QgsWCSConnectionItem : public QgsDataCollectionItem
virtual QList<QAction*> actions();
QgsWcsCapabilities mCapabilities;
- //QgsDataSourceURI mUri;
- //QgsOWSConnection mConnection;
QVector<QgsWcsCoverageSummary> mLayerProperties;
public slots:
@@ -0,0 +1,26 @@
+SET(OWS_SRCS
+ qgsowsprovider.cpp
+ qgsowsdataitems.cpp
+)
+SET(OWS_MOC_HDRS
+ qgsowsprovider.h
+ qgsowsdataitems.h
+)
+
+INCLUDE_DIRECTORIES (
+ ../../core
+ ../../gui
+ ${CMAKE_CURRENT_BINARY_DIR}/../../ui
+)
+
+QT4_WRAP_CPP(OWS_MOC_SRCS ${OWS_MOC_HDRS})
+ADD_LIBRARY (owsprovider MODULE ${OWS_SRCS} ${OWS_MOC_SRCS})
+
+TARGET_LINK_LIBRARIES (owsprovider
+ qgis_core
+ qgis_gui
+)
+
+INSTALL(TARGETS owsprovider
+ RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
+ LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
Oops, something went wrong.

0 comments on commit b6193db

Please sign in to comment.