Skip to content

Commit

Permalink
Usability improvements to the new vector layer dialog. Also refactore…
Browse files Browse the repository at this point in the history
…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.
4 changes: 2 additions & 2 deletions src/app/CMakeLists.txt
Expand Up @@ -20,7 +20,7 @@ SET(QGIS_APP_SRCS
qgsspatialitefilterproxymodel.cpp
qgsspatialitetablemodel.cpp
qgsdelattrdialog.cpp
qgsgeomtypedialog.cpp
qgsnewvectorlayerdialog.cpp
qgsgraduatedsymboldialog.cpp
qgshelpviewer.cpp
qgsidentifyresults.cpp
Expand Down Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -3139,6 +3139,9 @@ void QgisApp::fileNew( bool thePromptToSaveFlag )

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

if ( mMapCanvas && mMapCanvas->isDrawing() )
{
Expand All @@ -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 );
Expand Down Expand Up @@ -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()
Expand Down
@@ -1,5 +1,5 @@
/***************************************************************************
qgsgeomtypedialog.cpp - description
qgsnewvectorlayerdialog.cpp - description
-------------------
begin : October 2004
copyright : (C) 2004 by Marco Hugentobler
Expand All @@ -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() )
{
Expand All @@ -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();
Expand All @@ -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 )
Expand All @@ -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 )
Expand All @@ -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
Expand All @@ -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*/
Expand All @@ -49,4 +49,4 @@ class QgsGeomTypeDialog: public QDialog, private Ui::QgsGeomTypeDialogBase

};

#endif //QGSGEOMTYPEDIALOG_H
#endif //qgsnewvectorlayerdialog_H
1 change: 1 addition & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -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() );
Expand Down
144 changes: 0 additions & 144 deletions src/ui/qgsaddattrdialogbase.ui

This file was deleted.

4 changes: 2 additions & 2 deletions src/ui/qgsattributetabledialog.ui
Expand Up @@ -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/>
Expand All @@ -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/>
Expand Down

0 comments on commit 0277bc7

Please sign in to comment.