Showing with 49 additions and 36 deletions.
  1. +20 −19 src/app/qgsbrowserdockwidget.cpp
  2. +5 −2 src/browser/qgsbrowserbase.ui
  3. +17 −15 src/providers/gdal/qgsgdalprovider.cpp
  4. +7 −0 src/providers/ogr/qgsogrprovider.cpp
39 changes: 20 additions & 19 deletions src/app/qgsbrowserdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,27 @@ items on the tree view although the drop is actually managed by qgis app.
*/
class QgsBrowserTreeView : public QTreeView
{
public:
QgsBrowserTreeView( QWidget* parent ) : QTreeView(parent)
{
setDragDropMode( QTreeView::DragDrop ); // sets also acceptDrops + dragEnabled
setSelectionMode( QAbstractItemView::ExtendedSelection );
setContextMenuPolicy( Qt::CustomContextMenu );
}
public:
QgsBrowserTreeView( QWidget* parent ) : QTreeView( parent )
{
setDragDropMode( QTreeView::DragDrop ); // sets also acceptDrops + dragEnabled
setSelectionMode( QAbstractItemView::ExtendedSelection );
setContextMenuPolicy( Qt::CustomContextMenu );
setHeaderHidden( true );
}

void dragEnterEvent(QDragEnterEvent* e)
{
// accept drag enter so that our widget will not get ignored
// and drag events will not get passed to QgisApp
e->accept();
}
void dragMoveEvent(QDragMoveEvent* e)
{
// ignore all possibilities where an item could be dropped
// because we want that user drops the item on canvas / legend / app
e->ignore();
}
void dragEnterEvent( QDragEnterEvent* e )
{
// accept drag enter so that our widget will not get ignored
// and drag events will not get passed to QgisApp
e->accept();
}
void dragMoveEvent( QDragMoveEvent* e )
{
// ignore all possibilities where an item could be dropped
// because we want that user drops the item on canvas / legend / app
e->ignore();
}
};

QgsBrowserDockWidget::QgsBrowserDockWidget( QWidget * parent ) :
Expand Down
7 changes: 5 additions & 2 deletions src/browser/qgsbrowserbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>714</width>
<height>471</height>
<width>712</width>
<height>469</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -51,6 +51,9 @@
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
Expand Down
32 changes: 17 additions & 15 deletions src/providers/gdal/qgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,12 @@ void QgsGdalProvider::computeMinMax( int theBandNo )
return;
}
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
int bApproxOK=false;
int bApproxOK = false;
int bGotMin, bGotMax;
double adfMinMax[2];
adfMinMax[0] = GDALGetRasterMinimum( myGdalBand, &bGotMin );
adfMinMax[1] = GDALGetRasterMaximum( myGdalBand, &bGotMax );
if( ! ( bGotMin && bGotMax ) )
if ( !( bGotMin && bGotMax ) )
{
GDALComputeRasterMinMax( myGdalBand, TRUE, adfMinMax );
}
Expand Down Expand Up @@ -1838,7 +1838,7 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int theBandNo )
{
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
QgsRasterBandStats myRasterBandStats;
int bApproxOK=false;
int bApproxOK = false;
double pdfMin;
double pdfMax;
double pdfMean;
Expand All @@ -1847,26 +1847,26 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int theBandNo )
myProg.type = ProgressHistogram;
myProg.provider = this;

// double myerval =
// GDALComputeRasterStatistics (
// myGdalBand, bApproxOK, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev,
// progressCallback, &myProg ) ;
// double myerval =
// double myerval =
// GDALComputeRasterStatistics (
// myGdalBand, bApproxOK, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev,
// progressCallback, &myProg ) ;
// double myerval =
// GDALGetRasterStatistics ( myGdalBand, bApproxOK, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev);
// double myerval =
// double myerval =
// GDALGetRasterStatisticsProgress ( myGdalBand, bApproxOK, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev,
// progressCallback, &myProg );
// progressCallback, &myProg );

// try to fetch the cached stats (bForce=FALSE)
CPLErr myerval =
GDALGetRasterStatistics ( myGdalBand, bApproxOK, FALSE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev);
CPLErr myerval =
GDALGetRasterStatistics( myGdalBand, bApproxOK, FALSE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev );

// if cached stats are not found, compute them
if ( CE_Warning == myerval )
{
myerval = GDALComputeRasterStatistics ( myGdalBand, bApproxOK,
&pdfMin, &pdfMax, &pdfMean, &pdfStdDev,
progressCallback, &myProg ) ;
myerval = GDALComputeRasterStatistics( myGdalBand, bApproxOK,
&pdfMin, &pdfMax, &pdfMean, &pdfStdDev,
progressCallback, &myProg ) ;
}

// if stats are found populate the QgsRasterBandStats object
Expand Down Expand Up @@ -2010,6 +2010,8 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
if ( !hDS )
return 0;

GDALClose( hDS );

QgsDebugMsg( "GdalDataset opened " + thePath );

QString name = info.fileName();
Expand Down
7 changes: 7 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2288,7 +2288,10 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
int numLayers = OGR_DS_GetLayerCount( hDataSource );

if ( numLayers == 0 )
{
OGR_DS_Destroy( hDataSource );
return 0;
}

QgsDataCollectionItem * collection = 0;
if ( numLayers > 1 )
Expand Down Expand Up @@ -2352,10 +2355,14 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )

QgsOgrLayerItem * item = new QgsOgrLayerItem( collection ? collection : parentItem, name, path, layerUri, layerType );
if ( numLayers == 1 )
{
OGR_DS_Destroy( hDataSource );
return item;
}
collection->addChild( item );
}
collection->setPopulated();
OGR_DS_Destroy( hDataSource );
return collection;
}

Expand Down