Skip to content
Permalink
Browse files
Usability improvements to the new vector layer dialog. Also refactore…
…d so that the dialog an class names are now a more logical QgsNewVectorDialog

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11719 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Sep 27, 2009
1 parent 83c78fa commit 0277bc7
Show file tree
Hide file tree
Showing 9 changed files with 518 additions and 304 deletions.
@@ -20,7 +20,7 @@ SET(QGIS_APP_SRCS
qgsspatialitefilterproxymodel.cpp
qgsspatialitetablemodel.cpp
qgsdelattrdialog.cpp
qgsgeomtypedialog.cpp
qgsnewvectorlayerdialog.cpp
qgsgraduatedsymboldialog.cpp
qgshelpviewer.cpp
qgsidentifyresults.cpp
@@ -122,7 +122,7 @@ SET (QGIS_APP_MOC_HDRS
qgsconfigureshortcutsdialog.h
qgscustomprojectiondialog.h
qgsdelattrdialog.h
qgsgeomtypedialog.h
qgsnewvectorlayerdialog.h
qgsgraduatedsymboldialog.h
qgshelpviewer.h
qgsidentifyresults.h
@@ -102,7 +102,7 @@
#include "qgsogrsublayersdialog.h"
#include "qgsexception.h"
#include "qgsfeature.h"
#include "qgsgeomtypedialog.h"
#include "qgsnewvectorlayerdialog.h"
#include "qgshelpviewer.h"
#include "qgsgenericprojectionselector.h"
#include "qgslegend.h"
@@ -3139,6 +3139,9 @@ void QgisApp::fileNew( bool thePromptToSaveFlag )

void QgisApp::newVectorLayer()
{
QgsDebugMsg( "++++++++++++++++++++++++++++++++++++++++++" );
QgsDebugMsg( "newVectorLayer called" );
QgsDebugMsg( "++++++++++++++++++++++++++++++++++++++++++" );

if ( mMapCanvas && mMapCanvas->isDrawing() )
{
@@ -3148,13 +3151,14 @@ void QgisApp::newVectorLayer()
QGis::WkbType geometrytype;
QString fileformat;

QgsGeomTypeDialog geomDialog( this );
QgsNewVectorLayerDialog geomDialog( this );
if ( geomDialog.exec() == QDialog::Rejected )
{
return;
}
geometrytype = geomDialog.selectedType();
fileformat = geomDialog.selectedFileFormat();
QgsDebugMsg ( QString( "New file format will be: %1" ).arg( fileformat ) );

std::list<std::pair<QString, QString> > attributes;
geomDialog.attributes( attributes );
@@ -3260,6 +3264,9 @@ void QgisApp::newVectorLayer()
fileNames.append( fileName );
//todo: the last parameter will change accordingly to layer type
addVectorLayers( fileNames, enc, "file" );
QgsDebugMsg( "++++++++++++++++++++++++++++++++++++++++++" );
QgsDebugMsg( "newVectorLayer done!" );
QgsDebugMsg( "++++++++++++++++++++++++++++++++++++++++++" );
}

void QgisApp::fileOpen()
@@ -1,5 +1,5 @@
/***************************************************************************
qgsgeomtypedialog.cpp - description
qgsnewvectorlayerdialog.cpp - description
-------------------
begin : October 2004
copyright : (C) 2004 by Marco Hugentobler
@@ -16,41 +16,47 @@
***************************************************************************/
/* $Id$ */

#include "qgsgeomtypedialog.h"
#include "qgsnewvectorlayerdialog.h"
#include "qgsapplication.h"
#include "qgisapp.h" // <- for theme icons
#include "qgslogger.h"
#include <QPushButton>

QgsGeomTypeDialog::QgsGeomTypeDialog( QWidget *parent, Qt::WFlags fl )
QgsNewVectorLayerDialog::QgsNewVectorLayerDialog( QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
setupUi( this );
mAddAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionNewAttribute.png" ) );
mRemoveAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionDeleteAttribute.png" ) );
mTypeBox->addItem( tr( "String" ), "String" );
mTypeBox->addItem( tr( "Integer" ), "Integer" );
mTypeBox->addItem( tr( "Real" ), "Real" );
mTypeBox->addItem( tr( "Text data" ), "String" );
mTypeBox->addItem( tr( "Whole number" ), "Integer" );
mTypeBox->addItem( tr( "Decimal number" ), "Real" );

mPointRadioButton->setChecked( true );
mFileFormatComboBox->addItem( "ESRI Shapefile" );
/*mFileFormatComboBox->addItem("Comma Separated Value");
mFileFormatComboBox->addItem("GML");
mFileFormatComboBox->addItem("Mapinfo File");*/
mFileFormatComboBox->addItem( tr( "ESRI Shapefile" ), "ESRI Shapefile" );
/* Disabled until provider properly supports editing the created file formats */
//mFileFormatComboBox->addItem( tr( "Comma Separated Value" ), "Comma Separated Value" );
//mFileFormatComboBox->addItem(tr( "GML"), "GML" );
//mFileFormatComboBox->addItem(tr( "Mapinfo File" ), "Mapinfo File" );
if ( mFileFormatComboBox->count() == 1 )
{
mFileFormatComboBox->setVisible( false );
mFileFormatLabel->setVisible( false );
}
mOkButton = buttonBox->button( QDialogButtonBox::Ok );
mOkButton->setEnabled( false );
}

QgsGeomTypeDialog::~QgsGeomTypeDialog()
QgsNewVectorLayerDialog::~QgsNewVectorLayerDialog()
{
}

void QgsGeomTypeDialog::on_mTypeBox_currentIndexChanged( int index )
void QgsNewVectorLayerDialog::on_mTypeBox_currentIndexChanged( int index )
{
mPrecision->setEnabled( index == 2 ); // Real
}

QGis::WkbType QgsGeomTypeDialog::selectedType() const
QGis::WkbType QgsNewVectorLayerDialog::selectedType() const
{
if ( mPointRadioButton->isChecked() )
{
@@ -67,7 +73,7 @@ QGis::WkbType QgsGeomTypeDialog::selectedType() const
return QGis::WKBUnknown;
}

void QgsGeomTypeDialog::on_mAddAttributeButton_clicked()
void QgsNewVectorLayerDialog::on_mAddAttributeButton_clicked()
{
QString myName = mNameEdit->text();
QString myWidth = mWidth->text();
@@ -82,7 +88,7 @@ void QgsGeomTypeDialog::on_mAddAttributeButton_clicked()
mNameEdit->clear();
}

void QgsGeomTypeDialog::on_mRemoveAttributeButton_clicked()
void QgsNewVectorLayerDialog::on_mRemoveAttributeButton_clicked()
{
delete( mAttributeView->currentItem() );
if ( mAttributeView->topLevelItemCount() == 0 )
@@ -91,12 +97,12 @@ void QgsGeomTypeDialog::on_mRemoveAttributeButton_clicked()
}
}

void QgsGeomTypeDialog::on_buttonBox_helpRequested()
void QgsNewVectorLayerDialog::on_buttonBox_helpRequested()
{
QgsContextHelp::run( context_id );
}

void QgsGeomTypeDialog::attributes( std::list<std::pair<QString, QString> >& at ) const
void QgsNewVectorLayerDialog::attributes( std::list<std::pair<QString, QString> >& at ) const
{
QTreeWidgetItemIterator it( mAttributeView );
while ( *it )
@@ -109,7 +115,9 @@ void QgsGeomTypeDialog::attributes( std::list<std::pair<QString, QString> >& at
}
}

QString QgsGeomTypeDialog::selectedFileFormat() const
QString QgsNewVectorLayerDialog::selectedFileFormat() const
{
return mFileFormatComboBox->currentText();
//use userrole to avoid translated type string
QString myType = mFileFormatComboBox->itemData( mFileFormatComboBox->currentIndex(), Qt::UserRole ).toString();
return myType;
}
@@ -1,5 +1,5 @@
/***************************************************************************
qgsgeomtypedialog.h - description
qgsnewvectorlayerdialog.h - description
-------------------
begin : October 2004
copyright : (C) 2004 by Marco Hugentobler
@@ -15,21 +15,21 @@
* *
***************************************************************************/
/* $Id$ */
#ifndef QGSGEOMTYPEDIALOG_H
#define QGSGEOMTYPEDIALOG_H
#ifndef qgsnewvectorlayerdialog_H
#define qgsnewvectorlayerdialog_H

#include "ui_qgsgeomtypedialogbase.h"
#include "ui_qgsnewvectorlayerdialogbase.h"
#include "qgisgui.h"
#include "qgscontexthelp.h"

#include "qgis.h"

class QgsGeomTypeDialog: public QDialog, private Ui::QgsGeomTypeDialogBase
class QgsNewVectorLayerDialog: public QDialog, private Ui::QgsNewVectorLayerDialogBase
{
Q_OBJECT
public:
QgsGeomTypeDialog( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
~QgsGeomTypeDialog();
QgsNewVectorLayerDialog( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
~QgsNewVectorLayerDialog();
/**Returns the selected geometry type*/
QGis::WkbType selectedType() const;
/**Appends the chosen attribute names and types to at*/
@@ -49,4 +49,4 @@ class QgsGeomTypeDialog: public QDialog, private Ui::QgsGeomTypeDialogBase

};

#endif //QGSGEOMTYPEDIALOG_H
#endif //qgsnewvectorlayerdialog_H
@@ -1383,6 +1383,7 @@ QGISEXTERN bool createEmptyDataSource( const QString& uri,
QGis::WkbType vectortype,
const std::list<std::pair<QString, QString> >& attributes )
{
QgsDebugMsg( QString( "Creating empty vector layer with format: %1" ).arg( format ));
OGRSFDriverH driver;
QgsApplication::registerOgrDrivers();
driver = OGRGetDriverByName( format.toAscii() );

This file was deleted.

@@ -43,7 +43,7 @@
<item>
<widget class="QToolButton" name="mRemoveSelectionButton" >
<property name="toolTip" >
<string>Remove selection</string>
<string>Unselect all</string>
</property>
<property name="text" >
<string/>
@@ -65,7 +65,7 @@
<item>
<widget class="QToolButton" name="mSelectedToTopButton" >
<property name="toolTip" >
<string>Move selected to top</string>
<string>Move selection to top</string>
</property>
<property name="text" >
<string/>

0 comments on commit 0277bc7

Please sign in to comment.