Skip to content
Permalink
Browse files

Add error item to facilitate error handling

  • Loading branch information
wonder-sk committed Oct 14, 2011
1 parent befb5f6 commit fb6d5512a48dc31c84bab095ad57b065d9c4bc70
@@ -565,3 +565,16 @@ void QgsDirectoryParamWidget::showHideColumn()
}
settings.setValue( "/dataitem/directoryHiddenColumns", lst );
}


QgsErrorItem::QgsErrorItem( QgsDataItem* parent, QString error, QString path )
: QgsDataItem( QgsDataItem::Error, parent, error, path )
{
mIcon = QIcon( getThemePixmap( "/mIconDelete.png" ) );

mPopulated = true; // no more children
}

QgsErrorItem::~QgsErrorItem()
{
}
@@ -46,6 +46,7 @@ class CORE_EXPORT QgsDataItem : public QObject
Collection,
Directory,
Layer,
Error,
};

QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, QString name, QString path );
@@ -225,6 +226,24 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
static QVector<QLibrary*> mLibraries;
};

/**
Data item that can be used to report problems (e.g. network error)
*/
class CORE_EXPORT QgsErrorItem : public QgsDataItem
{
Q_OBJECT
public:

QgsErrorItem( QgsDataItem* parent, QString error, QString path );
~QgsErrorItem();

//QVector<QgsDataItem*> createChildren();
//virtual bool equal( const QgsDataItem *other );
};


// ---------

class QgsDirectoryParamWidget : public QTreeWidget
{
Q_OBJECT
@@ -29,7 +29,10 @@ QVector<QgsDataItem*> QgsPGConnectionItem::createChildren()
QgsDebugMsg( "mConnInfo = " + mConnInfo );

if ( !pgProvider->supportedLayers( mLayerProperties, true, false, false ) )
{
children.append( new QgsErrorItem( this, tr( "Failed to retrieve layers" ), mPath + "/error" ) );
return children;
}

QMap<QString, QVector<QgsPostgresLayerProperty> > schemasMap;
foreach( QgsPostgresLayerProperty layerProperty, mLayerProperties )
@@ -57,7 +57,7 @@ QVector<QgsDataItem*> QgsWFSConnectionItem::createChildren()
}
else
{
// TODO: return an "error" item
layers.append( new QgsErrorItem( this, tr( "Failed to retrieve layers" ), mPath + "/error" ) );
}

mConn->deleteLater();
@@ -31,7 +31,10 @@ QVector<QgsDataItem*> QgsWMSConnectionItem::createChildren()

// Attention: supportedLayers() gives tree leafes, not top level
if ( !wmsProvider->supportedLayers( mLayerProperties ) )
{
children.append( new QgsErrorItem( this, tr( "Failed to retrieve layers" ), mPath + "/error" ) );
return children;
}

QgsWmsCapabilitiesProperty mCapabilitiesProperty = wmsProvider->capabilitiesProperty();
QgsWmsCapabilityProperty capabilityProperty = mCapabilitiesProperty.capability;

0 comments on commit fb6d551

Please sign in to comment.
You can’t perform that action at this time.