[QGIS Commit] r11149 - in trunk/qgis/src: app ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jul 22 16:56:14 EDT 2009


Author: wonder
Date: 2009-07-22 16:56:14 -0400 (Wed, 22 Jul 2009)
New Revision: 11149

Added:
   trunk/qgis/src/app/qgsattributetypedialog.cpp
   trunk/qgis/src/app/qgsattributetypedialog.h
   trunk/qgis/src/app/qgsattributetypeloaddialog.cpp
   trunk/qgis/src/app/qgsattributetypeloaddialog.h
   trunk/qgis/src/ui/qgsattributeloadfrommap.ui
   trunk/qgis/src/ui/qgsattributetypeedit.ui
Modified:
   trunk/qgis/src/app/CMakeLists.txt
   trunk/qgis/src/app/qgsvectorlayerproperties.cpp
   trunk/qgis/src/app/qgsvectorlayerproperties.h
Log:
[FEATURE] GUI for setting edit widgets for layer attributes.
Additionally added a dialog for loading value map from a layer (could be aspatial table too!)
Contributed by Richard Kostecky.


Modified: trunk/qgis/src/app/CMakeLists.txt
===================================================================
--- trunk/qgis/src/app/CMakeLists.txt	2009-07-22 19:46:26 UTC (rev 11148)
+++ trunk/qgis/src/app/CMakeLists.txt	2009-07-22 20:56:14 UTC (rev 11149)
@@ -6,6 +6,8 @@
   qgsaddattrdialog.cpp
   qgsattributeactiondialog.cpp
   qgsattributedialog.cpp
+  qgsattributetypedialog.cpp
+  qgsattributetypeloaddialog.cpp
   qgsbookmarkitem.cpp
   qgsbookmarks.cpp
   qgsclipboard.cpp
@@ -108,6 +110,8 @@
   qgsaddattrdialog.h
   qgsattributeactiondialog.h
   qgsattributedialog.h
+  qgsattributetypedialog.h
+  qgsattributetypeloaddialog.h
   qgsbookmarks.h
   qgscontinuouscolordialog.h
   qgsconfigureshortcutsdialog.h

Added: trunk/qgis/src/app/qgsattributetypedialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributetypedialog.cpp	                        (rev 0)
+++ trunk/qgis/src/app/qgsattributetypedialog.cpp	2009-07-22 20:56:14 UTC (rev 11149)
@@ -0,0 +1,488 @@
+/***************************************************************************
+                         qgsattributetypedialog.cpp  -  description
+                             -------------------
+    begin                : June 2009
+    copyright            : (C) 2000 by Richard Kostecky
+    email                : cSf.Kostej at gmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id$ */
+
+#include "qgsattributetypedialog.h"
+
+#include "qgsattributetypeloaddialog.h"
+
+#include "qgsvectordataprovider.h"
+#include "qgslogger.h"
+
+#include <QTableWidgetItem>
+
+
+QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl )
+    : QDialog(),
+    mLayer( vl )
+{
+  setupUi( this );
+  tableWidget->insertRow(0);
+  connect( selectionComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setStackPage( int ) ) );
+  connect( removeSelectedButton, SIGNAL( pressed( ) ), this, SLOT( removeSelectedButtonPushed( ) ) );
+  connect( loadFromLayerButton, SIGNAL( pressed( ) ), this, SLOT( loadFromLayerButtonPushed( ) ) );
+  connect( tableWidget,  SIGNAL( cellChanged( int, int ) ), this, SLOT( vCellChanged( int, int ) ) );
+}
+
+
+QgsAttributeTypeDialog::~QgsAttributeTypeDialog()
+{
+
+}
+
+QgsVectorLayer::EditType QgsAttributeTypeDialog::editType()
+{
+  return mEditType;
+}
+
+QgsVectorLayer::RangeData QgsAttributeTypeDialog::rangeData()
+{
+  return mRangeData;
+}
+
+QMap<QString, QVariant> &QgsAttributeTypeDialog::valueMap()
+{
+  return mValueMap;
+}
+
+
+void QgsAttributeTypeDialog::vCellChanged(int row, int column)
+{
+  if (row == tableWidget->rowCount() -1)
+  {
+    tableWidget->insertRow(row + 1);
+  } //else check type
+}
+
+void QgsAttributeTypeDialog::removeSelectedButtonPushed()
+{
+  QList<QTableWidgetItem *> list = tableWidget->selectedItems();
+  QList<QTableWidgetItem *>::iterator it = list.begin();
+  QSet<int> rowsToRemove;
+  int removed = 0;
+  int i = 0;
+  for (; i < list.size(); i++)
+  {
+    if (list[i]->column() == 0)
+    {
+      int row = list[i]->row();
+      if (!rowsToRemove.contains( row ))
+      {
+        rowsToRemove.insert( row );
+      }
+    }
+  }
+  for (i = 0; i< rowsToRemove.values().size(); i++)
+  {
+    tableWidget->removeRow( rowsToRemove.values()[i] - removed );
+    removed++;
+  }
+}
+
+void QgsAttributeTypeDialog::loadFromLayerButtonPushed()
+{
+  QgsAttributeTypeLoadDialog layerDialog( mLayer );
+  if ( !layerDialog.exec() )
+    return;
+
+  tableWidget->clearContents();
+  for (int i = tableWidget->rowCount() -1; i > 0; i--)
+  {
+    tableWidget->removeRow(i);
+  }
+  int row = 0;
+  QMap<QString, QVariant> &map = layerDialog.valueMap();
+  for ( QMap<QString, QVariant>::iterator mit = map.begin(); mit != map.end(); mit++, row++ )
+  {
+    tableWidget->insertRow( row );
+    if ( mit.value().isNull() )
+    {
+      tableWidget->setItem( row, 0, new QTableWidgetItem( mit.key() ) );
+    }
+    else
+    {
+      tableWidget->setItem( row, 0, new QTableWidgetItem( mit.key() ) );
+      tableWidget->setItem( row, 1, new QTableWidgetItem( mit.value().toString() ) );
+    }
+  }
+
+}
+
+
+void QgsAttributeTypeDialog::setPageForIndex( int index )
+{
+  if ( mLayer->editType( index ) ==  QgsVectorLayer::LineEdit )
+  {
+    setPage( 0 );
+  }
+  else if ( mLayer->editType( index ) == QgsVectorLayer::Classification)
+  {
+    setPage( 1 );
+  }
+  else if ( mLayer->editType( index ) == QgsVectorLayer::EditRange ||
+            mLayer->editType( index ) == QgsVectorLayer::SliderRange )
+  {
+    setPage( 2 );
+  }
+  else if ( mLayer->editType( index ) == QgsVectorLayer::UniqueValues ||
+            mLayer->editType( index ) == QgsVectorLayer::UniqueValuesEditable )
+  {
+    setPage( 3 );
+  }
+  else if ( mLayer->editType( index ) == QgsVectorLayer::FileName)
+  {
+    setPage( 4 );
+  }
+  else if ( mLayer->editType( index ) == QgsVectorLayer::ValueMap)
+  {
+    setPage( 5 );
+  }
+  else if ( mLayer->editType( index ) == QgsVectorLayer::Enumeration)
+  {
+    setPage( 6 );
+  }
+  else if ( mLayer->editType( index ) == QgsVectorLayer::Immutable)
+  {
+    setPage( 7 );
+  }
+}
+
+void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editType )
+{
+  if ( editType ==  QgsVectorLayer::LineEdit )
+  {
+    setPage( 0 );
+  }
+  else if ( editType == QgsVectorLayer::Classification)
+  {
+    setPage( 1 );
+  }
+  else if ( editType == QgsVectorLayer::EditRange ||
+            editType == QgsVectorLayer::SliderRange )
+  {
+    setPage( 2 );
+  }
+  else if ( editType == QgsVectorLayer::UniqueValues ||
+            editType == QgsVectorLayer::UniqueValuesEditable )
+  {
+    setPage( 3 );
+  }
+  else if ( editType == QgsVectorLayer::FileName)
+  {
+    setPage( 4 );
+  }
+  else if ( editType == QgsVectorLayer::ValueMap)
+  {
+    setPage( 5 );
+  }
+  else if ( editType == QgsVectorLayer::Enumeration)
+  {
+    setPage( 6 );
+  }
+  else if ( editType == QgsVectorLayer::Immutable)
+  {
+    setPage( 7 );
+  }
+}
+
+void QgsAttributeTypeDialog::setValueMap(QMap<QString, QVariant> valueMap)
+{
+  mValueMap = valueMap;
+}
+
+void QgsAttributeTypeDialog::setRange(QgsVectorLayer::RangeData range)
+{
+  mRangeData = range;
+}
+
+void QgsAttributeTypeDialog::setIndex( int index, int editTypeInt )
+{
+  mIndex = index;
+  //need to set index for combobox
+  QgsVectorLayer::EditType editType;
+  if (editTypeInt > -1)
+  {
+    editType = QgsVectorLayer::EditType( editTypeInt );
+  }
+  else
+  {
+    editType = mLayer->editType( index );
+  }
+
+  setWindowTitle( defaultWindowTitle() + " \"" + mLayer->pendingFields()[index].name() + "\"");
+  QgsAttributeList attributeList = QgsAttributeList();
+  attributeList.append( index );
+  mLayer->select( attributeList, QgsRectangle(), false );
+
+  QgsFeature f;
+  QString text;
+  //calculate min and max for range for this field
+  if (mLayer->pendingFields()[index].type() == QVariant::Int)
+  {
+    sliderRadioButton->setDisabled( false );
+    int min;
+    int max;
+    //filling initial values
+    if (mLayer->nextFeature( f ))
+    {
+      min = f.attributeMap()[index].toInt();
+      max = f.attributeMap()[index].toInt();
+    }
+    for ( ; mLayer->nextFeature( f );  )
+    {
+      QVariant val = f.attributeMap()[index];
+      if ( val.isValid() && !val.isNull() )
+      {
+        int valInt = val.toInt();
+        if (min > valInt)
+            min = valInt;
+        if (max < valInt)
+            max = valInt;
+      }
+      text = tr( "Current minimum for this value is %1 and current maximum is %2." ).arg( min ).arg( max );
+    }
+  }
+  else if (mLayer->pendingFields()[index].type() == QVariant::Double)
+  {
+    double dMin;
+    double dMax;
+
+    if (mLayer->nextFeature( f ))
+    {
+      dMin = f.attributeMap()[index].toDouble();
+      dMax = f.attributeMap()[index].toDouble();
+    }
+
+    sliderRadioButton->setDisabled( true );
+    editableRadioButton->setChecked( true );
+    for ( ; mLayer->nextFeature( f );  )
+    {
+      QVariant val = f.attributeMap()[index];
+      if ( val.isValid() && !val.isNull() )
+      {
+        double dVal =  val.toDouble();
+        if (dMin > dVal)
+            dMin = dVal;
+        if (dMax < dVal)
+            dMax = dVal;
+      }
+      text = tr( "Current minimum for this value is %1 and current maximum is %2." ).arg( dMin ).arg( dMax );
+    }
+  }
+  else
+  {
+    text = tr( "Attribute has no integer or real type, threfore range is not usable.");
+  }
+  valuesLabel->setText(text);
+
+  //setPageForIndex( index );
+  setPageForEditType( editType );
+
+  if ( editType == QgsVectorLayer::ValueMap)
+  {
+
+    tableWidget->clearContents();
+    for (int i = tableWidget->rowCount() -1; i > 0; i--)
+    {
+      tableWidget->removeRow(i);
+    }
+
+    // if some value map already present use it
+    QMap<QString, QVariant> map;
+    if (!mValueMap.empty())
+    {
+      map = mValueMap;
+    }
+    else
+    {
+      map = mLayer->valueMap( index );
+    }
+
+    int row = 0;
+    for ( QMap<QString, QVariant>::iterator mit = map.begin(); mit != map.end(); mit++, row++ )
+    {
+      tableWidget->insertRow( row );
+      if ( mit.value().isNull() )
+      {
+        tableWidget->setItem( row, 0, new QTableWidgetItem( mit.key() ) );
+      }
+      else
+      {
+        tableWidget->setItem( row, 0, new QTableWidgetItem( mit.value().toString() ) );
+        tableWidget->setItem( row, 1, new QTableWidgetItem( mit.key() ) );
+      }
+    }
+
+  }
+  else if ( editType == QgsVectorLayer::EditRange ||
+            editType == QgsVectorLayer::SliderRange )
+  {
+    if (mLayer->pendingFields()[mIndex].type() != QVariant::Int)
+    {
+      minimumSpinBox->setValue( mLayer->range( index ).mMin.toInt() );
+      maximumSpinBox->setValue( mLayer->range( index ).mMax.toInt() );
+      stepSpinBox->setValue( mLayer->range( index ).mStep.toInt() );
+    }
+    else if ( mLayer->pendingFields()[mIndex].type() == QVariant::Double )
+    {
+      minimumDoubleSpinBox->setValue( mLayer->range( index ).mMin.toDouble() );
+      maximumDoubleSpinBox->setValue( mLayer->range( index ).mMax.toDouble() );
+      stepDoubleSpinBox->setValue( mLayer->range( index ).mStep.toDouble() );
+    }
+    if ( editType == QgsVectorLayer::EditRange )
+      editableRadioButton->setChecked( true );
+    else //slider range
+      sliderRadioButton->setChecked( true );
+  }
+}
+
+
+void QgsAttributeTypeDialog::setPage( int index )
+{
+  this->selectionComboBox->setCurrentIndex( index );
+  setStackPage( index );
+}
+
+void QgsAttributeTypeDialog::setStackPage( int index )
+{
+  this->stackedWidget->setCurrentIndex( index );
+
+  bool okDisabled = false;
+  if ( index == 2 )
+  {
+    if (mLayer->pendingFields()[mIndex].type() != QVariant::Double &&
+        mLayer->pendingFields()[mIndex].type() != QVariant::Int)
+    {
+      okDisabled = true;
+    }
+    else if (mLayer->pendingFields()[mIndex].type() != QVariant::Double)
+    {
+      this->rangeStackedWidget->setCurrentIndex( 0 );
+      //load data
+      minimumSpinBox->setValue( mRangeData.mMin.toInt() );
+      maximumSpinBox->setValue( mRangeData.mMax.toInt() );
+      stepSpinBox->setValue( mRangeData.mStep.toInt() );
+    }
+    else
+    {
+      this->rangeStackedWidget->setCurrentIndex( 1 );
+      //load data
+      minimumDoubleSpinBox->setValue( mRangeData.mMin.toDouble() );
+      maximumDoubleSpinBox->setValue( mRangeData.mMax.toDouble() );
+      stepDoubleSpinBox->setValue( mRangeData.mStep.toDouble() );
+    }
+  }
+  else if ( index == 6 )
+  {
+    QStringList list;
+    mLayer->dataProvider()->enumValues( mIndex, list );
+    if ( list.size() == 0 )
+    {
+      okDisabled = true;
+      enumerationWarningLabel->setText( tr( "Enumeration is not available for this attribute" ) );
+    }
+    else
+    {
+        enumerationWarningLabel->setText( "" );
+    }
+
+  }
+  stackedWidget->currentWidget()->setDisabled( okDisabled );
+  buttonBox->button( QDialogButtonBox::Ok )->setDisabled( okDisabled );
+}
+
+void QgsAttributeTypeDialog::accept()
+{
+  //store data to output variables
+  switch (selectionComboBox->currentIndex())
+  {
+    case 0:
+      mEditType = QgsVectorLayer::LineEdit;
+      break;
+    case 1:
+      mEditType = QgsVectorLayer::Classification;
+      break;
+    case 2:
+      //store range data
+      if ( mLayer->pendingFields()[mIndex].type() == QVariant::Int )
+      {
+        mRangeData = QgsVectorLayer::RangeData( minimumSpinBox->value(),
+                                                maximumSpinBox->value(),
+                                                stepSpinBox->value() );
+      }
+      else
+      {
+        mRangeData = QgsVectorLayer::RangeData( minimumDoubleSpinBox->value(),
+                                                maximumDoubleSpinBox->value(),
+                                                stepDoubleSpinBox->value() );
+      }
+      //select correct one
+      if (editableRadioButton->isChecked())
+      {
+        mEditType = QgsVectorLayer::EditRange;
+      }
+      else
+      {
+        mEditType = QgsVectorLayer::SliderRange;
+      }
+      break;
+    case 3:
+      if (editableUniqueValues->isChecked())
+      {
+        mEditType = QgsVectorLayer::UniqueValuesEditable;
+      }
+      else
+      {
+        mEditType = QgsVectorLayer::UniqueValues;
+      }
+      break;
+    case 4:
+      mEditType = QgsVectorLayer::FileName;
+      break;
+    case 5:
+      //store data to map
+      mValueMap.clear();
+      for (int i = 0; i < tableWidget->rowCount() - 1; i++)
+      {
+        if ( tableWidget->item(i, 1)->text().isNull() )
+        {
+          mValueMap.insert(tableWidget->item(i, 0)->text(), tableWidget->item(i, 0)->text());
+        }
+        else
+        {
+          mValueMap.insert(tableWidget->item(i, 1)->text(), tableWidget->item(i, 0)->text());
+        }
+      }
+      mEditType = QgsVectorLayer::ValueMap;
+      break;
+    case 6:
+      mEditType = QgsVectorLayer::Enumeration;
+      break;
+    case 7:
+      mEditType = QgsVectorLayer::Immutable;
+      break;
+    default:
+      mEditType = QgsVectorLayer::LineEdit;
+  }
+
+  QDialog::accept();
+}
+
+QString QgsAttributeTypeDialog::defaultWindowTitle()
+{
+  return tr( "Attribute Edit Dialog" );
+}

Added: trunk/qgis/src/app/qgsattributetypedialog.h
===================================================================
--- trunk/qgis/src/app/qgsattributetypedialog.h	                        (rev 0)
+++ trunk/qgis/src/app/qgsattributetypedialog.h	2009-07-22 20:56:14 UTC (rev 11149)
@@ -0,0 +1,136 @@
+/***************************************************************************
+                         qgsattributetypedialog.h  -  description
+                             -------------------
+    begin                : June 2009
+    copyright            : (C) 2009 by Richard Kostecky
+    email                : csf.kostej at gmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id$ */
+#ifndef QGSATTRIBUTETYPEDIALOG_H
+#define QGSATTRIBUTETYPEDIALOG_H
+
+#include "ui_qgsattributetypeedit.h"
+
+#include "qgsvectorlayer.h"
+
+class QDialog;
+class QLayout;
+class QgsField;
+
+class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
+{
+    Q_OBJECT
+
+  public:
+    QgsAttributeTypeDialog( QgsVectorLayer *vl );
+    ~QgsAttributeTypeDialog();
+
+    /**
+     * Overloaded accept method which will write the feature field
+     * values, then delegate to QDialog::accept()
+     */
+    void accept();
+
+    /**
+     * Setting index, which page should be selected
+     * @param index of page to be selected
+     * @param editTypeInt type of edit type which was selected before save
+     */
+    void setIndex( int index, int editTypeInt = -1 );
+
+    /**
+     * Setting page which is to be selected
+     * @param index index of page which was selected
+     */
+    void setPage( int index );
+
+    /**
+     * Getter to get selected edit type
+     * @return selected edit type
+     */
+    QgsVectorLayer::EditType editType();
+
+    /**
+     * Setter to value map variable to display actual value
+     * @param valueMap map which is to be dispayed in this dialog
+     */
+    void setValueMap( QMap<QString, QVariant> valueMap);
+
+    /**
+     * Setter to range for to be displayed and edited in this dialog
+     * @param rangeData rande data which is to be displayed
+     */
+    void setRange( QgsVectorLayer::RangeData rangeData );
+
+    /**
+     * Getter for value map after editing
+     * @return map which is to be returned
+     */
+    QMap<QString, QVariant> &valueMap();
+
+    /**
+     * Getter for range data
+     * @return range data after editing
+     */
+    QgsVectorLayer::RangeData rangeData();
+
+  private slots:
+    /**
+     * Slot to handle change of index in combobox to select correct page
+     * @param index index of value in combobox
+     */
+    void setStackPage( int index );
+
+    /**
+     * Slot to handle button push to delete selected rows
+     */
+    void removeSelectedButtonPushed( );
+
+    /**
+     * Slot to handle load from button pushed to display dialo to load data
+     */
+    void loadFromLayerButtonPushed( );
+
+    /**
+     * Slot to handle change of cell to have always empty row at end
+     * @param row index of row which was changed
+     * @param column index of column which was changed
+     */
+    void vCellChanged( int row, int column );
+
+  private:
+
+    QString defaultWindowTitle();
+
+    /**
+     * Function to set page index
+     * @param index index of page to be changed
+     */
+    void setPageForIndex( int index );
+
+    /**
+     * Function to set page according to edit type
+     * @param editType edit type to set page
+     */
+    void setPageForEditType( QgsVectorLayer::EditType editType );
+
+
+    QMap<QString, QVariant> mValueMap;
+
+    QgsVectorLayer *mLayer;
+    int mIndex;
+
+    QgsVectorLayer::RangeData mRangeData;
+    QgsVectorLayer::EditType mEditType;
+};
+
+#endif

Added: trunk/qgis/src/app/qgsattributetypeloaddialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributetypeloaddialog.cpp	                        (rev 0)
+++ trunk/qgis/src/app/qgsattributetypeloaddialog.cpp	2009-07-22 20:56:14 UTC (rev 11149)
@@ -0,0 +1,210 @@
+/***************************************************************************
+                         qgsattributetypeloaddialog.cpp
+                             -------------------
+    begin                : June 2009
+    copyright            : (C) 2000 by Richard Kostecky
+    email                : cSf.Kostej at gmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id$ */
+
+#include "qgsattributetypeloaddialog.h"
+
+#include "qgsmaplayer.h"
+#include "qgsvectordataprovider.h"
+#include "qgslogger.h"
+#include "qgsmaplayerregistry.h"
+
+#include <QTableWidgetItem>
+#include <QLineEdit>
+#include <QComboBox>
+#include <QLabel>
+#include <QFrame>
+#include <QScrollArea>
+#include <QCompleter>
+#include <QSpinBox>
+#include <QPushButton>
+#include <QHBoxLayout>
+#include <QFileDialog>
+
+QgsAttributeTypeLoadDialog::QgsAttributeTypeLoadDialog( QgsVectorLayer *vl )
+    : QDialog(),
+    mLayer( vl )
+{
+  setupUi( this );
+
+  connect( layerComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( fillComboBoxes( int ) ) );
+  connect( keyComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( createPreview( int ) ) );
+  connect( valueComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( createPreview( int ) ) );
+  connect( previewButton, SIGNAL( pressed( ) ), this, SLOT( previewButtonPushed( ) ) );
+
+  fillLayerList();
+}
+
+
+QgsAttributeTypeLoadDialog::~QgsAttributeTypeLoadDialog()
+{
+
+}
+
+
+void QgsAttributeTypeLoadDialog::setVectorLayer( QgsVectorLayer *layer )
+{
+  mLayer = layer;
+}
+
+
+
+void QgsAttributeTypeLoadDialog::previewButtonPushed()
+{
+  createPreview( valueComboBox->currentIndex(), true);
+}
+
+void QgsAttributeTypeLoadDialog::fillLayerList()
+{
+  layerComboBox->clear();
+  int i = 0;
+  QgsMapLayer* dataLayer;
+  QMap<QString, QgsMapLayer*>::iterator layer_it = QgsMapLayerRegistry::instance()->mapLayers().begin();
+  for ( ; layer_it != QgsMapLayerRegistry::instance()->mapLayers().end(); layer_it++ )
+  {
+    layerComboBox->addItem( layer_it.key() );
+  }
+}
+
+void QgsAttributeTypeLoadDialog::fillComboBoxes( int layerIndex )
+{
+  //clear comboboxes first
+  keyComboBox->clear();
+  valueComboBox->clear();
+
+  if (layerIndex < 0)
+  {
+    return;
+  }
+
+  QgsMapLayer* dataLayer = QgsMapLayerRegistry::instance()->mapLayer( layerComboBox->currentText() );
+  QgsVectorLayer* vLayer = dynamic_cast<QgsVectorLayer *>( dataLayer );
+  if (vLayer == NULL)
+  {
+      return;
+  }
+  QMap<QString, int> fieldMap = vLayer->dataProvider()->fieldNameMap();
+  QMap<QString, int>::iterator it = fieldMap.begin();
+  for (; it != fieldMap.end(); it++)
+  {
+    keyComboBox->addItem(it.key(), it.value());
+    valueComboBox->addItem(it.key(), it.value());
+  }
+
+}
+
+void QgsAttributeTypeLoadDialog::createPreview( int fieldIndex, bool full)
+{
+  previewTableWidget->clearContents();
+
+  for (int i = previewTableWidget->rowCount() -1; i > 0; i--)
+  {
+    previewTableWidget->removeRow(i);
+  }
+  if (layerComboBox->currentIndex() < 0 || fieldIndex < 0 )
+  {
+    //when nothing is selected there is no reason for preview
+    return;
+  }
+  int idx = keyComboBox->itemData(keyComboBox->currentIndex()).toInt();
+  int idx2 = valueComboBox->itemData(valueComboBox->currentIndex()).toInt();
+  QgsMapLayer* dataLayer = QgsMapLayerRegistry::instance()->mapLayer( layerComboBox->currentText() );
+  QgsVectorLayer* vLayer = dynamic_cast<QgsVectorLayer *>( dataLayer );
+  if (vLayer == NULL)
+  {
+      return;
+  }
+
+  QgsVectorDataProvider* dataProvider = vLayer->dataProvider();
+  dataProvider->enableGeometrylessFeatures( true );
+
+  QgsAttributeList attributeList = QgsAttributeList();
+  attributeList.append( idx );
+  attributeList.append( idx2 );
+  vLayer->select( attributeList, QgsRectangle(), false );
+
+  QgsFeature f;
+  QMap<QString, QVariant> valueMap;
+  while ( vLayer->nextFeature( f ) )
+  {
+    QVariant val1 = f.attributeMap()[idx];
+    QVariant val2 = f.attributeMap()[idx2];
+    if ( val1.isValid() && !val1.isNull() && !val1.toString().isEmpty()
+      && val2.isValid() && !val2.isNull() && !val2.toString().isEmpty() )
+    {
+      valueMap.insert(val1.toString(), val2.toString() );
+    }
+    if (!full && valueMap.size() > 8)
+        break; //just first entries all on button
+  }
+  int row = 0;
+  for ( QMap<QString, QVariant>::iterator mit = valueMap.begin(); mit != valueMap.end(); mit++, row++ )
+  {
+    previewTableWidget->insertRow( row );
+    previewTableWidget->setItem( row, 0, new QTableWidgetItem( mit.value().toString() ) );
+    previewTableWidget->setItem( row, 1, new QTableWidgetItem( mit.key() ) );
+  }
+
+  dataProvider->enableGeometrylessFeatures( false );
+}
+
+QMap<QString, QVariant> &QgsAttributeTypeLoadDialog::valueMap()
+{
+  return mValueMap;
+}
+
+void QgsAttributeTypeLoadDialog::loadDataToValueMap()
+{
+  mValueMap.clear();
+  int idx = keyComboBox->itemData(keyComboBox->currentIndex()).toInt();
+  int idx2 = valueComboBox->itemData(valueComboBox->currentIndex()).toInt();
+  QgsMapLayer* dataLayer = QgsMapLayerRegistry::instance()->mapLayer( layerComboBox->currentText() );
+  QgsVectorLayer* vLayer = dynamic_cast<QgsVectorLayer *>( dataLayer );
+  if (vLayer == NULL)
+  {
+      return;
+  }
+
+  QgsVectorDataProvider* dataProvider = vLayer->dataProvider();
+  dataProvider->enableGeometrylessFeatures( true );
+
+  QgsAttributeList attributeList = QgsAttributeList();
+  attributeList.append( idx );
+  attributeList.append( idx2 );
+  vLayer->select( attributeList, QgsRectangle(), false );
+
+  QgsFeature f;
+  while ( vLayer->nextFeature( f ) )
+  {
+    QVariant val = f.attributeMap()[idx];
+    if ( val.isValid() && !val.isNull() && !val.toString().isEmpty() )
+    {
+      mValueMap.insert(f.attributeMap()[idx2].toString(), val );
+    }
+  }
+  dataProvider->enableGeometrylessFeatures( false );
+}
+
+
+
+void QgsAttributeTypeLoadDialog::accept()
+{
+  //store data to output variable
+  loadDataToValueMap();
+  QDialog::accept();
+}
+

Added: trunk/qgis/src/app/qgsattributetypeloaddialog.h
===================================================================
--- trunk/qgis/src/app/qgsattributetypeloaddialog.h	                        (rev 0)
+++ trunk/qgis/src/app/qgsattributetypeloaddialog.h	2009-07-22 20:56:14 UTC (rev 11149)
@@ -0,0 +1,98 @@
+/***************************************************************************
+                         qgsattributetypeloaddialog.h
+                             -------------------
+    begin                : June 2009
+    copyright            : (C) 2009 by Richard Kostecky
+    email                : csf.kostej at gmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id$ */
+#ifndef QGSATTRIBUTETYPELOADDIALOG_H
+#define QGSATTRIBUTETYPELOADDIALOG_H
+
+#include "ui_qgsattributeloadfrommap.h"
+
+#include "qgsfeature.h"
+#include "qgsvectorlayer.h"
+#include <vector>
+
+class QDialog;
+class QLayout;
+class QgsField;
+class QgsMapCanvas;
+
+class QgsAttributeTypeLoadDialog: public QDialog, private Ui::QgsAttributeLoadValues
+{
+    Q_OBJECT
+
+  public:
+    QgsAttributeTypeLoadDialog( QgsVectorLayer *vl );
+    ~QgsAttributeTypeLoadDialog();
+
+    /**
+     * Overloaded accept method which will write the feature field
+     * values, then delegate to QDialog::accept()
+     */
+    void accept();
+
+    /**
+     * Sets predefined vector layer for selection of data
+     * @param layer Vector layer which is to be set as predefined one
+     */
+    void setVectorLayer( QgsVectorLayer *layer );
+
+    /**
+     * Getter to value map which is currently active
+     * @return value map of vlues selected from layer
+     */
+    QMap<QString, QVariant> &valueMap();
+
+  private slots:
+    /**
+     * Slot which reacts to change of selected layer to fill other two comboboxes with correct data
+     * @param layerIndex index of layer which was selected
+     */
+    void fillComboBoxes( int layerIndex );
+
+    /**
+     * Slot to react to button push or change of selected column for display of preview
+     * @param fieldIndex indexOfChangedField
+     * @param full flag if all values should be displayed or just preview of first 10
+     */
+    void createPreview( int fieldIndex, bool full = false);
+
+
+    /**
+     * Slot to react to value Preview button pushed
+     */
+    void previewButtonPushed( );
+
+  private:
+
+    /**
+     * Internal function to fill the list of layers
+     */
+    void fillLayerList();
+
+    /**
+     * Function to transfer data from layer to value map used in editing
+     */
+    void loadDataToValueMap();
+
+    QgsVectorLayer *mLayer;
+    int mIndex;
+
+
+    QMap<QString, QVariant> mValueMap;
+    QgsVectorLayer::EditType mEditType;
+};
+
+#endif

Modified: trunk/qgis/src/app/qgsvectorlayerproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsvectorlayerproperties.cpp	2009-07-22 19:46:26 UTC (rev 11148)
+++ trunk/qgis/src/app/qgsvectorlayerproperties.cpp	2009-07-22 20:56:14 UTC (rev 11149)
@@ -64,7 +64,8 @@
 QgsVectorLayerProperties::QgsVectorLayerProperties(
   QgsVectorLayer *lyr,
   QWidget * parent,
-  Qt::WFlags fl )
+  Qt::WFlags fl
+  )
     : QDialog( parent, fl ),
     layer( lyr ),
     mRendererDialog( 0 )
@@ -90,6 +91,7 @@
   mDeleteAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionDeleteAttribute.png" ) );
   mToggleEditingButton->setIcon( QgisApp::getThemeIcon( "/mActionToggleEditing.png" ) );
 
+
   // Create the Label dialog tab
   QVBoxLayout *layout = new QVBoxLayout( labelOptionsFrame );
   layout->setMargin( 0 );
@@ -146,7 +148,7 @@
 
   tblAttributes->clear();
 
-  tblAttributes->setColumnCount( 9 );
+  tblAttributes->setColumnCount( 8 );
   tblAttributes->setRowCount( fields.size() );
   tblAttributes->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "id" ) ) );
   tblAttributes->setHorizontalHeaderItem( 1, new QTableWidgetItem( tr( "name" ) ) );
@@ -155,8 +157,7 @@
   tblAttributes->setHorizontalHeaderItem( 4, new QTableWidgetItem( tr( "precision" ) ) );
   tblAttributes->setHorizontalHeaderItem( 5, new QTableWidgetItem( tr( "comment" ) ) );
   tblAttributes->setHorizontalHeaderItem( 6, new QTableWidgetItem( tr( "edit widget" ) ) );
-  tblAttributes->setHorizontalHeaderItem( 7, new QTableWidgetItem( tr( "values" ) ) );
-  tblAttributes->setHorizontalHeaderItem( 8, new QTableWidgetItem( tr( "alias" ) ) );
+  tblAttributes->setHorizontalHeaderItem( 7, new QTableWidgetItem( tr( "alias" ) ) );
 
   tblAttributes->setSelectionBehavior( QAbstractItemView::SelectRows );
   tblAttributes->setSelectionMode( QAbstractItemView::MultiSelection );
@@ -180,61 +181,144 @@
   for ( int i = 0; i < 6; i++ )
     tblAttributes->item( row, i )->setFlags( tblAttributes->item( row, i )->flags() & ~Qt::ItemIsEditable );
 
-  QComboBox *cb = new QComboBox();
-  cb->addItem( tr( "line edit" ), QgsVectorLayer::LineEdit );
-  cb->addItem( tr( "unique values" ), QgsVectorLayer::UniqueValues );
-  cb->addItem( tr( "unique values (editable)" ), QgsVectorLayer::UniqueValuesEditable );
-  cb->addItem( tr( "value map" ), QgsVectorLayer::ValueMap );
-  cb->addItem( tr( "classification" ), QgsVectorLayer::Classification );
-  cb->addItem( tr( "range (editable)" ), QgsVectorLayer::EditRange );
-  cb->addItem( tr( "range (slider)" ), QgsVectorLayer::SliderRange );
-  cb->addItem( tr( "file name" ), QgsVectorLayer::FileName );
-  cb->addItem( tr( "enumeration" ), QgsVectorLayer::Enumeration );
-  cb->addItem( tr( "immutable" ), QgsVectorLayer::Immutable );
-  cb->setSizeAdjustPolicy( QComboBox::AdjustToContentsOnFirstShow );
-  cb->setCurrentIndex( layer->editType( idx ) );
+  QString buttonText;
+  switch (layer->editType( idx ))
+  {
+    case QgsVectorLayer::LineEdit:
+      buttonText = "Line Edit";
+      break;
+    case QgsVectorLayer::UniqueValues:
+      buttonText = "Unique Values";
+      break;
+    case QgsVectorLayer::UniqueValuesEditable:
+      buttonText = "Unique Values Editable";
+      break;
+    case QgsVectorLayer::Classification:
+      buttonText = "Classification";
+      break;
+    case QgsVectorLayer::ValueMap:
+      buttonText = "Value Map";
+      break;
+    case QgsVectorLayer::EditRange:
+      buttonText = "Edit Range";
+      break;
+    case QgsVectorLayer::SliderRange:
+      buttonText = "Slider Range";
+      break;
+    case QgsVectorLayer::FileName:
+      buttonText = "File Name";
+      break;
+    case QgsVectorLayer::Enumeration:
+      buttonText =  tr( "Enumeration" );
+      break;
+    case QgsVectorLayer::Immutable:
+      buttonText =  tr( "Immutable" );
+      break;
+  }
+  QPushButton * pb = new QPushButton(buttonText);
+  tblAttributes->setCellWidget( row, 6, pb );
+  connect( pb, SIGNAL( pressed() ), this, SLOT( attributeTypeDialog( ) ) );
+  mButtonMap.insert( idx, pb );
 
-  tblAttributes->setCellWidget( row, 6, cb );
+  //set the alias for the attribute
+  tblAttributes->setItem( row, 7, new QTableWidgetItem(layer->attributeAlias(idx)));
 
-  if ( layer->editType( idx ) == QgsVectorLayer::ValueMap )
+}
+
+QgsVectorLayerProperties::~QgsVectorLayerProperties()
+{
+  disconnect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
+}
+
+void QgsVectorLayerProperties::attributeTypeDialog( )
+{
+  int index = -1;
+  QMap<int, QPushButton*>::iterator it = mButtonMap.begin();
+  for (; it != mButtonMap.end() ;it++)
   {
-    // TODO: create a gui for value maps
-    QStringList mapList;
-    QMap<QString, QVariant> &map = layer->valueMap( idx );
-    for ( QMap<QString, QVariant>::iterator mit = map.begin(); mit != map.end(); mit++ )
-    {
-      QgsDebugMsg( QString( "idx:%1 key:%2 value:%3" ).arg( idx ).arg( mit.key() ).arg( mit.value().toString() ) );
-      if ( mit.value().isNull() )
-        mapList << mit.key();
-      else
-        mapList << QString( "%1=%2" ).arg( mit.key() ).arg( mit.value().toString() );
-    }
+     if (it.value()->isDown())
+     {
+       index = it.key();
+     }
+  }
 
-    tblAttributes->setItem( row, 7, new QTableWidgetItem( mapList.join( ";" ) ) );
+  QgsAttributeTypeDialog attributeTypeDialog( layer );
+
+  if (mValueMaps.contains(index))
+  {
+    attributeTypeDialog.setValueMap(mValueMaps[index]);
   }
-  else if ( layer->editType( idx ) == QgsVectorLayer::EditRange ||
-            layer->editType( idx ) == QgsVectorLayer::SliderRange )
+  else
   {
-    tblAttributes->setItem(
-      row, 7,
-      new QTableWidgetItem( QString( "%1;%2;%3" )
-                            .arg( layer->range( idx ).mMin.toString() )
-                            .arg( layer->range( idx ).mMax.toString() )
-                            .arg( layer->range( idx ).mStep.toString() )
-                          )
-    );
+    attributeTypeDialog.setValueMap( QMap<QString, QVariant>() );
   }
 
-  //set the alias for the attribute
-  tblAttributes->setItem( row, 8, new QTableWidgetItem( layer->attributeAlias( idx ) ) );
-}
+  if (mRanges.contains(index))
+  {
+    attributeTypeDialog.setRange( mRanges[index] );
+  }
+  else
+  {
+    attributeTypeDialog.setRange( QgsVectorLayer::RangeData(0, 5, 1));
+  }
 
+  if (mEditTypeMap.contains(index))
+  {
+    attributeTypeDialog.setIndex( index, mEditTypeMap[index] );
+  }
+  else
+  {
+    attributeTypeDialog.setIndex( index );
+  }
 
-QgsVectorLayerProperties::~QgsVectorLayerProperties()
-{
-  disconnect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
+  if (!attributeTypeDialog.exec())
+    return;
+
+  QgsVectorLayer::EditType editType = attributeTypeDialog.editType();
+  mEditTypeMap.insert(index, editType);
+  QString buttonText;
+  switch ( editType )
+  {
+    case QgsVectorLayer::LineEdit:
+      buttonText = "Line Edit";
+      break;
+    case QgsVectorLayer::UniqueValues:
+      buttonText = "Unique Values";
+      break;
+    case QgsVectorLayer::UniqueValuesEditable:
+      buttonText = "Unique Values Editable";
+      break;
+    case QgsVectorLayer::Classification:
+      buttonText = "Classification";
+      break;
+    case QgsVectorLayer::ValueMap:
+      buttonText = "Value Map";
+      mValueMaps.insert(index, attributeTypeDialog.valueMap() );
+      break;
+    case QgsVectorLayer::EditRange:
+      buttonText = "Edit Range";
+      mRanges.insert(index, attributeTypeDialog.rangeData());
+      break;
+    case QgsVectorLayer::SliderRange:
+      buttonText = "Slider Range";
+      mRanges.insert(index, attributeTypeDialog.rangeData());
+      break;
+    case QgsVectorLayer::FileName:
+      buttonText = "File Name";
+      break;
+    case QgsVectorLayer::Enumeration:
+      buttonText = "Enumeration";
+      break;
+    case QgsVectorLayer::Immutable:
+      buttonText = "Immutable";
+      break;
+  }
+  QPushButton *pb = dynamic_cast<QPushButton*>( tblAttributes->cellWidget( index, 6 ) );
+  pb->setText( buttonText );
+
 }
 
+
 void QgsVectorLayerProperties::toggleEditing()
 {
   emit toggleEditing( layer );
@@ -267,10 +351,16 @@
   QgsAddAttrDialog dialog( layer->dataProvider(), this );
   if ( dialog.exec() == QDialog::Accepted )
   {
+    layer->beginEditCommand("Attribute added");
     if ( !addAttribute( dialog.field() ) )
     {
+      layer->destroyEditCommand();
       QMessageBox::information( this, tr( "Name conflict" ), tr( "The attribute could not be inserted. The name already exists in the table." ) );
     }
+    else
+    {
+      layer->endEditCommand();
+    }
   }
 }
 
@@ -300,7 +390,6 @@
     if (( *it )->column() == 0 )
       idxs << ( *it )->text().toInt();
   }
-
   for ( QList<int>::const_iterator it = idxs.begin(); it != idxs.end(); it++ )
   {
     layer->beginEditCommand( tr( "Deleted attribute" ) );
@@ -506,6 +595,53 @@
   QgsContextHelp::run( context_id );
 }
 
+
+QgsVectorLayer::EditType QgsVectorLayerProperties::getEditType(QString text)
+{
+  if (text == "Line Edit")
+  {
+    return QgsVectorLayer::LineEdit;
+  }
+  else if (text == "Unique Values")
+  {
+    return QgsVectorLayer::UniqueValues;
+  }
+  else if (text == "Unique Values Editable")
+  {
+    return QgsVectorLayer::UniqueValuesEditable;
+  }
+  else if (text == "Classification")
+  {
+    return QgsVectorLayer::Classification;
+  }
+  else if (text == "Value Map")
+  {
+    return QgsVectorLayer::ValueMap;
+  }
+  else if (text == "Edit Range")
+  {
+    return QgsVectorLayer::EditRange;
+  }
+  else if (text == "Slider Range")
+  {
+    return QgsVectorLayer::SliderRange;
+  }
+  else if (text == "File Name")
+  {
+    return QgsVectorLayer::FileName;
+  }
+  else if (text == "Enumeration")
+  {
+    return QgsVectorLayer::Enumeration;
+  }
+  else if (text == "Immutable")
+  {
+    return QgsVectorLayer::Immutable;
+  }
+  return QgsVectorLayer::LineEdit;
+}
+
+
 void QgsVectorLayerProperties::apply()
 {
   //
@@ -546,67 +682,28 @@
     int idx = tblAttributes->item( i, 0 )->text().toInt();
     const QgsField &field = layer->pendingFields()[idx];
 
-    QComboBox *cb = dynamic_cast<QComboBox*>( tblAttributes->cellWidget( i, 6 ) );
-    if ( !cb )
+    QPushButton *pb = dynamic_cast<QPushButton*>( tblAttributes->cellWidget( i, 6 ) );
+    if ( !pb )
       continue;
 
-    QgsVectorLayer::EditType editType = ( QgsVectorLayer::EditType ) cb->itemData( cb->currentIndex() ).toInt();
+    QgsVectorLayer::EditType editType = getEditType( pb->text());
     layer->setEditType( idx, editType );
 
-    QString value = tblAttributes->item( i, 7 ) ? tblAttributes->item( i, 7 )->text() : QString::null;
-
     if ( editType == QgsVectorLayer::ValueMap )
     {
-      QMap<QString, QVariant> &map = layer->valueMap( idx );
-      map.clear();
-
-      if ( !value.isEmpty() )
+      if (mValueMaps.contains( idx ))
       {
-        QStringList values = value.split( ";" );
-        for ( int j = 0; j < values.size(); j++ )
-        {
-          QStringList args = values[j].split( "=" );
-          QVariant value;
-
-          if ( args.size() == 1 || ( args.size() == 2 && args[0] == args[1] ) )
-          {
-            QgsDebugMsg( QString( "idx:%1 key:%2 value:%2" ).arg( idx ).arg( args[0] ) );
-            value = args[0];
-          }
-          else if ( args.size() == 2 )
-          {
-            QgsDebugMsg( QString( "idx:%1 key:%2 value:%3" ).arg( idx ).arg( args[0] ).arg( args[1] ) );
-            value = args[1];
-
-          }
-
-          if ( value.canConvert( field.type() ) )
-          {
-            map.insert( args[0], value );
-          }
-        }
+        QMap<QString, QVariant> &map = layer->valueMap( idx );
+        map.clear();
+        map = mValueMaps[idx];
       }
     }
     else if ( editType == QgsVectorLayer::EditRange ||
               editType == QgsVectorLayer::SliderRange )
     {
-      QStringList values = value.split( ";" );
-
-      if ( values.size() == 3 )
+      if (mRanges.contains( idx ) )
       {
-        QVariant min  = values[0];
-        QVariant max  = values[1];
-        QVariant step = values[2];
-
-        if ( min.canConvert( field.type() ) &&
-             max.canConvert( field.type() ) &&
-             step.canConvert( field.type() ) )
-        {
-          min.convert( field.type() );
-          max.convert( field.type() );
-          step.convert( field.type() );
-          layer->range( idx ) = QgsVectorLayer::RangeData( min, max, step );
-        }
+        layer->range( idx ) = mRanges[idx];
       }
     }
   }

Modified: trunk/qgis/src/app/qgsvectorlayerproperties.h
===================================================================
--- trunk/qgis/src/app/qgsvectorlayerproperties.h	2009-07-22 19:46:26 UTC (rev 11148)
+++ trunk/qgis/src/app/qgsvectorlayerproperties.h	2009-07-22 20:56:14 UTC (rev 11149)
@@ -25,7 +25,9 @@
 #include "qgsrenderer.h"
 #include "qgsaddattrdialog.h"
 #include "qgsdelattrdialog.h"
+#include "qgsattributetypedialog.h"
 #include "qgsfield.h"
+#include "qgsmapcanvas.h"
 
 class QgsMapLayer;
 
@@ -39,7 +41,7 @@
 {
     Q_OBJECT
   public:
-    QgsVectorLayerProperties( QgsVectorLayer *lyr = 0, QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
+    QgsVectorLayerProperties( QgsVectorLayer *lyr = 0, QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags);
     ~QgsVectorLayerProperties();
     /**Sets the legend type to "single symbol", "graduated symbol" or "continuous color"*/
     void setLegendType( QString type );
@@ -61,6 +63,8 @@
 
   public slots:
 
+    void attributeTypeDialog();
+
     void alterLayerDialog( const QString& string );
 
     /** Reset to original (vector layer) values */
@@ -123,6 +127,10 @@
     QgsAttributeActionDialog* actionDialog;
 
     QList<QgsApplyDialog*> mOverlayDialogs;
+    QMap<int, QPushButton*> mButtonMap;
+    QMap<int, QgsVectorLayer::EditType> mEditTypeMap;
+    QMap<int, QMap<QString, QVariant> > mValueMaps;
+    QMap<int, QgsVectorLayer::RangeData> mRanges;
 
     void updateButtons();
     void loadRows();
@@ -135,6 +143,7 @@
     //QPixmap bufferPixmap;
     static const int context_id = 94000531;
 
+    QgsVectorLayer::EditType getEditType(QString text);
 };
 
 inline QString QgsVectorLayerProperties::displayName()

Added: trunk/qgis/src/ui/qgsattributeloadfrommap.ui
===================================================================
--- trunk/qgis/src/ui/qgsattributeloadfrommap.ui	                        (rev 0)
+++ trunk/qgis/src/ui/qgsattributeloadfrommap.ui	2009-07-22 20:56:14 UTC (rev 11149)
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QgsAttributeLoadValues</class>
+ <widget class="QDialog" name="QgsAttributeLoadValues">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>362</width>
+    <height>374</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Load values from layer</string>
+  </property>
+  <widget class="QDialogButtonBox" name="buttonBox">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>340</y>
+     <width>341</width>
+     <height>32</height>
+    </rect>
+   </property>
+   <property name="orientation">
+    <enum>Qt::Horizontal</enum>
+   </property>
+   <property name="standardButtons">
+    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+   </property>
+  </widget>
+  <widget class="QWidget" name="gridLayoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>10</y>
+     <width>341</width>
+     <height>331</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="1" column="0">
+     <widget class="QLabel" name="layerLabel">
+      <property name="text">
+       <string>Layer</string>
+      </property>
+     </widget>
+    </item>
+    <item row="3" column="0">
+     <widget class="QLabel" name="keyLabel">
+      <property name="text">
+       <string>Description</string>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="1" colspan="2">
+     <widget class="QComboBox" name="layerComboBox"/>
+    </item>
+    <item row="5" column="0" colspan="3">
+     <widget class="QTableWidget" name="previewTableWidget">
+      <column>
+       <property name="text">
+        <string>Value</string>
+       </property>
+      </column>
+      <column>
+       <property name="text">
+        <string>Description</string>
+       </property>
+      </column>
+     </widget>
+    </item>
+    <item row="0" column="0" colspan="3">
+     <widget class="QLabel" name="valueTableLabel">
+      <property name="text">
+       <string>Select data from attributes in selected layer.</string>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="0">
+     <widget class="QLabel" name="valueLabel">
+      <property name="text">
+       <string>Value</string>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="1">
+     <widget class="QComboBox" name="valueComboBox"/>
+    </item>
+    <item row="2" column="2" rowspan="2">
+     <widget class="QPushButton" name="previewButton">
+      <property name="text">
+       <string>View All</string>
+      </property>
+     </widget>
+    </item>
+    <item row="3" column="1">
+     <widget class="QComboBox" name="keyComboBox"/>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>QgsAttributeLoadValues</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>QgsAttributeLoadValues</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

Added: trunk/qgis/src/ui/qgsattributetypeedit.ui
===================================================================
--- trunk/qgis/src/ui/qgsattributetypeedit.ui	                        (rev 0)
+++ trunk/qgis/src/ui/qgsattributetypeedit.ui	2009-07-22 20:56:14 UTC (rev 11149)
@@ -0,0 +1,499 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QgsAttributeTypeDialog</class>
+ <widget class="QDialog" name="QgsAttributeTypeDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>401</width>
+    <height>428</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Attribute Edit Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QComboBox" name="selectionComboBox">
+     <item>
+      <property name="text">
+       <string>Line edit</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Classification</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Range</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Unique values</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>File name</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Value map</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Enumeration</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Immutable</string>
+      </property>
+     </item>
+    </widget>
+   </item>
+   <item>
+    <widget class="QStackedWidget" name="stackedWidget">
+     <property name="currentIndex">
+      <number>0</number>
+     </property>
+     <widget class="QWidget" name="lineEditPage">
+      <layout class="QVBoxLayout" name="verticalLayout_9">
+       <item>
+        <widget class="QLabel" name="lineEditLabel">
+         <property name="text">
+          <string>Simple edit box. This is the default editation widget.</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer_5">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>321</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="classificationPage">
+      <layout class="QVBoxLayout" name="verticalLayout_10">
+       <item>
+        <widget class="QLabel" name="classificationLabel">
+         <property name="text">
+          <string>Displays combo box containing values of attribute used for classification.</string>
+         </property>
+         <property name="wordWrap">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer_6">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>304</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="rangePage">
+      <layout class="QVBoxLayout" name="verticalLayout_4">
+       <item>
+        <layout class="QVBoxLayout" name="verticalRangeLayout">
+         <item>
+          <widget class="QLabel" name="rangeLabel">
+           <property name="text">
+            <string>Allows to set numeric values from a specified range. The edit widget can be either a slider or a spin box.</string>
+           </property>
+           <property name="wordWrap">
+            <bool>true</bool>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <layout class="QGridLayout" name="gridRangeLayout">
+           <item row="0" column="0">
+            <widget class="QLabel" name="minimumLabel">
+             <property name="text">
+              <string>Minimum</string>
+             </property>
+            </widget>
+           </item>
+           <item row="1" column="0">
+            <widget class="QLabel" name="maximumLabel">
+             <property name="text">
+              <string>Maximum</string>
+             </property>
+            </widget>
+           </item>
+           <item row="2" column="0">
+            <widget class="QLabel" name="stepLabel">
+             <property name="text">
+              <string>Step</string>
+             </property>
+            </widget>
+           </item>
+           <item row="0" column="1" rowspan="3">
+            <widget class="QStackedWidget" name="rangeStackedWidget">
+             <property name="currentIndex">
+              <number>1</number>
+             </property>
+             <widget class="QWidget" name="intPage">
+              <layout class="QVBoxLayout" name="verticalLayout_11">
+               <item>
+                <widget class="QSpinBox" name="minimumSpinBox">
+                 <property name="maximum">
+                  <number>999999999</number>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QSpinBox" name="maximumSpinBox">
+                 <property name="maximum">
+                  <number>999999999</number>
+                 </property>
+                 <property name="value">
+                  <number>5</number>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QSpinBox" name="stepSpinBox">
+                 <property name="maximum">
+                  <number>999999999</number>
+                 </property>
+                 <property name="value">
+                  <number>1</number>
+                 </property>
+                </widget>
+               </item>
+              </layout>
+             </widget>
+             <widget class="QWidget" name="doublePage">
+              <layout class="QVBoxLayout" name="verticalLayout_12">
+               <item>
+                <widget class="QDoubleSpinBox" name="minimumDoubleSpinBox">
+                 <property name="maximum">
+                  <double>999999999.990000009536743</double>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QDoubleSpinBox" name="maximumDoubleSpinBox">
+                 <property name="maximum">
+                  <double>999999999.990000009536743</double>
+                 </property>
+                 <property name="value">
+                  <double>5.000000000000000</double>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QDoubleSpinBox" name="stepDoubleSpinBox">
+                 <property name="maximum">
+                  <double>999999999.990000009536743</double>
+                 </property>
+                 <property name="value">
+                  <double>1.000000000000000</double>
+                 </property>
+                </widget>
+               </item>
+              </layout>
+             </widget>
+            </widget>
+           </item>
+          </layout>
+         </item>
+         <item>
+          <widget class="QRadioButton" name="sliderRadioButton">
+           <property name="text">
+            <string>Slider</string>
+           </property>
+           <property name="checked">
+            <bool>true</bool>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QRadioButton" name="editableRadioButton">
+           <property name="text">
+            <string>Editable</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QLabel" name="valuesLabel">
+           <property name="text">
+            <string>Local minimum/maximum = 0/0</string>
+           </property>
+           <property name="wordWrap">
+            <bool>true</bool>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="uniqueValuesPage">
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <item>
+        <layout class="QVBoxLayout" name="verticalLayout_2">
+         <item>
+          <widget class="QLabel" name="label">
+           <property name="text">
+            <string>The user can select one of the values already used in the attribute. If editable, a line edit is shown with autocompletion support, otherwise a combo box is used.</string>
+           </property>
+           <property name="wordWrap">
+            <bool>true</bool>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QCheckBox" name="editableUniqueValues">
+           <property name="text">
+            <string>Editable</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer name="verticalSpacer">
+           <property name="orientation">
+            <enum>Qt::Vertical</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>20</width>
+             <height>40</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="fileNamePage">
+      <layout class="QVBoxLayout" name="verticalLayout_5">
+       <item>
+        <widget class="QLabel" name="fileNameLabel">
+         <property name="text">
+          <string>Simplifies file selection by adding a file chooser dialog.</string>
+         </property>
+         <property name="wordWrap">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer_2">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="valueMapPage">
+      <layout class="QGridLayout" name="gridLayout">
+       <item row="0" column="0" colspan="2">
+        <widget class="QLabel" name="valueMapLabel">
+         <property name="text">
+          <string>Combo box with predefined items. Value is stored in the attribute, description is shown in the combo box.</string>
+         </property>
+         <property name="wordWrap">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QPushButton" name="loadFromLayerButton">
+         <property name="text">
+          <string>Load Data from layer</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1">
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>227</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item row="2" column="0" colspan="2">
+        <widget class="QTableWidget" name="tableWidget">
+         <column>
+          <property name="text">
+           <string>Value</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>Description</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+       <item row="3" column="0">
+        <widget class="QPushButton" name="removeSelectedButton">
+         <property name="text">
+          <string>Remove Selected</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1">
+        <spacer name="horizontalSpacer_2">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>227</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="enumerationPage">
+      <layout class="QVBoxLayout" name="verticalLayout_7">
+       <item>
+        <widget class="QLabel" name="enumerationLabel">
+         <property name="text">
+          <string>Combo box with values that can be used within the column's type. Must be supported by the provider.</string>
+         </property>
+         <property name="wordWrap">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="enumerationWarningLabel">
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer_3">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>304</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="immutablePage">
+      <layout class="QVBoxLayout" name="verticalLayout_8">
+       <item>
+        <widget class="QLabel" name="immutableLabel">
+         <property name="text">
+          <string>Immutable attribute is read-only - user is not able to modify the contents.</string>
+         </property>
+         <property name="wordWrap">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer_4">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>304</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>QgsAttributeTypeDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>QgsAttributeTypeDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>



More information about the QGIS-commit mailing list