Skip to content
Permalink
Browse files

Let users know if no data displayed because all records are badly for…

…matted
  • Loading branch information
ccrook committed Apr 26, 2013
1 parent 56f4a5e commit f7dc548ae08dc28d19418984b35da82a95271580
@@ -36,6 +36,7 @@ QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget * parent, Qt
QDialog( parent, fl ),
mFile( new QgsDelimitedTextFile() ),
mExampleRowCount( 20 ),
mBadRowCount( 0 ),
mPluginKey( "/Plugin-DelimitedText" ),
mLastFileType( "" )
{
@@ -394,14 +395,15 @@ void QgsDelimitedTextSourceSelect::updateFieldLists()
QList<bool> isValidWkt;
QList<bool> isEmpty;
int counter = 0;
mBadRowCount = 0;
QStringList values;
QRegExp wktre( "^\\s*(?:MULTI)?(?:POINT|LINESTRING|POLYGON)\\s*Z?\\s*M?\\(", Qt::CaseInsensitive );

while ( counter < mExampleRowCount )
{
QgsDelimitedTextFile::Status status = mFile->nextRecord( values );
if ( status == QgsDelimitedTextFile::RecordEOF ) break;
if ( status != QgsDelimitedTextFile::RecordOk ) continue;
if ( status != QgsDelimitedTextFile::RecordOk ) { mBadRowCount++; continue; }
counter++;

// Look at count of non-blank fields
@@ -692,6 +694,10 @@ bool QgsDelimitedTextSourceSelect::validate()
else if ( tblSample->rowCount() == 0 )
{
message = tr( "No data found in file" );
if( mBadRowCount > 0 )
{
message = message + " (" + tr("%1 badly formatted records discarded").arg(mBadRowCount)+")";
}
}
else if ( geomTypeXY->isChecked() && ( cmbXField->currentText().isEmpty() || cmbYField->currentText().isEmpty() ) )
{
@@ -708,6 +714,11 @@ bool QgsDelimitedTextSourceSelect::validate()
else
{
enabled = true;
if( mBadRowCount > 0 )
{
message = tr("%1 badly formatted records discarded from sample data").arg(mBadRowCount);
}

}
lblStatus->setText( message );
return enabled;
@@ -50,6 +50,7 @@ class QgsDelimitedTextSourceSelect : public QDialog, private Ui::QgsDelimitedTex
private:
QgsDelimitedTextFile *mFile;
int mExampleRowCount;
int mBadRowCount;
QString mPluginKey;
QString mLastFileType;

0 comments on commit f7dc548

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