Skip to content

Commit ba58a44

Browse files
author
jef
committed
fix warnings
git-svn-id: http://svn.osgeo.org/qgis/trunk@12722 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1416065 commit ba58a44

File tree

3 files changed

+83
-95
lines changed

3 files changed

+83
-95
lines changed

src/app/composer/qgsattributeselectiondialog.cpp

+78-91
Original file line numberDiff line numberDiff line change
@@ -23,50 +23,50 @@
2323
#include <QLabel>
2424
#include <QLineEdit>
2525

26-
QgsAttributeSelectionDialog::QgsAttributeSelectionDialog(const QgsVectorLayer* vLayer, const QSet<int>& enabledAttributes, const QMap<int, QString>& aliasMap, \
27-
QWidget * parent, Qt::WindowFlags f): QDialog(parent, f), mVectorLayer(vLayer)
26+
QgsAttributeSelectionDialog::QgsAttributeSelectionDialog( const QgsVectorLayer* vLayer, const QSet<int>& enabledAttributes, const QMap<int, QString>& aliasMap,
27+
QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f ), mVectorLayer( vLayer )
2828
{
29-
if( vLayer )
30-
{
31-
mGridLayout = new QGridLayout(this);
32-
QLabel* attributeLabel = new QLabel(QString("<b>") + tr("Attribute") + QString("</b>"), this );
33-
attributeLabel->setTextFormat(Qt::RichText);
34-
mGridLayout->addWidget(attributeLabel, 0, 0);
35-
QLabel* aliasLabel = new QLabel(QString("<b>") + tr("Alias") + QString("</b>"), this );
36-
aliasLabel->setTextFormat(Qt::RichText);
37-
mGridLayout->addWidget(aliasLabel, 0, 1);
38-
39-
QgsFieldMap fieldMap = vLayer->pendingFields();
40-
QgsFieldMap::const_iterator fieldIt = fieldMap.constBegin();
41-
int layoutRowCounter = 1;
42-
for(; fieldIt != fieldMap.constEnd(); ++fieldIt)
43-
{
44-
QCheckBox* attributeCheckBox = new QCheckBox(fieldIt.value().name(), this);
45-
if( enabledAttributes.size() < 1 || enabledAttributes.contains(fieldIt.key()) )
46-
{
47-
attributeCheckBox->setCheckState(Qt::Checked);
48-
}
49-
else
50-
{
51-
attributeCheckBox->setCheckState(Qt::Unchecked);
52-
}
53-
mGridLayout->addWidget(attributeCheckBox, layoutRowCounter, 0);
29+
if ( vLayer )
30+
{
31+
mGridLayout = new QGridLayout( this );
32+
QLabel* attributeLabel = new QLabel( QString( "<b>" ) + tr( "Attribute" ) + QString( "</b>" ), this );
33+
attributeLabel->setTextFormat( Qt::RichText );
34+
mGridLayout->addWidget( attributeLabel, 0, 0 );
35+
QLabel* aliasLabel = new QLabel( QString( "<b>" ) + tr( "Alias" ) + QString( "</b>" ), this );
36+
aliasLabel->setTextFormat( Qt::RichText );
37+
mGridLayout->addWidget( aliasLabel, 0, 1 );
5438

55-
QLineEdit* attributeLineEdit = new QLineEdit(this);
56-
QMap<int, QString>::const_iterator aliasIt = aliasMap.find( fieldIt.key() );
57-
if(aliasIt != aliasMap.constEnd())
58-
{
59-
attributeLineEdit->setText(aliasIt.value());
60-
}
61-
mGridLayout->addWidget(attributeLineEdit, layoutRowCounter, 1);
62-
++layoutRowCounter;
63-
}
39+
QgsFieldMap fieldMap = vLayer->pendingFields();
40+
QgsFieldMap::const_iterator fieldIt = fieldMap.constBegin();
41+
int layoutRowCounter = 1;
42+
for ( ; fieldIt != fieldMap.constEnd(); ++fieldIt )
43+
{
44+
QCheckBox* attributeCheckBox = new QCheckBox( fieldIt.value().name(), this );
45+
if ( enabledAttributes.size() < 1 || enabledAttributes.contains( fieldIt.key() ) )
46+
{
47+
attributeCheckBox->setCheckState( Qt::Checked );
48+
}
49+
else
50+
{
51+
attributeCheckBox->setCheckState( Qt::Unchecked );
52+
}
53+
mGridLayout->addWidget( attributeCheckBox, layoutRowCounter, 0 );
6454

65-
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
66-
QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
67-
QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
68-
mGridLayout->addWidget( buttonBox, layoutRowCounter, 0, 3, 1);
55+
QLineEdit* attributeLineEdit = new QLineEdit( this );
56+
QMap<int, QString>::const_iterator aliasIt = aliasMap.find( fieldIt.key() );
57+
if ( aliasIt != aliasMap.constEnd() )
58+
{
59+
attributeLineEdit->setText( aliasIt.value() );
60+
}
61+
mGridLayout->addWidget( attributeLineEdit, layoutRowCounter, 1 );
62+
++layoutRowCounter;
6963
}
64+
65+
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
66+
QObject::connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
67+
QObject::connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
68+
mGridLayout->addWidget( buttonBox, layoutRowCounter, 0, 3, 1 );
69+
}
7070
}
7171

7272
QgsAttributeSelectionDialog::~QgsAttributeSelectionDialog()
@@ -76,69 +76,56 @@ QgsAttributeSelectionDialog::~QgsAttributeSelectionDialog()
7676

7777
QSet<int> QgsAttributeSelectionDialog::enabledAttributes() const
7878
{
79-
QSet<int> result;
80-
if(!mGridLayout || !mVectorLayer)
81-
{
82-
return result;
83-
}
79+
QSet<int> result;
80+
if ( !mGridLayout || !mVectorLayer )
81+
{
82+
return result;
83+
}
8484

85-
for( int i = 1; i < mGridLayout->rowCount(); ++i)
85+
for ( int i = 1; i < mGridLayout->rowCount(); ++i )
86+
{
87+
QLayoutItem *checkBoxItem = mGridLayout->itemAtPosition( i, 0 );
88+
if ( checkBoxItem )
8689
{
87-
bool boxChecked = false;
88-
QLayoutItem* checkBoxItem = mGridLayout->itemAtPosition(i, 0);
89-
if(checkBoxItem)
90-
{
91-
QWidget* checkBoxWidget = checkBoxItem->widget();
92-
if(checkBoxWidget)
93-
{
94-
QCheckBox* checkBox = dynamic_cast<QCheckBox*>(checkBoxWidget);
95-
if(checkBox)
96-
{
97-
if(checkBox->checkState() == Qt::Checked)
98-
{
99-
result.insert(mVectorLayer->fieldNameIndex(checkBox->text()));
100-
}
101-
}
102-
}
103-
}
90+
QCheckBox *checkBox = qobject_cast< QCheckBox * >( checkBoxItem->widget() );
91+
if ( checkBox && checkBox->checkState() == Qt::Checked )
92+
{
93+
result.insert( mVectorLayer->fieldNameIndex( checkBox->text() ) );
94+
}
10495
}
96+
}
10597

106-
return result;
98+
return result;
10799
}
108100

109101
QMap<int, QString> QgsAttributeSelectionDialog::aliasMap() const
110102
{
111-
QMap<int, QString> result;
112-
if(!mGridLayout || !mVectorLayer)
113-
{
114-
return result;
115-
}
103+
QMap<int, QString> result;
104+
if ( !mGridLayout || !mVectorLayer )
105+
{
106+
return result;
107+
}
116108

117-
for( int i = 1; i < mGridLayout->rowCount(); ++i)
109+
for ( int i = 1; i < mGridLayout->rowCount(); ++i )
110+
{
111+
QLayoutItem* lineEditItem = mGridLayout->itemAtPosition( i, 1 );
112+
QLayoutItem* checkBoxItem = mGridLayout->itemAtPosition( i, 0 );
113+
if ( lineEditItem && checkBoxItem )
118114
{
119-
QLayoutItem* lineEditItem = mGridLayout->itemAtPosition(i, 1);
120-
QLayoutItem* checkBoxItem = mGridLayout->itemAtPosition(i, 0);
121-
if(lineEditItem && checkBoxItem)
115+
QLineEdit *lineEdit = qobject_cast<QLineEdit*>( lineEditItem->widget() );
116+
QCheckBox *checkBox = qobject_cast<QCheckBox*>( checkBoxItem->widget() );
117+
if ( lineEdit )
118+
{
119+
QString aliasText = lineEdit->text();
120+
if ( !aliasText.isEmpty() && checkBox )
122121
{
123-
QWidget* lineEditWidget = lineEditItem->widget();
124-
QWidget* checkBoxWidget = checkBoxItem->widget();
125-
if(lineEditWidget)
126-
{
127-
QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(lineEditWidget);
128-
QCheckBox* checkBox = dynamic_cast<QCheckBox*>(checkBoxWidget);
129-
if(lineEdit)
130-
{
131-
QString aliasText = lineEdit->text();
132-
if(!aliasText.isEmpty())
133-
{
134-
//insert into map
135-
int fieldIndex = mVectorLayer->fieldNameIndex( checkBox->text() );
136-
result.insert(fieldIndex, aliasText);
137-
}
138-
}
139-
}
122+
//insert into map
123+
int fieldIndex = mVectorLayer->fieldNameIndex( checkBox->text() );
124+
result.insert( fieldIndex, aliasText );
140125
}
126+
}
141127
}
142-
return result;
128+
}
129+
return result;
143130
}
144131

src/app/qgsmaptoolcapture.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class QgsMapToolCapture : public QgsMapToolEdit
3939
};
4040

4141
//! constructor
42-
QgsMapToolCapture( QgsMapCanvas* canvas, CaptureMode tool );
42+
QgsMapToolCapture( QgsMapCanvas* canvas, CaptureMode mode );
4343

4444
//! destructor
4545
virtual ~QgsMapToolCapture();

src/core/gps/posix_qextserialport.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ warnings) in the project. Note that _TTY_NOWARN_ will also turn off portability
1313

1414
#include <stdio.h>
1515
#include "posix_qextserialport.h"
16+
#include "qgslogger.h"
1617

1718
/*!
1819
\fn Posix_QextSerialPort::Posix_QextSerialPort()
@@ -858,10 +859,10 @@ bool Posix_QextSerialPort::open( OpenMode mode )
858859
{
859860
/*open the port*/
860861
Posix_File->setFileName( port );
861-
qDebug( "Trying to open File" );
862+
QgsDebugMsg( "Trying to open File" );
862863
if ( Posix_File->open( QIODevice::ReadWrite | QIODevice::Unbuffered ) )
863864
{
864-
qDebug( "Opened File successfully" );
865+
QgsDebugMsg( "Opened File successfully" );
865866
/*set open mode*/
866867
QIODevice::open( mode );
867868

@@ -889,7 +890,7 @@ bool Posix_QextSerialPort::open( OpenMode mode )
889890
}
890891
else
891892
{
892-
qDebug( "Could not open File! Error code : %d", Posix_File->error() );
893+
QgsDebugMsg( QString( "Could not open File! Error code: %1" ).arg( Posix_File->error() ) );
893894
}
894895
}
895896
UNLOCK_MUTEX();

0 commit comments

Comments
 (0)