27 #include <QPushButton>
31 #include <QFileDialog>
44 mTypeBox->addItem(
tr(
"Text data" ),
"String" );
45 mTypeBox->addItem(
tr(
"Whole number" ),
"Integer" );
46 mTypeBox->addItem(
tr(
"Decimal number" ),
"Real" );
47 mTypeBox->addItem(
tr(
"Date" ),
"Date" );
52 mPointRadioButton->setChecked(
true );
53 mFileFormatComboBox->addItem(
tr(
"ESRI Shapefile" ),
"ESRI Shapefile" );
56 mFileFormatComboBox->addItem(
tr(
"Comma Separated Value" ),
"Comma Separated Value" );
57 mFileFormatComboBox->addItem(
tr(
"GML" ),
"GML" );
58 mFileFormatComboBox->addItem(
tr(
"Mapinfo File" ),
"Mapinfo File" );
60 if ( mFileFormatComboBox->count() == 1 )
62 mFileFormatComboBox->setVisible(
false );
63 mFileFormatLabel->setVisible(
false );
66 mFileFormatComboBox->setCurrentIndex( 0 );
75 int encindex = mFileEncoding->findText( enc );
78 mFileEncoding->insertItem( 0, enc );
81 mFileEncoding->setCurrentIndex( encindex );
83 mOkButton = buttonBox->button( QDialogButtonBox::Ok );
90 mCrsSelector->setCrs( defaultCrs );
95 mAddAttributeButton->setEnabled(
false );
96 mRemoveAttributeButton->setEnabled(
false );
108 if ( mFileFormatComboBox->currentText() ==
tr(
"ESRI Shapefile" ) )
109 mNameEdit->setMaxLength( 10 );
111 mNameEdit->setMaxLength( 32767 );
120 if ( mWidth->text().toInt() < 1 || mWidth->text().toInt() > 255 )
121 mWidth->setText(
"80" );
122 mPrecision->setEnabled(
false );
127 if ( mWidth->text().toInt() < 1 || mWidth->text().toInt() > 10 )
128 mWidth->setText(
"10" );
129 mPrecision->setEnabled(
false );
134 if ( mWidth->text().toInt() < 1 || mWidth->text().toInt() > 20 )
135 mWidth->setText(
"20" );
136 mPrecision->setEnabled(
true );
148 if ( mPointRadioButton->isChecked() )
152 else if ( mLineRadioButton->isChecked() )
156 else if ( mPolygonRadioButton->isChecked() )
165 return mCrsSelector->crs().srsid();
170 QString myName = mNameEdit->text();
171 QString myWidth = mWidth->text();
172 QString myPrecision = mPrecision->isEnabled() ? mPrecision->text() :
"";
174 QString myType = mTypeBox->itemData( mTypeBox->currentIndex(), Qt::UserRole ).toString();
176 if ( mAttributeView->topLevelItemCount() > 0 )
185 delete mAttributeView->currentItem();
186 if ( mAttributeView->topLevelItemCount() == 0 )
208 QString myType = mFileFormatComboBox->itemData( mFileFormatComboBox->currentIndex(), Qt::UserRole ).toString();
214 return mFileEncoding->currentText();
219 mAddAttributeButton->setDisabled( name.
isEmpty() || mAttributeView->findItems( name, Qt::MatchExactly ).size() > 0 );
224 mRemoveAttributeButton->setDisabled( mAttributeView->selectedItems().size() == 0 );
232 if ( geomDialog.
exec() == QDialog::Rejected )
255 if ( fileformat ==
"ESRI Shapefile" && !fileName.
endsWith(
".shp", Qt::CaseInsensitive ) )
258 settings.
setValue(
"/UI/lastVectorFileFilterDir",
QFileInfo( fileName ).absolutePath() );
259 settings.
setValue(
"/UI/encoding", enc );
266 bool loaded = myLib->
load();
271 typedef bool ( *createEmptyDataSourceProc )(
const QString&,
const QString&,
const QString&,
QGis::WkbType,
273 createEmptyDataSourceProc createEmptyDataSource = ( createEmptyDataSourceProc )
cast_to_fptr( myLib->
resolve(
"createEmptyDataSource" ) );
274 if ( createEmptyDataSource )
279 if ( !createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, &srs ) )
281 return QString::null;
287 return QString::null;
292 QgsDebugMsg(
"Resolving newEmptyDataSource(...) failed" );
293 return QString::null;
void nameChanged(const QString &)
QByteArray toByteArray() const
static QgsProviderRegistry * instance(const QString &pluginPath=QString::null)
Means of accessing canonical single instance.
QString selectedFileEncoding() const
Returns the file format for storage.
void on_mTypeBox_currentIndexChanged(int index)
QString library(const QString &providerKey) const
Return path for the library of the provider.
void validate()
Perform some validation on this CRS.
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
int selectedCrsId() const
Returns the selected crs id.
~QgsNewVectorLayerDialog()
WkbType
Used for symbology operations.
QString selectedFileFormat() const
Returns the file format for storage.
QString tr(const char *sourceText, const char *disambiguation, int n)
static const QStringList & availableEncodings()
Returns a list of available encodings.
void setValue(const QString &key, const QVariant &value)
bool createFromOgcWmsCrs(QString theCrs)
Set up this CRS from the given OGC CRS.
QgsNewVectorLayerDialog(QWidget *parent=0, const Qt::WindowFlags &fl=QgisGui::ModalDialogFlags)
static QString runAndCreateLayer(QWidget *parent=0, QString *enc=0)
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
void on_mAddAttributeButton_clicked()
const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
void on_mRemoveAttributeButton_clicked()
A registry / canonical manager of data providers.
QVariant value(const QString &key, const QVariant &defaultValue) const
void attributes(QList< QPair< QString, QString > > &at) const
Appends the chosen attribute names and types to at.
QGis::WkbType selectedType() const
Returns the selected geometry type.
void * resolve(const char *symbol)
Class for storing a coordinate reference system (CRS)
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFlags< QFileDialog::Option > options)
void(*)() cast_to_fptr(void *p)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QString text(int column) const
void on_mFileFormatComboBox_currentIndexChanged(int index)
static QString filterForDriver(const QString &driverName)
Creates a filter for an OGR driver key.