add support for multiline edit widget

git-svn-id: http://svn.osgeo.org/qgis/trunk@12165 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
jef 2009-11-17 18:47:47 +00:00
parent 5a43c276e3
commit a4758ff01f
6 changed files with 67 additions and 22 deletions

View File

@ -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 {

View File

@ -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 )
{
@ -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;
@ -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 );

View File

@ -249,6 +249,9 @@ void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editTy
setPage( 9 );
break;
case QgsVectorLayer::TextEdit:
setPage( 10 );
case QgsVectorLayer::LineEdit:
setPage( 0 );
break;
@ -459,6 +462,7 @@ void QgsAttributeTypeDialog::accept()
//store data to output variables
switch ( selectionComboBox->currentIndex() )
{
default:
case 0:
mEditType = QgsVectorLayer::LineEdit;
break;
@ -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();

View File

@ -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 )

View File

@ -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

View File

@ -66,6 +66,11 @@
<string>Checkbox</string>
</property>
</item>
<item>
<property name="text">
<string>Text edit</string>
</property>
</item>
</widget>
</item>
<item>
@ -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">
@ -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>