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
pcav committed Apr 15, 2012
2 parents 8f6d941 + 9da981b commit e51dd2c
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 28 deletions.
2 changes: 1 addition & 1 deletion doc/TRANSLATORS
@@ -1,7 +1,7 @@
<style>table {font-size:80%;}th {text-align:left; }.bartodo{ background-color:red;width:100px;height:20px;}.bardone{ background-color:green;width:80px;height:20px;font-size:80%;text-align:center;padding-top:4px;height:16px;color:white;}</style><table><tr><th colspan="2" style="width:250px;">Language</th><th>Finished %</th><th>Translators</th></tr>

<tr><td><img src="qrc:/images/flags/de.png"></td><td>German</td><td><div class="bartodo"><div class="bardone" style="width:99.9px">99.9</div></div></td><td>Jürgen E. Fischer, Stephan Holl, Otto Dassau, Werner Macho</tr></tr>
<tr><td><img src="qrc:/images/flags/et.png"></td><td>Estonian</td><td><div class="bartodo"><div class="bardone" style="width:99.9px">99.9</div></div></td><td>Veiko Viil</tr></tr>
<tr><td><img src="qrc:/images/flags/et_EE.png"></td><td>Estonian (Estonia)</td><td><div class="bartodo"><div class="bardone" style="width:99.9px">99.9</div></div></td><td>Veiko Viil</tr></tr>
<tr><td><img src="qrc:/images/flags/es.png"></td><td>Spanish</td><td><div class="bartodo"><div class="bardone" style="width:99.1px">99.1</div></div></td><td>Carlos Dávila, Javier César Aldariz, Gabriela Awad, Edwin Amado, Mayeul Kauffmann</tr></tr>
<tr><td><img src="qrc:/images/flags/hu.png"></td><td>Hungarian</td><td><div class="bartodo"><div class="bardone" style="width:96.6px">96.6</div></div></td><td>Zoltan Siki</tr></tr>
<tr><td><img src="qrc:/images/flags/fr.png"></td><td>French</td><td><div class="bartodo"><div class="bardone" style="width:96.6px">96.6</div></div></td><td>Eve Rousseau, Marc Monnerat, Lionel Roubeyrie, Jean Roc Morreale, Benjamin Bohard, Jeremy Garniaux, Yves Jacolin, Benjamin Lerre, Stéphane Morel, Marie Silvestre, Tahir Tamba, Xavier M, Mayeul Kauffmann, Mehdi Semchaoui</tr></tr>
Expand Down
File renamed without changes.
Binary file removed images/flags/et.png
Binary file not shown.
Binary file added images/flags/et_EE.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion images/images.qrc
Expand Up @@ -386,7 +386,6 @@
<file>flags/de.png</file>
<file>flags/el_GR.png</file>
<file>flags/es.png</file>
<file>flags/et.png</file>
<file>flags/fa.png</file>
<file>flags/fi.png</file>
<file>flags/fr.png</file>
Expand Down Expand Up @@ -426,6 +425,7 @@
<file>flags/zh_TW.png</file>
<file>flags/en_US.png</file>
<file>flags/da_DK.png</file>
<file>flags/et_EE.png</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
2 changes: 1 addition & 1 deletion scripts/tsstat.pl
Expand Up @@ -29,7 +29,7 @@
de => 'Jürgen E. Fischer, Stephan Holl, Otto Dassau, Werner Macho',
es => 'Carlos Dávila, Javier César Aldariz, Gabriela Awad, Edwin Amado, Mayeul Kauffmann',
el_GR => 'Evripidis Argyropoulos, Mike Pegnigiannis, Nikos Ves',
et => 'Veiko Viil',
et_EE => 'Veiko Viil',
fa => 'Mola Pahnadayan',
fi => 'Marko Jarvenpaa',
fr => 'Eve Rousseau, Marc Monnerat, Lionel Roubeyrie, Jean Roc Morreale, Benjamin Bohard, Jeremy Garniaux, Yves Jacolin, Benjamin Lerre, Stéphane Morel, Marie Silvestre, Tahir Tamba, Xavier M, Mayeul Kauffmann, Mehdi Semchaoui',
Expand Down
2 changes: 1 addition & 1 deletion src/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -1866,7 +1866,7 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int theBandNo )
{
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
QgsRasterBandStats myRasterBandStats;
int bApproxOK = false;
int bApproxOK = true;
double pdfMin;
double pdfMax;
double pdfMean;
Expand Down
28 changes: 28 additions & 0 deletions src/providers/postgres/qgspostgresdataitems.cpp
Expand Up @@ -8,6 +8,8 @@

#include <QMessageBox>

QGISEXTERN bool deleteLayer( const QString& uri, QString& errCause );

// ---------------------------------------------------------------------------
QgsPGConnectionItem::QgsPGConnectionItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
Expand Down Expand Up @@ -237,6 +239,32 @@ QgsPGLayerItem::~QgsPGLayerItem()
{
}

QList<QAction*> QgsPGLayerItem::actions()
{
QList<QAction*> lst;

QAction* actionDeleteLayer = new QAction( tr( "Delete layer" ), this );
connect( actionDeleteLayer, SIGNAL( triggered() ), this, SLOT( deleteLayer() ) );
lst.append( actionDeleteLayer );

return lst;
}

void QgsPGLayerItem::deleteLayer()
{
QString errCause;
bool res = ::deleteLayer( mUri, errCause );
if ( !res )
{
QMessageBox::warning( 0, tr( "Delete layer" ), errCause );
}
else
{
QMessageBox::information( 0, tr( "Delete layer" ), tr( "Layer deleted successfully." ) );
mParent->refresh();
}
}

QString QgsPGLayerItem::createUri()
{
QString pkColName = mLayerProperty.pkCols.size() > 0 ? mLayerProperty.pkCols.at( 0 ) : QString::null;
Expand Down
5 changes: 5 additions & 0 deletions src/providers/postgres/qgspostgresdataitems.h
Expand Up @@ -83,6 +83,11 @@ class QgsPGLayerItem : public QgsLayerItem

QString createUri();

virtual QList<QAction*> actions();

public slots:
void deleteLayer();

private:
QgsPostgresLayerProperty mLayerProperty;
};
Expand Down
79 changes: 76 additions & 3 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -2934,9 +2934,9 @@ QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer(
}
schemaTableName += quotedIdentifier( tableName );

QgsDebugMsg( QString( "Connection info is " ).arg( dsUri.connectionInfo() ) );
QgsDebugMsg( QString( "Geometry column is: " ).arg( geometryColumn ) );
QgsDebugMsg( QString( "Schema is: " ).arg( schemaName ) );
QgsDebugMsg( QString( "Connection info is: %1" ).arg( dsUri.connectionInfo() ) );
QgsDebugMsg( QString( "Geometry column is: %1" ).arg( geometryColumn ) );
QgsDebugMsg( QString( "Schema is: %1" ).arg( schemaName ) );
QgsDebugMsg( QString( "Table name is: %1" ).arg( tableName ) );

// create the table
Expand Down Expand Up @@ -3248,3 +3248,76 @@ QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(
oldToNewAttrIdxMap, errorMessage, options
);
}

QGISEXTERN bool deleteLayer( const QString& uri, QString& errCause )
{
QgsDebugMsg( "deleting layer " + uri );

QgsDataSourceURI dsUri( uri );
QString schemaName = dsUri.schema();
QString tableName = dsUri.table();
QString geometryCol = dsUri.geometryColumn();

QString schemaTableName;
if ( !schemaName.isEmpty() )
{
schemaTableName = QgsPostgresConn::quotedIdentifier( schemaName ) + ".";
}
schemaTableName += QgsPostgresConn::quotedIdentifier( tableName );

QgsPostgresConn* conn = QgsPostgresConn::connectDb( dsUri.connectionInfo(), false );
if ( !conn )
{
errCause = QObject::tr( "Connection to database failed" );
return false;
}

// check the geometry column count
QString sql = QString( "SELECT count(*) "
"FROM geometry_columns, pg_class, pg_namespace "
"WHERE f_table_name=relname AND f_table_schema=nspname "
"AND pg_class.relnamespace=pg_namespace.oid "
"AND f_table_schema=%1 AND f_table_name=%2" )
.arg( QgsPostgresConn::quotedValue( schemaName ) )
.arg( QgsPostgresConn::quotedValue( tableName ) );
QgsPostgresResult result = conn->PQexec( sql );
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
{
errCause = QObject::tr( "Unable to delete layer %1: \n%2" )
.arg( schemaTableName )
.arg( result.PQresultErrorMessage() );
conn->disconnect();
return false;
}

int count = result.PQgetvalue( 0, 0 ).toInt();

if ( !geometryCol.isEmpty() && count > 1 )
{
// the table has more geometry columns, drop just the geometry column
sql = QString( "SELECT DropGeometryColumn(%1,%2,%3)" )
.arg( QgsPostgresConn::quotedValue( schemaName ) )
.arg( QgsPostgresConn::quotedValue( tableName ) )
.arg( QgsPostgresConn::quotedValue( geometryCol ) );
}
else
{
// drop the table
sql = QString( "SELECT DropGeometryTable(%1,%2)" )
.arg( QgsPostgresConn::quotedValue( schemaName ) )
.arg( QgsPostgresConn::quotedValue( tableName ) );
}

result = conn->PQexec( sql );
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
{
errCause = QObject::tr( "Unable to delete layer %1: \n%2" )
.arg( schemaTableName )
.arg( result.PQresultErrorMessage() );
conn->disconnect();
return false;
}

conn->disconnect();
return true;
}
54 changes: 34 additions & 20 deletions tests/src/core/qgsrenderchecker.cpp
Expand Up @@ -23,6 +23,7 @@
#include <QCryptographicHash>
#include <QByteArray>
#include <QDebug>
#include <QBuffer>

QgsRenderChecker::QgsRenderChecker( ) :
mReport( "" ),
Expand Down Expand Up @@ -52,7 +53,20 @@ void QgsRenderChecker::setControlName(const QString theName)
+ theName + ".png";
}

bool QgsRenderChecker::isKnownAnomaly( QImage theDifferenceImage )
QString QgsRenderChecker::imageToHash( QString theImageFile )
{
QImage myImage;
myImage.load( theImageFile );
QByteArray myByteArray;
QBuffer myBuffer( &myByteArray );
myImage.save(&myBuffer, "PNG");
QString myImageString = QString::fromUtf8( myByteArray.toBase64().data() );
QCryptographicHash myHash( QCryptographicHash::Md5 );
myHash.addData(myImageString.toUtf8());
return myHash.result().toHex().constData();
}

bool QgsRenderChecker::isKnownAnomaly( QString theDiffImageFile )
{
QString myControlImageDir = controlImagePath() + mControlName
+ QDir::separator();
Expand All @@ -64,32 +78,32 @@ bool QgsRenderChecker::isKnownAnomaly( QImage theDifferenceImage )
//remove the control file from teh list as the anomalies are
//all files except the control file
myList.removeAt(myList.indexOf(mExpectedImageFile));
//todo compare each hash to diff path
QByteArray myData((const char*)theDifferenceImage.bits(),
theDifferenceImage.numBytes());
QByteArray mySourceHash = QCryptographicHash::hash(
myData, QCryptographicHash::Md5);

QString myImageHash = imageToHash( theDiffImageFile );


for (int i = 0; i < myList.size(); ++i)
{
QString myFile = myList.at(i);
mReport += "<tr><td colspan=3>"
"Checking if " + myFile + " is a known anomaly.";
mReport += "</td></tr>";
QImage myAnomalyImage( myFile );
QByteArray myData((const char*)myAnomalyImage.bits(),
myAnomalyImage.numBytes());
QByteArray myAnomolyHash = QCryptographicHash::hash(
myData, QCryptographicHash::Md5);
QString myHashMessage = QString("Source image hash %1 : Anomaly hash: %2").arg(
QString(mySourceHash.toHex())).arg(QString(myAnomolyHash.toHex()));
//fro CDash
QString myAnomalyHash = imageToHash( controlImagePath() + mControlName
+ QDir::separator() + myFile );
QString myHashMessage = QString(
"Checking if anomaly %1 (hash %2)")
.arg( myFile )
.arg( myAnomalyHash );
myHashMessage += QString( " matches %1 (hash %2)" )
.arg( theDiffImageFile )
.arg( myImageHash );
//foo CDash
QString myMeasureMessage = "<DartMeasurement name=\"Anomoly check"
"\" type=\"text/text\">" + myHashMessage +
"</DartMeasurement>";
qDebug() << myMeasureMessage;
mReport += "<tr><td colspan=3>" + myHashMessage + "</td></tr>";
if ( mySourceHash.toHex() == myAnomolyHash.toHex() )
if ( myImageHash == myAnomalyHash )
{
mReport += "<tr><td colspan=3>"
"Anomaly found! " + myFile;
Expand Down Expand Up @@ -179,7 +193,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
QImage myDifferenceImage( myExpectedImage.width(),
myExpectedImage.height(),
QImage::Format_RGB32 );
QString myResultDiffImage = QDir::tempPath() + QDir::separator() +
QString myDiffImageFile = QDir::tempPath() + QDir::separator() +
QDir::separator() +
theTestName + "_result_diff.png";
myDifferenceImage.fill( qRgb( 152, 219, 249 ) );
Expand Down Expand Up @@ -213,7 +227,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
"\"></td>\n<td><img src=\"file://" +
mExpectedImageFile +
"\"></td><td><img src=\"file://" +
myResultDiffImage +
myDiffImageFile +
"\"></td>\n</tr>\n</table>";
//
// To get the images into CDash
Expand All @@ -224,7 +238,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
"<DartMeasurementFile name=\"Expected Image\" type=\"image/png\">" +
mExpectedImageFile + "</DartMeasurementFile>"
"<DartMeasurementFile name=\"Difference Image\" type=\"image/png\">" +
myResultDiffImage + "</DartMeasurementFile>";
myDiffImageFile + "</DartMeasurementFile>";
qDebug( ) << myDashMessage;

//
Expand Down Expand Up @@ -266,7 +280,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
//
//save the diff image to disk
//
myDifferenceImage.save( myResultDiffImage );
myDifferenceImage.save( myDiffImageFile );

//
// Send match result to debug
Expand All @@ -293,7 +307,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
"</DartMeasurement>";
qDebug( ) << myDashMessage;

bool myAnomalyMatchFlag = isKnownAnomaly( myDifferenceImage );
bool myAnomalyMatchFlag = isKnownAnomaly( myDiffImageFile );

if ( myAnomalyMatchFlag )
{
Expand Down
5 changes: 4 additions & 1 deletion tests/src/core/qgsrenderchecker.h
Expand Up @@ -49,6 +49,9 @@ class QgsRenderChecker
* controlImagePath + '/' + mControlName + '/' + mControlName + '.png'
*/
void setControlName(const QString theName);
/** Get an md5 hash that uniquely identifies an image */
QString imageToHash( QString theImageFile );

void setRenderedImage (QString theImageFileName) { mRenderedImageFile = theImageFileName; };
void setMapRenderer ( QgsMapRenderer * thepMapRenderer) { mpMapRenderer = thepMapRenderer; };
/**
Expand Down Expand Up @@ -81,7 +84,7 @@ class QgsRenderChecker
* acceptible.
* @return a bool indicating if the diff matched one of the anomaly files
*/
bool isKnownAnomaly( QImage theDifferenceImage );
bool isKnownAnomaly( QString theDiffImageFile );

private:

Expand Down

0 comments on commit e51dd2c

Please sign in to comment.