Skip to content

Commit

Permalink
misc cleanups:
Browse files Browse the repository at this point in the history
- added Q_OBJECT to various classes where lupdate was complaining
- fix some warnings (mostly potentially uninitialized variables)
- introduce doubleNear(a,b,epsilon) to compare doubles
- fix new composer pagesizes
- cleanup edit type labels in vector properties (marked translation strings,
  synced with qgsattributetypeedit.ui, removed redundant code)
- allow update_ts_files.sh for specified languages
- german translation update



git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11241 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Aug 1, 2009
1 parent f4975c5 commit eccf3a2
Show file tree
Hide file tree
Showing 22 changed files with 435 additions and 415 deletions.
457 changes: 266 additions & 191 deletions i18n/qgis_de.ts

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions scripts/update_ts_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ PATH=$QTDIR/bin:$PATH
#first tar the qt_xx.ts files in i18n folder such that lupdate does not
#merge the qgis strings to them
echo Creating qt_ts.tar
tar -cvf i18n/qt_ts.tar i18n/qt_*.ts
rm i18n/qt_*.ts
tar --remove-files -cvf i18n/qt_ts.tar i18n/qt_*.ts
exclude=
for i in "$@"; do
exclude="$exclude --exclude i18n/qgis_$i.ts"
done
if [ -n "$exclude" ]; then
tar --remove-files -cvf i18n/qgis_ts.tar i18n/qgis_*.ts$exclude
fi
echo Updating python plugin translations
for i in python/plugins/*/.; do
cd $i
Expand All @@ -34,4 +40,9 @@ rm python/plugins/*/python-i18n.cpp i18n/qgis_*.ts.bak
echo Removing qmake project file
rm qgis_ts.pro
echo Unpacking qt_ts.tar
tar -xvf i18n/qt_ts.tar
tar -xvf i18n/qt_ts.tar
rm i18n/qt_ts.tar
if [ -f i18n/qgis_ts.tar ]; then
echo Unpacking i18n/qgis_ts.tar
rm i18n/qgis_ts.tar
fi
5 changes: 5 additions & 0 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolmovefeature.h
qgsmaptoolnodetool.h
qgsmaptoolselect.h
qgsmaptooladdvertex.h
qgsmaptooldeletering.h
qgsmaptooldeletepart.h
qgsmaptooldeletevertex.h
qgsmaptoolmovevertex.h
qgsmaptoolsimplify.h

qgsmeasuretool.h
Expand Down
36 changes: 20 additions & 16 deletions src/app/composer/qgscompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* *
***************************************************************************/

#include <qgis.h>
#include "qgscompositionwidget.h"
#include "qgscomposition.h"
#include <QColorDialog>
Expand Down Expand Up @@ -115,6 +116,7 @@ void QgsCompositionWidget::createPaperEntries()
QList<QgsCompositionPaper> formats;

formats
// ISO formats
<< QgsCompositionPaper( tr( "A5 (148x210 mm)" ), 148, 210 )
<< QgsCompositionPaper( tr( "A4 (210x297 mm)" ), 210, 297 )
<< QgsCompositionPaper( tr( "A3 (297x420 mm)" ), 297, 420 )
Expand All @@ -127,18 +129,19 @@ void QgsCompositionWidget::createPaperEntries()
<< QgsCompositionPaper( tr( "B2 (500 x 707 mm)" ), 500, 707 )
<< QgsCompositionPaper( tr( "B1 (707 x 1000 mm)" ), 707, 1000 )
<< QgsCompositionPaper( tr( "B0 (1000 x 1414 mm)" ), 1000, 1414 )
<< QgsCompositionPaper( tr( "Legal (8.5x14 inches)" ), 216, 356 )
<< QgsCompositionPaper( tr( "ANSI A (Letter; 8.5x11 inches)" ), 216, 279 )
<< QgsCompositionPaper( tr( "ANSI B (Tabloid; 11x17 inches)" ), 279, 432 )
<< QgsCompositionPaper( tr( "ANSI C (17x22 inches)" ), 432, 559 )
<< QgsCompositionPaper( tr( "ANSI D (22x34 inches)" ), 559, 864 )
<< QgsCompositionPaper( tr( "ANSI E (34x44 inches)" ), 864, 1118 )
<< QgsCompositionPaper( tr( "Arch A (9x12 inches)" ), 229, 305 )
<< QgsCompositionPaper( tr( "Arch B (12x18 inches)" ), 305, 457 )
<< QgsCompositionPaper( tr( "Arch C (18x24 inches)" ), 457, 610 )
<< QgsCompositionPaper( tr( "Arch D (24x36 inches)" ), 610, 914 )
<< QgsCompositionPaper( tr( "Arch E (36x48 inches)" ), 914, 1219 )
<< QgsCompositionPaper( tr( "Arch E1 (30x42 inches)" ), 762, 1067 )
// North american formats
<< QgsCompositionPaper( tr( "Legal (8.5x14 inches)" ), 215.9, 355.6 )
<< QgsCompositionPaper( tr( "ANSI A (Letter; 8.5x11 inches)" ), 215.9, 279.4 )
<< QgsCompositionPaper( tr( "ANSI B (Tabloid; 11x17 inches)" ), 279.4, 431.8 )
<< QgsCompositionPaper( tr( "ANSI C (17x22 inches)" ), 431.8, 558.8 )
<< QgsCompositionPaper( tr( "ANSI D (22x34 inches)" ), 558.8, 863.6 )
<< QgsCompositionPaper( tr( "ANSI E (34x44 inches)" ), 863.6, 1117.6 )
<< QgsCompositionPaper( tr( "Arch A (9x12 inches)" ), 228.6, 304.8 )
<< QgsCompositionPaper( tr( "Arch B (12x18 inches)" ), 304.8, 457.2 )
<< QgsCompositionPaper( tr( "Arch C (18x24 inches)" ), 457.2, 609.6 )
<< QgsCompositionPaper( tr( "Arch D (24x36 inches)" ), 609.6, 914.4 )
<< QgsCompositionPaper( tr( "Arch E (36x48 inches)" ), 914.4, 1219.2 )
<< QgsCompositionPaper( tr( "Arch E1 (30x42 inches)" ), 762, 1066.8 )
;

mPaperSizeComboBox->blockSignals( true );
Expand Down Expand Up @@ -257,12 +260,12 @@ void QgsCompositionWidget::setSize( QLineEdit *le, double v )
if ( mPaperUnitsComboBox->currentIndex() == 0 )
{
// mm
le->setText( QString::number( v ) );
le->setText( QString("%1").arg( v ) );
}
else
{
// inch (show width in inch)
le->setText( QString::number( v / 25.4 ) );
le->setText( QString("%1").arg( v / 25.4 ) );
}
}

Expand Down Expand Up @@ -369,11 +372,12 @@ void QgsCompositionWidget::displayCompositionWidthHeight()
QgsCompositionPaper currentPaper = paper_it.value();

//consider width and height values may be exchanged
if (( currentPaper.mWidth == paperWidth && currentPaper.mHeight == paperHeight )
|| ( currentPaper.mWidth == paperHeight && currentPaper.mHeight == paperWidth ) )
if (( doubleNear( currentPaper.mWidth, paperWidth ) && doubleNear( currentPaper.mHeight, paperHeight ) )
|| ( doubleNear( currentPaper.mWidth, paperHeight ) && doubleNear( currentPaper.mHeight, paperWidth ) ) )
{
mPaperSizeComboBox->setCurrentIndex( mPaperSizeComboBox->findText( paper_it.key() ) );
found = true;
break;
}
}

Expand Down
131 changes: 45 additions & 86 deletions src/app/qgsattributetypedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include <QTableWidgetItem>

#include <climits>
#include <cfloat>

QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl )
: QDialog(),
Expand Down Expand Up @@ -123,80 +125,49 @@ void QgsAttributeTypeDialog::loadFromLayerButtonPushed()
}


void QgsAttributeTypeDialog::setPageForIndex( int index )
void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editType )
{
if ( mLayer->editType( index ) == QgsVectorLayer::LineEdit )
{
setPage( 0 );
}
else if ( mLayer->editType( index ) == QgsVectorLayer::Classification )
{
setPage( 1 );
}
else if ( mLayer->editType( index ) == QgsVectorLayer::EditRange ||
mLayer->editType( index ) == QgsVectorLayer::SliderRange )
{
setPage( 2 );
}
else if ( mLayer->editType( index ) == QgsVectorLayer::UniqueValues ||
mLayer->editType( index ) == QgsVectorLayer::UniqueValuesEditable )
{
setPage( 3 );
}
else if ( mLayer->editType( index ) == QgsVectorLayer::FileName )
{
setPage( 4 );
}
else if ( mLayer->editType( index ) == QgsVectorLayer::ValueMap )
{
setPage( 5 );
}
else if ( mLayer->editType( index ) == QgsVectorLayer::Enumeration )
switch ( editType )
{
setPage( 6 );
}
else if ( mLayer->editType( index ) == QgsVectorLayer::Immutable )
{
setPage( 7 );
case QgsVectorLayer::Classification:
setPage( 1 );
break;

case QgsVectorLayer::EditRange:
case QgsVectorLayer::SliderRange:
setPage( 2 );
break;

case QgsVectorLayer::UniqueValues:
case QgsVectorLayer::UniqueValuesEditable:
setPage( 3 );
break;

case QgsVectorLayer::FileName:
setPage( 4 );
break;

case QgsVectorLayer::ValueMap:
setPage( 5 );
break;

case QgsVectorLayer::Enumeration:
setPage( 6 );
break;

case QgsVectorLayer::Immutable:
setPage( 7 );
break;

case QgsVectorLayer::LineEdit:
setPage( 0 );
break;
}
}

void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editType )
void QgsAttributeTypeDialog::setPageForIndex( int index )
{
if ( editType == QgsVectorLayer::LineEdit )
{
setPage( 0 );
}
else if ( editType == QgsVectorLayer::Classification )
{
setPage( 1 );
}
else if ( editType == QgsVectorLayer::EditRange ||
editType == QgsVectorLayer::SliderRange )
{
setPage( 2 );
}
else if ( editType == QgsVectorLayer::UniqueValues ||
editType == QgsVectorLayer::UniqueValuesEditable )
{
setPage( 3 );
}
else if ( editType == QgsVectorLayer::FileName )
{
setPage( 4 );
}
else if ( editType == QgsVectorLayer::ValueMap )
{
setPage( 5 );
}
else if ( editType == QgsVectorLayer::Enumeration )
{
setPage( 6 );
}
else if ( editType == QgsVectorLayer::Immutable )
{
setPage( 7 );
}
setPageForEditType( mLayer->editType( index ) );
}

void QgsAttributeTypeDialog::setValueMap( QMap<QString, QVariant> valueMap )
Expand Down Expand Up @@ -234,15 +205,9 @@ void QgsAttributeTypeDialog::setIndex( int index, int editTypeInt )
if ( mLayer->pendingFields()[index].type() == QVariant::Int )
{
sliderRadioButton->setDisabled( false );
int min;
int max;
//filling initial values
if ( mLayer->nextFeature( f ) )
{
min = f.attributeMap()[index].toInt();
max = f.attributeMap()[index].toInt();
}
for ( ; mLayer->nextFeature( f ); )
int min = INT_MIN;
int max = INT_MAX;
while ( mLayer->nextFeature( f ) )
{
QVariant val = f.attributeMap()[index];
if ( val.isValid() && !val.isNull() )
Expand All @@ -258,18 +223,12 @@ void QgsAttributeTypeDialog::setIndex( int index, int editTypeInt )
}
else if ( mLayer->pendingFields()[index].type() == QVariant::Double )
{
double dMin;
double dMax;

if ( mLayer->nextFeature( f ) )
{
dMin = f.attributeMap()[index].toDouble();
dMax = f.attributeMap()[index].toDouble();
}
double dMin = -DBL_MAX;
double dMax = DBL_MAX;

sliderRadioButton->setDisabled( true );
editableRadioButton->setChecked( true );
for ( ; mLayer->nextFeature( f ); )
while ( mLayer->nextFeature( f ) )
{
QVariant val = f.attributeMap()[index];
if ( val.isValid() && !val.isNull() )
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmaptooladdvertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class QgsRubberBand;
/**Map tool to add vertices to line/polygon features*/
class QgsMapToolAddVertex: public QgsMapToolVertexEdit
{
Q_OBJECT

public:
QgsMapToolAddVertex( QgsMapCanvas* canvas );
virtual ~QgsMapToolAddVertex();
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmaptooldeletepart.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class QgsVertexMarker;
/**Map tool to delete vertices from line/polygon features*/
class QgsMapToolDeletePart: public QgsMapToolVertexEdit
{
Q_OBJECT

public:
QgsMapToolDeletePart( QgsMapCanvas* canvas );
virtual ~QgsMapToolDeletePart();
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmaptooldeletering.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class QgsVertexMarker;

class QgsMapToolDeleteRing : public QgsMapToolVertexEdit
{
Q_OBJECT

public:
QgsMapToolDeleteRing( QgsMapCanvas* canvas );
virtual ~QgsMapToolDeleteRing();
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmaptooldeletevertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class QgsVertexMarker;

class QgsMapToolDeleteVertex: public QgsMapToolVertexEdit
{
Q_OBJECT

public:
QgsMapToolDeleteVertex( QgsMapCanvas* canvas );
virtual ~QgsMapToolDeleteVertex();
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmaptoolmovevertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class QgsRubberBand;
/**A maptool to move vertices of line or polygon fetures*/
class QgsMapToolMoveVertex: public QgsMapToolVertexEdit
{
Q_OBJECT

public:
QgsMapToolMoveVertex( QgsMapCanvas* canvas );
virtual ~QgsMapToolMoveVertex();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void QgsMapToolNodeTool::createTopologyRubbedBands( QgsVectorLayer* vlayer, QLis
trb->setColor( Qt::red );

int tVertex = resultIt.value().snappedVertexNr;
int tVertexBackup, tVertexAfter;
int tVertexBackup = -1, tVertexAfter = -1;
int tVertexFirst = tVertex;//vertex number to check for cycling
QgsFeature topolFeature;

Expand Down
11 changes: 6 additions & 5 deletions src/app/qgsmaptoolsimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#include <QMouseEvent>
#include <QMessageBox>

#include <math.h>
#include <cmath>
#include <cfloat>

QgsSimplifyDialog::QgsSimplifyDialog( QWidget* parent )
: QDialog( parent )
Expand Down Expand Up @@ -193,14 +194,14 @@ bool QgsMapToolSimplify::calculateSliderBoudaries()
found = false;
int requiredCnt = ( isLine ? 2 : 4 ); //4 for polygon is correct because first and last points are the same
bool bottomFound = false;
double highTol, lowTol;// two boundaries to be used when no directly correct solution is found
double highTol = DBL_MAX, lowTol = DBL_MIN;// two boundaries to be used when no directly correct solution is found
// calculate minimum tolerance where minimum (requiredCnt) of vertexes are left in geometry
while ( !found )
{

int foundVertexes = QgsSimplifyFeature::simplifyPoints( pts, tol ).size();
if ( foundVertexes < requiredCnt + 1 )
{ //requred or lower number of verticies found
{ //required or lower number of verticies found
if ( foundVertexes == requiredCnt )
{
found = true;
Expand All @@ -211,7 +212,7 @@ bool QgsMapToolSimplify::calculateSliderBoudaries()
bottomFound = true;
highTol = tol;
tol = ( highTol + lowTol ) / 2;
if ( highTol / lowTol < 1.00000001 )
if ( doubleNear( highTol, lowTol ) )
{ //solving problem that two points are in same distance from line, so they will be both excluded at same time
//so some time more than required count of vertices can stay
found = true;
Expand All @@ -225,7 +226,7 @@ bool QgsMapToolSimplify::calculateSliderBoudaries()
{
lowTol = tol;
tol = ( highTol + lowTol ) / 2;
if ( highTol / lowTol < 1.00000001 )
if ( doubleNear( highTol, lowTol ) )
{ //solving problem that two points are in same distance from line, so they will be both excluded at same time
//so some time more than required count of vertices can stay
found = true;
Expand Down
Loading

0 comments on commit eccf3a2

Please sign in to comment.