Skip to content

Commit

Permalink
add support for multiline edit widget
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12165 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 17, 2009
1 parent 7ea8e7e commit 907ff17
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 22 deletions.
4 changes: 3 additions & 1 deletion python/core/qgsvectorlayer.sip
Expand Up @@ -16,7 +16,9 @@ public:
CheckBox, /* @note added in 1.4 */
FileName,
Enumeration, /* @note added in 1.4 */
Immutable /* @note added in 1.4 */
Immutable, /* @note added in 1.4 */
Hidden, /* @note added in 1.4 */
TextEdit /* @note added in 1.4 */
};

struct RangeData {
Expand Down
8 changes: 6 additions & 2 deletions src/app/qgsattributeeditor.cpp
Expand Up @@ -242,7 +242,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
if ( editor )
cb = qobject_cast<QCheckBox*>( editor );
else
cb = new QCheckBox();
cb = new QCheckBox( parent );

if ( cb )
{
Expand All @@ -254,8 +254,8 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
// fall-through

case QgsVectorLayer::LineEdit:
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::UniqueValuesEditable:
default:
{
QLineEdit *le = NULL;
QTextEdit *te = NULL;
Expand All @@ -267,6 +267,10 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
te = qobject_cast<QTextEdit *>( editor );
pte = qobject_cast<QPlainTextEdit *>( editor );
}
else if ( editType == QgsVectorLayer::TextEdit )
{
pte = new QPlainTextEdit( parent );
}
else
{
le = new QLineEdit( parent );
Expand Down
9 changes: 7 additions & 2 deletions src/app/qgsattributetypedialog.cpp
Expand Up @@ -249,6 +249,9 @@ void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editTy
setPage( 9 );
break;

case QgsVectorLayer::TextEdit:
setPage( 10 );

case QgsVectorLayer::LineEdit:
setPage( 0 );
break;
Expand Down Expand Up @@ -459,6 +462,7 @@ void QgsAttributeTypeDialog::accept()
//store data to output variables
switch ( selectionComboBox->currentIndex() )
{
default:
case 0:
mEditType = QgsVectorLayer::LineEdit;
break;
Expand Down Expand Up @@ -530,8 +534,9 @@ void QgsAttributeTypeDialog::accept()
case 9:
mEditType = QgsVectorLayer::CheckBox;
break;
default:
mEditType = QgsVectorLayer::LineEdit;
case 10:
mEditType = QgsVectorLayer::TextEdit;
break;
}

QDialog::accept();
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -579,6 +579,7 @@ void QgsVectorLayerProperties::setupEditTypes()
editTypeMap.insert( QgsVectorLayer::Immutable, tr( "Immutable" ) );
editTypeMap.insert( QgsVectorLayer::Hidden, tr( "Hidden" ) );
editTypeMap.insert( QgsVectorLayer::CheckBox, tr( "Checkbox" ) );
editTypeMap.insert( QgsVectorLayer::TextEdit, tr( "Text edit" ) );
}

QString QgsVectorLayerProperties::editTypeButtonText( QgsVectorLayer::EditType type )
Expand Down
33 changes: 17 additions & 16 deletions src/core/qgsvectorlayer.h
Expand Up @@ -55,12 +55,12 @@ typedef QSet<int> QgsAttributeIds;

class QgsLabelingEngineInterface
{
public:
virtual ~QgsLabelingEngineInterface() {}
virtual int prepareLayer(QgsVectorLayer* layer, int& attrIndex) = 0;
virtual void registerFeature(QgsVectorLayer* layer, QgsFeature& feat) = 0;
//void calculateLabeling() = 0;
//void drawLabeling(QgsRenderContext& context) = 0;
public:
virtual ~QgsLabelingEngineInterface() {}
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex ) = 0;
virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat ) = 0;
//void calculateLabeling() = 0;
//void drawLabeling(QgsRenderContext& context) = 0;
};


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

struct RangeData
Expand Down Expand Up @@ -176,15 +177,15 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer

/** Sets the renderer. If a renderer is already present, it is deleted */
void setRenderer( QgsRenderer * r );

/** Return renderer V2. Added in QGIS 1.4 */
QgsFeatureRendererV2* rendererV2();
/** Set renderer V2. Added in QGIS 1.4 */
void setRendererV2(QgsFeatureRendererV2* r);
void setRendererV2( QgsFeatureRendererV2* r );
/** Return whether using renderer V2. Added in QGIS 1.4 */
bool isUsingRendererV2();
/** set whether to use renderer V2 for drawing. Added in QGIS 1.4 */
void setUsingRendererV2(bool usingRendererV2);
void setUsingRendererV2( bool usingRendererV2 );

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

/** Assign a custom labeling engine with layer. Added in v1.4 */
void setLabelingEngine(QgsLabelingEngineInterface* engine);
void setLabelingEngine( QgsLabelingEngineInterface* engine );

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

/**set edit type*/
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 );

Expand Down Expand Up @@ -736,10 +737,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer

/** Renderer object which holds the information about how to display the features */
QgsRenderer *mRenderer;

/** Renderer V2 */
QgsFeatureRendererV2 *mRendererV2;

/** whether to use V1 or V2 renderer */
bool mUsingRendererV2;

Expand Down Expand Up @@ -769,7 +770,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
QMap< QString, EditType > mEditTypes;
QMap< QString, QMap<QString, QVariant> > mValueMaps;
QMap< QString, RangeData > mRanges;
QMap< QString, QPair<QString,QString> > mCheckedStates;
QMap< QString, QPair<QString, QString> > mCheckedStates;
QString mEditForm;

bool mFetching;
Expand Down
34 changes: 33 additions & 1 deletion src/ui/qgsattributetypeedit.ui
Expand Up @@ -66,6 +66,11 @@
<string>Checkbox</string>
</property>
</item>
<item>
<property name="text">
<string>Text edit</string>
</property>
</item>
</widget>
</item>
<item>
Expand All @@ -77,7 +82,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>9</number>
<number>0</number>
</property>
<widget class="QWidget" name="lineEditPage">
<layout class="QVBoxLayout" name="verticalLayout_1">
Expand Down Expand Up @@ -544,6 +549,33 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="textEditPage">
<layout class="QVBoxLayout" name="verticalLayout_25">
<item>
<widget class="QLabel" name="hiddenLabel_3">
<property name="text">
<string>A text edit field that accepts multiple lines will be used.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_17">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>302</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
Expand Down

0 comments on commit 907ff17

Please sign in to comment.