25 changes: 25 additions & 0 deletions src/app/ogr/qgsogrhelperfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,31 @@ QString createDatabaseURI( QString connectionType, QString host, QString databas
uri += QString( ",password=%1" ).arg( password );
}
}
else if ( connectionType == "MSSQL" )
{
uri = "MSSQL:";

if ( !host.isEmpty() )
{
uri += QString( ";server=%1" ).arg( host );

if ( !port.isEmpty() )
uri += QString( ",%1" ).arg( port );
}

if ( !user.isEmpty() )
{
uri += QString( ";uid=%1" ).arg( user );

if ( !password.isEmpty() )
uri += QString( ";pwd=%1" ).arg( password );
}
else
uri += ";trusted_connection=yes";

if ( !database.isEmpty() )
uri += QString( ";database=%1" ).arg( database );
}
else if ( connectionType == "Oracle Spatial" )
{
uri = "OCI:" + user;
Expand Down
5 changes: 4 additions & 1 deletion src/app/ogr/qgsopenvectorlayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ void QgsOpenVectorLayerDialog::accept()
bool makeConnection = false;
if ( pass.isEmpty() )
{
pass = QInputDialog::getText( this,
if ( cmbDatabaseTypes->currentText() == "MSSQL" )
makeConnection = true;
else
pass = QInputDialog::getText( this,
tr( "Password for " ) + user,
tr( "Please enter your password:" ),
QLineEdit::Password, QString::null,
Expand Down
32 changes: 27 additions & 5 deletions src/app/ogr/qgsvectorlayersaveasdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
#include "qgsgenericprojectionselector.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorfilewriter.h"
#include "qgscoordinatereferencesystem.h"

#include <QSettings>
#include <QFileDialog>
#include <QTextCodec>

QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QWidget* parent, Qt::WFlags fl )
QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
, mCRS( -1 )
, mCRS( srsid )
{
setupUi( this );

Expand All @@ -53,9 +54,13 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QWidget* parent, Qt::WFl
idx = 0;
}

mEncodingComboBox->setCurrentIndex( idx );
mCRSSelection->clear();
mCRSSelection->addItems( QStringList() << tr( "Layer CRS" ) << tr( "Project CRS" ) << tr( "Selected CRS" ) );

QgsCoordinateReferenceSystem srs( srsid, QgsCoordinateReferenceSystem::InternalCrsId );
leCRS->setText( srs.description() );

leCRS->setText( tr( "Original CRS" ) );
mEncodingComboBox->setCurrentIndex( idx );
on_mFormatComboBox_currentIndexChanged( mFormatComboBox->currentIndex() );
}

Expand All @@ -72,6 +77,11 @@ void QgsVectorLayerSaveAsDialog::accept()
QDialog::accept();
}

void QgsVectorLayerSaveAsDialog::on_mCRSSelection_currentIndexChanged( int idx )
{
leCRS->setEnabled( idx == 2 );
}

void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx )
{
browseFilename->setEnabled( true );
Expand Down Expand Up @@ -120,6 +130,7 @@ void QgsVectorLayerSaveAsDialog::on_browseCRS_clicked()
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
mCRS = srs.srsid();
leCRS->setText( srs.description() );
mCRSSelection->setCurrentIndex( 2 );
}

delete mySelector;
Expand All @@ -142,7 +153,18 @@ QString QgsVectorLayerSaveAsDialog::format() const

long QgsVectorLayerSaveAsDialog::crs() const
{
return mCRS;
if ( mCRSSelection->currentIndex() == 0 )
{
return -1; // Layer CRS
}
else if ( mCRSSelection->currentIndex() == 1 )
{
return -2; // Project CRS
}
else
{
return mCRS;
}
}

QStringList QgsVectorLayerSaveAsDialog::datasourceOptions() const
Expand Down
3 changes: 2 additions & 1 deletion src/app/ogr/qgsvectorlayersaveasdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav
Q_OBJECT

public:
QgsVectorLayerSaveAsDialog( QWidget* parent = 0, Qt::WFlags fl = 0 );
QgsVectorLayerSaveAsDialog( long srsid, QWidget* parent = 0, Qt::WFlags fl = 0 );
~QgsVectorLayerSaveAsDialog();

QString format() const;
Expand All @@ -44,6 +44,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav

private slots:
void on_mFormatComboBox_currentIndexChanged( int idx );
void on_mCRSSelection_currentIndexChanged( int idx );
void on_browseFilename_clicked();
void on_browseCRS_clicked();
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
Expand Down
23 changes: 10 additions & 13 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3284,29 +3284,26 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection )

QgsCoordinateReferenceSystem destCRS;

QgsVectorLayerSaveAsDialog *dialog = new QgsVectorLayerSaveAsDialog( this );
QgsVectorLayerSaveAsDialog *dialog = new QgsVectorLayerSaveAsDialog( vlayer->crs().srsid(), this );

if ( dialog->exec() == QDialog::Accepted )
{
QString encoding = dialog->encoding();
QString vectorFilename = dialog->filename();
QString format = dialog->format();

if ( dialog->crs() < 0 )
switch ( dialog->crs() )
{
// Find out if we have projections enabled or not
if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
case -2: // Project CRS
destCRS = mMapCanvas->mapRenderer()->destinationCrs();
}
else
{
break;
case -1: // Layer CRS
destCRS = vlayer->crs();
}
}
else
{
destCRS = QgsCoordinateReferenceSystem( dialog->crs(), QgsCoordinateReferenceSystem::InternalCrsId );
break;

default: // Selected CRS
destCRS = QgsCoordinateReferenceSystem( dialog->crs(), QgsCoordinateReferenceSystem::InternalCrsId );
break;
}

// ok if the file existed it should be deleted now so we can continue...
Expand Down
6 changes: 6 additions & 0 deletions src/app/qgshighlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "qgsgeometry.h"
#include "qgsmapcanvas.h"
#include "qgsmaprenderer.h"
#include "qgscoordinatetransform.h"
#include "qgsvectorlayer.h"
#include <QPainter>

Expand All @@ -31,6 +32,11 @@ QgsHighlight::QgsHighlight( QgsMapCanvas* mapCanvas, QgsGeometry *geom, QgsVecto
, mLayer( layer )
{
mGeometry = geom ? new QgsGeometry( *geom ) : 0;
if ( mapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
QgsCoordinateTransform transform( mLayer->crs(), mapCanvas->mapRenderer()->destinationCrs() );
mGeometry->transform( transform );
}
updateRect();
update();
setColor( QColor( Qt::lightGray ) );
Expand Down
6 changes: 4 additions & 2 deletions src/app/qgsmaptooladdfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,16 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
{
//not a polygon type. Impossible to get there
}
/*else if ( avoidIntersectionsReturn == 2 ) //MH120131: disable this error message until there is a better way to cope with the single type / multi type problem
#if 0
else if ( avoidIntersectionsReturn == 2 ) //MH120131: disable this error message until there is a better way to cope with the single type / multi type problem
{
//bail out...
QMessageBox::critical( 0, tr( "Error" ), tr( "The feature could not be added because removing the polygon intersections would change the geometry type" ) );
delete f;
stopCapturing();
return;
}*/
}
#endif
else if ( avoidIntersectionsReturn == 3 )
{
QMessageBox::critical( 0, tr( "Error" ), tr( "An error was reported during intersection removal" ) );
Expand Down
14 changes: 13 additions & 1 deletion src/app/qgsmergeattributesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgsattributeeditor.h"

#include <limits>
#include <QComboBox>
#include <QSettings>

QgsMergeAttributesDialog::QgsMergeAttributesDialog( const QgsFeatureList &features, QgsVectorLayer *vl, QgsMapCanvas *canvas, QWidget *parent, Qt::WindowFlags f )
: QDialog( parent, f )
Expand All @@ -46,15 +48,25 @@ QgsMergeAttributesDialog::QgsMergeAttributesDialog( const QgsFeatureList &featur

mFromSelectedPushButton->setIcon( QgisApp::getThemeIcon( "mActionFromSelectedFeature.png" ) );
mRemoveFeatureFromSelectionButton->setIcon( QgisApp::getThemeIcon( "mActionRemoveSelectedFeature.png" ) );

QSettings settings;
restoreGeometry( settings.value( "/Windows/MergeAttributes/geometry" ).toByteArray() );
}

QgsMergeAttributesDialog::QgsMergeAttributesDialog(): QDialog()
QgsMergeAttributesDialog::QgsMergeAttributesDialog()
: QDialog()
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/MergeAttributes/geometry" ).toByteArray() );
}

QgsMergeAttributesDialog::~QgsMergeAttributesDialog()
{
QSettings settings;
settings.setValue( "/Windows/MergeAttributes/geometry", saveGeometry() );

delete mSelectionRubberBand;
}

Expand Down
43 changes: 14 additions & 29 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3324,6 +3324,9 @@ bool QgsVectorLayer::addAttribute( const QgsField &field )
if ( !isEditable() )
return false;

if ( field.name().isEmpty() )
return false;

for ( QgsFieldMap::const_iterator it = mUpdatedFields.begin(); it != mUpdatedFields.end(); it++ )
{
if ( it.value().name() == field.name() )
Expand Down Expand Up @@ -3769,41 +3772,22 @@ bool QgsVectorLayer::rollBack()

if ( isModified() )
{
while ( mAddedAttributeIds.size() > 0 )
{
int idx = *mAddedAttributeIds.begin();
mAddedAttributeIds.remove( idx );
mUpdatedFields.remove( idx );
emit attributeDeleted( idx );
}

while ( mDeletedAttributeIds.size() > 0 )
while ( undoStack()->canUndo() )
{
int idx = *mDeletedAttributeIds.begin();
mDeletedAttributeIds.remove( idx );
emit attributeAdded( idx );
undoStack()->undo();
}

// roll back changed attribute values
mChangedAttributeValues.clear();

// roll back changed geometries
mChangedGeometries.clear();

// Roll back added features
// Delete the features themselves before deleting the references to them.
mAddedFeatures.clear();

// Roll back deleted features
mDeletedFeatureIds.clear();
Q_ASSERT( mAddedAttributeIds.isEmpty() );
Q_ASSERT( mDeletedAttributeIds.isEmpty() );
Q_ASSERT( mChangedAttributeValues.isEmpty() );
Q_ASSERT( mChangedGeometries.isEmpty() );
Q_ASSERT( mAddedFeatures.isEmpty() );

updateFieldMap();
}

deleteCachedGeometries();

undoStack()->clear();

mEditable = false;
emit editingStopped();

Expand Down Expand Up @@ -4738,13 +4722,12 @@ void QgsVectorLayer::redoEditCommand( QgsUndoCommand* cmd )
if ( attrChIt.value().target.isNull() )
{
mChangedAttributeValues[fid].remove( attrChIt.key() );
if ( mChangedAttributeValues[fid].isEmpty() )
mChangedAttributeValues.remove( fid );
}
else
{
mChangedAttributeValues[fid][attrChIt.key()] = attrChIt.value().target;
QgsFeature f;
featureAtId( fid, f, false, true );
f.changeAttribute( attrChIt.key(), attrChIt.value().target );
}
}
else
Expand Down Expand Up @@ -4868,6 +4851,8 @@ void QgsVectorLayer::undoEditCommand( QgsUndoCommand* cmd )
if ( attrChIt.value().isFirstChange )
{
mChangedAttributeValues[fid].remove( attrChIt.key() );
if ( mChangedAttributeValues[fid].isEmpty() )
mChangedAttributeValues.remove( fid );
}
else
{
Expand Down
11 changes: 8 additions & 3 deletions src/helpviewer/qgshelpviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ void QgsHelpViewer::loadContext( const QString &contextId )
// get the help content and title from the localized file
QString helpContents;
QFile file( fullHelpPath );

QString missingError = tr("<h3>Opps! QGIS can't find help for this form.</h3>"
"The help file for %1 was not found for your language<br>"
"If you would like to create it, contact the QGIS development team"
).arg( contextId );

// check to see if the localized version exists
if ( !file.exists() )
{
Expand All @@ -136,13 +142,12 @@ void QgsHelpViewer::loadContext( const QString &contextId )
// translate this for us message
if ( !lang.contains( "en_" ) )
{
helpContents = "<i>" + tr( "This help file is not available in your language %1. If you would like to translate it, please contact the QGIS development team." ).arg( lang ) + "</i><hr />";
helpContents = missingError;
}
}
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
helpContents = tr( "This help file does not exist for your language:<p><b>%1</b><p>If you would like to create it, contact the QGIS development team" )
.arg( fullHelpPath );
helpContents = missingError;
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions src/helpviewer/qgshelpviewerbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWebView" name="webView">
<property name="url">
Expand Down
4 changes: 4 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,10 @@ QString createFilters( QString type )
{
myDatabaseDrivers += QObject::tr( "MySQL" ) + ",MySQL;";
}
else if ( driverName.startsWith( "MSSQL" ) )
{
myDatabaseDrivers += QObject::tr( "MSSQL" ) + ",MSSQL;";
}
else if ( driverName.startsWith( "OCI" ) )
{
myDatabaseDrivers += QObject::tr( "Oracle Spatial" ) + ",OCI;";
Expand Down
Loading