From ca4a1e77550ea65ad51930902aa57142a441d9a8 Mon Sep 17 00:00:00 2001 From: g_j_m Date: Mon, 22 Jan 2007 02:38:33 +0000 Subject: [PATCH] Fix compiler warnings git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6451 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/app/composer/qgscomposeritem.cpp | 2 +- src/app/composer/qgscomposermap.cpp | 6 +- src/app/composer/qgscomposerscalebar.cpp | 2 +- src/app/composer/qgscomposervectorlegend.cpp | 6 +- src/app/composer/qgscomposition.cpp | 2 +- src/app/qgscustomprojectiondialog.cpp | 114 ++++++++++--------- src/app/qgsdbsourceselect.cpp | 4 +- src/app/qgspastetransformations.cpp | 2 +- src/app/qgsserversourceselect.cpp | 6 +- 9 files changed, 79 insertions(+), 65 deletions(-) diff --git a/src/app/composer/qgscomposeritem.cpp b/src/app/composer/qgscomposeritem.cpp index dcc52bda700..dd5debcf051 100644 --- a/src/app/composer/qgscomposeritem.cpp +++ b/src/app/composer/qgscomposeritem.cpp @@ -24,7 +24,7 @@ QgsComposerItem::QgsComposerItem(void) { - mSelected; + mSelected = false; mPlotStyle = QgsComposition::Preview; } diff --git a/src/app/composer/qgscomposermap.cpp b/src/app/composer/qgscomposermap.cpp index 6a8206571eb..47832ee15de 100644 --- a/src/app/composer/qgscomposermap.cpp +++ b/src/app/composer/qgscomposermap.cpp @@ -24,6 +24,7 @@ #include "qgsvectorlayer.h" #include #include +#include QgsComposerMap::QgsComposerMap ( QgsComposition *composition, int id, int x, int y, int width, int height ) : QWidget(), Q3CanvasRectangle(x,y,width,height,0) @@ -236,7 +237,7 @@ void QgsComposerMap::cache ( void ) // 1 pixel in cache should have ia similar size as 1 pixel in canvas // but it can result in big cache -> limit - int w = Q3CanvasRectangle::width() * mComposition->viewScale(); + int w = static_cast(round(Q3CanvasRectangle::width() * mComposition->viewScale())); w = w < 1000 ? w : 1000; int h = (int) ( mExtent.height() * w / mExtent.width() ); // It can happen that extent is not initialised well -> check @@ -397,6 +398,7 @@ double QgsComposerMap::scaleFromUserScale ( double us ) case QGis::FEET : s = 304.8 * mComposition->scale() / us; break; + case QGis::UNKNOWN : case QGis::DEGREES : s = mComposition->scale() / us; break; @@ -416,6 +418,7 @@ double QgsComposerMap::userScaleFromScale ( double s ) us = 304.8 * mComposition->scale() / s; break; case QGis::DEGREES : + case QGis::UNKNOWN : us = mComposition->scale() / s; break; } @@ -559,6 +562,7 @@ void QgsComposerMap::setOptions ( void ) mScaleLineEdit->setText ( QString("%1").arg((int)mUserScale) ); break; case QGis::DEGREES : + case QGis::UNKNOWN : mScaleLineEdit->setText ( QString("%1").arg(mUserScale,0,'f') ); break; } diff --git a/src/app/composer/qgscomposerscalebar.cpp b/src/app/composer/qgscomposerscalebar.cpp index 080f7d3fb2d..fc75fa447a5 100644 --- a/src/app/composer/qgscomposerscalebar.cpp +++ b/src/app/composer/qgscomposerscalebar.cpp @@ -425,7 +425,7 @@ void QgsComposerScalebar::setOptions ( void ) bool found = false; mMapComboBox->insertItem ( "", 0 ); mMaps.push_back ( 0 ); - for ( int i = 0; i < maps.size(); i++ ) { + for ( uint i = 0; i < maps.size(); i++ ) { mMapComboBox->insertItem ( maps[i]->name(), i+1 ); mMaps.push_back ( maps[i]->id() ); diff --git a/src/app/composer/qgscomposervectorlegend.cpp b/src/app/composer/qgscomposervectorlegend.cpp index f01658b2988..602d0e4c3c5 100644 --- a/src/app/composer/qgscomposervectorlegend.cpp +++ b/src/app/composer/qgscomposervectorlegend.cpp @@ -241,7 +241,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p ) std::vector groupLayers; // vector of layers std::vector itemHeights; // maximum item sizes std::vector itemLabels; // item labels - int sectionItemsCount = 0; + unsigned int sectionItemsCount = 0; QString sectionTitle; for ( int j = nlayers - 1; j >= 0; j-- ) { @@ -407,7 +407,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p ) } /* add height of section items */ height = groupStartHeight; - for ( int j = 0; j < itemHeights.size(); j++ ) { + for ( uint j = 0; j < itemHeights.size(); j++ ) { height += mSymbolSpace + itemHeights[j]; } if ( sectionItemsCount > 1 ) { // add more space to separate section from next item @@ -615,7 +615,7 @@ void QgsComposerVectorLegend::setOptions ( void ) bool found = false; mMapComboBox->insertItem ( "", 0 ); mMaps.push_back ( 0 ); - for ( int i = 0; i < maps.size(); i++ ) { + for ( uint i = 0; i < maps.size(); i++ ) { mMapComboBox->insertItem ( maps[i]->name(), i+1 ); mMaps.push_back ( maps[i]->id() ); diff --git a/src/app/composer/qgscomposition.cpp b/src/app/composer/qgscomposition.cpp index f68f32555e5..879a2b97071 100644 --- a/src/app/composer/qgscomposition.cpp +++ b/src/app/composer/qgscomposition.cpp @@ -95,7 +95,7 @@ QgsComposition::QgsComposition( QgsComposer *c, int id ) mPapers.push_back ( QgsCompositionPaper( tr("Legal (8.5x14 inches)"), 216, 356 ) ); mPaper = mDefaultPaper = mCustomPaper = 0; - for( int i = 0; i < mPapers.size(); i++ ) { + for( uint i = 0; i < mPapers.size(); i++ ) { mPaperSizeComboBox->insertItem( mPapers[i].mName ); // Map - A4 land for now, if future read from template if ( mPapers[i].mWidth == 210 && mPapers[i].mHeight == 297 ){ diff --git a/src/app/qgscustomprojectiondialog.cpp b/src/app/qgscustomprojectiondialog.cpp index b6284d4ceac..be43a4ee742 100644 --- a/src/app/qgscustomprojectiondialog.cpp +++ b/src/app/qgscustomprojectiondialog.cpp @@ -185,7 +185,7 @@ void QgsCustomProjectionDialog::on_pbnDelete_clicked() #endif if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; + sqlite3_step(myPreparedStatement); } // close the sqlite3 statement sqlite3_finalize(myPreparedStatement); @@ -242,9 +242,11 @@ long QgsCustomProjectionDialog::getRecordCount() // XXX Need to free memory from the error msg if one is set if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; - QString myRecordCountString = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); - myRecordCount=myRecordCountString.toLong(); + if (sqlite3_step(myPreparedStatement) == SQLITE_ROW) + { + QString myRecordCountString = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); + myRecordCount=myRecordCountString.toLong(); + } } // close the sqlite3 statement sqlite3_finalize(myPreparedStatement); @@ -275,8 +277,8 @@ QString QgsCustomProjectionDialog::getProjectionFamilyName(QString theProjection // XXX Need to free memory from the error msg if one is set if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; - myName = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); + if (sqlite3_step(myPreparedStatement) == SQLITE_ROW) + myName = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); } // close the sqlite3 statement sqlite3_finalize(myPreparedStatement); @@ -306,8 +308,8 @@ QString QgsCustomProjectionDialog::getEllipsoidName(QString theEllipsoidAcronym) // XXX Need to free memory from the error msg if one is set if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; - myName = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); + if (sqlite3_step(myPreparedStatement) == SQLITE_ROW) + myName = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); } // close the sqlite3 statement sqlite3_finalize(myPreparedStatement); @@ -337,8 +339,8 @@ QString QgsCustomProjectionDialog::getProjectionFamilyAcronym(QString theProject // XXX Need to free memory from the error msg if one is set if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; - myName = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); + if (sqlite3_step(myPreparedStatement) == SQLITE_ROW) + myName = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); } // close the sqlite3 statement sqlite3_finalize(myPreparedStatement); @@ -368,8 +370,8 @@ QString QgsCustomProjectionDialog::getEllipsoidAcronym(QString theEllipsoidName) // XXX Need to free memory from the error msg if one is set if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; - myName = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); + if (sqlite3_step(myPreparedStatement) == SQLITE_ROW) + myName = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); } // close the sqlite3 statement sqlite3_finalize(myPreparedStatement); @@ -405,16 +407,18 @@ void QgsCustomProjectionDialog::on_pbnFirst_clicked() // XXX Need to free memory from the error msg if one is set if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; - mCurrentRecordId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); - leName->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,1))); - //QString myProjectionFamilyId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,2)); - //cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId)); - //QString myEllipsoidId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,3)); - //cboEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId)); - leParameters->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,4))); - mCurrentRecordLong=1; - lblRecordNo->setText(QString::number(mCurrentRecordLong) + " of " + QString::number(mRecordCountLong)); + if (sqlite3_step(myPreparedStatement) == SQLITE_ROW) + { + mCurrentRecordId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); + leName->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,1))); + //QString myProjectionFamilyId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,2)); + //cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId)); + //QString myEllipsoidId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,3)); + //cboEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId)); + leParameters->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,4))); + mCurrentRecordLong=1; + lblRecordNo->setText(QString::number(mCurrentRecordLong) + " of " + QString::number(mRecordCountLong)); + } } else { @@ -481,16 +485,18 @@ void QgsCustomProjectionDialog::on_pbnPrevious_clicked() // XXX Need to free memory from the error msg if one is set if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; - mCurrentRecordId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); - leName->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,1))); - //QString myProjectionFamilyId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,2)); - //cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId)); - //QString myEllipsoidId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,3)); - //cboEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId)); - leParameters->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,4))), - --mCurrentRecordLong; - lblRecordNo->setText(QString::number(mCurrentRecordLong) + " of " + QString::number(mRecordCountLong)); + if (sqlite3_step(myPreparedStatement) == SQLITE_ROW) + { + mCurrentRecordId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); + leName->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,1))); + //QString myProjectionFamilyId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,2)); + //cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId)); + //QString myEllipsoidId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,3)); + //cboEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId)); + leParameters->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,4))), + --mCurrentRecordLong; + lblRecordNo->setText(QString::number(mCurrentRecordLong) + " of " + QString::number(mRecordCountLong)); + } } else { @@ -559,16 +565,18 @@ void QgsCustomProjectionDialog::on_pbnNext_clicked() // XXX Need to free memory from the error msg if one is set if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; - mCurrentRecordId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); - leName->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,1))); - //QString myProjectionFamilyId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,2)); - //cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId)); - //QString myEllipsoidId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,3)); - //cboEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId)); - leParameters->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,4))); - ++mCurrentRecordLong; - lblRecordNo->setText(QString::number(mCurrentRecordLong) + " of " + QString::number(mRecordCountLong)); + if (sqlite3_step(myPreparedStatement) == SQLITE_ROW) + { + mCurrentRecordId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); + leName->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,1))); + //QString myProjectionFamilyId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,2)); + //cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId)); + //QString myEllipsoidId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,3)); + //cboEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId)); + leParameters->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,4))); + ++mCurrentRecordLong; + lblRecordNo->setText(QString::number(mCurrentRecordLong) + " of " + QString::number(mRecordCountLong)); + } } else { @@ -632,16 +640,18 @@ void QgsCustomProjectionDialog::on_pbnLast_clicked() // XXX Need to free memory from the error msg if one is set if(myResult == SQLITE_OK) { - sqlite3_step(myPreparedStatement) == SQLITE_ROW; - mCurrentRecordId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); - leName->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,1))); - //QString myProjectionFamilyId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,2)); - //cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId)); - //QString myEllipsoidId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,3)); - //cboEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId)); - leParameters->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,4))); - mCurrentRecordLong =mRecordCountLong; - lblRecordNo->setText(QString::number(mCurrentRecordLong) + " of " + QString::number(mRecordCountLong)); + if (sqlite3_step(myPreparedStatement) == SQLITE_ROW) + { + mCurrentRecordId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,0)); + leName->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,1))); + //QString myProjectionFamilyId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,2)); + //cboProjectionFamily->setCurrentText(getProjectionFamilyName(myProjectionFamilyId)); + //QString myEllipsoidId = QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,3)); + //cboEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId)); + leParameters->setText(QString::fromUtf8((char *)sqlite3_column_text(myPreparedStatement,4))); + mCurrentRecordLong =mRecordCountLong; + lblRecordNo->setText(QString::number(mCurrentRecordLong) + " of " + QString::number(mRecordCountLong)); + } } else { diff --git a/src/app/qgsdbsourceselect.cpp b/src/app/qgsdbsourceselect.cpp index 0ce1b793f44..1de3a5ce546 100644 --- a/src/app/qgsdbsourceselect.cpp +++ b/src/app/qgsdbsourceselect.cpp @@ -37,7 +37,7 @@ email : sherman at mrcc.com #include QgsDbSourceSelect::QgsDbSourceSelect(QgisApp *app, Qt::WFlags fl) - : QDialog(app, fl), qgisApp(app), mColumnTypeThread(NULL), pd(0) + : QDialog(app, fl), mColumnTypeThread(NULL), qgisApp(app), pd(0) { setupUi(this); btnAdd->setEnabled(false); @@ -729,7 +729,7 @@ void QgsGeomColumnTypeThread::getLayerTypes() { PQsetClientEncoding(pd, "UNICODE"); - for (int i = 0; i < schemas.size(); ++i) + for (uint i = 0; i < schemas.size(); ++i) { QString query = QgsDbSourceSelect::makeGeomQuery(schemas[i], tables[i], diff --git a/src/app/qgspastetransformations.cpp b/src/app/qgspastetransformations.cpp index 43756d935dd..599ef76f550 100644 --- a/src/app/qgspastetransformations.cpp +++ b/src/app/qgspastetransformations.cpp @@ -71,7 +71,7 @@ void QgsPasteTransformations::accept() QString sourceKey = sourceLayerComboBox ->currentText(); QString destinationKey = destinationLayerComboBox->currentText(); - for (int i = 0; i < mSourceTransfers.size(); i++) + for (uint i = 0; i < mSourceTransfers.size(); i++) { settings.writeEntry( baseKey + "/" + sourceKey + "/" + destinationKey + "/" + diff --git a/src/app/qgsserversourceselect.cpp b/src/app/qgsserversourceselect.cpp index 907e627f1fd..fd1a56743f7 100644 --- a/src/app/qgsserversourceselect.cpp +++ b/src/app/qgsserversourceselect.cpp @@ -45,9 +45,9 @@ static long DEFAULT_WMS_EPSG = 4326; // WGS 84 QgsServerSourceSelect::QgsServerSourceSelect(QgisApp * app, QWidget * parent, Qt::WFlags fl) : QDialog(parent, fl), + m_Epsg(DEFAULT_WMS_EPSG), qgisApp(app), - mWmsProvider(0), - m_Epsg(DEFAULT_WMS_EPSG) + mWmsProvider(0) { setupUi(this); connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); @@ -206,7 +206,7 @@ bool QgsServerSourceSelect::populateLayerList(QgsWmsProvider* wmsProvider) // Also insert the styles // Layer Styles - for (int j = 0; j < layer->style.size(); j++) + for (uint j = 0; j < layer->style.size(); j++) { #ifdef QGISDEBUG std::cout << "QgsServerSourceSelect::populateLayerList: got style name " << layer->style[j].name.toLocal8Bit().data() << " and title '" << layer->style[j].title.toLocal8Bit().data() << "'." << std::endl;