Skip to content

Commit e51dd2c

Browse files
committedApr 15, 2012
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents 8f6d941 + 9da981b commit e51dd2c

File tree

12 files changed

+151
-28
lines changed

12 files changed

+151
-28
lines changed
 

‎doc/TRANSLATORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<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>
22

33
<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>
4-
<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>
4+
<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>
55
<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>
66
<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>
77
<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>
File renamed without changes.

‎images/flags/et.png

-592 Bytes
Binary file not shown.

‎images/flags/et_EE.png

429 Bytes
Loading

‎images/images.qrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@
386386
<file>flags/de.png</file>
387387
<file>flags/el_GR.png</file>
388388
<file>flags/es.png</file>
389-
<file>flags/et.png</file>
390389
<file>flags/fa.png</file>
391390
<file>flags/fi.png</file>
392391
<file>flags/fr.png</file>
@@ -426,6 +425,7 @@
426425
<file>flags/zh_TW.png</file>
427426
<file>flags/en_US.png</file>
428427
<file>flags/da_DK.png</file>
428+
<file>flags/et_EE.png</file>
429429
</qresource>
430430
<qresource prefix="/images/tips">
431431
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>

‎scripts/tsstat.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
de => 'Jürgen E. Fischer, Stephan Holl, Otto Dassau, Werner Macho',
3030
es => 'Carlos Dávila, Javier César Aldariz, Gabriela Awad, Edwin Amado, Mayeul Kauffmann',
3131
el_GR => 'Evripidis Argyropoulos, Mike Pegnigiannis, Nikos Ves',
32-
et => 'Veiko Viil',
32+
et_EE => 'Veiko Viil',
3333
fa => 'Mola Pahnadayan',
3434
fi => 'Marko Jarvenpaa',
3535
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',

‎src/providers/gdal/qgsgdalprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,7 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int theBandNo )
18661866
{
18671867
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
18681868
QgsRasterBandStats myRasterBandStats;
1869-
int bApproxOK = false;
1869+
int bApproxOK = true;
18701870
double pdfMin;
18711871
double pdfMax;
18721872
double pdfMean;

‎src/providers/postgres/qgspostgresdataitems.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <QMessageBox>
1010

11+
QGISEXTERN bool deleteLayer( const QString& uri, QString& errCause );
12+
1113
// ---------------------------------------------------------------------------
1214
QgsPGConnectionItem::QgsPGConnectionItem( QgsDataItem* parent, QString name, QString path )
1315
: QgsDataCollectionItem( parent, name, path )
@@ -237,6 +239,32 @@ QgsPGLayerItem::~QgsPGLayerItem()
237239
{
238240
}
239241

242+
QList<QAction*> QgsPGLayerItem::actions()
243+
{
244+
QList<QAction*> lst;
245+
246+
QAction* actionDeleteLayer = new QAction( tr( "Delete layer" ), this );
247+
connect( actionDeleteLayer, SIGNAL( triggered() ), this, SLOT( deleteLayer() ) );
248+
lst.append( actionDeleteLayer );
249+
250+
return lst;
251+
}
252+
253+
void QgsPGLayerItem::deleteLayer()
254+
{
255+
QString errCause;
256+
bool res = ::deleteLayer( mUri, errCause );
257+
if ( !res )
258+
{
259+
QMessageBox::warning( 0, tr( "Delete layer" ), errCause );
260+
}
261+
else
262+
{
263+
QMessageBox::information( 0, tr( "Delete layer" ), tr( "Layer deleted successfully." ) );
264+
mParent->refresh();
265+
}
266+
}
267+
240268
QString QgsPGLayerItem::createUri()
241269
{
242270
QString pkColName = mLayerProperty.pkCols.size() > 0 ? mLayerProperty.pkCols.at( 0 ) : QString::null;

‎src/providers/postgres/qgspostgresdataitems.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ class QgsPGLayerItem : public QgsLayerItem
8383

8484
QString createUri();
8585

86+
virtual QList<QAction*> actions();
87+
88+
public slots:
89+
void deleteLayer();
90+
8691
private:
8792
QgsPostgresLayerProperty mLayerProperty;
8893
};

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,9 +2934,9 @@ QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer(
29342934
}
29352935
schemaTableName += quotedIdentifier( tableName );
29362936

2937-
QgsDebugMsg( QString( "Connection info is " ).arg( dsUri.connectionInfo() ) );
2938-
QgsDebugMsg( QString( "Geometry column is: " ).arg( geometryColumn ) );
2939-
QgsDebugMsg( QString( "Schema is: " ).arg( schemaName ) );
2937+
QgsDebugMsg( QString( "Connection info is: %1" ).arg( dsUri.connectionInfo() ) );
2938+
QgsDebugMsg( QString( "Geometry column is: %1" ).arg( geometryColumn ) );
2939+
QgsDebugMsg( QString( "Schema is: %1" ).arg( schemaName ) );
29402940
QgsDebugMsg( QString( "Table name is: %1" ).arg( tableName ) );
29412941

29422942
// create the table
@@ -3248,3 +3248,76 @@ QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(
32483248
oldToNewAttrIdxMap, errorMessage, options
32493249
);
32503250
}
3251+
3252+
QGISEXTERN bool deleteLayer( const QString& uri, QString& errCause )
3253+
{
3254+
QgsDebugMsg( "deleting layer " + uri );
3255+
3256+
QgsDataSourceURI dsUri( uri );
3257+
QString schemaName = dsUri.schema();
3258+
QString tableName = dsUri.table();
3259+
QString geometryCol = dsUri.geometryColumn();
3260+
3261+
QString schemaTableName;
3262+
if ( !schemaName.isEmpty() )
3263+
{
3264+
schemaTableName = QgsPostgresConn::quotedIdentifier( schemaName ) + ".";
3265+
}
3266+
schemaTableName += QgsPostgresConn::quotedIdentifier( tableName );
3267+
3268+
QgsPostgresConn* conn = QgsPostgresConn::connectDb( dsUri.connectionInfo(), false );
3269+
if ( !conn )
3270+
{
3271+
errCause = QObject::tr( "Connection to database failed" );
3272+
return false;
3273+
}
3274+
3275+
// check the geometry column count
3276+
QString sql = QString( "SELECT count(*) "
3277+
"FROM geometry_columns, pg_class, pg_namespace "
3278+
"WHERE f_table_name=relname AND f_table_schema=nspname "
3279+
"AND pg_class.relnamespace=pg_namespace.oid "
3280+
"AND f_table_schema=%1 AND f_table_name=%2" )
3281+
.arg( QgsPostgresConn::quotedValue( schemaName ) )
3282+
.arg( QgsPostgresConn::quotedValue( tableName ) );
3283+
QgsPostgresResult result = conn->PQexec( sql );
3284+
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
3285+
{
3286+
errCause = QObject::tr( "Unable to delete layer %1: \n%2" )
3287+
.arg( schemaTableName )
3288+
.arg( result.PQresultErrorMessage() );
3289+
conn->disconnect();
3290+
return false;
3291+
}
3292+
3293+
int count = result.PQgetvalue( 0, 0 ).toInt();
3294+
3295+
if ( !geometryCol.isEmpty() && count > 1 )
3296+
{
3297+
// the table has more geometry columns, drop just the geometry column
3298+
sql = QString( "SELECT DropGeometryColumn(%1,%2,%3)" )
3299+
.arg( QgsPostgresConn::quotedValue( schemaName ) )
3300+
.arg( QgsPostgresConn::quotedValue( tableName ) )
3301+
.arg( QgsPostgresConn::quotedValue( geometryCol ) );
3302+
}
3303+
else
3304+
{
3305+
// drop the table
3306+
sql = QString( "SELECT DropGeometryTable(%1,%2)" )
3307+
.arg( QgsPostgresConn::quotedValue( schemaName ) )
3308+
.arg( QgsPostgresConn::quotedValue( tableName ) );
3309+
}
3310+
3311+
result = conn->PQexec( sql );
3312+
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
3313+
{
3314+
errCause = QObject::tr( "Unable to delete layer %1: \n%2" )
3315+
.arg( schemaTableName )
3316+
.arg( result.PQresultErrorMessage() );
3317+
conn->disconnect();
3318+
return false;
3319+
}
3320+
3321+
conn->disconnect();
3322+
return true;
3323+
}

‎tests/src/core/qgsrenderchecker.cpp

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <QCryptographicHash>
2424
#include <QByteArray>
2525
#include <QDebug>
26+
#include <QBuffer>
2627

2728
QgsRenderChecker::QgsRenderChecker( ) :
2829
mReport( "" ),
@@ -52,7 +53,20 @@ void QgsRenderChecker::setControlName(const QString theName)
5253
+ theName + ".png";
5354
}
5455

55-
bool QgsRenderChecker::isKnownAnomaly( QImage theDifferenceImage )
56+
QString QgsRenderChecker::imageToHash( QString theImageFile )
57+
{
58+
QImage myImage;
59+
myImage.load( theImageFile );
60+
QByteArray myByteArray;
61+
QBuffer myBuffer( &myByteArray );
62+
myImage.save(&myBuffer, "PNG");
63+
QString myImageString = QString::fromUtf8( myByteArray.toBase64().data() );
64+
QCryptographicHash myHash( QCryptographicHash::Md5 );
65+
myHash.addData(myImageString.toUtf8());
66+
return myHash.result().toHex().constData();
67+
}
68+
69+
bool QgsRenderChecker::isKnownAnomaly( QString theDiffImageFile )
5670
{
5771
QString myControlImageDir = controlImagePath() + mControlName
5872
+ QDir::separator();
@@ -64,32 +78,32 @@ bool QgsRenderChecker::isKnownAnomaly( QImage theDifferenceImage )
6478
//remove the control file from teh list as the anomalies are
6579
//all files except the control file
6680
myList.removeAt(myList.indexOf(mExpectedImageFile));
67-
//todo compare each hash to diff path
68-
QByteArray myData((const char*)theDifferenceImage.bits(),
69-
theDifferenceImage.numBytes());
70-
QByteArray mySourceHash = QCryptographicHash::hash(
71-
myData, QCryptographicHash::Md5);
81+
82+
QString myImageHash = imageToHash( theDiffImageFile );
83+
7284

7385
for (int i = 0; i < myList.size(); ++i)
7486
{
7587
QString myFile = myList.at(i);
7688
mReport += "<tr><td colspan=3>"
7789
"Checking if " + myFile + " is a known anomaly.";
7890
mReport += "</td></tr>";
79-
QImage myAnomalyImage( myFile );
80-
QByteArray myData((const char*)myAnomalyImage.bits(),
81-
myAnomalyImage.numBytes());
82-
QByteArray myAnomolyHash = QCryptographicHash::hash(
83-
myData, QCryptographicHash::Md5);
84-
QString myHashMessage = QString("Source image hash %1 : Anomaly hash: %2").arg(
85-
QString(mySourceHash.toHex())).arg(QString(myAnomolyHash.toHex()));
86-
//fro CDash
91+
QString myAnomalyHash = imageToHash( controlImagePath() + mControlName
92+
+ QDir::separator() + myFile );
93+
QString myHashMessage = QString(
94+
"Checking if anomaly %1 (hash %2)")
95+
.arg( myFile )
96+
.arg( myAnomalyHash );
97+
myHashMessage += QString( " matches %1 (hash %2)" )
98+
.arg( theDiffImageFile )
99+
.arg( myImageHash );
100+
//foo CDash
87101
QString myMeasureMessage = "<DartMeasurement name=\"Anomoly check"
88102
"\" type=\"text/text\">" + myHashMessage +
89103
"</DartMeasurement>";
90104
qDebug() << myMeasureMessage;
91105
mReport += "<tr><td colspan=3>" + myHashMessage + "</td></tr>";
92-
if ( mySourceHash.toHex() == myAnomolyHash.toHex() )
106+
if ( myImageHash == myAnomalyHash )
93107
{
94108
mReport += "<tr><td colspan=3>"
95109
"Anomaly found! " + myFile;
@@ -179,7 +193,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
179193
QImage myDifferenceImage( myExpectedImage.width(),
180194
myExpectedImage.height(),
181195
QImage::Format_RGB32 );
182-
QString myResultDiffImage = QDir::tempPath() + QDir::separator() +
196+
QString myDiffImageFile = QDir::tempPath() + QDir::separator() +
183197
QDir::separator() +
184198
theTestName + "_result_diff.png";
185199
myDifferenceImage.fill( qRgb( 152, 219, 249 ) );
@@ -213,7 +227,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
213227
"\"></td>\n<td><img src=\"file://" +
214228
mExpectedImageFile +
215229
"\"></td><td><img src=\"file://" +
216-
myResultDiffImage +
230+
myDiffImageFile +
217231
"\"></td>\n</tr>\n</table>";
218232
//
219233
// To get the images into CDash
@@ -224,7 +238,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
224238
"<DartMeasurementFile name=\"Expected Image\" type=\"image/png\">" +
225239
mExpectedImageFile + "</DartMeasurementFile>"
226240
"<DartMeasurementFile name=\"Difference Image\" type=\"image/png\">" +
227-
myResultDiffImage + "</DartMeasurementFile>";
241+
myDiffImageFile + "</DartMeasurementFile>";
228242
qDebug( ) << myDashMessage;
229243

230244
//
@@ -266,7 +280,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
266280
//
267281
//save the diff image to disk
268282
//
269-
myDifferenceImage.save( myResultDiffImage );
283+
myDifferenceImage.save( myDiffImageFile );
270284

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

296-
bool myAnomalyMatchFlag = isKnownAnomaly( myDifferenceImage );
310+
bool myAnomalyMatchFlag = isKnownAnomaly( myDiffImageFile );
297311

298312
if ( myAnomalyMatchFlag )
299313
{

‎tests/src/core/qgsrenderchecker.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class QgsRenderChecker
4949
* controlImagePath + '/' + mControlName + '/' + mControlName + '.png'
5050
*/
5151
void setControlName(const QString theName);
52+
/** Get an md5 hash that uniquely identifies an image */
53+
QString imageToHash( QString theImageFile );
54+
5255
void setRenderedImage (QString theImageFileName) { mRenderedImageFile = theImageFileName; };
5356
void setMapRenderer ( QgsMapRenderer * thepMapRenderer) { mpMapRenderer = thepMapRenderer; };
5457
/**
@@ -81,7 +84,7 @@ class QgsRenderChecker
8184
* acceptible.
8285
* @return a bool indicating if the diff matched one of the anomaly files
8386
*/
84-
bool isKnownAnomaly( QImage theDifferenceImage );
87+
bool isKnownAnomaly( QString theDiffImageFile );
8588

8689
private:
8790

0 commit comments

Comments
 (0)
Please sign in to comment.