mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
apply Review
This commit is contained in:
parent
10413ee046
commit
6c979ccb3e
@ -136,8 +136,8 @@ void QgsDelimitedTextSourceSelect::addButtonClicked()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<QgsDelimitedTextFile> mFile( std::make_unique<QgsDelimitedTextFile>() );
|
QgsDelimitedTextFile mFile;
|
||||||
if ( !loadDelimitedFileDefinition( mFile.get() ) )
|
if ( !loadDelimitedFileDefinition( mFile ) )
|
||||||
{
|
{
|
||||||
QMessageBox::warning( this, tr( "Invalid delimited text file" ), tr( "Please enter a valid file and delimiter" ) );
|
QMessageBox::warning( this, tr( "Invalid delimited text file" ), tr( "Please enter a valid file and delimiter" ) );
|
||||||
return;
|
return;
|
||||||
@ -146,7 +146,7 @@ void QgsDelimitedTextSourceSelect::addButtonClicked()
|
|||||||
cancelScanTask();
|
cancelScanTask();
|
||||||
|
|
||||||
//Build the delimited text URI from the user provided information
|
//Build the delimited text URI from the user provided information
|
||||||
const QString datasourceUrl { url( mFile.get() ) };
|
const QString datasourceUrl { url( mFile ) };
|
||||||
|
|
||||||
// store the settings
|
// store the settings
|
||||||
saveSettings();
|
saveSettings();
|
||||||
@ -341,28 +341,28 @@ void QgsDelimitedTextSourceSelect::saveSettingsForFile( const QString &filename
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool QgsDelimitedTextSourceSelect::loadDelimitedFileDefinition( QgsDelimitedTextFile *file )
|
bool QgsDelimitedTextSourceSelect::loadDelimitedFileDefinition( QgsDelimitedTextFile &file )
|
||||||
{
|
{
|
||||||
file->setFileName( mFileWidget->filePath() );
|
file.setFileName( mFileWidget->filePath() );
|
||||||
file->setEncoding( cmbEncoding->currentText() );
|
file.setEncoding( cmbEncoding->currentText() );
|
||||||
if ( delimiterChars->isChecked() )
|
if ( delimiterChars->isChecked() )
|
||||||
{
|
{
|
||||||
file->setTypeCSV( selectedChars(), txtQuoteChars->text(), txtEscapeChars->text() );
|
file.setTypeCSV( selectedChars(), txtQuoteChars->text(), txtEscapeChars->text() );
|
||||||
}
|
}
|
||||||
else if ( delimiterRegexp->isChecked() )
|
else if ( delimiterRegexp->isChecked() )
|
||||||
{
|
{
|
||||||
file->setTypeRegexp( txtDelimiterRegexp->text() );
|
file.setTypeRegexp( txtDelimiterRegexp->text() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file->setTypeCSV();
|
file.setTypeCSV();
|
||||||
}
|
}
|
||||||
file->setSkipLines( rowCounter->value() );
|
file.setSkipLines( rowCounter->value() );
|
||||||
file->setUseHeader( cbxUseHeader->isChecked() );
|
file.setUseHeader( cbxUseHeader->isChecked() );
|
||||||
file->setDiscardEmptyFields( cbxSkipEmptyFields->isChecked() );
|
file.setDiscardEmptyFields( cbxSkipEmptyFields->isChecked() );
|
||||||
file->setTrimFields( cbxTrimFields->isChecked() );
|
file.setTrimFields( cbxTrimFields->isChecked() );
|
||||||
file->setMaxFields( mMaxFields );
|
file.setMaxFields( mMaxFields );
|
||||||
return file->isValid();
|
return file.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -395,8 +395,8 @@ void QgsDelimitedTextSourceSelect::updateFieldLists()
|
|||||||
tblSample->clear();
|
tblSample->clear();
|
||||||
tblSample->setColumnCount( 0 );
|
tblSample->setColumnCount( 0 );
|
||||||
tblSample->setRowCount( 0 );
|
tblSample->setRowCount( 0 );
|
||||||
std::unique_ptr<QgsDelimitedTextFile> mFile( std::make_unique<QgsDelimitedTextFile>() );
|
QgsDelimitedTextFile mFile;
|
||||||
if ( !loadDelimitedFileDefinition( mFile.get() ) )
|
if ( !loadDelimitedFileDefinition( mFile ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Put a sample set of records into the sample box. Also while scanning assess suitability of
|
// Put a sample set of records into the sample box. Also while scanning assess suitability of
|
||||||
@ -413,7 +413,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists()
|
|||||||
|
|
||||||
while ( counter < mExampleRowCount )
|
while ( counter < mExampleRowCount )
|
||||||
{
|
{
|
||||||
const QgsDelimitedTextFile::Status status = mFile->nextRecord( values );
|
const QgsDelimitedTextFile::Status status = mFile.nextRecord( values );
|
||||||
if ( status == QgsDelimitedTextFile::RecordEOF )
|
if ( status == QgsDelimitedTextFile::RecordEOF )
|
||||||
break;
|
break;
|
||||||
if ( status != QgsDelimitedTextFile::RecordOk )
|
if ( status != QgsDelimitedTextFile::RecordOk )
|
||||||
@ -488,7 +488,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList fieldList = mFile->fieldNames();
|
QStringList fieldList = mFile.fieldNames();
|
||||||
|
|
||||||
if ( isEmpty.size() < fieldList.size() )
|
if ( isEmpty.size() < fieldList.size() )
|
||||||
{
|
{
|
||||||
@ -537,7 +537,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists()
|
|||||||
// Run the scan in a separate thread
|
// Run the scan in a separate thread
|
||||||
cancelScanTask();
|
cancelScanTask();
|
||||||
|
|
||||||
mScanTask = new QgsDelimitedTextFileScanTask( url( mFile.get(), /* skip overridden types */ true ) );
|
mScanTask = new QgsDelimitedTextFileScanTask( url( mFile, /* skip overridden types */ true ) );
|
||||||
mCancelButton->show();
|
mCancelButton->show();
|
||||||
connect( mScanTask, &QgsDelimitedTextFileScanTask::scanCompleted, this, [=]( const QgsFields &fields ) {
|
connect( mScanTask, &QgsDelimitedTextFileScanTask::scanCompleted, this, [=]( const QgsFields &fields ) {
|
||||||
updateFieldTypes( fields );
|
updateFieldTypes( fields );
|
||||||
@ -745,7 +745,7 @@ bool QgsDelimitedTextSourceSelect::validate()
|
|||||||
message = tr( "At least one delimiter character must be specified" );
|
message = tr( "At least one delimiter character must be specified" );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<QgsDelimitedTextFile> mFile( std::make_unique<QgsDelimitedTextFile>() );
|
QgsDelimitedTextFile mFile;
|
||||||
if ( message.isEmpty() && delimiterRegexp->isChecked() )
|
if ( message.isEmpty() && delimiterRegexp->isChecked() )
|
||||||
{
|
{
|
||||||
const QRegularExpression re( txtDelimiterRegexp->text() );
|
const QRegularExpression re( txtDelimiterRegexp->text() );
|
||||||
@ -764,7 +764,7 @@ bool QgsDelimitedTextSourceSelect::validate()
|
|||||||
// continue...
|
// continue...
|
||||||
}
|
}
|
||||||
// Hopefully won't hit this none-specific message, but just in case ...
|
// Hopefully won't hit this none-specific message, but just in case ...
|
||||||
else if ( !loadDelimitedFileDefinition( mFile.get() ) )
|
else if ( !loadDelimitedFileDefinition( mFile ) )
|
||||||
{
|
{
|
||||||
message = tr( "Definition of filename and delimiters is not valid" );
|
message = tr( "Definition of filename and delimiters is not valid" );
|
||||||
}
|
}
|
||||||
@ -861,9 +861,9 @@ void QgsDelimitedTextSourceSelect::updateCrsWidgetVisibility()
|
|||||||
textLabelCrs->setVisible( !geomTypeNone->isChecked() );
|
textLabelCrs->setVisible( !geomTypeNone->isChecked() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsDelimitedTextSourceSelect::url( QgsDelimitedTextFile *file, bool skipOverriddenTypes )
|
QString QgsDelimitedTextSourceSelect::url( QgsDelimitedTextFile &file, bool skipOverriddenTypes )
|
||||||
{
|
{
|
||||||
QUrl url = file->url();
|
QUrl url = file.url();
|
||||||
QUrlQuery query( url );
|
QUrlQuery query( url );
|
||||||
|
|
||||||
query.addQueryItem( QStringLiteral( "detectTypes" ), cbxDetectTypes->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
|
query.addQueryItem( QStringLiteral( "detectTypes" ), cbxDetectTypes->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
|
||||||
@ -969,7 +969,7 @@ void QgsDelimitedTextSourceSelect::cancelScanTask()
|
|||||||
if ( mScanTask )
|
if ( mScanTask )
|
||||||
{
|
{
|
||||||
mScanTask->cancel();
|
mScanTask->cancel();
|
||||||
mScanTask = nullptr;
|
mScanTask.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ class QgsDelimitedTextSourceSelect : public QgsAbstractDataSourceWidget, private
|
|||||||
QgsDelimitedTextSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Standalone );
|
QgsDelimitedTextSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Standalone );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool loadDelimitedFileDefinition( QgsDelimitedTextFile *file );
|
bool loadDelimitedFileDefinition( QgsDelimitedTextFile &file );
|
||||||
void updateFieldLists();
|
void updateFieldLists();
|
||||||
QString selectedChars();
|
QString selectedChars();
|
||||||
void setSelectedChars( const QString &delimiters );
|
void setSelectedChars( const QString &delimiters );
|
||||||
@ -115,7 +115,7 @@ class QgsDelimitedTextSourceSelect : public QgsAbstractDataSourceWidget, private
|
|||||||
QButtonGroup *bgGeomType = nullptr;
|
QButtonGroup *bgGeomType = nullptr;
|
||||||
void showHelp();
|
void showHelp();
|
||||||
void updateCrsWidgetVisibility();
|
void updateCrsWidgetVisibility();
|
||||||
QString url( QgsDelimitedTextFile *file, bool skipOverriddenTypes = false );
|
QString url( QgsDelimitedTextFile &file, bool skipOverriddenTypes = false );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addButtonClicked() override;
|
void addButtonClicked() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user