Skip to content

Commit a4758ff

Browse files
author
jef
committed
add support for multiline edit widget
git-svn-id: http://svn.osgeo.org/qgis/trunk@12165 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5a43c27 commit a4758ff

6 files changed

+67
-22
lines changed

python/core/qgsvectorlayer.sip

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public:
1616
CheckBox, /* @note added in 1.4 */
1717
FileName,
1818
Enumeration, /* @note added in 1.4 */
19-
Immutable /* @note added in 1.4 */
19+
Immutable, /* @note added in 1.4 */
20+
Hidden, /* @note added in 1.4 */
21+
TextEdit /* @note added in 1.4 */
2022
};
2123

2224
struct RangeData {

src/app/qgsattributeeditor.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
242242
if ( editor )
243243
cb = qobject_cast<QCheckBox*>( editor );
244244
else
245-
cb = new QCheckBox();
245+
cb = new QCheckBox( parent );
246246

247247
if ( cb )
248248
{
@@ -254,8 +254,8 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
254254
// fall-through
255255

256256
case QgsVectorLayer::LineEdit:
257+
case QgsVectorLayer::TextEdit:
257258
case QgsVectorLayer::UniqueValuesEditable:
258-
default:
259259
{
260260
QLineEdit *le = NULL;
261261
QTextEdit *te = NULL;
@@ -267,6 +267,10 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
267267
te = qobject_cast<QTextEdit *>( editor );
268268
pte = qobject_cast<QPlainTextEdit *>( editor );
269269
}
270+
else if ( editType == QgsVectorLayer::TextEdit )
271+
{
272+
pte = new QPlainTextEdit( parent );
273+
}
270274
else
271275
{
272276
le = new QLineEdit( parent );

src/app/qgsattributetypedialog.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editTy
249249
setPage( 9 );
250250
break;
251251

252+
case QgsVectorLayer::TextEdit:
253+
setPage( 10 );
254+
252255
case QgsVectorLayer::LineEdit:
253256
setPage( 0 );
254257
break;
@@ -459,6 +462,7 @@ void QgsAttributeTypeDialog::accept()
459462
//store data to output variables
460463
switch ( selectionComboBox->currentIndex() )
461464
{
465+
default:
462466
case 0:
463467
mEditType = QgsVectorLayer::LineEdit;
464468
break;
@@ -530,8 +534,9 @@ void QgsAttributeTypeDialog::accept()
530534
case 9:
531535
mEditType = QgsVectorLayer::CheckBox;
532536
break;
533-
default:
534-
mEditType = QgsVectorLayer::LineEdit;
537+
case 10:
538+
mEditType = QgsVectorLayer::TextEdit;
539+
break;
535540
}
536541

537542
QDialog::accept();

src/app/qgsvectorlayerproperties.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ void QgsVectorLayerProperties::setupEditTypes()
579579
editTypeMap.insert( QgsVectorLayer::Immutable, tr( "Immutable" ) );
580580
editTypeMap.insert( QgsVectorLayer::Hidden, tr( "Hidden" ) );
581581
editTypeMap.insert( QgsVectorLayer::CheckBox, tr( "Checkbox" ) );
582+
editTypeMap.insert( QgsVectorLayer::TextEdit, tr( "Text edit" ) );
582583
}
583584

584585
QString QgsVectorLayerProperties::editTypeButtonText( QgsVectorLayer::EditType type )

src/core/qgsvectorlayer.h

+17-16
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ typedef QSet<int> QgsAttributeIds;
5555

5656
class QgsLabelingEngineInterface
5757
{
58-
public:
59-
virtual ~QgsLabelingEngineInterface() {}
60-
virtual int prepareLayer(QgsVectorLayer* layer, int& attrIndex) = 0;
61-
virtual void registerFeature(QgsVectorLayer* layer, QgsFeature& feat) = 0;
62-
//void calculateLabeling() = 0;
63-
//void drawLabeling(QgsRenderContext& context) = 0;
58+
public:
59+
virtual ~QgsLabelingEngineInterface() {}
60+
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex ) = 0;
61+
virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat ) = 0;
62+
//void calculateLabeling() = 0;
63+
//void drawLabeling(QgsRenderContext& context) = 0;
6464
};
6565

6666

@@ -86,7 +86,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
8686
FileName,
8787
Enumeration,
8888
Immutable, /*The attribute value should not be changed in the attribute form*/
89-
Hidden /*The attribute value should not be shown in the attribute form @added in 1.4 */
89+
Hidden, /*The attribute value should not be shown in the attribute form @added in 1.4 */
90+
TextEdit /*multiline edit @added in 1.4*/
9091
};
9192

9293
struct RangeData
@@ -176,15 +177,15 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
176177

177178
/** Sets the renderer. If a renderer is already present, it is deleted */
178179
void setRenderer( QgsRenderer * r );
179-
180+
180181
/** Return renderer V2. Added in QGIS 1.4 */
181182
QgsFeatureRendererV2* rendererV2();
182183
/** Set renderer V2. Added in QGIS 1.4 */
183-
void setRendererV2(QgsFeatureRendererV2* r);
184+
void setRendererV2( QgsFeatureRendererV2* r );
184185
/** Return whether using renderer V2. Added in QGIS 1.4 */
185186
bool isUsingRendererV2();
186187
/** set whether to use renderer V2 for drawing. Added in QGIS 1.4 */
187-
void setUsingRendererV2(bool usingRendererV2);
188+
void setUsingRendererV2( bool usingRendererV2 );
188189

189190
/** Draw layer with renderer V2. Added in QGIS 1.4 */
190191
void drawRendererV2( QgsRenderContext& rendererContext, bool labeling );
@@ -362,7 +363,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
362363
bool hasLabelsEnabled( void ) const;
363364

364365
/** Assign a custom labeling engine with layer. Added in v1.4 */
365-
void setLabelingEngine(QgsLabelingEngineInterface* engine);
366+
void setLabelingEngine( QgsLabelingEngineInterface* engine );
366367

367368
/** Returns true if the provider is in editing mode */
368369
virtual bool isEditable() const;
@@ -477,10 +478,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
477478

478479
/**set edit type*/
479480
void setEditType( int idx, EditType edit );
480-
481+
481482
/** set string representing 'true' for a checkbox (added in 1.4) */
482483
void setCheckedState( int idx, QString checked, QString notChecked );
483-
484+
484485
/** return string representing 'true' for a checkbox (added in 1.4) */
485486
QPair<QString, QString> checkedState( int idx );
486487

@@ -736,10 +737,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
736737

737738
/** Renderer object which holds the information about how to display the features */
738739
QgsRenderer *mRenderer;
739-
740+
740741
/** Renderer V2 */
741742
QgsFeatureRendererV2 *mRendererV2;
742-
743+
743744
/** whether to use V1 or V2 renderer */
744745
bool mUsingRendererV2;
745746

@@ -769,7 +770,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
769770
QMap< QString, EditType > mEditTypes;
770771
QMap< QString, QMap<QString, QVariant> > mValueMaps;
771772
QMap< QString, RangeData > mRanges;
772-
QMap< QString, QPair<QString,QString> > mCheckedStates;
773+
QMap< QString, QPair<QString, QString> > mCheckedStates;
773774
QString mEditForm;
774775

775776
bool mFetching;

src/ui/qgsattributetypeedit.ui

+33-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@
6666
<string>Checkbox</string>
6767
</property>
6868
</item>
69+
<item>
70+
<property name="text">
71+
<string>Text edit</string>
72+
</property>
73+
</item>
6974
</widget>
7075
</item>
7176
<item>
@@ -77,7 +82,7 @@
7782
</sizepolicy>
7883
</property>
7984
<property name="currentIndex">
80-
<number>9</number>
85+
<number>0</number>
8186
</property>
8287
<widget class="QWidget" name="lineEditPage">
8388
<layout class="QVBoxLayout" name="verticalLayout_1">
@@ -544,6 +549,33 @@
544549
</item>
545550
</layout>
546551
</widget>
552+
<widget class="QWidget" name="textEditPage">
553+
<layout class="QVBoxLayout" name="verticalLayout_25">
554+
<item>
555+
<widget class="QLabel" name="hiddenLabel_3">
556+
<property name="text">
557+
<string>A text edit field that accepts multiple lines will be used.</string>
558+
</property>
559+
<property name="wordWrap">
560+
<bool>true</bool>
561+
</property>
562+
</widget>
563+
</item>
564+
<item>
565+
<spacer name="verticalSpacer_17">
566+
<property name="orientation">
567+
<enum>Qt::Vertical</enum>
568+
</property>
569+
<property name="sizeHint" stdset="0">
570+
<size>
571+
<width>20</width>
572+
<height>302</height>
573+
</size>
574+
</property>
575+
</spacer>
576+
</item>
577+
</layout>
578+
</widget>
547579
</widget>
548580
</item>
549581
<item>

0 commit comments

Comments
 (0)