137 changes: 68 additions & 69 deletions python/plugins/sextante/modeler/ModelerGraphicItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, element, elementIndex, model):
elif isinstance(element, basestring): #output name
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/output.png")
self.pixmap = icon.pixmap(20, 20, state=QtGui.QIcon.On)
self.text = element
self.text = element
else:
state=QtGui.QIcon.On
if self.elementIndex in self.model.deactivated:
Expand All @@ -60,57 +60,57 @@ def __init__(self, element, elementIndex, model):
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
self.setZValue(1000)

if not isinstance(element, basestring):
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/edit.png")
pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, ModelerGraphicItem.BOX_HEIGHT / 2 - FlatButtonGraphicItem.HEIGHT / 2 + 1)
pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, ModelerGraphicItem.BOX_HEIGHT / 2 - FlatButtonGraphicItem.HEIGHT / 2 + 1)
self.editButton = FlatButtonGraphicItem(icon, pt, self.editElement)
self.editButton.setParentItem(self)
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/delete.png")
pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, -ModelerGraphicItem.BOX_HEIGHT / 2 + FlatButtonGraphicItem.HEIGHT / 2 + 1)
pt = QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, -ModelerGraphicItem.BOX_HEIGHT / 2 + FlatButtonGraphicItem.HEIGHT / 2 + 1)
self.deleteButton = FlatButtonGraphicItem(icon, pt, self.removeElement)
self.deleteButton.setParentItem(self)
if isinstance(element, GeoAlgorithm):
if element.parameters:

if isinstance(element, GeoAlgorithm):
if element.parameters:
pt = self.getLinkPointForParameter(-1)
x = self.getXPositionForFoldButton()
x = self.getXPositionForFoldButton()
pt = QtCore.QPointF(x, pt.y() + 3)
self.inButton = FoldButtonGraphicItem(pt, self.foldInput)
self.inButton.setParentItem(self)
if element.outputs:
pt = self.getLinkPointForOutput(-1)
x = self.getXPositionForFoldButton()
pt = QtCore.QPointF(x, pt.y() + 3)
x = self.getXPositionForFoldButton()
pt = QtCore.QPointF(x, pt.y() + 3)
self.outButton = FoldButtonGraphicItem(pt, self.foldOutput)
self.outButton.setParentItem(self)


def foldInput(self, folded):
self.inputFolded = folded
self.prepareGeometryChange()
if self.element.outputs:
self.prepareGeometryChange()
if self.element.outputs:
pt = self.getLinkPointForOutput(-1)
x = self.getXPositionForFoldButton()
x = self.getXPositionForFoldButton()
pt = QtCore.QPointF(x, pt.y())
self.outButton.position = pt
self.update()

def foldOutput(self, folded):
self.outputFolded = folded
self.prepareGeometryChange()
self.update()
self.outputFolded = folded
self.prepareGeometryChange()
self.update()

def addArrow(self, arrow):
self.arrows.append(arrow)

def boundingRect(self):
font = QtGui.QFont("Verdana", 8)
fm = QtGui.QFontMetricsF(font)
fm = QtGui.QFontMetricsF(font)
numParams = 0 if self.inputFolded else len(self.element.parameters)
numOutputs = 0 if self.outputFolded else len(self.element.outputs)
numElements = numParams + numOutputs + 3
h = (fm.height() * 1.2) * numElements
numOutputs = 0 if self.outputFolded else len(self.element.outputs)
numElements = numParams + numOutputs + 3
h = (fm.height() * 1.2) * numElements
rect = QtCore.QRectF(-(ModelerGraphicItem.BOX_WIDTH + 2)/2, -(ModelerGraphicItem.BOX_HEIGHT + 2)/2,
ModelerGraphicItem.BOX_WIDTH + 2, ModelerGraphicItem.BOX_HEIGHT + h)
return rect
Expand Down Expand Up @@ -200,37 +200,37 @@ def paint(self, painter, option, widget=None):
painter.setPen(QtGui.QPen(QtCore.Qt.blue))
if isinstance(self.element, GeoAlgorithm):
if self.elementIndex in self.model.deactivated:
painter.setPen(QtGui.QPen(QtCore.Qt.lightGray))
painter.setPen(QtGui.QPen(QtCore.Qt.lightGray))
fm = QtGui.QFontMetricsF(font)
text = self.getAdjustedText(self.text)
h = fm.height()
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 25, h/2.0)
painter.drawText(pt, text)
painter.setPen(QtGui.QPen(QtCore.Qt.black))
if isinstance(self.element, GeoAlgorithm):
if isinstance(self.element, GeoAlgorithm):
h = (fm.height() * 1.2)
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 25, h)
painter.drawText(pt, "In")
i = 1
if not self.inputFolded:
for param in self.element.parameters:
text = self.getAdjustedText(param.description)
text = self.getAdjustedText(param.description)
h = (fm.height() * 1.2) * (i + 1)
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 33, h)
painter.drawText(pt, text)
i += 1
i += 1
h = (fm.height() * 1.2) * (i + 1)
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 25, h)
painter.drawText(pt, "Out")
i += 1
if not self.outputFolded:
for out in self.element.outputs:
text = self.getAdjustedText(out.description)
text = self.getAdjustedText(out.description)
h = (fm.height() * 1.2) * (i + 1)
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + 33, h)
painter.drawText(pt, text)
i += 1
Expand All @@ -243,28 +243,28 @@ def getLinkPointForParameter(self, paramIndex):
paramIndex = -1
offsetX = 17
font = QtGui.QFont("Verdana", 8)
fm = QtGui.QFontMetricsF(font)
if isinstance(self.element, GeoAlgorithm):
fm = QtGui.QFontMetricsF(font)
if isinstance(self.element, GeoAlgorithm):
h = (fm.height() * 1.2) * (paramIndex + 2) - fm.height() / 2.0 + 2
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
else:
h = 0
return QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH)/2 + offsetX, h)


def getXPositionForFoldButton(self):
return 0
def getLinkPointForOutput(self, outputIndex):
if isinstance(self.element, GeoAlgorithm):

def getLinkPointForOutput(self, outputIndex):
if isinstance(self.element, GeoAlgorithm):
numParams = 0 if self.inputFolded else len(self.element.parameters)
outputIndex = outputIndex if not self.outputFolded else -1
text = self.getAdjustedText(self.element.outputs[outputIndex].description)
outputIndex = outputIndex if not self.outputFolded else -1
text = self.getAdjustedText(self.element.outputs[outputIndex].description)
font = QtGui.QFont("Verdana", 8)
fm = QtGui.QFontMetricsF(font)
fm = QtGui.QFontMetricsF(font)
w = fm.width(QtCore.QString(text))
h = (fm.height() * 1.2) * (outputIndex + 3 + numParams) - fm.height() / 2.0
y = h + ModelerGraphicItem.BOX_HEIGHT / 2.0 + 2
y = h + ModelerGraphicItem.BOX_HEIGHT / 2.0 + 2
x = -(ModelerGraphicItem.BOX_WIDTH)/2 + 33 + w + 5 if not self.outputFolded else 10
return QtCore.QPointF(x, y)
else:
Expand All @@ -279,9 +279,9 @@ def itemChange(self, change, value):

def polygon(self):
font = QtGui.QFont("Verdana", 8)
fm = QtGui.QFontMetricsF(font)
numElements = len(self.element.parameters) + len(self.element.outputs) + 3
h = (fm.height() * 1.2) * numElements
fm = QtGui.QFontMetricsF(font)
numElements = len(self.element.parameters) + len(self.element.outputs) + 3
h = (fm.height() * 1.2) * numElements
pol = QtGui.QPolygonF([
QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH + 2)/2, -(ModelerGraphicItem.BOX_HEIGHT + 2)/2),
QtCore.QPointF(-(ModelerGraphicItem.BOX_WIDTH + 2)/2, (ModelerGraphicItem.BOX_HEIGHT + 2)/2 + h),
Expand All @@ -291,62 +291,61 @@ def polygon(self):
return pol

class FlatButtonGraphicItem(QtGui.QGraphicsItem):

WIDTH = 16
HEIGHT = 16
HEIGHT = 16

def __init__(self, icon, position, action):
super(FlatButtonGraphicItem, self).__init__(None, None)
self.setAcceptHoverEvents(True)
self.setAcceptHoverEvents(True)
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, False)
self.pixmap = icon.pixmap(self.WIDTH, self.HEIGHT, state=QtGui.QIcon.On)
self.position = position
self.isIn = False
self.action = action
self.isIn = False
self.action = action

def mousePressEvent(self, event):
self.action()

def paint(self, painter, option, widget=None):
pt = QtCore.QPointF(-self.WIDTH / 2, -self.HEIGHT / 2) + self.position
rect = QtCore.QRectF(pt.x(), pt.y(), self.WIDTH, self.HEIGHT)
rect = QtCore.QRectF(pt.x(), pt.y(), self.WIDTH, self.HEIGHT)
if self.isIn:
painter.setPen(QtGui.QPen(QtCore.Qt.transparent, 1))
painter.setBrush(QtGui.QBrush(QtCore.Qt.lightGray, QtCore.Qt.SolidPattern))
painter.setBrush(QtGui.QBrush(QtCore.Qt.lightGray, QtCore.Qt.SolidPattern))
else:
painter.setPen(QtGui.QPen(QtCore.Qt.transparent, 1))
painter.setPen(QtGui.QPen(QtCore.Qt.transparent, 1))
painter.setBrush(QtGui.QBrush(QtCore.Qt.white, QtCore.Qt.SolidPattern))
painter.drawRect(rect)
painter.drawRect(rect)
painter.drawPixmap(pt.x(), pt.y(), self.pixmap)

def boundingRect(self):
rect = QtCore.QRectF(self.position.x() - self.WIDTH / 2, self.position.y() - self.HEIGHT / 2, self.WIDTH, self.HEIGHT)
return rect
return rect

def hoverEnterEvent(self, event):
self.isIn = True
self.isIn = True
self.update()

def hoverLeaveEvent(self, event):
self.isIn = False
self.isIn = False
self.update()

class FoldButtonGraphicItem(FlatButtonGraphicItem):

WIDTH = 11
HEIGHT = 11
icons = { True : QtGui.QIcon(os.path.dirname(__file__) + "/../images/plus.png"),

icons = { True : QtGui.QIcon(os.path.dirname(__file__) + "/../images/plus.png"),
False : QtGui.QIcon(os.path.dirname(__file__) + "/../images/minus.png")}

def __init__(self, position, action):
self.folded = True
icon = self.icons[True]
super(FoldButtonGraphicItem, self).__init__(icon, position, action)
super(FoldButtonGraphicItem, self).__init__(icon, position, action)

def mousePressEvent(self, event):
self.folded = not self.folded
icon = self.icons[self.folded]
self.pixmap = icon.pixmap(self.WIDTH, self.HEIGHT, state=QtGui.QIcon.On)
self.action(self.folded)

26 changes: 13 additions & 13 deletions python/plugins/sextante/modeler/ModelerScene.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def getAlgorithmPositions(self):
for item in self.algItems:
pos.append(item.pos())
return pos

def getOutputPositions(self):
pos = []
for alg in self.outputItems:
outputPos = {}
for key,value in alg.iteritems():
for key,value in alg.iteritems():
if value is not None:
outputPos[key] = value.pos()
else:
Expand Down Expand Up @@ -125,7 +125,7 @@ def paintModel(self, model):
item.setPos(model.algPos[iAlg])
self.algItems.append(item)
iAlg+=1

#and then the arrows
iAlg=0
for alg in model.algs:
Expand All @@ -143,27 +143,27 @@ def paintModel(self, model):
arrow = ModelerArrowItem(self.algItems[depend], -1, self.algItems[iAlg], -1)
self.addItem(arrow)
iAlg+=1
#and finally the outputs

#and finally the outputs
for iAlg, alg in enumerate(model.algs):
outputs = model.algOutputs[iAlg]
outputItems = {}
outputs = model.algOutputs[iAlg]
outputItems = {}
for idx, key in enumerate(outputs.keys()):
out = outputs[key]
if out is not None:
out = outputs[key]
if out is not None:
item = ModelerGraphicItem(out, idx, model)
item.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
item.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
self.addItem(item)
pos = model.outputPos[iAlg][key]
pos = model.outputPos[iAlg][key]
if pos is None:
pos = self.algItems[iAlg].pos() + QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH,0) + self.algItems[iAlg].getLinkPointForOutput(idx)
pos = self.algItems[iAlg].pos() + QtCore.QPointF(ModelerGraphicItem.BOX_WIDTH,0) + self.algItems[iAlg].getLinkPointForOutput(idx)
item.setPos(pos)
outputItems[key] = item
outputItems[key] = item
arrow = ModelerArrowItem(self.algItems[iAlg], idx, item, -1)
self.addItem(arrow)
else:
outputItems[key] = None
outputItems[key] = None
self.outputItems.append(outputItems)


Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2934,7 +2934,7 @@ void QgisApp::addDatabaseLayers( QStringList const & layerPathList, QString cons
else
{
QgsMessageLog::logMessage( tr( "%1 is an invalid layer - not loaded" ).arg( layerPath ) );
QLabel* msgLabel = new QLabel( tr( "%1 is an invalid layer and cannot be loaded. Please check the <a href=\"#messageLog\">message log</a> for further info." ).arg( layerPath ), messageBar() );
QLabel *msgLabel = new QLabel( tr( "%1 is an invalid layer and cannot be loaded. Please check the <a href=\"#messageLog\">message log</a> for further info." ).arg( layerPath ), messageBar() );
msgLabel->setWordWrap( true );
connect( msgLabel, SIGNAL( linkActivated( QString ) ), mLogDock, SLOT( show() ) );
messageBar()->pushWidget( msgLabel,
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//! Add a Delimited Text layer to the map
void addDelimitedTextLayer();
//! Add a vector layer defined by uri, layer name, data source uri
void addSelectedVectorLayer(QString uri, QString layerName, QString provider );
void addSelectedVectorLayer( QString uri, QString layerName, QString provider );
//#ifdef HAVE_MSSQL
//! Add a MSSQL layer to the map
void addMssqlLayer();
Expand Down
128 changes: 64 additions & 64 deletions src/app/qgscustomprojectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget *parent, Qt::WFlag
}

populateList();
if( !customCRSnames.empty() )
if ( !customCRSnames.empty() )
{
leName->setText( customCRSnames[0] );
teParameters->setPlainText( customCRSparameters[0] );
leNameList->setCurrentItem( leNameList->topLevelItem( 0 ) );
}
leNameList->hideColumn(QGIS_CRS_ID_COLUMN);

leNameList->hideColumn( QGIS_CRS_ID_COLUMN );

}

QgsCustomProjectionDialog::~QgsCustomProjectionDialog()
Expand Down Expand Up @@ -107,15 +107,15 @@ void QgsCustomProjectionDialog::populateList()
QgsCoordinateReferenceSystem crs;
while ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
{
id= QString::fromUtf8( ( char* ) sqlite3_column_text( myPreparedStatement, 0 ) );
name= QString::fromUtf8( ( char* ) sqlite3_column_text( myPreparedStatement, 1 ) );
parameters= QString::fromUtf8( ( char* ) sqlite3_column_text( myPreparedStatement, 2 ) );
id = QString::fromUtf8(( char* ) sqlite3_column_text( myPreparedStatement, 0 ) );
name = QString::fromUtf8(( char* ) sqlite3_column_text( myPreparedStatement, 1 ) );
parameters = QString::fromUtf8(( char* ) sqlite3_column_text( myPreparedStatement, 2 ) );

crs.createFromProj4( parameters );
existingCRSnames[id] = name;
existingCRSparameters[id] = crs.toProj4();

newItem = new QTreeWidgetItem( leNameList, QStringList( ) );
newItem = new QTreeWidgetItem( leNameList, QStringList( ) );
newItem->setText( QGIS_CRS_NAME_COLUMN, name );
newItem->setText( QGIS_CRS_ID_COLUMN, id );
newItem->setText( QGIS_CRS_PARAMETERS_COLUMN, crs.toProj4() );
Expand All @@ -127,11 +127,11 @@ void QgsCustomProjectionDialog::populateList()
}
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
leNameList->sortByColumn( QGIS_CRS_NAME_COLUMN,Qt::AscendingOrder );

leNameList->sortByColumn( QGIS_CRS_NAME_COLUMN, Qt::AscendingOrder );

QTreeWidgetItemIterator it( leNameList );
while( *it )
while ( *it )
{
QString id = ( *it )->text( QGIS_CRS_ID_COLUMN );
customCRSids.push_back( id );
Expand All @@ -147,7 +147,7 @@ bool QgsCustomProjectionDialog::deleteCRS( QString id )
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;

QString mySql = "delete from tbl_srs where srs_id=" + quotedValue( id );
QgsDebugMsg( mySql );
//check the db is available
Expand All @@ -170,7 +170,7 @@ bool QgsCustomProjectionDialog::deleteCRS( QString id )
return myResult == SQLITE_OK;
}

void QgsCustomProjectionDialog::insertProjection(QString myProjectionAcronym)
void QgsCustomProjectionDialog::insertProjection( QString myProjectionAcronym )
{
sqlite3 *myDatabase;
sqlite3_stmt *myPreparedStatement;
Expand Down Expand Up @@ -235,31 +235,31 @@ void QgsCustomProjectionDialog::insertProjection(QString myProjectionAcronym)
sqlite3_close( myDatabase );
}

bool QgsCustomProjectionDialog::saveCRS(QgsCoordinateReferenceSystem myCRS, QString myName, QString myId, bool newEntry)
bool QgsCustomProjectionDialog::saveCRS( QgsCoordinateReferenceSystem myCRS, QString myName, QString myId, bool newEntry )
{
QString mySql;
int return_id;
QString myProjectionAcronym = myCRS.projectionAcronym();
QString myEllipsoidAcronym = myCRS.ellipsoidAcronym();
QgsDebugMsg( QString("Saving a CRS:%1, %2, %3").arg(myName).arg(myCRS.toProj4()).arg(newEntry) );
if( newEntry )
QString myEllipsoidAcronym = myCRS.ellipsoidAcronym();
QgsDebugMsg( QString( "Saving a CRS:%1, %2, %3" ).arg( myName ).arg( myCRS.toProj4() ).arg( newEntry ) );
if ( newEntry )
{
return_id=myCRS.saveAsUserCRS(myName);
if(return_id==-1)
return_id = myCRS.saveAsUserCRS( myName );
if ( return_id == -1 )
return false;
else
myId = QString::number(return_id);
myId = QString::number( return_id );
}
else
{
mySql = "update tbl_srs set description="
+ quotedValue( myName )
+ ",projection_acronym=" + quotedValue( myProjectionAcronym )
+ ",ellipsoid_acronym=" + quotedValue( myEllipsoidAcronym )
+ ",parameters=" + quotedValue( myCRS.toProj4() )
+ ",is_geo=0" // <--shamelessly hard coded for now
+ " where srs_id=" + quotedValue( myId )
;
+ quotedValue( myName )
+ ",projection_acronym=" + quotedValue( myProjectionAcronym )
+ ",ellipsoid_acronym=" + quotedValue( myEllipsoidAcronym )
+ ",parameters=" + quotedValue( myCRS.toProj4() )
+ ",is_geo=0" // <--shamelessly hard coded for now
+ " where srs_id=" + quotedValue( myId )
;
QgsDebugMsg( mySql );
sqlite3 *myDatabase;
const char *myTail;
Expand All @@ -285,17 +285,17 @@ bool QgsCustomProjectionDialog::saveCRS(QgsCoordinateReferenceSystem myCRS, QStr
sqlite3_finalize( myPreparedStatement );
// close sqlite3 db
sqlite3_close( myDatabase );
if(myResult != SQLITE_OK)
if ( myResult != SQLITE_OK )
return false;
}
existingCRSparameters[myId] = myCRS.toProj4();
existingCRSnames[myId] = myName;

// If we have a projection acronym not in the user db previously, add it.
// This is a must, or else we can't select it from the vw_srs table.
// Actually, add it always and let the SQL PRIMARY KEY remove duplicates.
insertProjection( myProjectionAcronym );

return true;
}

Expand All @@ -305,28 +305,28 @@ void QgsCustomProjectionDialog::on_pbnAdd_clicked()
QString name = tr( "new CRS" );
QString id = "";
QgsCoordinateReferenceSystem parameters;
QTreeWidgetItem* newItem = new QTreeWidgetItem( leNameList, QStringList( ) );

QTreeWidgetItem* newItem = new QTreeWidgetItem( leNameList, QStringList( ) );

newItem->setText( QGIS_CRS_NAME_COLUMN, name );
newItem->setText( QGIS_CRS_ID_COLUMN, id );
newItem->setText( QGIS_CRS_PARAMETERS_COLUMN, parameters.toProj4());
newItem->setText( QGIS_CRS_PARAMETERS_COLUMN, parameters.toProj4() );
customCRSnames.push_back( name );
customCRSids.push_back ( id);
customCRSids.push_back( id );
customCRSparameters.push_back( parameters.toProj4() );
leNameList->setCurrentItem( newItem );
}

void QgsCustomProjectionDialog::on_pbnRemove_clicked()
{
int i = leNameList->currentIndex().row();
if( i == -1 )
if ( i == -1 )
{
return;
}
QTreeWidgetItem* item = leNameList->takeTopLevelItem( i );
delete item;
if( customCRSids[i] != "" )
if ( customCRSids[i] != "" )
{
deletedCRSs.push_back( customCRSids[i] );
}
Expand All @@ -339,15 +339,15 @@ void QgsCustomProjectionDialog::on_leNameList_currentItemChanged( QTreeWidgetIte
{
//Store the modifications made to the current element before moving on
int currentIndex, previousIndex;
if( previous )
if ( previous )
{
previousIndex = leNameList->indexOfTopLevelItem( previous );
customCRSnames[previousIndex] = leName->text();
customCRSparameters[previousIndex] = teParameters->toPlainText();
previous->setText( QGIS_CRS_NAME_COLUMN, leName->text() );
previous->setText( QGIS_CRS_PARAMETERS_COLUMN, teParameters->toPlainText() );
}
if( current )
if ( current )
{
currentIndex = leNameList->indexOfTopLevelItem( current );
leName->setText( customCRSnames[currentIndex] );
Expand All @@ -358,28 +358,28 @@ void QgsCustomProjectionDialog::on_leNameList_currentItemChanged( QTreeWidgetIte
//Can happen that current is null, for example if we just deleted the last element
leName->setText( "" );
teParameters->setPlainText( "" );
return;
return;
}
return;
}

void QgsCustomProjectionDialog::on_pbnCopyCRS_clicked()
{
{
QgsDebugMsg( "Entered" );
QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector( this );
if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs;
QString id = mySelector->selectedAuthId();
srs.createFromOgcWmsCrs( id );
if (leNameList->topLevelItemCount() == 0 )
if ( leNameList->topLevelItemCount() == 0 )
{
on_pbnAdd_clicked();
}
teParameters->setPlainText( srs.toProj4() );
customCRSparameters[leNameList->currentIndex().row()] = srs.toProj4();
leNameList->currentItem()->setText( QGIS_CRS_PARAMETERS_COLUMN, srs.toProj4() );

}
delete mySelector;
}
Expand All @@ -389,58 +389,58 @@ void QgsCustomProjectionDialog::on_buttonBox_accepted()
QgsDebugMsg( "Entered" );
//Update the current CRS:
int i = leNameList->currentIndex().row();
if(i != -1)
if ( i != -1 )
{
customCRSnames[i] = leName->text();
customCRSparameters[i] = teParameters->toPlainText();
}

QgsDebugMsg( "We save the modified CRS." );

//Check if all CRS are valid:
QgsCoordinateReferenceSystem CRS;
for( size_t i = 0; i < customCRSids.size(); ++i )
for ( size_t i = 0; i < customCRSids.size(); ++i )
{
CRS.createFromProj4(customCRSparameters[i]);
if( CRS.isValid()==false )
CRS.createFromProj4( customCRSparameters[i] );
if ( CRS.isValid() == false )
{
QMessageBox::information( this, tr( "QGIS Custom Projection" ),
tr( "The proj4 definition of '%1' is not valid." ).arg(customCRSnames[i]) );
tr( "The proj4 definition of '%1' is not valid." ).arg( customCRSnames[i] ) );
return;
}
}
//Modify the CRS changed:
bool save_success=true;
for( size_t i = 0; i < customCRSids.size(); ++i )
bool save_success = true;
for ( size_t i = 0; i < customCRSids.size(); ++i )
{
CRS.createFromProj4(customCRSparameters[i]);
CRS.createFromProj4( customCRSparameters[i] );
//Test if we just added this CRS (if it has no existing ID)
if( customCRSids[i] == "" )
if ( customCRSids[i] == "" )
{
save_success = save_success && saveCRS( CRS,customCRSnames[i], "", true);
save_success = save_success && saveCRS( CRS, customCRSnames[i], "", true );
}
else
{
if ( existingCRSnames[customCRSids[i]]!=customCRSnames[i] || existingCRSparameters[customCRSids[i]] != customCRSparameters[i] )
if ( existingCRSnames[customCRSids[i]] != customCRSnames[i] || existingCRSparameters[customCRSids[i]] != customCRSparameters[i] )
{
save_success = save_success && saveCRS(CRS, customCRSnames[i], customCRSids[i], false );
save_success = save_success && saveCRS( CRS, customCRSnames[i], customCRSids[i], false );
}
}
if( ! save_success )
if ( ! save_success )
{
QgsDebugMsg( QString( "Error when saving CRS '%1'" ).arg( customCRSnames[i] ));
QgsDebugMsg( QString( "Error when saving CRS '%1'" ).arg( customCRSnames[i] ) );
}
}
QgsDebugMsg( "We remove the deleted CRS." );
for( size_t i = 0; i < deletedCRSs.size(); ++i )
for ( size_t i = 0; i < deletedCRSs.size(); ++i )
{
save_success=save_success && deleteCRS( deletedCRSs[i] );
if( ! save_success )
save_success = save_success && deleteCRS( deletedCRSs[i] );
if ( ! save_success )
{
QgsDebugMsg( QString( "Problem for layer '%1'" ).arg( customCRSparameters[i] ));
QgsDebugMsg( QString( "Problem for layer '%1'" ).arg( customCRSparameters[i] ) );
}
}
if( save_success )
if ( save_success )
{
accept();
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgscustomprojectiondialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ class QgsCustomProjectionDialog : public QDialog, private Ui::QgsCustomProjectio

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
void on_buttonBox_accepted();

private:

//helper functions
void populateList();
QString quotedValue( QString value );
bool deleteCRS( QString id );
bool saveCRS( QgsCoordinateReferenceSystem myParameters, QString myName, QString myId, bool newEntry );
void insertProjection( QString myProjectionAcronym );

//These two QMap store the values as they are on the database when loading
QMap <QString, QString> existingCRSparameters;
QMap <QString, QString> existingCRSnames;

//These three vectors store the value updated with the current modifications
std::vector<QString> customCRSnames;
std::vector<QString> customCRSids;
std::vector<QString> customCRSparameters;

//vector saving the CRS to be deleted
std::vector<QString> deletedCRSs;
std::vector<QString> deletedCRSs;

//Columns in the tree widget
enum columns { QGIS_CRS_NAME_COLUMN, QGIS_CRS_ID_COLUMN, QGIS_CRS_PARAMETERS_COLUMN };
Expand Down
10 changes: 5 additions & 5 deletions src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,20 +1475,20 @@ bool QgsCoordinateReferenceSystem::saveAsUserCRS( QString name )
QgsMessageLog::logMessage( QObject::tr( "Saved user CRS [%1]" ).arg( toProj4() ), QObject::tr( "CRS" ) );

int return_id;
if(myResult == SQLITE_OK)
if ( myResult == SQLITE_OK )
{
return_id = sqlite3_last_insert_rowid( myDatabase );
setInternalId(return_id);
setInternalId( return_id );

//We add the just created user CRS to the list of recently used CRS
QSettings settings;
//QStringList recentProjections = settings.value( "/UI/recentProjections" ).toStringList();
QStringList projectionsProj4 = settings.value( "/UI/recentProjectionsProj4" ).toStringList();
QStringList projectionsAuthId = settings.value( "/UI/recentProjectionsAuthId" ).toStringList();
//recentProjections.append();
//settings.setValue( "/UI/recentProjections", recentProjections );
projectionsProj4.append(toProj4());
projectionsAuthId.append(authid());
projectionsProj4.append( toProj4() );
projectionsAuthId.append( authid() );
settings.setValue( "/UI/recentProjectionsProj4", projectionsProj4 );
settings.setValue( "/UI/recentProjectionsAuthId", projectionsAuthId );

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1768,14 +1768,14 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
QDomElement e = featureBlendModeNode.toElement();
setFeatureBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) e.text().toInt() ) );
}

// get and set the layer transparency if it exists
QDomNode layerTransparencyNode = node.namedItem( "layerTransparency" );
if ( !layerTransparencyNode.isNull() )
{
QDomElement e = layerTransparencyNode.toElement();
setLayerTransparency( e.text().toInt() );
}
}

// use scale dependent visibility flag
QDomElement e = node.toElement();
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1234,15 +1234,15 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
* @note added in 2.0
*/
QPainter::CompositionMode featureBlendMode() const;

/* Set the transparency for the vector layer
* @note added in 2.0
*/
void setLayerTransparency( int layerTransparency );
/* Returns the current transparency for the vector layer
* @note added in 2.0
*/
int layerTransparency() const;
int layerTransparency() const;

public slots:
/**
Expand Down Expand Up @@ -1500,7 +1500,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer

/** Blend mode for features */
QPainter::CompositionMode mFeatureBlendMode;

/** Layer transparency */
int mLayerTransparency;

Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterresamplefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ QgsRasterBlock * QgsRasterResampleFilter::block( int bandNo, QgsRectangle const
// Do no oversampling if no resampler for zoomed in / zoomed out (nearest neighbour)
// We do mZoomedInResampler if oversampling == 1 (otherwise for example reprojected
// zoom in rasters are never resampled because projector limits resolution.
if (( (oversampling < 1.0 || qgsDoubleNear( oversampling, 1.0) ) && !mZoomedInResampler ) || ( oversampling > 1.0 && !mZoomedOutResampler ) )
if ((( oversampling < 1.0 || qgsDoubleNear( oversampling, 1.0 ) ) && !mZoomedInResampler ) || ( oversampling > 1.0 && !mZoomedOutResampler ) )
{
QgsDebugMsg( "No oversampling." );
return mInput->block( bandNumber, extent, width, height );
Expand Down Expand Up @@ -198,7 +198,7 @@ QgsRasterBlock * QgsRasterResampleFilter::block( int bandNo, QgsRectangle const

QImage dstImg = QImage( width, height, QImage::Format_ARGB32_Premultiplied );

if ( mZoomedInResampler && (oversamplingX < 1.0 || qgsDoubleNear( oversampling, 1.0) ) )
if ( mZoomedInResampler && ( oversamplingX < 1.0 || qgsDoubleNear( oversampling, 1.0 ) ) )
{
QgsDebugMsg( "zoomed in resampling" );
mZoomedInResampler->resample( img, dstImg );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsattributedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
if ( !myWidget )
continue;

QLabel * mypLabel = new QLabel( mypInnerFrame );
QLabel *mypLabel = new QLabel( mypInnerFrame );
mypInnerLayout->addWidget( mypLabel, index, 0 );
if ( myFieldType == QVariant::Int )
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsnewhttpconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void QgsNewHttpConnection::accept()
url.removeEncodedQueryItem( params["FORMAT"].first );
}

if( url.encodedPath().isEmpty() )
if ( url.encodedPath().isEmpty() )
{
url.setEncodedPath( "/" );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsprojectionselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void QgsProjectionSelector::applySelection( int column, QString value )
}
else
{
QgsDebugMsg( QString("nothing found for %1,%2" ).arg( column ).arg( value ) );
QgsDebugMsg( QString( "nothing found for %1,%2" ).arg( column ).arg( value ) );
// unselect the selected item to avoid confusing the user
lstCoordinateSystems->clearSelection();
lstRecent->clearSelection();
Expand Down
6 changes: 3 additions & 3 deletions src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog( QgsVectorLayer* la

// Feature blend mode
mFeatureBlendComboBox->setBlendMode( mLayer->featureBlendMode() );

// Layer transparency
mLayerTransparencySlider->setValue( mLayer->layerTransparency() );
mLayerTransparencySpnBx->setValue( mLayer->layerTransparency() );

// connect layer transparency slider and spin box
connect( mLayerTransparencySlider, SIGNAL( valueChanged( int ) ), mLayerTransparencySpnBx, SLOT( setValue( int ) ) );
connect( mLayerTransparencySpnBx, SIGNAL( valueChanged( int ) ), mLayerTransparencySlider, SLOT( setValue( int ) ) );
connect( mLayerTransparencySpnBx, SIGNAL( valueChanged( int ) ), mLayerTransparencySlider, SLOT( setValue( int ) ) );

QPixmap pix;
QgsRendererV2Registry* reg = QgsRendererV2Registry::instance();
Expand Down Expand Up @@ -187,7 +187,7 @@ void QgsRendererV2PropertiesDialog::apply()
// set the blend modes for the layer
mLayer->setBlendMode( mBlendModeComboBox->blendMode() );
mLayer->setFeatureBlendMode( mFeatureBlendComboBox->blendMode() );

// set transparency for the layer
mLayer->setLayerTransparency( mLayerTransparencySlider->value() );
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void QgsVectorGradientColorRampV2Dialog::stopDoubleClicked( QTreeWidgetItem* ite
}
else
{
color = QColorDialog::getColor( item->data( 0, StopColorRole ).value<QColor>(), this, tr("Edit Stop Color"), QColorDialog::ShowAlphaChannel );
color = QColorDialog::getColor( item->data( 0, StopColorRole ).value<QColor>(), this, tr( "Edit Stop Color" ), QColorDialog::ShowAlphaChannel );
}
if ( !color.isValid() )
return;
Expand Down Expand Up @@ -320,7 +320,7 @@ void QgsVectorGradientColorRampV2Dialog::addStop()
// but not needed at this time because of the other Qt bug
// FIXME need to also check max QT_VERSION when Qt bug(s) fixed
#ifndef Q_WS_MAC
QColor color = QColorDialog::getColor( QColor(), this, tr("Add Color Stop"), QColorDialog::ShowAlphaChannel );
QColor color = QColorDialog::getColor( QColor(), this, tr( "Add Color Stop" ), QColorDialog::ShowAlphaChannel );

if ( !color.isValid() )
return;
Expand Down Expand Up @@ -351,7 +351,7 @@ void QgsVectorGradientColorRampV2Dialog::addStop()
lst << "." << QString(( val < 10 ) ? '0' + QString::number( val ) : QString::number( val ) );

#ifdef Q_WS_MAC
QColor color = QColorDialog::getColor( QColor(), this, tr("Add Color Stop"), QColorDialog::ShowAlphaChannel );
QColor color = QColorDialog::getColor( QColor(), this, tr( "Add Color Stop" ), QColorDialog::ShowAlphaChannel );

if ( !color.isValid() )
return;
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgis_map_serv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ int main( int argc, char * argv[] )
continue;
}

if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 )
if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 )
{
QDomDocument capabilitiesDocument;
try
Expand Down
22 changes: 11 additions & 11 deletions src/plugins/topology/checkDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,17 +427,17 @@ void checkDock::validateSelected()

void checkDock::toggleErrorMarker()
{
QList<QgsRubberBand*>::const_iterator it;
for ( it = mRbErrorMarkers.begin(); it != mRbErrorMarkers.end(); ++it )
QList<QgsRubberBand*>::const_iterator it;
for ( it = mRbErrorMarkers.begin(); it != mRbErrorMarkers.end(); ++it )
{
QgsRubberBand* rb = *it;
if ( mToggleRubberband->isChecked() )
{
QgsRubberBand* rb = *it;
if ( mToggleRubberband->isChecked() )
{
rb->show();
}
else
{
rb->hide();
}
rb->show();
}
else
{
rb->hide();
}
}
}
28 changes: 14 additions & 14 deletions src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe
{
mFeatureIds = P->mSpatialIndex->intersects( rect );
// Sort for efficient sequential retrieval
qSort(mFeatureIds.begin(), mFeatureIds.end());
QgsDebugMsg( QString("Layer has spatial index - selected %1 features from index").arg(mFeatureIds.size()) );
qSort( mFeatureIds.begin(), mFeatureIds.end() );
QgsDebugMsg( QString( "Layer has spatial index - selected %1 features from index" ).arg( mFeatureIds.size() ) );
mMode = FeatureIds;
mTestSubset = false;
mTestGeometry = mTestGeometryExact;
Expand All @@ -109,13 +109,13 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe
// If we have a subset index then use it..
if ( mMode == FileScan && P->mUseSubsetIndex )
{
QgsDebugMsg( QString("Layer has subset index - use %1 items from subset index").arg(P->mSubsetIndex.size()) );
QgsDebugMsg( QString( "Layer has subset index - use %1 items from subset index" ).arg( P->mSubsetIndex.size() ) );
mTestSubset = false;
mMode = SubsetIndex;
}

// Otherwise just have to scan the file
if( mMode == FileScan )
if ( mMode == FileScan )
{
QgsDebugMsg( "File will be scanned for desired features" );
}
Expand All @@ -125,16 +125,16 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe
// if testing the subset expression, and it uses geometry.
if ( mRequest.flags() & QgsFeatureRequest::NoGeometry &&
! mTestGeometry &&
! ( mTestSubset && P->mSubsetExpression->needsGeometry() ) )
!( mTestSubset && P->mSubsetExpression->needsGeometry() ) )
{
QgsDebugMsg( "Feature geometries not required" );
mLoadGeometry = false;
}

QgsDebugMsg( QString("Iterator is scanning file: ") + (scanningFile() ? "Yes" : "No"));
QgsDebugMsg( QString("Iterator is loading geometries: ") + (loadGeometry() ? "Yes" : "No"));
QgsDebugMsg( QString("Iterator is testing geometries: ") + (testGeometry() ? "Yes" : "No"));
QgsDebugMsg( QString("Iterator is testing subset: ") + (testSubset() ? "Yes" : "No"));
QgsDebugMsg( QString( "Iterator is scanning file: " ) + ( scanningFile() ? "Yes" : "No" ) );
QgsDebugMsg( QString( "Iterator is loading geometries: " ) + ( loadGeometry() ? "Yes" : "No" ) );
QgsDebugMsg( QString( "Iterator is testing geometries: " ) + ( testGeometry() ? "Yes" : "No" ) );
QgsDebugMsg( QString( "Iterator is testing subset: " ) + ( testSubset() ? "Yes" : "No" ) );

rewind();
}
Expand All @@ -160,23 +160,23 @@ bool QgsDelimitedTextFeatureIterator::nextFeature( QgsFeature& feature )
}
else
{
while( ! gotFeature )
while ( ! gotFeature )
{
qint64 fid = -1;
if ( mMode == FeatureIds )
{
if( mNextId < mFeatureIds.size() )
if ( mNextId < mFeatureIds.size() )
{
fid = mFeatureIds[mNextId];
}
}
else if( mNextId < P->mSubsetIndex.size() )
else if ( mNextId < P->mSubsetIndex.size() )
{
fid = P->mSubsetIndex[mNextId];
}
if( fid < 0 ) break;
if ( fid < 0 ) break;
mNextId++;
gotFeature = (P->setNextFeatureId( fid ) && P->nextFeature( feature, P->mFile, this ));
gotFeature = ( P->setNextFeatureId( fid ) && P->nextFeature( feature, P->mFile, this ) );
}
}

Expand Down
37 changes: 20 additions & 17 deletions src/providers/delimitedtext/qgsdelimitedtextfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ QgsDelimitedTextFile::QgsDelimitedTextFile( QString url ) :
mEncoding( "UTF-8" ),
mFile( 0 ),
mStream( 0 ),
mUseWatcher( false ),
mUseWatcher( true ),
mWatcher( 0 ),
mDefinitionValid( false ),
mUseHeader( true ),
Expand Down Expand Up @@ -106,7 +106,7 @@ bool QgsDelimitedTextFile::open()
mMaxRecordNumber = -1;
mHoldCurrentRecord = false;
if ( mWatcher ) delete mWatcher;
if( mUseWatcher )
if ( mUseWatcher )
{
mWatcher = new QFileSystemWatcher( this );
mWatcher->addPath( mFileName );
Expand Down Expand Up @@ -153,9 +153,9 @@ bool QgsDelimitedTextFile::setFromUrl( QUrl &url )
}

//
if ( url.hasQueryItem( "watchFile" ) )
if ( url.hasQueryItem( "useWatcher" ) )
{
mUseWatcher = ! url.queryItemValue( "watchFile" ).toUpper().startsWith( 'N' );;
mUseWatcher = ! url.queryItemValue( "useWatcher" ).toUpper().startsWith( 'N' );;
}

// The default type is csv, to be consistent with the
Expand Down Expand Up @@ -264,7 +264,10 @@ QUrl QgsDelimitedTextFile::url()
url.addQueryItem( "encoding", mEncoding );
}

if( mUseWatcher ) url.addQueryItem( "watchFile", "yes");
if ( !mUseWatcher )
{
url.addQueryItem( "useWatcher", "no" );
}

url.addQueryItem( "type", type() );
if ( mType == DelimTypeRegexp )
Expand Down Expand Up @@ -312,7 +315,7 @@ void QgsDelimitedTextFile::setEncoding( QString encoding )
mEncoding = encoding;
}

void QgsDelimitedTextFile::setUseWatcher(bool useWatcher)
void QgsDelimitedTextFile::setUseWatcher( bool useWatcher )
{
resetDefinition();
mUseWatcher = useWatcher;
Expand Down Expand Up @@ -496,10 +499,10 @@ int QgsDelimitedTextFile::fieldIndex( QString name )

}

bool QgsDelimitedTextFile::setNextRecordId(long nextRecordId )
bool QgsDelimitedTextFile::setNextRecordId( long nextRecordId )
{
mHoldCurrentRecord = nextRecordId == mRecordLineNumber;
if( mHoldCurrentRecord ) return true;
if ( mHoldCurrentRecord ) return true;
return setNextLineNumber( nextRecordId );
}

Expand All @@ -509,7 +512,7 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::nextRecord( QStringList &reco
record.clear();
Status status = RecordOk;

if( mHoldCurrentRecord )
if ( mHoldCurrentRecord )
{
mHoldCurrentRecord = false;
}
Expand All @@ -530,11 +533,11 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::nextRecord( QStringList &reco
mRecordNumber++;
if ( mRecordNumber > mMaxRecordNumber ) mMaxRecordNumber = mRecordNumber;
}
status = (this->*mParser )( buffer, mCurrentRecord );
status = ( this->*mParser )( buffer, mCurrentRecord );
}
if( status == RecordOk )
if ( status == RecordOk )
{
record.append(mCurrentRecord);
record.append( mCurrentRecord );
}
return status;
}
Expand Down Expand Up @@ -565,7 +568,7 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::reset()
result = nextRecord( names );
setFieldNames( names );
}
if( result == RecordOk ) mRecordNumber = 0;
if ( result == RecordOk ) mRecordNumber = 0;
return result;
}

Expand Down Expand Up @@ -593,16 +596,16 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::nextLine( QString &buffer, bo
bool QgsDelimitedTextFile::setNextLineNumber( long nextLineNumber )
{
if ( ! mStream ) return false;
if ( mLineNumber > nextLineNumber-1 )
if ( mLineNumber > nextLineNumber - 1 )
{
mRecordNumber = -1;
mStream->seek(0);
mStream->seek( 0 );
mLineNumber = 0;
}
QString buffer;
while( mLineNumber < nextLineNumber-1 )
while ( mLineNumber < nextLineNumber - 1 )
{
if( nextLine(buffer,false) != RecordOk ) return false;
if ( nextLine( buffer, false ) != RecordOk ) return false;
}
return true;

Expand Down
20 changes: 10 additions & 10 deletions src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )

void QgsDelimitedTextProvider::resetCachedSubset()
{
mCachedSubsetString=QString();
mCachedSubsetString = QString();
mCachedUseSubsetIndex = false;
mCachedUseSpatialIndex = false;
}
Expand Down Expand Up @@ -755,8 +755,8 @@ bool QgsDelimitedTextProvider::setSubsetString( QString subset, bool updateFeatu
{
// If not changing string, then oll ok, nothing to do

if( subset.isNull() ) subset="";
if( subset == mSubsetString ) return true;
if ( subset.isNull() ) subset = "";
if ( subset == mSubsetString ) return true;

bool valid = true;

Expand Down Expand Up @@ -814,16 +814,16 @@ bool QgsDelimitedTextProvider::setSubsetString( QString subset, bool updateFeatu

if ( updateFeatureCount )
{
if( ! mCachedSubsetString.isNull() && mSubsetString == mCachedSubsetString )
if ( ! mCachedSubsetString.isNull() && mSubsetString == mCachedSubsetString )
{
QgsDebugMsg(QString("DelimitedText: Resetting cached subset string %1").arg(mSubsetString));
QgsDebugMsg( QString( "DelimitedText: Resetting cached subset string %1" ).arg( mSubsetString ) );
mUseSpatialIndex = mCachedUseSpatialIndex;
mUseSubsetIndex = mCachedUseSubsetIndex;
resetCachedSubset();
}
else
{
QgsDebugMsg(QString("DelimitedText: Setting new subset string %1").arg(mSubsetString));
QgsDebugMsg( QString( "DelimitedText: Setting new subset string %1" ).arg( mSubsetString ) );
// Reset the subset index
rescanFile();
// Encode the subset string into the data source URI.
Expand All @@ -833,11 +833,11 @@ bool QgsDelimitedTextProvider::setSubsetString( QString subset, bool updateFeatu
else
{
// If not already using temporary subset, then cache the current subset
QgsDebugMsg(QString("DelimitedText: Setting temporary subset string %1").arg(mSubsetString));
if( mCachedSubsetString.isNull() )
QgsDebugMsg( QString( "DelimitedText: Setting temporary subset string %1" ).arg( mSubsetString ) );
if ( mCachedSubsetString.isNull() )
{
QgsDebugMsg(QString("DelimitedText: Caching previous subset %1").arg(previousSubset));
mCachedSubsetString=previousSubset;
QgsDebugMsg( QString( "DelimitedText: Caching previous subset %1" ).arg( previousSubset ) );
mCachedSubsetString = previousSubset;
mCachedUseSpatialIndex = mUseSpatialIndex;
mCachedUseSubsetIndex = mUseSubsetIndex;
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/delimitedtext/qgsdelimitedtextprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class QgsDelimitedTextProvider : public QgsVectorDataProvider
QgsGeometry* loadGeometryXY( const QStringList& tokens, QgsDelimitedTextFeatureIterator *iterator );
void fetchAttribute( QgsFeature& feature, int fieldIdx, const QStringList& tokens );
void setUriParameter( QString parameter, QString value );
bool setNextFeatureId( qint64 fid ) { return mFile->setNextRecordId( (long) fid ); }
bool setNextFeatureId( qint64 fid ) { return mFile->setNextRecordId(( long ) fid ); }


QgsGeometry *geomFromWkt( QString &sWkt );
Expand Down
28 changes: 14 additions & 14 deletions src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget * parent, Qt
buttonBox->button( QDialogButtonBox::Ok )->hide();
}

bgFileFormat=new QButtonGroup(this);
bgFileFormat->addButton(delimiterCSV,swFileFormat->indexOf( swpCSVOptions));
bgFileFormat->addButton(delimiterChars,swFileFormat->indexOf( swpDelimOptions));
bgFileFormat->addButton(delimiterRegexp,swFileFormat->indexOf( swpRegexpOptions));
bgFileFormat = new QButtonGroup( this );
bgFileFormat->addButton( delimiterCSV, swFileFormat->indexOf( swpCSVOptions ) );
bgFileFormat->addButton( delimiterChars, swFileFormat->indexOf( swpDelimOptions ) );
bgFileFormat->addButton( delimiterRegexp, swFileFormat->indexOf( swpRegexpOptions ) );

bgGeomType=new QButtonGroup(this);
bgGeomType->addButton(geomTypeXY,swGeomType->indexOf( swpGeomXY));
bgGeomType->addButton(geomTypeWKT,swGeomType->indexOf( swpGeomWKT));
bgGeomType->addButton(geomTypeNone,swGeomType->indexOf( swpGeomNone));
bgGeomType = new QButtonGroup( this );
bgGeomType->addButton( geomTypeXY, swGeomType->indexOf( swpGeomXY ) );
bgGeomType->addButton( geomTypeWKT, swGeomType->indexOf( swpGeomWKT ) );
bgGeomType->addButton( geomTypeNone, swGeomType->indexOf( swpGeomNone ) );

connect( bgFileFormat, SIGNAL(buttonClicked(int)), swFileFormat, SLOT(setCurrentIndex(int)));
connect( bgGeomType, SIGNAL(buttonClicked(int)),swGeomType,SLOT(setCurrentIndex(int)));
connect( bgFileFormat, SIGNAL( buttonClicked( int ) ), swFileFormat, SLOT( setCurrentIndex( int ) ) );
connect( bgGeomType, SIGNAL( buttonClicked( int ) ), swGeomType, SLOT( setCurrentIndex( int ) ) );

cmbEncoding->clear();
cmbEncoding->addItems( QgsVectorDataProvider::availableEncodings() );
Expand Down Expand Up @@ -187,7 +187,7 @@ void QgsDelimitedTextSourceSelect::on_buttonBox_accepted()
url.addQueryItem( "geomType", "none" );
}

if( ! geomTypeNone->isChecked()) url.addQueryItem( "spatialIndex", cbxSpatialIndex->isChecked() ? "yes" : "no" );
if ( ! geomTypeNone->isChecked() ) url.addQueryItem( "spatialIndex", cbxSpatialIndex->isChecked() ? "yes" : "no" );
url.addQueryItem( "subsetIndex", cbxSubsetIndex->isChecked() ? "yes" : "no" );
url.addQueryItem( "watchFile", cbxWatchFile->isChecked() ? "yes" : "no" );

Expand Down Expand Up @@ -317,9 +317,9 @@ void QgsDelimitedTextSourceSelect::saveSettings( QString subkey, bool saveGeomSe
settings.setValue( key + "/trimFields", cbxTrimFields->isChecked() ? "true" : "false" );
settings.setValue( key + "/skipEmptyFields", cbxSkipEmptyFields->isChecked() ? "true" : "false" );
settings.setValue( key + "/decimalPoint", cbxPointIsComma->isChecked() ? "," : "." );
settings.setValue( key + "/subsetIndex", cbxSubsetIndex->isChecked() ? "true" : "false");
settings.setValue( key + "/spatialIndex", cbxSpatialIndex->isChecked() ? "true" : "false");
settings.setValue( key + "/watchFile", cbxWatchFile->isChecked() ? "true" : "false");
settings.setValue( key + "/subsetIndex", cbxSubsetIndex->isChecked() ? "true" : "false" );
settings.setValue( key + "/spatialIndex", cbxSpatialIndex->isChecked() ? "true" : "false" );
settings.setValue( key + "/watchFile", cbxWatchFile->isChecked() ? "true" : "false" );
if ( saveGeomSettings )
{
QString geomColumnType = "none";
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wms/qgswmssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ bool QgsWMSSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider )
}
else
{
lstTilesets->setRowCount( 0 );
lstTilesets->setRowCount( 0 );
}

// If we got some layers, let the user add them to the map
Expand Down
56 changes: 28 additions & 28 deletions tests/src/python/test_qgsdelimitedtextprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def delimitedTextData( testname, filename, requests, verbose, **params ):

def printWanted( testname, result ):
# Routine to export the result as a function definition
print
print
print "def {0}():".format(testname)
data=result['data']
log=result['log']
Expand Down Expand Up @@ -470,8 +470,8 @@ def test_024_filter_rect_xy(self):
filename='testextpt.txt'
params={'yField': 'y', 'delimiter': '|', 'type': 'csv', 'xField': 'x'}
requests=[
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [110, 130, 130, 150]}]
runTest(filename,requests,**params)

Expand All @@ -480,8 +480,8 @@ def test_025_filter_rect_wkt(self):
filename='testextw.txt'
params={'delimiter': '|', 'type': 'csv', 'wktField': 'wkt'}
requests=[
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [110, 130, 130, 150]}]
runTest(filename,requests,**params)

Expand All @@ -490,9 +490,9 @@ def test_026_filter_fid(self):
filename='test.csv'
params={'geomType': 'none', 'type': 'csv'}
requests=[
{'fid': 3},
{'fid': 9},
{'fid': 20},
{'fid': 3},
{'fid': 9},
{'fid': 20},
{'fid': 3}]
runTest(filename,requests,**params)

Expand All @@ -501,11 +501,11 @@ def test_027_filter_attributes(self):
filename='test.csv'
params={'geomType': 'none', 'type': 'csv'}
requests=[
{'attributes': [1, 3]},
{'fid': 9},
{'attributes': [1, 3], 'fid': 9},
{'attributes': [3, 1], 'fid': 9},
{'attributes': [1, 3, 7], 'fid': 9},
{'attributes': [1, 3]},
{'fid': 9},
{'attributes': [1, 3], 'fid': 9},
{'attributes': [3, 1], 'fid': 9},
{'attributes': [1, 3, 7], 'fid': 9},
{'attributes': [], 'fid': 9}]
runTest(filename,requests,**params)

Expand Down Expand Up @@ -534,20 +534,20 @@ def deletefile( layer ):
os.remove(filename)
params={'geomType': 'none', 'type': 'csv', 'watchFile' : 'yes' }
requests=[
{'fid': 3},
{'fid': 3},
{},
{'fid': 7},
{'fid': 7},
updatefile1,
{'fid': 3},
{'fid': 4},
{'fid': 3},
{'fid': 4},
{},
{'fid': 7},
{'fid': 7},
updatefile2,
{'fid': 2},
{'fid': 2},
{},
{'fid': 7},
{'fid': 7},
deletefile,
{'fid': 2},
{'fid': 2},
{},
]
runTest(filename,requests,**params)
Expand All @@ -557,8 +557,8 @@ def test_030_filter_rect_xy_spatial_index(self):
filename='testextpt.txt'
params={'yField': 'y', 'delimiter': '|', 'type': 'csv', 'xField': 'x', 'spatialIndex': 'Y' }
requests=[
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [110, 130, 130, 150]},
{},
{'extents': [-1000, -1000, 1000, 1000]}
Expand All @@ -570,8 +570,8 @@ def test_031_filter_rect_wkt_spatial_index(self):
filename='testextw.txt'
params={'delimiter': '|', 'type': 'csv', 'wktField': 'wkt', 'spatialIndex': 'Y' }
requests=[
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [110, 130, 130, 150]},
{},
{'extents': [-1000, -1000, 1000, 1000]}
Expand All @@ -583,11 +583,11 @@ def test_032_filter_rect_wkt_create_spatial_index(self):
filename='testextw.txt'
params={'delimiter': '|', 'type': 'csv', 'wktField': 'wkt' }
requests=[
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50]},
{},
lambda layer: layer.dataProvider().createSpatialIndex(),
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [10, 30, 30, 50]},
{'extents': [10, 30, 30, 50], 'exact': 1},
{'extents': [110, 130, 130, 150]},
{},
{'extents': [-1000, -1000, 1000, 1000]}
Expand Down