Skip to content

Commit

Permalink
Merge branch 'master' of github.com:qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Apr 14, 2012
2 parents aab9976 + 847650e commit 7e318c5
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 44 deletions.
4 changes: 2 additions & 2 deletions python/core/qgis.sip
Expand Up @@ -103,12 +103,12 @@ public:
/** Wkt string that represents a geographic coord sys
* @note added in 1.8 to replace GEOWkt
*/
const QString GEOWKT;
const QString GEOWKT;
/** Wkt string that represents a geographic coord sys
* @note deprecated in 1.8 due to violation of coding conventions (globals
* should be in all caps).
*/
const QString GEOWkt /Deprecated/;
const QString GEOWkt /Deprecated/;

/** PROJ4 string that represents a geographic coord sys */
const QString GEOPROJ4;
Expand Down
6 changes: 4 additions & 2 deletions python/core/qgsvectorfilewriter.sip
Expand Up @@ -52,7 +52,8 @@ public:
QString *errorMessage = 0,
const QStringList &datasourceOptions = QStringList(),
const QStringList &layerOptions = QStringList(),
bool skipAttributeCreation = FALSE // added in 1.7
bool skipAttributeCreation = FALSE, // added in 1.7
QString *newFilename = 0
);

/** create shapefile and initialize it */
Expand All @@ -63,7 +64,8 @@ public:
const QgsCoordinateReferenceSystem* srs,
const QString& driverName = "ESRI Shapefile",
const QStringList &datasourceOptions = QStringList(),
const QStringList &layerOptions = QStringList() );
const QStringList &layerOptions = QStringList(),
QString *newFilename = 0 );

/**Returns map with format filter string as key and OGR format key as value*/
static QMap< QString, QString> supportedFiltersAndFormats();
Expand Down
3 changes: 3 additions & 0 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -937,7 +937,10 @@ void QgsLegend::addLayers( QList<QgsMapLayer *> theLayerList )
{
QgsMapLayer * myFirstLayer = theLayerList.at( 0 );
if ( !mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
mMapCanvas->mapRenderer()->setDestinationCrs( myFirstLayer->crs() );
mMapCanvas->mapRenderer()->setMapUnits( myFirstLayer->crs().mapUnits() );
}
mMapCanvas->zoomToFullExtent();
mMapCanvas->clearExtentHistory();
}
Expand Down
20 changes: 11 additions & 9 deletions src/app/qgisapp.cpp
Expand Up @@ -648,7 +648,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
#else
//remove mActionTouch button
delete mActionTouch;
mActionTouch=0;
mActionTouch = 0;
#endif

// update windows
Expand Down Expand Up @@ -765,7 +765,7 @@ bool QgisApp::event( QEvent * event )
done = true;
}
#ifdef HAVE_TOUCH
else if (event->type() == QEvent::Gesture )
else if ( event->type() == QEvent::Gesture )
{
done = gestureEvent( static_cast<QGestureEvent*>( event ) );
}
Expand Down Expand Up @@ -3631,20 +3631,22 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection )

QgsVectorFileWriter::WriterError error;
QString errorMessage;
QString newFilename;
error = QgsVectorFileWriter::writeAsVectorFormat(
vlayer, vectorFilename, encoding, &destCRS, format,
saveOnlySelection,
&errorMessage,
datasourceOptions, dialog->layerOptions(),
dialog->skipAttributeCreation() );
dialog->skipAttributeCreation(),
&newFilename );

QApplication::restoreOverrideCursor();

if ( error == QgsVectorFileWriter::NoError )
{
if ( dialog->addToCanvas() )
{
addVectorLayers( QStringList( vectorFilename ), encoding, "file" );
addVectorLayers( QStringList( newFilename ), encoding, "file" );
}
QMessageBox::information( 0, tr( "Saving done" ), tr( "Export to vector file has been completed" ) );
}
Expand Down Expand Up @@ -4700,10 +4702,10 @@ void QgisApp::isInOverview()

void QgisApp::removingLayers( QStringList theLayers )
{
foreach (const QString &layerId, theLayers)
foreach( const QString &layerId, theLayers )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer*>(
QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
if ( !vlayer || !vlayer->isEditable() )
return;

Expand Down Expand Up @@ -6027,9 +6029,9 @@ void QgisApp::markDirty()
//changed from layerWasAdded to layersWereAdded in 1.8
void QgisApp::layersWereAdded( QList<QgsMapLayer *> theLayers )
{
for (int i = 0; i < theLayers.size(); ++i)
for ( int i = 0; i < theLayers.size(); ++i )
{
QgsMapLayer * layer = theLayers.at(i);
QgsMapLayer * layer = theLayers.at( i );
QgsDataProvider *provider = 0;

QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
Expand Down Expand Up @@ -7448,7 +7450,7 @@ QMenu* QgisApp::createPopupMenu()
}

#ifdef HAVE_TOUCH
bool QgisApp::gestureEvent(QGestureEvent *event)
bool QgisApp::gestureEvent( QGestureEvent *event )
{
if ( QGesture *tapAndHold = event->gesture( Qt::TapAndHoldGesture ) )
{
Expand Down
9 changes: 9 additions & 0 deletions src/app/qgsbrowserdockwidget.cpp
Expand Up @@ -135,6 +135,15 @@ void QgsBrowserDockWidget::showEvent( QShowEvent * e )
mBrowserView->setTextElideMode( Qt::ElideNone );
mBrowserView->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
mBrowserView->header()->setStretchLastSection( false );

// find root favourites item
for ( int i = 0; i < mModel->rowCount(); i++ )
{
QModelIndex index = mModel->index( i, 0 );
QgsDataItem* item = mModel->dataItem( index );
if ( item && item->type() == QgsDataItem::Favourites )
mBrowserView->expand( index );
}
}

QDockWidget::showEvent( e );
Expand Down
29 changes: 5 additions & 24 deletions src/core/qgsbrowsermodel.cpp
Expand Up @@ -35,33 +35,14 @@ void QgsBrowserModel::addRootItems()
mRootItems << item;

// add favourite directories
QSettings settings;
QStringList favDirs = settings.value( "/browser/favourites", QVariant() ).toStringList();
// if there are 5 or more items, create a "Favourites" Root item
// perhaps this should be the default?
if ( favDirs.count() >= 5 )
QgsFavouritesItem *favitem = new QgsFavouritesItem( NULL, tr( "Favourites" ) );
if ( favitem )
{
QgsFavouritesItem *item = new QgsFavouritesItem( NULL, tr( "Favourites" ), "" );
if ( item )
{
connectItem( item );
mRootItems << item;
}
}
else
{
foreach( QString favDir, favDirs )
{
item = new QgsDirectoryItem( NULL, favDir, favDir );
if ( item )
{
item->setIcon( QgsFavouritesItem::iconFavourites() );
mRootItems << item;
connectItem( item );
}
}
connectItem( favitem );
mRootItems << favitem;
}

// add drives
foreach( QFileInfo drive, QDir::drives() )
{
QString path = drive.absolutePath();
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsdataitem.cpp
Expand Up @@ -642,7 +642,7 @@ QgsErrorItem::~QgsErrorItem()
QgsFavouritesItem::QgsFavouritesItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
mType = Collection; //favourites?
mType = Favourites;
mIcon = iconFavourites();
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsdataitem.h
Expand Up @@ -48,6 +48,7 @@ class CORE_EXPORT QgsDataItem : public QObject
Directory,
Layer,
Error,
Favourites
};

QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, QString name, QString path );
Expand Down Expand Up @@ -277,7 +278,7 @@ class CORE_EXPORT QgsFavouritesItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsFavouritesItem( QgsDataItem* parent, QString name, QString path );
QgsFavouritesItem( QgsDataItem* parent, QString name, QString path = QString() );
~QgsFavouritesItem();

QVector<QgsDataItem*> createChildren();
Expand Down
11 changes: 8 additions & 3 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -59,7 +59,8 @@ QgsVectorFileWriter::QgsVectorFileWriter(
const QgsCoordinateReferenceSystem* srs,
const QString& driverName,
const QStringList &datasourceOptions,
const QStringList &layerOptions
const QStringList &layerOptions,
QString *newFilename
)
: mDS( NULL )
, mLayer( NULL )
Expand Down Expand Up @@ -387,6 +388,9 @@ QgsVectorFileWriter::QgsVectorFileWriter(
// create geometry which will be used for import
mGeom = createEmptyGeometry( mWkbType );
}

if ( newFilename )
*newFilename = vectorFileName;
}

OGRGeometryH QgsVectorFileWriter::createEmptyGeometry( QGis::WkbType wkbType )
Expand Down Expand Up @@ -584,7 +588,8 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
QString *errorMessage,
const QStringList &datasourceOptions,
const QStringList &layerOptions,
bool skipAttributeCreation )
bool skipAttributeCreation,
QString *newFilename )
{
const QgsCoordinateReferenceSystem* outputCRS;
QgsCoordinateTransform* ct = 0;
Expand All @@ -607,7 +612,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
outputCRS = &layer->crs();
}
QgsVectorFileWriter* writer =
new QgsVectorFileWriter( fileName, fileEncoding, skipAttributeCreation ? QgsFieldMap() : layer->pendingFields(), layer->wkbType(), outputCRS, driverName, datasourceOptions, layerOptions );
new QgsVectorFileWriter( fileName, fileEncoding, skipAttributeCreation ? QgsFieldMap() : layer->pendingFields(), layer->wkbType(), outputCRS, driverName, datasourceOptions, layerOptions, newFilename );

// check whether file creation was successful
WriterError err = writer->hasError();
Expand Down
6 changes: 4 additions & 2 deletions src/core/qgsvectorfilewriter.h
Expand Up @@ -79,7 +79,8 @@ class CORE_EXPORT QgsVectorFileWriter
QString *errorMessage = 0,
const QStringList &datasourceOptions = QStringList(), // added in 1.6
const QStringList &layerOptions = QStringList(), // added in 1.6
bool skipAttributeCreation = false // added in 1.6
bool skipAttributeCreation = false, // added in 1.6
QString *newFilename = 0 // added in 1.9
);

/** create shapefile and initialize it */
Expand All @@ -90,7 +91,8 @@ class CORE_EXPORT QgsVectorFileWriter
const QgsCoordinateReferenceSystem* srs,
const QString& driverName = "ESRI Shapefile",
const QStringList &datasourceOptions = QStringList(), // added in 1.6
const QStringList &layerOptions = QStringList() // added in 1.6
const QStringList &layerOptions = QStringList(), // added in 1.6
QString *newFilename = 0 // added in 1.9
);

/**Returns map with format filter string as key and OGR format key as value*/
Expand Down

0 comments on commit 7e318c5

Please sign in to comment.