Skip to content

Commit 32648f6

Browse files
author
mhugent
committed
Support for long int in attribute dialog and editor. Fixes bug #2928
git-svn-id: http://svn.osgeo.org/qgis/trunk@14006 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b452bb8 commit 32648f6

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/app/qgsattributedialog.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
146146
{
147147
mypLabel->setText( myFieldName + tr( " (dbl)" ) );
148148
}
149+
else if ( myFieldType == QVariant::LongLong )
150+
{
151+
mypLabel->setText( myFieldName + tr( " (long)" ) );
152+
}
149153
else //string
150154
{
151155
//any special behaviour for string goes here

src/gui/qgsattributeeditor.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
354354
le->setCompleter( c );
355355
}
356356

357-
if ( myFieldType == QVariant::Int )
357+
if ( myFieldType == QVariant::Int || myFieldType == QVariant::LongLong )
358358
{
359359
le->setValidator( new QIntValidator( le ) );
360360
}
@@ -545,6 +545,20 @@ bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int
545545
}
546546
}
547547
break;
548+
case QVariant::LongLong:
549+
{
550+
bool ok;
551+
qlonglong myLongValue = text.toLong( &ok );
552+
if ( ok && !text.isEmpty() )
553+
{
554+
value = QVariant( myLongValue );
555+
modified = true;
556+
}
557+
else if ( modified )
558+
{
559+
value = QVariant( theField.type() );
560+
}
561+
}
548562
case QVariant::Double:
549563
{
550564
bool ok;
@@ -668,7 +682,7 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
668682

669683
QString text;
670684
if ( value.isNull() )
671-
if ( myFieldType == QVariant::Int || myFieldType == QVariant::Double )
685+
if ( myFieldType == QVariant::Int || myFieldType == QVariant::Double || myFieldType == QVariant::LongLong )
672686
text = "";
673687
else
674688
text = "NULL";

0 commit comments

Comments
 (0)