Skip to content

Commit b27b6a9

Browse files
committedMar 31, 2013
[FEATURE] add widgets for photos and webpages
1 parent 04d1611 commit b27b6a9

9 files changed

+434
-111
lines changed
 

‎src/app/qgsattributetypedialog.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ QString QgsAttributeTypeDialog::dateFormat()
8484
return mDateFormat;
8585
}
8686

87+
QSize QgsAttributeTypeDialog::widgetSize()
88+
{
89+
return mWidgetSize;
90+
}
91+
8792
QMap<QString, QVariant> &QgsAttributeTypeDialog::valueMap()
8893
{
8994
return mValueMap;
@@ -325,6 +330,14 @@ void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editTy
325330
case QgsVectorLayer::UuidGenerator:
326331
setPage( 13 );
327332
break;
333+
334+
case QgsVectorLayer::Photo:
335+
setPage( 14 );
336+
break;
337+
338+
case QgsVectorLayer::Webview:
339+
setPage( 15 );
340+
break;
328341
}
329342
}
330343

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

364+
void QgsAttributeTypeDialog::setWidgetSize( QSize widgetSize )
365+
{
366+
mWidgetSize = widgetSize;
367+
}
368+
351369
void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editType )
352370
{
353371
mIndex = index;
@@ -490,6 +508,11 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
490508
leDateFormat->setText( mDateFormat );
491509
break;
492510

511+
case QgsVectorLayer::Photo:
512+
sbWidgetWidth->setValue( mWidgetSize.width() );
513+
sbWidgetHeight->setValue( mWidgetSize.height() );
514+
break;
515+
493516
case QgsVectorLayer::LineEdit:
494517
case QgsVectorLayer::UniqueValues:
495518
case QgsVectorLayer::Classification:
@@ -500,6 +523,7 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
500523
case QgsVectorLayer::Hidden:
501524
case QgsVectorLayer::TextEdit:
502525
case QgsVectorLayer::UuidGenerator:
526+
case QgsVectorLayer::Webview:
503527
break;
504528
}
505529
}
@@ -554,6 +578,7 @@ void QgsAttributeTypeDialog::setStackPage( int index )
554578
}
555579

556580
}
581+
557582
stackedWidget->currentWidget()->setDisabled( okDisabled );
558583
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( okDisabled );
559584
}
@@ -667,6 +692,13 @@ void QgsAttributeTypeDialog::accept()
667692
case 13:
668693
mEditType = QgsVectorLayer::UuidGenerator;
669694
break;
695+
case 14:
696+
mEditType = QgsVectorLayer::Photo;
697+
mWidgetSize = QSize( sbWidgetWidth->value(), sbWidgetHeight->value() );
698+
break;
699+
case 15:
700+
mEditType = QgsVectorLayer::Webview;
701+
break;
670702
}
671703

672704
QDialog::accept();

‎src/app/qgsattributetypedialog.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
8888
*/
8989
void setDateFormat( QString dateFormat );
9090

91+
/**
92+
* Setter to widget size
93+
* @param widgetSize size of widget
94+
*/
95+
void setWidgetSize( QSize widgetSize );
96+
9197
/**
9298
* Setter for checkbox for editable state of field
9399
* @param bool editable
@@ -122,6 +128,11 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
122128
*/
123129
QString dateFormat();
124130

131+
/**
132+
* Getter for widget size
133+
*/
134+
QSize widgetSize();
135+
125136
/**
126137
* Getter for checkbox for editable state of field
127138
*/
@@ -193,6 +204,7 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
193204
QgsVectorLayer::ValueRelationData mValueRelationData;
194205
QgsVectorLayer::EditType mEditType;
195206
QString mDateFormat;
207+
QSize mWidgetSize;
196208
};
197209

198210
#endif

‎src/app/qgsfieldsproperties.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ void QgsFieldsProperties::attributeTypeDialog()
488488
attributeTypeDialog.setCheckedState( checkStates.first, checkStates.second );
489489

490490
attributeTypeDialog.setDateFormat( mDateFormat.value( index, mLayer->dateFormat( index ) ) );
491-
491+
attributeTypeDialog.setWidgetSize( mWidgetSize.value( index, mLayer->widgetSize( index ) ) );
492492
attributeTypeDialog.setFieldEditable( mFieldEditables.value( index, mLayer->fieldEditable( index ) ) );
493493

494494
attributeTypeDialog.setIndex( index, mEditTypeMap.value( index, mLayer->editType( index ) ) );
@@ -522,6 +522,9 @@ void QgsFieldsProperties::attributeTypeDialog()
522522
case QgsVectorLayer::Calendar:
523523
mDateFormat.insert( index, attributeTypeDialog.dateFormat() );
524524
break;
525+
case QgsVectorLayer::Photo:
526+
mWidgetSize.insert( index, attributeTypeDialog.widgetSize() );
527+
break;
525528
case QgsVectorLayer::LineEdit:
526529
case QgsVectorLayer::TextEdit:
527530
case QgsVectorLayer::UniqueValues:
@@ -532,6 +535,7 @@ void QgsFieldsProperties::attributeTypeDialog()
532535
case QgsVectorLayer::Immutable:
533536
case QgsVectorLayer::Hidden:
534537
case QgsVectorLayer::UuidGenerator:
538+
case QgsVectorLayer::Webview:
535539
break;
536540
}
537541

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

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

877+
case QgsVectorLayer::Photo:
878+
if ( mWidgetSize.contains( idx ) )
879+
{
880+
mLayer->widgetSize( idx ) = mWidgetSize[idx];
881+
}
882+
break;
883+
871884
case QgsVectorLayer::LineEdit:
872885
case QgsVectorLayer::UniqueValues:
873886
case QgsVectorLayer::UniqueValuesEditable:
@@ -878,6 +891,7 @@ void QgsFieldsProperties::apply()
878891
case QgsVectorLayer::Hidden:
879892
case QgsVectorLayer::TextEdit:
880893
case QgsVectorLayer::UuidGenerator:
894+
case QgsVectorLayer::Webview:
881895
break;
882896
}
883897

‎src/app/qgsfieldsproperties.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
131131
QMap<int, QgsVectorLayer::EditType> mEditTypeMap;
132132
QMap<int, QPushButton*> mButtonMap;
133133
QMap<int, QString> mDateFormat;
134+
QMap<int, QSize> mWidgetSize;
134135

135136
enum attrColumns
136137
{

‎src/core/qgsvectorlayer.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,10 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
24092409
mDateFormats[ name ] = editTypeElement.attribute( "dateFormat" );
24102410
break;
24112411

2412+
case Photo:
2413+
mWidgetSize[ name ] = QSize( editTypeElement.attribute( "widgetWidth" ).toInt(), editTypeElement.attribute( "widgetHeight" ).toInt() );
2414+
break;
2415+
24122416
case Classification:
24132417
case FileName:
24142418
case Immutable:
@@ -2419,6 +2423,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
24192423
case UniqueValues:
24202424
case UniqueValuesEditable:
24212425
case UuidGenerator:
2426+
case Webview:
24222427
break;
24232428
}
24242429
}
@@ -2728,6 +2733,11 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
27282733
editTypeElement.setAttribute( "dateFormat", mDateFormats[ it.key()] );
27292734
break;
27302735

2736+
case Photo:
2737+
editTypeElement.setAttribute( "widgetWidth", mWidgetSize[ it.key()].width() );
2738+
editTypeElement.setAttribute( "widgetHeight", mWidgetSize[ it.key()].height() );
2739+
break;
2740+
27312741
case LineEdit:
27322742
case UniqueValues:
27332743
case UniqueValuesEditable:
@@ -2738,6 +2748,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
27382748
case Enumeration:
27392749
case Immutable:
27402750
case UuidGenerator:
2751+
case Webview:
27412752
break;
27422753
}
27432754

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

3680+
QSize &QgsVectorLayer::widgetSize( int idx )
3681+
{
3682+
const QgsFields &fields = pendingFields();
3683+
3684+
QString fieldName = fields[idx].name();
3685+
3686+
if ( !mWidgetSize.contains( fieldName ) )
3687+
mWidgetSize[fieldName] = QSize( 0, 0 );
3688+
3689+
return mWidgetSize[fieldName];
3690+
}
3691+
36693692
bool QgsVectorLayer::fieldEditable( int idx )
36703693
{
36713694
const QgsFields &fields = pendingFields();

‎src/core/qgsvectorlayer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
176176
DialRange, /* dial range @added in 1.5 */
177177
ValueRelation, /* value map from an table @added in 1.8 */
178178
UuidGenerator, /* uuid generator - readonly and automatically intialized @added in 1.9 */
179+
Photo, /* phote widget @added in 1.9 */
180+
Webview, /* webview widget @added in 1.9 */
179181
};
180182

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

764+
/**access widget size for photo and webview widget
765+
* @note added in 1.9
766+
*/
767+
QSize &widgetSize( int idx );
768+
762769
/**is edit widget editable
763770
* @note added in 1.9
764771
**/
@@ -1066,6 +1073,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
10661073
QMap< QString, QPair<QString, QString> > mCheckedStates;
10671074
QMap< QString, ValueRelationData > mValueRelations;
10681075
QMap< QString, QString> mDateFormats;
1076+
QMap< QString, QSize> mWidgetSize;
10691077

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

0 commit comments

Comments
 (0)
Please sign in to comment.