Skip to content
Permalink
Browse files
[FEATURE] add widgets for photos and webpages
  • Loading branch information
jef-n committed Mar 31, 2013
1 parent 04d1611 commit b27b6a9a4ddea5bfde222c8c4e6f9929edd448c6
@@ -84,6 +84,11 @@ QString QgsAttributeTypeDialog::dateFormat()
return mDateFormat;
}

QSize QgsAttributeTypeDialog::widgetSize()
{
return mWidgetSize;
}

QMap<QString, QVariant> &QgsAttributeTypeDialog::valueMap()
{
return mValueMap;
@@ -325,6 +330,14 @@ void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editTy
case QgsVectorLayer::UuidGenerator:
setPage( 13 );
break;

case QgsVectorLayer::Photo:
setPage( 14 );
break;

case QgsVectorLayer::Webview:
setPage( 15 );
break;
}
}

@@ -348,6 +361,11 @@ void QgsAttributeTypeDialog::setDateFormat( QString dateFormat )
mDateFormat = dateFormat;
}

void QgsAttributeTypeDialog::setWidgetSize( QSize widgetSize )
{
mWidgetSize = widgetSize;
}

void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editType )
{
mIndex = index;
@@ -490,6 +508,11 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
leDateFormat->setText( mDateFormat );
break;

case QgsVectorLayer::Photo:
sbWidgetWidth->setValue( mWidgetSize.width() );
sbWidgetHeight->setValue( mWidgetSize.height() );
break;

case QgsVectorLayer::LineEdit:
case QgsVectorLayer::UniqueValues:
case QgsVectorLayer::Classification:
@@ -500,6 +523,7 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
case QgsVectorLayer::Hidden:
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::UuidGenerator:
case QgsVectorLayer::Webview:
break;
}
}
@@ -554,6 +578,7 @@ void QgsAttributeTypeDialog::setStackPage( int index )
}

}

stackedWidget->currentWidget()->setDisabled( okDisabled );
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( okDisabled );
}
@@ -667,6 +692,13 @@ void QgsAttributeTypeDialog::accept()
case 13:
mEditType = QgsVectorLayer::UuidGenerator;
break;
case 14:
mEditType = QgsVectorLayer::Photo;
mWidgetSize = QSize( sbWidgetWidth->value(), sbWidgetHeight->value() );
break;
case 15:
mEditType = QgsVectorLayer::Webview;
break;
}

QDialog::accept();
@@ -88,6 +88,12 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
*/
void setDateFormat( QString dateFormat );

/**
* Setter to widget size
* @param widgetSize size of widget
*/
void setWidgetSize( QSize widgetSize );

/**
* Setter for checkbox for editable state of field
* @param bool editable
@@ -122,6 +128,11 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
*/
QString dateFormat();

/**
* Getter for widget size
*/
QSize widgetSize();

/**
* Getter for checkbox for editable state of field
*/
@@ -193,6 +204,7 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
QgsVectorLayer::ValueRelationData mValueRelationData;
QgsVectorLayer::EditType mEditType;
QString mDateFormat;
QSize mWidgetSize;
};

#endif
@@ -488,7 +488,7 @@ void QgsFieldsProperties::attributeTypeDialog()
attributeTypeDialog.setCheckedState( checkStates.first, checkStates.second );

attributeTypeDialog.setDateFormat( mDateFormat.value( index, mLayer->dateFormat( index ) ) );

attributeTypeDialog.setWidgetSize( mWidgetSize.value( index, mLayer->widgetSize( index ) ) );
attributeTypeDialog.setFieldEditable( mFieldEditables.value( index, mLayer->fieldEditable( index ) ) );

attributeTypeDialog.setIndex( index, mEditTypeMap.value( index, mLayer->editType( index ) ) );
@@ -522,6 +522,9 @@ void QgsFieldsProperties::attributeTypeDialog()
case QgsVectorLayer::Calendar:
mDateFormat.insert( index, attributeTypeDialog.dateFormat() );
break;
case QgsVectorLayer::Photo:
mWidgetSize.insert( index, attributeTypeDialog.widgetSize() );
break;
case QgsVectorLayer::LineEdit:
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::UniqueValues:
@@ -532,6 +535,7 @@ void QgsFieldsProperties::attributeTypeDialog()
case QgsVectorLayer::Immutable:
case QgsVectorLayer::Hidden:
case QgsVectorLayer::UuidGenerator:
case QgsVectorLayer::Webview:
break;
}

@@ -741,6 +745,8 @@ void QgsFieldsProperties::setupEditTypes()
editTypeMap.insert( QgsVectorLayer::Calendar, tr( "Calendar" ) );
editTypeMap.insert( QgsVectorLayer::ValueRelation, tr( "Value relation" ) );
editTypeMap.insert( QgsVectorLayer::UuidGenerator, tr( "UUID generator" ) );
editTypeMap.insert( QgsVectorLayer::Photo, tr( "Photo" ) );
editTypeMap.insert( QgsVectorLayer::Webview, tr( "Webview" ) );
}

QString QgsFieldsProperties::editTypeButtonText( QgsVectorLayer::EditType type )
@@ -868,6 +874,13 @@ void QgsFieldsProperties::apply()
}
break;

case QgsVectorLayer::Photo:
if ( mWidgetSize.contains( idx ) )
{
mLayer->widgetSize( idx ) = mWidgetSize[idx];
}
break;

case QgsVectorLayer::LineEdit:
case QgsVectorLayer::UniqueValues:
case QgsVectorLayer::UniqueValuesEditable:
@@ -878,6 +891,7 @@ void QgsFieldsProperties::apply()
case QgsVectorLayer::Hidden:
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::UuidGenerator:
case QgsVectorLayer::Webview:
break;
}

@@ -131,6 +131,7 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
QMap<int, QgsVectorLayer::EditType> mEditTypeMap;
QMap<int, QPushButton*> mButtonMap;
QMap<int, QString> mDateFormat;
QMap<int, QSize> mWidgetSize;

enum attrColumns
{
@@ -2409,6 +2409,10 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
mDateFormats[ name ] = editTypeElement.attribute( "dateFormat" );
break;

case Photo:
mWidgetSize[ name ] = QSize( editTypeElement.attribute( "widgetWidth" ).toInt(), editTypeElement.attribute( "widgetHeight" ).toInt() );
break;

case Classification:
case FileName:
case Immutable:
@@ -2419,6 +2423,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
case UniqueValues:
case UniqueValuesEditable:
case UuidGenerator:
case Webview:
break;
}
}
@@ -2728,6 +2733,11 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
editTypeElement.setAttribute( "dateFormat", mDateFormats[ it.key()] );
break;

case Photo:
editTypeElement.setAttribute( "widgetWidth", mWidgetSize[ it.key()].width() );
editTypeElement.setAttribute( "widgetHeight", mWidgetSize[ it.key()].height() );
break;

case LineEdit:
case UniqueValues:
case UniqueValuesEditable:
@@ -2738,6 +2748,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
case Enumeration:
case Immutable:
case UuidGenerator:
case Webview:
break;
}

@@ -3666,6 +3677,18 @@ QString &QgsVectorLayer::dateFormat( int idx )
return mDateFormats[fieldName];
}

QSize &QgsVectorLayer::widgetSize( int idx )
{
const QgsFields &fields = pendingFields();

QString fieldName = fields[idx].name();

if ( !mWidgetSize.contains( fieldName ) )
mWidgetSize[fieldName] = QSize( 0, 0 );

return mWidgetSize[fieldName];
}

bool QgsVectorLayer::fieldEditable( int idx )
{
const QgsFields &fields = pendingFields();
@@ -176,6 +176,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
DialRange, /* dial range @added in 1.5 */
ValueRelation, /* value map from an table @added in 1.8 */
UuidGenerator, /* uuid generator - readonly and automatically intialized @added in 1.9 */
Photo, /* phote widget @added in 1.9 */
Webview, /* webview widget @added in 1.9 */
};

struct RangeData
@@ -759,6 +761,11 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
QString &dateFormat( int idx );

/**access widget size for photo and webview widget
* @note added in 1.9
*/
QSize &widgetSize( int idx );

/**is edit widget editable
* @note added in 1.9
**/
@@ -1066,6 +1073,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
QMap< QString, QPair<QString, QString> > mCheckedStates;
QMap< QString, ValueRelationData > mValueRelations;
QMap< QString, QString> mDateFormats;
QMap< QString, QSize> mWidgetSize;

/** Defines the default layout to use for the attribute editor (Drag and drop, UI File, Generated) */
EditorLayout mEditorLayout;

0 comments on commit b27b6a9

Please sign in to comment.