mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
[FEATURE] customizable attribute forms using Qt Designer dialog UIs
- add support for checkbox edit type and edit forms for vector layers - selection of ui file in vector layer properties (general tab) - the forms are opened when a feature is added or via identify. The widgets on the ui have to be named like the attribute they are supposed to edit or show. If the vector layer is not in editing mode, the widgets will be disabled git-svn-id: http://svn.osgeo.org/qgis/trunk@12077 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
be95d79255
commit
6b7ad07597
@ -13,9 +13,10 @@ public:
|
|||||||
Classification,
|
Classification,
|
||||||
EditRange,
|
EditRange,
|
||||||
SliderRange
|
SliderRange
|
||||||
|
CheckBox, /* @note added in 1.4 */
|
||||||
FileName,
|
FileName,
|
||||||
Enumeration,
|
Enumeration, /* @note added in 1.4 */
|
||||||
Immutable
|
Immutable /* @note added in 1.4 */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RangeData {
|
struct RangeData {
|
||||||
@ -154,7 +155,7 @@ public:
|
|||||||
* @param subset The subset string. This may be the where clause of a sql statement
|
* @param subset The subset string. This may be the where clause of a sql statement
|
||||||
* or other defintion string specific to the underlying dataprovider
|
* or other defintion string specific to the underlying dataprovider
|
||||||
* and data store.
|
* and data store.
|
||||||
* @return true, when setting the string was successful, false otherwise (added in 1.4)
|
* @return true, when setting the string was successful, false otherwise (@note added in 1.4)
|
||||||
*/
|
*/
|
||||||
virtual bool setSubsetString(QString subset);
|
virtual bool setSubsetString(QString subset);
|
||||||
|
|
||||||
@ -387,6 +388,27 @@ public:
|
|||||||
/**set edit type*/
|
/**set edit type*/
|
||||||
void setEditType(int idx, EditType edit);
|
void setEditType(int idx, EditType edit);
|
||||||
|
|
||||||
|
/** set string representing 'true' for a checkbox
|
||||||
|
@note added in 1.4
|
||||||
|
*/
|
||||||
|
void setCheckedState( int idx, QString checked, QString notChecked );
|
||||||
|
|
||||||
|
/** return string representing 'true' for a checkbox
|
||||||
|
@note added in 1.4
|
||||||
|
*/
|
||||||
|
// FIXME: need SIP binding for QPair<QString, QString>
|
||||||
|
// QPair<QString, QString> checkedState( int idx );
|
||||||
|
|
||||||
|
/** get edit form
|
||||||
|
@note added in 1.4
|
||||||
|
*/
|
||||||
|
QString editForm();
|
||||||
|
|
||||||
|
/** set edit form
|
||||||
|
@note added in 1.4
|
||||||
|
*/
|
||||||
|
void setEditForm( QString ui );
|
||||||
|
|
||||||
/**access value map*/
|
/**access value map*/
|
||||||
QMap<QString, QVariant> &valueMap(int idx);
|
QMap<QString, QVariant> &valueMap(int idx);
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ bool QgsOverlayAnalyzer::intersection( QgsVectorLayer* layerA, QgsVectorLayer* l
|
|||||||
|
|
||||||
QgsVectorFileWriter vWriter( shapefileName, dpA->encoding(), fieldsA, outputType, &crs );
|
QgsVectorFileWriter vWriter( shapefileName, dpA->encoding(), fieldsA, outputType, &crs );
|
||||||
QgsFeature currentFeature;
|
QgsFeature currentFeature;
|
||||||
QgsGeometry* dissolveGeometry; //dissolve geometry (if dissolve enabled)
|
|
||||||
QgsSpatialIndex index;
|
QgsSpatialIndex index;
|
||||||
|
|
||||||
//take only selection
|
//take only selection
|
||||||
|
@ -251,6 +251,7 @@ INCLUDE_DIRECTORIES(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR} composer legend attributetable
|
${CMAKE_CURRENT_SOURCE_DIR} composer legend attributetable
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../ui
|
${CMAKE_CURRENT_BINARY_DIR}/../ui
|
||||||
|
${QT_QTUITOOLS_INCLUDE_DIR}
|
||||||
../core
|
../core
|
||||||
../core/composer ../core/raster ../core/renderer ../core/symbology
|
../core/composer ../core/raster ../core/renderer ../core/symbology
|
||||||
../gui
|
../gui
|
||||||
@ -295,6 +296,7 @@ TARGET_LINK_LIBRARIES(qgis
|
|||||||
${QT_QTSVG_LIBRARY}
|
${QT_QTSVG_LIBRARY}
|
||||||
${QT_QTNETWORK_LIBRARY}
|
${QT_QTNETWORK_LIBRARY}
|
||||||
${QT_QTSQL_LIBRARY}
|
${QT_QTSQL_LIBRARY}
|
||||||
|
${QT_QTUITOOLS_LIBRARY}
|
||||||
#should only be needed for win
|
#should only be needed for win
|
||||||
${QT_QTMAIN_LIBRARY}
|
${QT_QTMAIN_LIBRARY}
|
||||||
qgis_core
|
qgis_core
|
||||||
|
@ -62,7 +62,7 @@ QWidget *QgsAttributeTableDelegate::createEditor(
|
|||||||
if ( vl == NULL )
|
if ( vl == NULL )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
QWidget *widget = QgsAttributeEditor::createAttributeEditor( parent, vl, fieldIdx( index ), index.model()->data( index, Qt::EditRole ) );
|
QWidget *widget = QgsAttributeEditor::createAttributeEditor( parent, 0, vl, fieldIdx( index ), index.model()->data( index, Qt::EditRole ) );
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
@ -30,29 +30,74 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QUiLoader>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeature )
|
QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeature )
|
||||||
: QDialog(),
|
: mDialog( 0 ),
|
||||||
mSettingsPath( "/Windows/AttributeDialog/" ),
|
mSettingsPath( "/Windows/AttributeDialog/" ),
|
||||||
mLayer( vl ),
|
mLayer( vl ),
|
||||||
mpFeature( thepFeature )
|
mpFeature( thepFeature )
|
||||||
{
|
{
|
||||||
setupUi( this );
|
|
||||||
if ( mpFeature == NULL || vl->dataProvider() == NULL )
|
if ( mpFeature == NULL || vl->dataProvider() == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QgsFieldMap &theFieldMap = vl->pendingFields();
|
const QgsFieldMap &theFieldMap = vl->pendingFields();
|
||||||
|
|
||||||
if ( theFieldMap.isEmpty() )
|
if ( theFieldMap.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QgsAttributeMap myAttributes = mpFeature->attributeMap();
|
QgsAttributeMap myAttributes = mpFeature->attributeMap();
|
||||||
|
|
||||||
|
QDialogButtonBox *buttonBox = NULL;
|
||||||
|
|
||||||
|
if ( !vl->editForm().isEmpty() )
|
||||||
|
{
|
||||||
|
QFile file( vl->editForm() );
|
||||||
|
file.open( QFile::ReadOnly );
|
||||||
|
QUiLoader loader;
|
||||||
|
QWidget *myWidget = loader.load( &file, NULL );
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
mDialog = qobject_cast<QDialog*>( myWidget );
|
||||||
|
buttonBox = myWidget->findChild<QDialogButtonBox*>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !mDialog )
|
||||||
|
{
|
||||||
|
mDialog = new QDialog();
|
||||||
|
|
||||||
|
QGridLayout *gridLayout;
|
||||||
|
QFrame *mFrame;
|
||||||
|
|
||||||
|
if ( mDialog->objectName().isEmpty() )
|
||||||
|
mDialog->setObjectName( QString::fromUtf8( "QgsAttributeDialogBase" ) );
|
||||||
|
|
||||||
|
mDialog->resize( 447, 343 );
|
||||||
|
gridLayout = new QGridLayout( mDialog );
|
||||||
|
gridLayout->setSpacing( 6 );
|
||||||
|
gridLayout->setMargin( 11 );
|
||||||
|
gridLayout->setObjectName( QString::fromUtf8( "gridLayout" ) );
|
||||||
|
mFrame = new QFrame( mDialog );
|
||||||
|
mFrame->setObjectName( QString::fromUtf8( "mFrame" ) );
|
||||||
|
mFrame->setFrameShape( QFrame::StyledPanel );
|
||||||
|
mFrame->setFrameShadow( QFrame::Raised );
|
||||||
|
|
||||||
|
gridLayout->addWidget( mFrame, 0, 0, 1, 1 );
|
||||||
|
|
||||||
|
buttonBox = new QDialogButtonBox( mDialog );
|
||||||
|
buttonBox->setObjectName( QString::fromUtf8( "buttonBox" ) );
|
||||||
|
gridLayout->addWidget( buttonBox, 2, 0, 1, 1 );
|
||||||
|
|
||||||
//
|
//
|
||||||
//Set up dynamic inside a scroll box
|
//Set up dynamic inside a scroll box
|
||||||
//
|
//
|
||||||
QVBoxLayout * mypOuterLayout = new QVBoxLayout();
|
QVBoxLayout * mypOuterLayout = new QVBoxLayout();
|
||||||
mypOuterLayout->setContentsMargins( 0, 0, 0, 0 );
|
mypOuterLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
//transfers layout ownership so no need to call delete
|
//transfers layout ownership so no need to call delete
|
||||||
|
|
||||||
mFrame->setLayout( mypOuterLayout );
|
mFrame->setLayout( mypOuterLayout );
|
||||||
QScrollArea * mypScrollArea = new QScrollArea();
|
QScrollArea * mypScrollArea = new QScrollArea();
|
||||||
//transfers scroll area ownership so no need to call delete
|
//transfers scroll area ownership so no need to call delete
|
||||||
@ -66,9 +111,7 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
|
|||||||
QGridLayout * mypInnerLayout = new QGridLayout( mypInnerFrame );
|
QGridLayout * mypInnerLayout = new QGridLayout( mypInnerFrame );
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for ( QgsAttributeMap::const_iterator it = myAttributes.begin();
|
for ( QgsAttributeMap::const_iterator it = myAttributes.begin(); it != myAttributes.end(); ++it )
|
||||||
it != myAttributes.end();
|
|
||||||
++it )
|
|
||||||
{
|
{
|
||||||
const QgsField &field = theFieldMap[it.key()];
|
const QgsField &field = theFieldMap[it.key()];
|
||||||
|
|
||||||
@ -76,7 +119,7 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
|
|||||||
QString myFieldName = vl->attributeDisplayName( it.key() );
|
QString myFieldName = vl->attributeDisplayName( it.key() );
|
||||||
int myFieldType = field.type();
|
int myFieldType = field.type();
|
||||||
|
|
||||||
QWidget *myWidget = QgsAttributeEditor::createAttributeEditor( 0, vl, it.key(), it.value() );
|
QWidget *myWidget = QgsAttributeEditor::createAttributeEditor( 0, 0, vl, it.key(), it.value() );
|
||||||
if ( !myWidget )
|
if ( !myWidget )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -96,6 +139,8 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
|
|||||||
mypLabel->setText( myFieldName + tr( " (txt)" ) );
|
mypLabel->setText( myFieldName + tr( " (txt)" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myWidget->setEnabled( vl->isEditable() );
|
||||||
|
|
||||||
mypInnerLayout->addWidget( myWidget, index, 1 );
|
mypInnerLayout->addWidget( myWidget, index, 1 );
|
||||||
mpIndizes << it.key();
|
mpIndizes << it.key();
|
||||||
mpWidgets << myWidget;
|
mpWidgets << myWidget;
|
||||||
@ -106,6 +151,47 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
|
|||||||
{
|
{
|
||||||
mpWidgets.first()->setFocus( Qt::OtherFocusReason );
|
mpWidgets.first()->setFocus( Qt::OtherFocusReason );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( QgsAttributeMap::const_iterator it = myAttributes.begin(); it != myAttributes.end(); ++it )
|
||||||
|
{
|
||||||
|
const QgsField &field = theFieldMap[it.key()];
|
||||||
|
|
||||||
|
QWidget *myWidget = mDialog->findChild<QWidget*>( field.name() );
|
||||||
|
if ( !myWidget )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QgsAttributeEditor::createAttributeEditor( mDialog, myWidget, vl, it.key(), it.value() );
|
||||||
|
|
||||||
|
myWidget->setEnabled( vl->isEditable() );
|
||||||
|
|
||||||
|
mpIndizes << it.key();
|
||||||
|
mpWidgets << myWidget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( buttonBox )
|
||||||
|
{
|
||||||
|
buttonBox->clear();
|
||||||
|
|
||||||
|
if( vl->isEditable() )
|
||||||
|
{
|
||||||
|
buttonBox->setStandardButtons( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
||||||
|
connect( buttonBox, SIGNAL( accepted() ), mDialog, SLOT( accept() ) );
|
||||||
|
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buttonBox->setStandardButtons( QDialogButtonBox::Cancel );
|
||||||
|
}
|
||||||
|
|
||||||
|
connect( buttonBox, SIGNAL( rejected() ), mDialog, SLOT( reject() ) );
|
||||||
|
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( rejected() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QMetaObject::connectSlotsByName( mDialog );
|
||||||
|
|
||||||
restoreGeometry();
|
restoreGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,12 +203,13 @@ QgsAttributeDialog::~QgsAttributeDialog()
|
|||||||
|
|
||||||
void QgsAttributeDialog::accept()
|
void QgsAttributeDialog::accept()
|
||||||
{
|
{
|
||||||
|
if ( !mLayer->isEditable() )
|
||||||
|
return;
|
||||||
|
|
||||||
//write the new values back to the feature
|
//write the new values back to the feature
|
||||||
QgsAttributeMap myAttributes = mpFeature->attributeMap();
|
QgsAttributeMap myAttributes = mpFeature->attributeMap();
|
||||||
int myIndex = 0;
|
int myIndex = 0;
|
||||||
for ( QgsAttributeMap::const_iterator it = myAttributes.begin();
|
for ( QgsAttributeMap::const_iterator it = myAttributes.begin(); it != myAttributes.end(); ++it )
|
||||||
it != myAttributes.end();
|
|
||||||
++it )
|
|
||||||
{
|
{
|
||||||
QVariant value;
|
QVariant value;
|
||||||
|
|
||||||
@ -132,17 +219,21 @@ void QgsAttributeDialog::accept()
|
|||||||
|
|
||||||
++myIndex;
|
++myIndex;
|
||||||
}
|
}
|
||||||
QDialog::accept();
|
}
|
||||||
|
|
||||||
|
int QgsAttributeDialog::exec()
|
||||||
|
{
|
||||||
|
return mDialog->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAttributeDialog::saveGeometry()
|
void QgsAttributeDialog::saveGeometry()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue( mSettingsPath + "geometry", QDialog::saveGeometry() );
|
settings.setValue( mSettingsPath + "geometry", mDialog->saveGeometry() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAttributeDialog::restoreGeometry()
|
void QgsAttributeDialog::restoreGeometry()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QDialog::restoreGeometry( settings.value( mSettingsPath + "geometry" ).toByteArray() );
|
mDialog->restoreGeometry( settings.value( mSettingsPath + "geometry" ).toByteArray() );
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,7 @@
|
|||||||
#ifndef QGSATTRIBUTEDIALOG_H
|
#ifndef QGSATTRIBUTEDIALOG_H
|
||||||
#define QGSATTRIBUTEDIALOG_H
|
#define QGSATTRIBUTEDIALOG_H
|
||||||
|
|
||||||
#include "ui_qgsattributedialogbase.h"
|
|
||||||
|
|
||||||
#include "qgsfeature.h"
|
#include "qgsfeature.h"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class QDialog;
|
class QDialog;
|
||||||
class QgsFeature;
|
class QgsFeature;
|
||||||
@ -29,7 +26,7 @@ class QLayout;
|
|||||||
class QgsField;
|
class QgsField;
|
||||||
class QgsVectorLayer;
|
class QgsVectorLayer;
|
||||||
|
|
||||||
class QgsAttributeDialog: public QDialog, private Ui::QgsAttributeDialogBase
|
class QgsAttributeDialog : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -37,26 +34,33 @@ class QgsAttributeDialog: public QDialog, private Ui::QgsAttributeDialogBase
|
|||||||
QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature * thepFeature );
|
QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature * thepFeature );
|
||||||
~QgsAttributeDialog();
|
~QgsAttributeDialog();
|
||||||
|
|
||||||
/** Overloaded accept method which will write the feature field
|
|
||||||
* values, then delegate to QDialog::accept()
|
|
||||||
*/
|
|
||||||
void accept();
|
|
||||||
/** Saves the size and position for the next time
|
/** Saves the size and position for the next time
|
||||||
* this dialog box was used.
|
* this dialog box was used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void saveGeometry();
|
void saveGeometry();
|
||||||
|
|
||||||
/** Restores the size and position from the last time
|
/** Restores the size and position from the last time
|
||||||
* this dialog box was used.
|
* this dialog box was used.
|
||||||
*/
|
*/
|
||||||
void restoreGeometry();
|
void restoreGeometry();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/** Overloaded accept method which will write the feature field
|
||||||
|
* values, then delegate to QDialog::accept()
|
||||||
|
*/
|
||||||
|
void accept();
|
||||||
|
|
||||||
|
int exec();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
QDialog *mDialog;
|
||||||
QString mSettingsPath;
|
QString mSettingsPath;
|
||||||
QList<QWidget *> mpWidgets;
|
QList<QWidget *> mpWidgets;
|
||||||
QList<int> mpIndizes;
|
QList<int> mpIndizes;
|
||||||
QgsVectorLayer *mLayer;
|
QgsVectorLayer *mLayer;
|
||||||
QgsFeature *mpFeature;
|
QgsFeature *mpFeature;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,8 +24,11 @@
|
|||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
@ -51,12 +54,23 @@ void QgsAttributeEditor::selectFileName( void )
|
|||||||
le->setText( fileName );
|
le->setText( fileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLayer *vl, int idx, const QVariant &value )
|
QComboBox *QgsAttributeEditor::comboBox( QWidget *editor, QWidget *parent )
|
||||||
|
{
|
||||||
|
QComboBox *cb = NULL;
|
||||||
|
if ( editor )
|
||||||
|
cb = qobject_cast<QComboBox *>( editor );
|
||||||
|
else
|
||||||
|
cb = new QComboBox( parent );
|
||||||
|
|
||||||
|
return cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value )
|
||||||
{
|
{
|
||||||
if ( !vl )
|
if ( !vl )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
QWidget *myWidget;
|
QWidget *myWidget = NULL;
|
||||||
QgsVectorLayer::EditType editType = vl->editType( idx );
|
QgsVectorLayer::EditType editType = vl->editType( idx );
|
||||||
const QgsField &field = vl->pendingFields()[idx];
|
const QgsField &field = vl->pendingFields()[idx];
|
||||||
QVariant::Type myFieldType = field.type();
|
QVariant::Type myFieldType = field.type();
|
||||||
@ -68,7 +82,9 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
QList<QVariant> values;
|
QList<QVariant> values;
|
||||||
vl->dataProvider()->uniqueValues( idx, values );
|
vl->dataProvider()->uniqueValues( idx, values );
|
||||||
|
|
||||||
QComboBox *cb = new QComboBox( parent );
|
QComboBox *cb = comboBox( editor, parent );
|
||||||
|
if ( cb )
|
||||||
|
{
|
||||||
cb->setEditable( true );
|
cb->setEditable( true );
|
||||||
|
|
||||||
for ( QList<QVariant>::iterator it = values.begin(); it != values.end(); it++ )
|
for ( QList<QVariant>::iterator it = values.begin(); it != values.end(); it++ )
|
||||||
@ -76,6 +92,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
|
|
||||||
myWidget = cb;
|
myWidget = cb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QgsVectorLayer::Enumeration:
|
case QgsVectorLayer::Enumeration:
|
||||||
@ -83,7 +100,9 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
QStringList enumValues;
|
QStringList enumValues;
|
||||||
vl->dataProvider()->enumValues( idx, enumValues );
|
vl->dataProvider()->enumValues( idx, enumValues );
|
||||||
|
|
||||||
QComboBox *cb = new QComboBox( parent );
|
QComboBox *cb = comboBox( editor, parent );
|
||||||
|
if ( cb )
|
||||||
|
{
|
||||||
QStringList::const_iterator s_it = enumValues.constBegin();
|
QStringList::const_iterator s_it = enumValues.constBegin();
|
||||||
for ( ; s_it != enumValues.constEnd(); ++s_it )
|
for ( ; s_it != enumValues.constEnd(); ++s_it )
|
||||||
{
|
{
|
||||||
@ -92,14 +111,16 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
|
|
||||||
myWidget = cb;
|
myWidget = cb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QgsVectorLayer::ValueMap:
|
case QgsVectorLayer::ValueMap:
|
||||||
{
|
{
|
||||||
const QMap<QString, QVariant> &map = vl->valueMap( idx );
|
const QMap<QString, QVariant> &map = vl->valueMap( idx );
|
||||||
|
|
||||||
QComboBox *cb = new QComboBox( parent );
|
QComboBox *cb = comboBox( editor, parent );
|
||||||
|
if ( cb )
|
||||||
|
{
|
||||||
for ( QMap<QString, QVariant>::const_iterator it = map.begin(); it != map.end(); it++ )
|
for ( QMap<QString, QVariant>::const_iterator it = map.begin(); it != map.end(); it++ )
|
||||||
{
|
{
|
||||||
cb->addItem( it.key(), it.value() );
|
cb->addItem( it.key(), it.value() );
|
||||||
@ -107,6 +128,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
|
|
||||||
myWidget = cb;
|
myWidget = cb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QgsVectorLayer::Classification:
|
case QgsVectorLayer::Classification:
|
||||||
@ -133,7 +155,9 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QComboBox *cb = new QComboBox( parent );
|
QComboBox *cb = comboBox( editor, parent );
|
||||||
|
if ( cb )
|
||||||
|
{
|
||||||
for ( QMap<QString, QString>::const_iterator it = classes.begin(); it != classes.end(); it++ )
|
for ( QMap<QString, QString>::const_iterator it = classes.begin(); it != classes.end(); it++ )
|
||||||
{
|
{
|
||||||
cb->addItem( it.value(), it.key() );
|
cb->addItem( it.value(), it.key() );
|
||||||
@ -141,6 +165,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
|
|
||||||
myWidget = cb;
|
myWidget = cb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QgsVectorLayer::SliderRange:
|
case QgsVectorLayer::SliderRange:
|
||||||
@ -154,35 +179,74 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
|
|
||||||
if ( editType == QgsVectorLayer::EditRange )
|
if ( editType == QgsVectorLayer::EditRange )
|
||||||
{
|
{
|
||||||
QSpinBox *sb = new QSpinBox( parent );
|
QSpinBox *sb = NULL;
|
||||||
|
|
||||||
|
if ( editor )
|
||||||
|
sb = qobject_cast<QSpinBox *>( editor );
|
||||||
|
else
|
||||||
|
sb = new QSpinBox( parent );
|
||||||
|
|
||||||
|
if ( sb )
|
||||||
|
{
|
||||||
sb->setRange( min, max );
|
sb->setRange( min, max );
|
||||||
sb->setSingleStep( step );
|
sb->setSingleStep( step );
|
||||||
|
|
||||||
myWidget = sb;
|
myWidget = sb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QSlider *sl = new QSlider( Qt::Horizontal, parent );
|
QSlider *sl = NULL;
|
||||||
|
|
||||||
|
if ( editor )
|
||||||
|
sl = qobject_cast<QSlider*>( editor );
|
||||||
|
else
|
||||||
|
sl = new QSlider( Qt::Horizontal, parent );
|
||||||
|
|
||||||
|
if ( sl )
|
||||||
|
{
|
||||||
sl->setRange( min, max );
|
sl->setRange( min, max );
|
||||||
sl->setSingleStep( step );
|
sl->setSingleStep( step );
|
||||||
|
|
||||||
myWidget = sl;
|
myWidget = sl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ( myFieldType == QVariant::Double )
|
else if ( myFieldType == QVariant::Double )
|
||||||
|
{
|
||||||
|
QDoubleSpinBox *dsb = NULL;
|
||||||
|
if ( editor )
|
||||||
|
dsb = qobject_cast<QDoubleSpinBox*>( editor );
|
||||||
|
else
|
||||||
|
dsb = new QDoubleSpinBox( parent );
|
||||||
|
|
||||||
|
if ( dsb )
|
||||||
{
|
{
|
||||||
double min = vl->range( idx ).mMin.toDouble();
|
double min = vl->range( idx ).mMin.toDouble();
|
||||||
double max = vl->range( idx ).mMax.toDouble();
|
double max = vl->range( idx ).mMax.toDouble();
|
||||||
double step = vl->range( idx ).mStep.toDouble();
|
double step = vl->range( idx ).mStep.toDouble();
|
||||||
QDoubleSpinBox *dsb = new QDoubleSpinBox( parent );
|
|
||||||
|
|
||||||
dsb->setRange( min, max );
|
dsb->setRange( min, max );
|
||||||
dsb->setSingleStep( step );
|
dsb->setSingleStep( step );
|
||||||
|
|
||||||
myWidget = dsb;
|
myWidget = dsb;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case QgsVectorLayer::CheckBox:
|
||||||
|
{
|
||||||
|
QCheckBox *cb = NULL;
|
||||||
|
if ( editor )
|
||||||
|
cb = qobject_cast<QCheckBox*>( editor );
|
||||||
|
else
|
||||||
|
cb = new QCheckBox();
|
||||||
|
|
||||||
|
if ( cb )
|
||||||
|
{
|
||||||
|
myWidget = cb;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,15 +255,25 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
|
|
||||||
case QgsVectorLayer::LineEdit:
|
case QgsVectorLayer::LineEdit:
|
||||||
case QgsVectorLayer::UniqueValuesEditable:
|
case QgsVectorLayer::UniqueValuesEditable:
|
||||||
case QgsVectorLayer::Immutable:
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
QLineEdit *le = new QLineEdit( parent );
|
QLineEdit *le = NULL;
|
||||||
|
QTextEdit *te = NULL;
|
||||||
|
QPlainTextEdit *pte = NULL;
|
||||||
|
|
||||||
if ( editType == QgsVectorLayer::Immutable )
|
if ( editor )
|
||||||
{
|
{
|
||||||
le->setEnabled( false );
|
le = qobject_cast<QLineEdit *>( editor );
|
||||||
|
te = qobject_cast<QTextEdit *>( editor );
|
||||||
|
pte = qobject_cast<QPlainTextEdit *>( editor );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
le = new QLineEdit( parent );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( le )
|
||||||
|
{
|
||||||
|
|
||||||
if ( editType == QgsVectorLayer::UniqueValuesEditable )
|
if ( editType == QgsVectorLayer::UniqueValuesEditable )
|
||||||
{
|
{
|
||||||
@ -226,6 +300,18 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
|
|
||||||
myWidget = le;
|
myWidget = le;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( te )
|
||||||
|
{
|
||||||
|
te->setAcceptRichText(true);
|
||||||
|
myWidget = te;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pte )
|
||||||
|
{
|
||||||
|
myWidget = pte;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QgsVectorLayer::Hidden:
|
case QgsVectorLayer::Hidden:
|
||||||
@ -234,10 +320,23 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
|
|
||||||
case QgsVectorLayer::FileName:
|
case QgsVectorLayer::FileName:
|
||||||
{
|
{
|
||||||
QLineEdit *le = new QLineEdit();
|
QPushButton *pb = NULL;
|
||||||
|
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
|
||||||
|
if ( le )
|
||||||
|
{
|
||||||
|
if ( le )
|
||||||
|
myWidget = le;
|
||||||
|
|
||||||
|
if( editor->parent() )
|
||||||
|
{
|
||||||
|
pb = editor->parent()->findChild<QPushButton *>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
le = new QLineEdit();
|
||||||
|
|
||||||
QPushButton *pb = new QPushButton( tr( "..." ) );
|
QPushButton *pb = new QPushButton( tr( "..." ) );
|
||||||
connect( pb, SIGNAL( clicked() ), new QgsAttributeEditor( pb ), SLOT( selectFileName() ) );
|
|
||||||
|
|
||||||
QHBoxLayout *hbl = new QHBoxLayout();
|
QHBoxLayout *hbl = new QHBoxLayout();
|
||||||
hbl->addWidget( le );
|
hbl->addWidget( le );
|
||||||
@ -246,9 +345,18 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QgsVectorLa
|
|||||||
myWidget = new QWidget( parent );
|
myWidget = new QWidget( parent );
|
||||||
myWidget->setLayout( hbl );
|
myWidget->setLayout( hbl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( pb )
|
||||||
|
connect( pb, SIGNAL( clicked() ), new QgsAttributeEditor( pb ), SLOT( selectFileName() ) );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( editType == QgsVectorLayer::Immutable )
|
||||||
|
{
|
||||||
|
myWidget->setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
setValue( myWidget, vl, idx, value );
|
setValue( myWidget, vl, idx, value );
|
||||||
|
|
||||||
return myWidget;
|
return myWidget;
|
||||||
@ -275,6 +383,28 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTextEdit *te = qobject_cast<QTextEdit *>( widget );
|
||||||
|
if ( te )
|
||||||
|
{
|
||||||
|
text = te->toHtml();
|
||||||
|
modified = te->document()->isModified();
|
||||||
|
if( text == "NULL" )
|
||||||
|
{
|
||||||
|
text = QString::null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( widget );
|
||||||
|
if ( pte )
|
||||||
|
{
|
||||||
|
text = pte->toPlainText();
|
||||||
|
modified = pte->document()->isModified();
|
||||||
|
if( text == "NULL" )
|
||||||
|
{
|
||||||
|
text = QString::null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QComboBox *cb = qobject_cast<QComboBox *>( widget );
|
QComboBox *cb = qobject_cast<QComboBox *>( widget );
|
||||||
if ( cb )
|
if ( cb )
|
||||||
{
|
{
|
||||||
@ -301,12 +431,20 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
|
|||||||
{
|
{
|
||||||
text = QString::number( slider->value() );
|
text = QString::number( slider->value() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( widget );
|
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( widget );
|
||||||
if ( dsb )
|
if ( dsb )
|
||||||
{
|
{
|
||||||
text = QString::number( dsb->value() );
|
text = QString::number( dsb->value() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QCheckBox *ckb = qobject_cast<QCheckBox *>( widget );
|
||||||
|
if ( ckb )
|
||||||
|
{
|
||||||
|
QPair<QString, QString> states = vl->checkedState( idx );
|
||||||
|
text = ckb->isChecked() ? states.first : states.second;
|
||||||
|
}
|
||||||
|
|
||||||
le = widget->findChild<QLineEdit *>();
|
le = widget->findChild<QLineEdit *>();
|
||||||
if ( le )
|
if ( le )
|
||||||
{
|
{
|
||||||
@ -411,6 +549,17 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case QgsVectorLayer::CheckBox:
|
||||||
|
{
|
||||||
|
QCheckBox *cb = qobject_cast<QCheckBox *>( editor );
|
||||||
|
if( cb )
|
||||||
|
{
|
||||||
|
QPair<QString, QString> states = vl->checkedState( idx );
|
||||||
|
cb->setChecked( value == states.first );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fall-through
|
// fall-through
|
||||||
|
|
||||||
case QgsVectorLayer::LineEdit:
|
case QgsVectorLayer::LineEdit:
|
||||||
@ -419,7 +568,9 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
|
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
|
||||||
if ( le == NULL )
|
QTextEdit *te = qobject_cast<QTextEdit *>( editor );
|
||||||
|
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( editor );
|
||||||
|
if ( !le && !te && !pte )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
@ -431,7 +582,12 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
|
|||||||
else
|
else
|
||||||
text = value.toString();
|
text = value.toString();
|
||||||
|
|
||||||
|
if( le )
|
||||||
le->setText( text );
|
le->setText( text );
|
||||||
|
if( te )
|
||||||
|
te->setHtml( text );
|
||||||
|
if( pte )
|
||||||
|
pte->setPlainText( text );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
class QObject;
|
class QObject;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
class QgsVectorLayer;
|
class QgsVectorLayer;
|
||||||
|
class QComboBox;
|
||||||
|
|
||||||
class QgsAttributeEditor : public QObject
|
class QgsAttributeEditor : public QObject
|
||||||
{
|
{
|
||||||
@ -30,10 +31,13 @@ class QgsAttributeEditor : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QgsAttributeEditor( QObject *parent ) : QObject( parent ) {}
|
QgsAttributeEditor( QObject *parent ) : QObject( parent ) {}
|
||||||
static QWidget *createAttributeEditor( QWidget *parent, QgsVectorLayer *vl, int idx, const QVariant &value );
|
static QWidget *createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value );
|
||||||
static bool retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value );
|
static bool retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value );
|
||||||
static bool setValue( QWidget *widget, QgsVectorLayer *vl, int idx, const QVariant &value );
|
static bool setValue( QWidget *widget, QgsVectorLayer *vl, int idx, const QVariant &value );
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QComboBox *comboBox( QWidget *editor, QWidget *parent );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void selectFileName( void );
|
void selectFileName( void );
|
||||||
};
|
};
|
||||||
|
@ -66,6 +66,16 @@ QMap<QString, QVariant> &QgsAttributeTypeDialog::valueMap()
|
|||||||
return mValueMap;
|
return mValueMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPair<QString, QString> QgsAttributeTypeDialog::checkedState()
|
||||||
|
{
|
||||||
|
return QPair<QString, QString>( leCheckedState->text(), leUncheckedState->text() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsAttributeTypeDialog::setCheckedState( QString checked, QString unchecked )
|
||||||
|
{
|
||||||
|
leCheckedState->setText( checked );
|
||||||
|
leUncheckedState->setText( unchecked );
|
||||||
|
}
|
||||||
|
|
||||||
void QgsAttributeTypeDialog::vCellChanged( int row, int column )
|
void QgsAttributeTypeDialog::vCellChanged( int row, int column )
|
||||||
{
|
{
|
||||||
@ -235,6 +245,10 @@ void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editTy
|
|||||||
setPage( 8 );
|
setPage( 8 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case QgsVectorLayer::CheckBox:
|
||||||
|
setPage( 9 );
|
||||||
|
break;
|
||||||
|
|
||||||
case QgsVectorLayer::LineEdit:
|
case QgsVectorLayer::LineEdit:
|
||||||
setPage( 0 );
|
setPage( 0 );
|
||||||
break;
|
break;
|
||||||
@ -513,6 +527,9 @@ void QgsAttributeTypeDialog::accept()
|
|||||||
case 8:
|
case 8:
|
||||||
mEditType = QgsVectorLayer::Hidden;
|
mEditType = QgsVectorLayer::Hidden;
|
||||||
break;
|
break;
|
||||||
|
case 9:
|
||||||
|
mEditType = QgsVectorLayer::CheckBox;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
mEditType = QgsVectorLayer::LineEdit;
|
mEditType = QgsVectorLayer::LineEdit;
|
||||||
}
|
}
|
||||||
|
@ -66,11 +66,23 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
|
|||||||
void setValueMap( QMap<QString, QVariant> valueMap );
|
void setValueMap( QMap<QString, QVariant> valueMap );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter to range for to be displayed and edited in this dialog
|
* Setter to range to be displayed and edited in this dialog
|
||||||
* @param rangeData rande data which is to be displayed
|
* @param rangeData range data which is to be displayed
|
||||||
*/
|
*/
|
||||||
void setRange( QgsVectorLayer::RangeData rangeData );
|
void setRange( QgsVectorLayer::RangeData rangeData );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter to checked state to be displayed and edited in this dialog
|
||||||
|
* @param checked string that represents the checked state
|
||||||
|
*/
|
||||||
|
void setCheckedState( QString checked, QString unchecked );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for checked state after editing
|
||||||
|
* @return string representing the checked
|
||||||
|
*/
|
||||||
|
QPair<QString, QString> checkedState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for value map after editing
|
* Getter for value map after editing
|
||||||
* @return map which is to be returned
|
* @return map which is to be returned
|
||||||
|
@ -147,8 +147,8 @@ void QgsIdentifyResults::addFeature( QgsMapLayer *layer, int fid,
|
|||||||
{
|
{
|
||||||
connect( vlayer, SIGNAL( layerDeleted() ), this, SLOT( layerDestroyed() ) );
|
connect( vlayer, SIGNAL( layerDeleted() ), this, SLOT( layerDestroyed() ) );
|
||||||
connect( vlayer, SIGNAL( featureDeleted( int ) ), this, SLOT( featureDeleted( int ) ) );
|
connect( vlayer, SIGNAL( featureDeleted( int ) ), this, SLOT( featureDeleted( int ) ) );
|
||||||
connect( vlayer, SIGNAL( editingStarted() ), this, SLOT( addEditAction() ) );
|
connect( vlayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
|
||||||
connect( vlayer, SIGNAL( editingStopped() ), this, SLOT( removeEditAction() ) );
|
connect( vlayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -176,24 +176,22 @@ void QgsIdentifyResults::addFeature( QgsMapLayer *layer, int fid,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( vlayer && ( vlayer->actions()->size() > 0 || vlayer->isEditable() ) )
|
if ( vlayer )
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *actionItem = new QTreeWidgetItem( QStringList() << tr( "(Actions)" ) );
|
QTreeWidgetItem *actionItem = new QTreeWidgetItem( QStringList() << tr( "(Actions)" ) );
|
||||||
actionItem->setData( 0, Qt::UserRole, "actions" );
|
actionItem->setData( 0, Qt::UserRole, "actions" );
|
||||||
featItem->addChild( actionItem );
|
featItem->addChild( actionItem );
|
||||||
|
|
||||||
QTreeWidgetItem *twi;
|
QTreeWidgetItem *editItem = new QTreeWidgetItem( QStringList() << "" << (vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ) ) );
|
||||||
|
editItem->setIcon( 0, QgisApp::getThemeIcon( vlayer->isEditable() ? "/mIconEditable.png" : "/mIconEditable.png" ) );
|
||||||
if ( vlayer->isEditable() )
|
editItem->setData( 0, Qt::UserRole, "edit" );
|
||||||
{
|
actionItem->addChild( editItem );
|
||||||
addEditAction( actionItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( int i = 0; i < vlayer->actions()->size(); i++ )
|
for ( int i = 0; i < vlayer->actions()->size(); i++ )
|
||||||
{
|
{
|
||||||
QgsAttributeAction::aIter iter = vlayer->actions()->retrieveAction( i );
|
QgsAttributeAction::aIter iter = vlayer->actions()->retrieveAction( i );
|
||||||
|
|
||||||
twi = new QTreeWidgetItem( QStringList() << "" << iter->name() );
|
QTreeWidgetItem *twi = new QTreeWidgetItem( QStringList() << "" << iter->name() );
|
||||||
twi->setIcon( 0, QgisApp::getThemeIcon( "/mAction.png" ) );
|
twi->setIcon( 0, QgisApp::getThemeIcon( "/mAction.png" ) );
|
||||||
twi->setData( 0, Qt::UserRole, "action" );
|
twi->setData( 0, Qt::UserRole, "action" );
|
||||||
twi->setData( 0, Qt::UserRole + 1, QVariant::fromValue( i ) );
|
twi->setData( 0, Qt::UserRole + 1, QVariant::fromValue( i ) );
|
||||||
@ -204,6 +202,40 @@ void QgsIdentifyResults::addFeature( QgsMapLayer *layer, int fid,
|
|||||||
layItem->addChild( featItem );
|
layItem->addChild( featItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsIdentifyResults::editingToggled()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *layItem = layerItem( sender() );
|
||||||
|
QgsVectorLayer *vlayer = vectorLayer( layItem );
|
||||||
|
if( !layItem || !vlayer )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// iterate features
|
||||||
|
int i;
|
||||||
|
for( i=0; i<layItem->childCount(); i++ )
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *featItem = layItem->child(i);
|
||||||
|
|
||||||
|
int j;
|
||||||
|
for( j=0; j<featItem->childCount() && featItem->child(j)->data( 0, Qt::UserRole ).toString() != "actions"; j++ )
|
||||||
|
QgsDebugMsg( QString("%1: skipped %2").arg( featItem->child(j)->data( 0, Qt::UserRole ).toString() ) );
|
||||||
|
|
||||||
|
if( j==featItem->childCount() || featItem->child(j)->childCount()<1 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QTreeWidgetItem *actions = featItem->child(j);
|
||||||
|
|
||||||
|
for( j=0; i<actions->childCount() && actions->child(j)->data( 0, Qt::UserRole ).toString() != "edit"; j++ )
|
||||||
|
;
|
||||||
|
|
||||||
|
if( j==actions->childCount() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QTreeWidgetItem *editItem = actions->child(j);
|
||||||
|
editItem->setIcon( 0, QgisApp::getThemeIcon( vlayer->isEditable() ? "/mIconEditable.png" : "/mIconEditable.png" ) );
|
||||||
|
editItem->setText( 1, vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Call to show the dialog box.
|
// Call to show the dialog box.
|
||||||
void QgsIdentifyResults::show()
|
void QgsIdentifyResults::show()
|
||||||
{
|
{
|
||||||
@ -223,15 +255,12 @@ void QgsIdentifyResults::show()
|
|||||||
{
|
{
|
||||||
highlightFeature( featItem );
|
highlightFeature( featItem );
|
||||||
|
|
||||||
if ( layer->isEditable() )
|
// if this is the only feature and it's on a vector layer
|
||||||
{
|
// don't show the form dialog instead of the results window
|
||||||
// if this is the only feature, it's on a vector layer and that layer is editable:
|
featureForm( featItem );
|
||||||
// don't show the edit dialog instead of the results window
|
|
||||||
editFeature( featItem );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// expand first layer and feature
|
// expand first layer and feature
|
||||||
featItem->setExpanded( true );
|
featItem->setExpanded( true );
|
||||||
@ -240,6 +269,7 @@ void QgsIdentifyResults::show()
|
|||||||
|
|
||||||
QDialog::show();
|
QDialog::show();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slot called when user clicks the Close button
|
// Slot called when user clicks the Close button
|
||||||
// (saves the current window size/position)
|
// (saves the current window size/position)
|
||||||
void QgsIdentifyResults::close()
|
void QgsIdentifyResults::close()
|
||||||
@ -247,6 +277,7 @@ void QgsIdentifyResults::close()
|
|||||||
saveWindowLocation();
|
saveWindowLocation();
|
||||||
done( 0 );
|
done( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the current window size/position before closing
|
// Save the current window size/position before closing
|
||||||
// from window menu or X in titlebar
|
// from window menu or X in titlebar
|
||||||
void QgsIdentifyResults::closeEvent( QCloseEvent *e )
|
void QgsIdentifyResults::closeEvent( QCloseEvent *e )
|
||||||
@ -256,83 +287,11 @@ void QgsIdentifyResults::closeEvent( QCloseEvent *e )
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsIdentifyResults::addEditAction( QTreeWidgetItem *item )
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *editItem = new QTreeWidgetItem( QStringList() << "" << tr( "Edit feature" ) );
|
|
||||||
editItem->setIcon( 0, QgisApp::getThemeIcon( "/mIconEditable.png" ) );
|
|
||||||
editItem->setData( 0, Qt::UserRole, "edit" );
|
|
||||||
item->addChild( editItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
void QgsIdentifyResults::addOrRemoveEditAction( bool addItem )
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *layItem = layerItem( sender() );
|
|
||||||
|
|
||||||
for ( int i = 0; i < layItem->childCount(); i++ )
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *featItem = layItem->child( i );
|
|
||||||
QTreeWidgetItem *actionsItem = 0;
|
|
||||||
|
|
||||||
for ( int j = 0; j < featItem->childCount(); j++ )
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *attrItem = featItem->child( j );
|
|
||||||
|
|
||||||
if ( attrItem->childCount() == 0 || attrItem->data( 0, Qt::UserRole ).toString() != "actions" )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
actionsItem = attrItem;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( addItem )
|
|
||||||
{
|
|
||||||
if ( !actionsItem )
|
|
||||||
{
|
|
||||||
actionsItem = new QTreeWidgetItem( QStringList() << tr( "(Actions)" ) );
|
|
||||||
actionsItem->setData( 0, Qt::UserRole, "actions" );
|
|
||||||
featItem->addChild( actionsItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
addEditAction( actionsItem );
|
|
||||||
}
|
|
||||||
else if ( actionsItem )
|
|
||||||
{
|
|
||||||
for ( int k = 0; k < actionsItem->childCount(); k++ )
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *editItem = actionsItem->child( k );
|
|
||||||
if ( editItem->data( 0, Qt::UserRole ).toString() != "edit" )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
delete editItem;
|
|
||||||
|
|
||||||
if ( actionsItem->childCount() == 0 )
|
|
||||||
delete actionsItem;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QgsDebugMsg( "actions item not found" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QgsIdentifyResults::addEditAction()
|
|
||||||
{
|
|
||||||
addOrRemoveEditAction( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
void QgsIdentifyResults::removeEditAction()
|
|
||||||
{
|
|
||||||
addOrRemoveEditAction( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
void QgsIdentifyResults::itemClicked( QTreeWidgetItem *item, int column )
|
void QgsIdentifyResults::itemClicked( QTreeWidgetItem *item, int column )
|
||||||
{
|
{
|
||||||
if ( item->data( 0, Qt::UserRole ).toString() == "edit" )
|
if ( item->data( 0, Qt::UserRole ).toString() == "edit" )
|
||||||
{
|
{
|
||||||
editFeature( item );
|
featureForm( item );
|
||||||
}
|
}
|
||||||
else if ( item->data( 0, Qt::UserRole ).toString() == "action" )
|
else if ( item->data( 0, Qt::UserRole ).toString() == "action" )
|
||||||
{
|
{
|
||||||
@ -362,12 +321,9 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
|
|||||||
|
|
||||||
QAction *a;
|
QAction *a;
|
||||||
|
|
||||||
if ( vlayer->isEditable() )
|
a = mActionPopup->addAction( vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ) );
|
||||||
{
|
|
||||||
a = mActionPopup->addAction( tr( "Edit feature" ) );
|
|
||||||
a->setEnabled( true );
|
a->setEnabled( true );
|
||||||
a->setData( QVariant::fromValue( -6 ) );
|
a->setData( QVariant::fromValue( -6 ) );
|
||||||
}
|
|
||||||
|
|
||||||
a = mActionPopup->addAction( tr( "Zoom to feature" ) );
|
a = mActionPopup->addAction( tr( "Zoom to feature" ) );
|
||||||
a->setEnabled( true );
|
a->setEnabled( true );
|
||||||
@ -454,7 +410,7 @@ void QgsIdentifyResults::popupItemSelected( QAction* menuAction )
|
|||||||
switch ( action )
|
switch ( action )
|
||||||
{
|
{
|
||||||
case -6:
|
case -6:
|
||||||
editFeature( item );
|
featureForm( item );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -5:
|
case -5:
|
||||||
@ -694,8 +650,8 @@ void QgsIdentifyResults::disconnectLayer( QObject *layer )
|
|||||||
{
|
{
|
||||||
disconnect( vlayer, SIGNAL( layerDeleted() ), this, SLOT( layerDestroyed() ) );
|
disconnect( vlayer, SIGNAL( layerDeleted() ), this, SLOT( layerDestroyed() ) );
|
||||||
disconnect( vlayer, SIGNAL( featureDeleted( int ) ), this, SLOT( featureDeleted( int ) ) );
|
disconnect( vlayer, SIGNAL( featureDeleted( int ) ), this, SLOT( featureDeleted( int ) ) );
|
||||||
disconnect( vlayer, SIGNAL( editingStarted() ), this, SLOT( addEditAction() ) );
|
disconnect( vlayer, SIGNAL( editingStarted() ), this, SLOT( changeEditAction() ) );
|
||||||
disconnect( vlayer, SIGNAL( editingStopped() ), this, SLOT( removeEditAction() ) );
|
disconnect( vlayer, SIGNAL( editingStopped() ), this, SLOT( changeEditAction() ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -810,10 +766,10 @@ void QgsIdentifyResults::zoomToFeature( QTreeWidgetItem *item )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QgsIdentifyResults::editFeature( QTreeWidgetItem *item )
|
void QgsIdentifyResults::featureForm( QTreeWidgetItem *item )
|
||||||
{
|
{
|
||||||
QgsVectorLayer *layer = vectorLayer( item );
|
QgsVectorLayer *layer = vectorLayer( item );
|
||||||
if ( !layer || !layer->isEditable() )
|
if ( !layer )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QTreeWidgetItem *featItem = featureItem( item );
|
QTreeWidgetItem *featItem = featureItem( item );
|
||||||
|
@ -80,7 +80,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
|
|||||||
void popupItemSelected( QAction* menuAction );
|
void popupItemSelected( QAction* menuAction );
|
||||||
|
|
||||||
void layerDestroyed();
|
void layerDestroyed();
|
||||||
|
void editingToggled();
|
||||||
void featureDeleted( int fid );
|
void featureDeleted( int fid );
|
||||||
|
|
||||||
//! Context help
|
//! Context help
|
||||||
@ -96,9 +96,6 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
|
|||||||
/* Item in tree was clicked */
|
/* Item in tree was clicked */
|
||||||
void itemClicked( QTreeWidgetItem *lvi, int column );
|
void itemClicked( QTreeWidgetItem *lvi, int column );
|
||||||
|
|
||||||
void addEditAction();
|
|
||||||
void removeEditAction();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMenu *mActionPopup;
|
QMenu *mActionPopup;
|
||||||
QgsVectorLayer *mRubberBandLayer;
|
QgsVectorLayer *mRubberBandLayer;
|
||||||
@ -113,8 +110,6 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
|
|||||||
QTreeWidgetItem *layerItem( QObject *layer );
|
QTreeWidgetItem *layerItem( QObject *layer );
|
||||||
QTreeWidgetItem *retrieveAttributes( QTreeWidgetItem *item, std::vector< std::pair<QString, QString> > &attributes );
|
QTreeWidgetItem *retrieveAttributes( QTreeWidgetItem *item, std::vector< std::pair<QString, QString> > &attributes );
|
||||||
void clearRubberBand();
|
void clearRubberBand();
|
||||||
void addEditAction( QTreeWidgetItem * );
|
|
||||||
void addOrRemoveEditAction( bool addItem );
|
|
||||||
void disconnectLayer( QObject *object );
|
void disconnectLayer( QObject *object );
|
||||||
|
|
||||||
void setColumnText( int column, const QString & label );
|
void setColumnText( int column, const QString & label );
|
||||||
@ -124,7 +119,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
|
|||||||
|
|
||||||
void highlightFeature( QTreeWidgetItem *item );
|
void highlightFeature( QTreeWidgetItem *item );
|
||||||
void zoomToFeature( QTreeWidgetItem *item );
|
void zoomToFeature( QTreeWidgetItem *item );
|
||||||
void editFeature( QTreeWidgetItem *item );
|
void featureForm( QTreeWidgetItem *item );
|
||||||
|
|
||||||
void doAction( QTreeWidgetItem *item, int action );
|
void doAction( QTreeWidgetItem *item, int action );
|
||||||
|
|
||||||
|
@ -125,6 +125,8 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
|
|||||||
leSpatialRefSys->setText( layer->srs().toProj4() );
|
leSpatialRefSys->setText( layer->srs().toProj4() );
|
||||||
leSpatialRefSys->setCursorPosition( 0 );
|
leSpatialRefSys->setCursorPosition( 0 );
|
||||||
|
|
||||||
|
leEditForm->setText( layer->editForm() );
|
||||||
|
|
||||||
connect( sliderTransparency, SIGNAL( valueChanged( int ) ), this, SLOT( sliderTransparency_valueChanged( int ) ) );
|
connect( sliderTransparency, SIGNAL( valueChanged( int ) ), this, SLOT( sliderTransparency_valueChanged( int ) ) );
|
||||||
|
|
||||||
//for each overlay plugin create a new tab
|
//for each overlay plugin create a new tab
|
||||||
@ -236,6 +238,11 @@ void QgsVectorLayerProperties::attributeTypeDialog( )
|
|||||||
attributeTypeDialog.setIndex( index );
|
attributeTypeDialog.setIndex( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( mCheckedStates.contains( index ) )
|
||||||
|
{
|
||||||
|
attributeTypeDialog.setCheckedState( mCheckedStates[index].first, mCheckedStates[index].second );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !attributeTypeDialog.exec() )
|
if ( !attributeTypeDialog.exec() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -253,6 +260,8 @@ void QgsVectorLayerProperties::attributeTypeDialog( )
|
|||||||
case QgsVectorLayer::SliderRange:
|
case QgsVectorLayer::SliderRange:
|
||||||
mRanges.insert( index, attributeTypeDialog.rangeData() );
|
mRanges.insert( index, attributeTypeDialog.rangeData() );
|
||||||
break;
|
break;
|
||||||
|
case QgsVectorLayer::CheckBox:
|
||||||
|
mCheckedStates.insert( index, attributeTypeDialog.checkedState() );
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -550,6 +559,7 @@ void QgsVectorLayerProperties::setupEditTypes()
|
|||||||
editTypeMap.insert( QgsVectorLayer::Enumeration, tr( "Enumeration" ) );
|
editTypeMap.insert( QgsVectorLayer::Enumeration, tr( "Enumeration" ) );
|
||||||
editTypeMap.insert( QgsVectorLayer::Immutable, tr( "Immutable" ) );
|
editTypeMap.insert( QgsVectorLayer::Immutable, tr( "Immutable" ) );
|
||||||
editTypeMap.insert( QgsVectorLayer::Hidden, tr( "Hidden" ) );
|
editTypeMap.insert( QgsVectorLayer::Hidden, tr( "Hidden" ) );
|
||||||
|
editTypeMap.insert( QgsVectorLayer::CheckBox, tr( "Checkbox" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsVectorLayerProperties::editTypeButtonText( QgsVectorLayer::EditType type )
|
QString QgsVectorLayerProperties::editTypeButtonText( QgsVectorLayer::EditType type )
|
||||||
@ -586,6 +596,8 @@ void QgsVectorLayerProperties::apply()
|
|||||||
// update the display field
|
// update the display field
|
||||||
layer->setDisplayField( displayFieldComboBox->currentText() );
|
layer->setDisplayField( displayFieldComboBox->currentText() );
|
||||||
|
|
||||||
|
layer->setEditForm( leEditForm->text() );
|
||||||
|
|
||||||
actionDialog->apply();
|
actionDialog->apply();
|
||||||
|
|
||||||
labelDialog->apply();
|
labelDialog->apply();
|
||||||
@ -620,6 +632,13 @@ void QgsVectorLayerProperties::apply()
|
|||||||
layer->range( idx ) = mRanges[idx];
|
layer->range( idx ) = mRanges[idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( editType == QgsVectorLayer::CheckBox )
|
||||||
|
{
|
||||||
|
if ( mCheckedStates.contains( idx ) )
|
||||||
|
{
|
||||||
|
layer->setCheckedState( idx, mCheckedStates[idx].first, mCheckedStates[idx].second );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsSingleSymbolDialog *sdialog =
|
QgsSingleSymbolDialog *sdialog =
|
||||||
@ -1053,6 +1072,18 @@ void QgsVectorLayerProperties::on_mCalculateFieldButton_clicked()
|
|||||||
calc.exec();
|
calc.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsVectorLayerProperties::on_pbnSelectEditForm_clicked()
|
||||||
|
{
|
||||||
|
QSettings myQSettings;
|
||||||
|
QString lastUsedDir = myQSettings.value( "style/lastUIDir", "." ).toString();
|
||||||
|
QString uifilename = QFileDialog::getOpenFileName( this, tr( "Select edit form" ), lastUsedDir, tr( "UI file (*.ui)" ) );
|
||||||
|
|
||||||
|
if ( uifilename.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
leEditForm->setText( uifilename );
|
||||||
|
}
|
||||||
|
|
||||||
QList<QgsVectorOverlayPlugin*> QgsVectorLayerProperties::overlayPlugins() const
|
QList<QgsVectorOverlayPlugin*> QgsVectorLayerProperties::overlayPlugins() const
|
||||||
{
|
{
|
||||||
QList<QgsVectorOverlayPlugin*> pluginList;
|
QList<QgsVectorOverlayPlugin*> pluginList;
|
||||||
|
@ -102,6 +102,7 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
|
|||||||
void on_pbnSaveStyleAs_clicked();
|
void on_pbnSaveStyleAs_clicked();
|
||||||
void on_tblAttributes_cellChanged( int row, int column );
|
void on_tblAttributes_cellChanged( int row, int column );
|
||||||
void on_mCalculateFieldButton_clicked();
|
void on_mCalculateFieldButton_clicked();
|
||||||
|
void on_pbnSelectEditForm_clicked();
|
||||||
|
|
||||||
void addAttribute();
|
void addAttribute();
|
||||||
void deleteAttribute();
|
void deleteAttribute();
|
||||||
@ -145,6 +146,7 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
|
|||||||
QMap<int, QgsVectorLayer::EditType> mEditTypeMap;
|
QMap<int, QgsVectorLayer::EditType> mEditTypeMap;
|
||||||
QMap<int, QMap<QString, QVariant> > mValueMaps;
|
QMap<int, QMap<QString, QVariant> > mValueMaps;
|
||||||
QMap<int, QgsVectorLayer::RangeData> mRanges;
|
QMap<int, QgsVectorLayer::RangeData> mRanges;
|
||||||
|
QMap<int, QPair<QString, QString> > mCheckedStates;
|
||||||
|
|
||||||
void updateButtons();
|
void updateButtons();
|
||||||
void loadRows();
|
void loadRows();
|
||||||
|
@ -2357,8 +2357,19 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
|
|||||||
|
|
||||||
mRanges[ name ] = RangeData( min, max, step );
|
mRanges[ name ] = RangeData( min, max, step );
|
||||||
}
|
}
|
||||||
|
else if( editType == CheckBox )
|
||||||
|
{
|
||||||
|
mCheckedStates[ name ] = QPair<QString, QString>( editTypeElement.attribute( "checked" ), editTypeElement.attribute( "unchecked" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode editFormNode = node.namedItem( "editform" );
|
||||||
|
if ( !editFormNode.isNull() )
|
||||||
|
{
|
||||||
|
QDomElement e = editFormNode.toElement();
|
||||||
|
mEditForm = e.text();
|
||||||
|
}
|
||||||
|
|
||||||
mAttributeAliasMap.clear();
|
mAttributeAliasMap.clear();
|
||||||
QDomNode aliasesNode = node.namedItem( "aliases" );
|
QDomNode aliasesNode = node.namedItem( "aliases" );
|
||||||
@ -2504,6 +2515,14 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
|
|||||||
editTypeElement.setAttribute( "step", mRanges[ it.key()].mStep.toString() );
|
editTypeElement.setAttribute( "step", mRanges[ it.key()].mStep.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( it.value() == CheckBox )
|
||||||
|
{
|
||||||
|
if ( mCheckedStates.contains( it.key() ) )
|
||||||
|
{
|
||||||
|
editTypeElement.setAttribute( "checked", mCheckedStates[ it.key()].first );
|
||||||
|
editTypeElement.setAttribute( "unchecked", mCheckedStates[ it.key()].second );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
editTypesElement.appendChild( editTypeElement );
|
editTypesElement.appendChild( editTypeElement );
|
||||||
}
|
}
|
||||||
@ -2511,6 +2530,11 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
|
|||||||
node.appendChild( editTypesElement );
|
node.appendChild( editTypesElement );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDomElement efField = doc.createElement( "editform" );
|
||||||
|
QDomText efText = doc.createTextNode( mEditForm );
|
||||||
|
efField.appendChild( efText );
|
||||||
|
node.appendChild( efField );
|
||||||
|
|
||||||
//attribute aliases
|
//attribute aliases
|
||||||
if ( mAttributeAliasMap.size() > 0 )
|
if ( mAttributeAliasMap.size() > 0 )
|
||||||
{
|
{
|
||||||
@ -3708,6 +3732,16 @@ void QgsVectorLayer::setEditType( int idx, EditType type )
|
|||||||
mEditTypes[ fields[idx].name()] = type;
|
mEditTypes[ fields[idx].name()] = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString QgsVectorLayer::editForm()
|
||||||
|
{
|
||||||
|
return mEditForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsVectorLayer::setEditForm( QString ui )
|
||||||
|
{
|
||||||
|
mEditForm = ui;
|
||||||
|
}
|
||||||
|
|
||||||
QMap< QString, QVariant > &QgsVectorLayer::valueMap( int idx )
|
QMap< QString, QVariant > &QgsVectorLayer::valueMap( int idx )
|
||||||
{
|
{
|
||||||
const QgsFieldMap &fields = pendingFields();
|
const QgsFieldMap &fields = pendingFields();
|
||||||
@ -4091,3 +4125,19 @@ void QgsVectorLayer::undoEditCommand( QgsUndoCommand* cmd )
|
|||||||
// it's not ideal to trigger refresh from here
|
// it's not ideal to trigger refresh from here
|
||||||
triggerRepaint();
|
triggerRepaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsVectorLayer::setCheckedState( int idx, QString checked, QString unchecked )
|
||||||
|
{
|
||||||
|
const QgsFieldMap &fields = pendingFields();
|
||||||
|
if ( fields.contains( idx ) )
|
||||||
|
mCheckedStates[ fields[idx].name() ] = QPair<QString, QString>( checked, unchecked );
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair<QString, QString> QgsVectorLayer::checkedState( int idx )
|
||||||
|
{
|
||||||
|
const QgsFieldMap &fields = pendingFields();
|
||||||
|
if ( fields.contains( idx ) && mCheckedStates.contains( fields[idx].name() ) )
|
||||||
|
return mCheckedStates[ fields[idx].name() ];
|
||||||
|
else
|
||||||
|
return QPair<QString,QString>( "1", "0" );
|
||||||
|
}
|
||||||
|
@ -53,9 +53,6 @@ typedef QSet<int> QgsFeatureIds;
|
|||||||
typedef QSet<int> QgsAttributeIds;
|
typedef QSet<int> QgsAttributeIds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** \ingroup core
|
/** \ingroup core
|
||||||
* Vector layer backed by a data source provider.
|
* Vector layer backed by a data source provider.
|
||||||
*/
|
*/
|
||||||
@ -73,6 +70,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
|||||||
Classification,
|
Classification,
|
||||||
EditRange,
|
EditRange,
|
||||||
SliderRange,
|
SliderRange,
|
||||||
|
CheckBox, /* added in 1.4 */
|
||||||
FileName,
|
FileName,
|
||||||
Enumeration,
|
Enumeration,
|
||||||
Immutable, /*The attribute value should not be changed in the attribute form*/
|
Immutable, /*The attribute value should not be changed in the attribute form*/
|
||||||
@ -451,6 +449,18 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
|||||||
/**set edit type*/
|
/**set edit type*/
|
||||||
void setEditType( int idx, EditType edit );
|
void setEditType( int idx, EditType edit );
|
||||||
|
|
||||||
|
/** set string representing 'true' for a checkbox (added in 1.4) */
|
||||||
|
void setCheckedState( int idx, QString checked, QString notChecked );
|
||||||
|
|
||||||
|
/** return string representing 'true' for a checkbox (added in 1.4) */
|
||||||
|
QPair<QString, QString> checkedState( int idx );
|
||||||
|
|
||||||
|
/** get edit form (added in 1.4) */
|
||||||
|
QString editForm();
|
||||||
|
|
||||||
|
/** set edit form (added in 1.4) */
|
||||||
|
void setEditForm( QString ui );
|
||||||
|
|
||||||
/**access value map*/
|
/**access value map*/
|
||||||
QMap<QString, QVariant> &valueMap( int idx );
|
QMap<QString, QVariant> &valueMap( int idx );
|
||||||
|
|
||||||
@ -719,6 +729,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
|||||||
QMap< QString, EditType > mEditTypes;
|
QMap< QString, EditType > mEditTypes;
|
||||||
QMap< QString, QMap<QString, QVariant> > mValueMaps;
|
QMap< QString, QMap<QString, QVariant> > mValueMaps;
|
||||||
QMap< QString, RangeData > mRanges;
|
QMap< QString, RangeData > mRanges;
|
||||||
|
QMap< QString, QPair<QString,QString> > mCheckedStates;
|
||||||
|
QString mEditForm;
|
||||||
|
|
||||||
bool mFetching;
|
bool mFetching;
|
||||||
QgsRectangle mFetchRect;
|
QgsRectangle mFetchRect;
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
<ui version="4.0" >
|
|
||||||
<class>QgsAttributeDialogBase</class>
|
|
||||||
<widget class="QDialog" name="QgsAttributeDialogBase" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>447</width>
|
|
||||||
<height>343</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
|
||||||
<string>Enter Attribute Values</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" >
|
|
||||||
<item row="0" column="0" >
|
|
||||||
<widget class="QFrame" name="mFrame" >
|
|
||||||
<property name="frameShape" >
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow" >
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" >
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
|
||||||
<property name="standardButtons" >
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<layoutdefault spacing="6" margin="11" />
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>QgsAttributeDialogBase</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>277</x>
|
|
||||||
<y>318</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>325</x>
|
|
||||||
<y>279</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>QgsAttributeDialogBase</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>208</x>
|
|
||||||
<y>308</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>163</x>
|
|
||||||
<y>284</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>401</width>
|
<width>471</width>
|
||||||
<height>428</height>
|
<height>428</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -61,12 +61,23 @@
|
|||||||
<string>Hidden</string>
|
<string>Hidden</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Checkbox</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="lineEditPage">
|
<widget class="QWidget" name="lineEditPage">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_1">
|
<layout class="QVBoxLayout" name="verticalLayout_1">
|
||||||
@ -486,6 +497,53 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="checkBoxPage">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>453</width>
|
||||||
|
<height>333</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLineEdit" name="leCheckedState"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Representation for checked state</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Representation for unchecked state</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QLineEdit" name="leUncheckedState"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_8">
|
||||||
|
<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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
<enum>QTabWidget::Rounded</enum>
|
<enum>QTabWidget::Rounded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab2">
|
<widget class="QWidget" name="tab2">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -410,21 +410,21 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="3">
|
<item row="3" column="0" colspan="3">
|
||||||
<widget class="QLineEdit" name="leSpatialRefSys">
|
<widget class="QLineEdit" name="leSpatialRefSys">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QPushButton" name="pbnIndex">
|
<widget class="QPushButton" name="pbnIndex">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Create Spatial Index</string>
|
<string>Create Spatial Index</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
<item row="4" column="2">
|
||||||
<widget class="QPushButton" name="pbnChangeSpatialRefSys">
|
<widget class="QPushButton" name="pbnChangeSpatialRefSys">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Specify the coordinate reference system of the layer's geometry.</string>
|
<string>Specify the coordinate reference system of the layer's geometry.</string>
|
||||||
@ -437,6 +437,23 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit UI</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="leEditForm"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPushButton" name="pbnSelectEditForm">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user