Skip to content
Permalink
Browse files

fix warnings

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12722 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Jan 9, 2010
1 parent 43797ae commit b05d2d4c21f800dedeab3f5531445d759a5a2eff
@@ -23,50 +23,50 @@
#include <QLabel>
#include <QLineEdit>

QgsAttributeSelectionDialog::QgsAttributeSelectionDialog(const QgsVectorLayer* vLayer, const QSet<int>& enabledAttributes, const QMap<int, QString>& aliasMap, \
QWidget * parent, Qt::WindowFlags f): QDialog(parent, f), mVectorLayer(vLayer)
QgsAttributeSelectionDialog::QgsAttributeSelectionDialog( const QgsVectorLayer* vLayer, const QSet<int>& enabledAttributes, const QMap<int, QString>& aliasMap,
QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f ), mVectorLayer( vLayer )
{
if( vLayer )
{
mGridLayout = new QGridLayout(this);
QLabel* attributeLabel = new QLabel(QString("<b>") + tr("Attribute") + QString("</b>"), this );
attributeLabel->setTextFormat(Qt::RichText);
mGridLayout->addWidget(attributeLabel, 0, 0);
QLabel* aliasLabel = new QLabel(QString("<b>") + tr("Alias") + QString("</b>"), this );
aliasLabel->setTextFormat(Qt::RichText);
mGridLayout->addWidget(aliasLabel, 0, 1);

QgsFieldMap fieldMap = vLayer->pendingFields();
QgsFieldMap::const_iterator fieldIt = fieldMap.constBegin();
int layoutRowCounter = 1;
for(; fieldIt != fieldMap.constEnd(); ++fieldIt)
{
QCheckBox* attributeCheckBox = new QCheckBox(fieldIt.value().name(), this);
if( enabledAttributes.size() < 1 || enabledAttributes.contains(fieldIt.key()) )
{
attributeCheckBox->setCheckState(Qt::Checked);
}
else
{
attributeCheckBox->setCheckState(Qt::Unchecked);
}
mGridLayout->addWidget(attributeCheckBox, layoutRowCounter, 0);
if ( vLayer )
{
mGridLayout = new QGridLayout( this );
QLabel* attributeLabel = new QLabel( QString( "<b>" ) + tr( "Attribute" ) + QString( "</b>" ), this );
attributeLabel->setTextFormat( Qt::RichText );
mGridLayout->addWidget( attributeLabel, 0, 0 );
QLabel* aliasLabel = new QLabel( QString( "<b>" ) + tr( "Alias" ) + QString( "</b>" ), this );
aliasLabel->setTextFormat( Qt::RichText );
mGridLayout->addWidget( aliasLabel, 0, 1 );

QLineEdit* attributeLineEdit = new QLineEdit(this);
QMap<int, QString>::const_iterator aliasIt = aliasMap.find( fieldIt.key() );
if(aliasIt != aliasMap.constEnd())
{
attributeLineEdit->setText(aliasIt.value());
}
mGridLayout->addWidget(attributeLineEdit, layoutRowCounter, 1);
++layoutRowCounter;
}
QgsFieldMap fieldMap = vLayer->pendingFields();
QgsFieldMap::const_iterator fieldIt = fieldMap.constBegin();
int layoutRowCounter = 1;
for ( ; fieldIt != fieldMap.constEnd(); ++fieldIt )
{
QCheckBox* attributeCheckBox = new QCheckBox( fieldIt.value().name(), this );
if ( enabledAttributes.size() < 1 || enabledAttributes.contains( fieldIt.key() ) )
{
attributeCheckBox->setCheckState( Qt::Checked );
}
else
{
attributeCheckBox->setCheckState( Qt::Unchecked );
}
mGridLayout->addWidget( attributeCheckBox, layoutRowCounter, 0 );

QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
mGridLayout->addWidget( buttonBox, layoutRowCounter, 0, 3, 1);
QLineEdit* attributeLineEdit = new QLineEdit( this );
QMap<int, QString>::const_iterator aliasIt = aliasMap.find( fieldIt.key() );
if ( aliasIt != aliasMap.constEnd() )
{
attributeLineEdit->setText( aliasIt.value() );
}
mGridLayout->addWidget( attributeLineEdit, layoutRowCounter, 1 );
++layoutRowCounter;
}

QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
QObject::connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
QObject::connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
mGridLayout->addWidget( buttonBox, layoutRowCounter, 0, 3, 1 );
}
}

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

QSet<int> QgsAttributeSelectionDialog::enabledAttributes() const
{
QSet<int> result;
if(!mGridLayout || !mVectorLayer)
{
return result;
}
QSet<int> result;
if ( !mGridLayout || !mVectorLayer )
{
return result;
}

for( int i = 1; i < mGridLayout->rowCount(); ++i)
for ( int i = 1; i < mGridLayout->rowCount(); ++i )
{
QLayoutItem *checkBoxItem = mGridLayout->itemAtPosition( i, 0 );
if ( checkBoxItem )
{
bool boxChecked = false;
QLayoutItem* checkBoxItem = mGridLayout->itemAtPosition(i, 0);
if(checkBoxItem)
{
QWidget* checkBoxWidget = checkBoxItem->widget();
if(checkBoxWidget)
{
QCheckBox* checkBox = dynamic_cast<QCheckBox*>(checkBoxWidget);
if(checkBox)
{
if(checkBox->checkState() == Qt::Checked)
{
result.insert(mVectorLayer->fieldNameIndex(checkBox->text()));
}
}
}
}
QCheckBox *checkBox = qobject_cast< QCheckBox * >( checkBoxItem->widget() );
if ( checkBox && checkBox->checkState() == Qt::Checked )
{
result.insert( mVectorLayer->fieldNameIndex( checkBox->text() ) );
}
}
}

return result;
return result;
}

QMap<int, QString> QgsAttributeSelectionDialog::aliasMap() const
{
QMap<int, QString> result;
if(!mGridLayout || !mVectorLayer)
{
return result;
}
QMap<int, QString> result;
if ( !mGridLayout || !mVectorLayer )
{
return result;
}

for( int i = 1; i < mGridLayout->rowCount(); ++i)
for ( int i = 1; i < mGridLayout->rowCount(); ++i )
{
QLayoutItem* lineEditItem = mGridLayout->itemAtPosition( i, 1 );
QLayoutItem* checkBoxItem = mGridLayout->itemAtPosition( i, 0 );
if ( lineEditItem && checkBoxItem )
{
QLayoutItem* lineEditItem = mGridLayout->itemAtPosition(i, 1);
QLayoutItem* checkBoxItem = mGridLayout->itemAtPosition(i, 0);
if(lineEditItem && checkBoxItem)
QLineEdit *lineEdit = qobject_cast<QLineEdit*>( lineEditItem->widget() );
QCheckBox *checkBox = qobject_cast<QCheckBox*>( checkBoxItem->widget() );
if ( lineEdit )
{
QString aliasText = lineEdit->text();
if ( !aliasText.isEmpty() && checkBox )
{
QWidget* lineEditWidget = lineEditItem->widget();
QWidget* checkBoxWidget = checkBoxItem->widget();
if(lineEditWidget)
{
QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(lineEditWidget);
QCheckBox* checkBox = dynamic_cast<QCheckBox*>(checkBoxWidget);
if(lineEdit)
{
QString aliasText = lineEdit->text();
if(!aliasText.isEmpty())
{
//insert into map
int fieldIndex = mVectorLayer->fieldNameIndex( checkBox->text() );
result.insert(fieldIndex, aliasText);
}
}
}
//insert into map
int fieldIndex = mVectorLayer->fieldNameIndex( checkBox->text() );
result.insert( fieldIndex, aliasText );
}
}
}
return result;
}
return result;
}

@@ -39,7 +39,7 @@ class QgsMapToolCapture : public QgsMapToolEdit
};

//! constructor
QgsMapToolCapture( QgsMapCanvas* canvas, CaptureMode tool );
QgsMapToolCapture( QgsMapCanvas* canvas, CaptureMode mode );

//! destructor
virtual ~QgsMapToolCapture();
@@ -13,6 +13,7 @@ warnings) in the project. Note that _TTY_NOWARN_ will also turn off portability

#include <stdio.h>
#include "posix_qextserialport.h"
#include "qgslogger.h"

/*!
\fn Posix_QextSerialPort::Posix_QextSerialPort()
@@ -858,10 +859,10 @@ bool Posix_QextSerialPort::open( OpenMode mode )
{
/*open the port*/
Posix_File->setFileName( port );
qDebug( "Trying to open File" );
QgsDebugMsg( "Trying to open File" );
if ( Posix_File->open( QIODevice::ReadWrite | QIODevice::Unbuffered ) )
{
qDebug( "Opened File successfully" );
QgsDebugMsg( "Opened File successfully" );
/*set open mode*/
QIODevice::open( mode );

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

0 comments on commit b05d2d4

Please sign in to comment.
You can’t perform that action at this time.