void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
{
  QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
  if ( !lvi || lvi->text( QgisCrsIdColumn ).isEmpty() )
    return;

  QgsCoordinateReferenceSystem currentCrs = crs();
  if ( !currentCrs.isValid() )
    return;

  QgsRectangle rect = currentCrs.bounds();
  if ( !qgsDoubleNear( rect.area(), 0.0 ) )
  {
    QgsGeometry geom;
    if ( rect.xMinimum() > rect.xMaximum() )
    {
      QgsRectangle rect1 = QgsRectangle( -180, rect.yMinimum(), rect.xMaximum(), rect.yMaximum() );
      QgsRectangle rect2 = QgsRectangle( rect.xMinimum(), rect.yMinimum(), 180, rect.yMaximum() );
      geom = QgsGeometry::fromRect( rect1 );
      geom.addPart( QgsGeometry::fromRect( rect2 ) );
    }
    else
    {
      geom = QgsGeometry::fromRect( rect );
    }
    mPreviewBand->setToGeometry( geom, nullptr );
    mPreviewBand->setColor( QColor( 255, 0, 0, 65 ) );
    QgsRectangle extent = geom.boundingBox();
    extent.scale( 1.1 );
    mAreaCanvas->setExtent( extent );
    mAreaCanvas->refresh();
    mPreviewBand->show();
    QString extentString = tr( "Extent: %1, %2, %3, %4" )
                           .arg( rect.xMinimum(), 0, 'f', 2 )
                           .arg( rect.yMinimum(), 0, 'f', 2 )
                           .arg( rect.xMaximum(), 0, 'f', 2 )
                           .arg( rect.yMaximum(), 0, 'f', 2 );
    QString proj4String = tr( "Proj4: %1" ).arg( selectedProj4String() );
    teProjection->setText( extentString + "\n" + proj4String );
  }
  else
  {
    mPreviewBand->hide();
    mAreaCanvas->zoomToFullExtent();
    QString extentString = tr( "Extent: Extent not known" );
    QString proj4String = tr( "Proj4: %1" ).arg( selectedProj4String() );
    teProjection->setText( extentString + "\n" + proj4String );
  }
}
// New coordinate system selected from the list
void QgsProjectionSelector::coordinateSystemSelected( QTreeWidgetItem * theItem )
{
    // If the item has children, it's not an end node in the tree, and
    // hence is just a grouping thingy, not an actual CRS.
    if ( theItem != NULL && theItem->childCount() == 0 )
    {
        // Found a real CRS
        QString myDescription;
        emit sridSelected( QString::number( selectedCrsId() ) );
        QString myProjString = selectedProj4String();
        lstCoordinateSystems->scrollToItem( theItem );
        teProjection->setText( myProjString );
    }
    else
    {
        // Not an CRS - remove the highlight so the user doesn't get too confused
        lstCoordinateSystems->setItemSelected( theItem, FALSE );  // TODO - make this work.
        teProjection->setText( "" );
    }
}