mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Changes to support a comment for each attribute in vector data. Now
requires support in providers. Addresses ticket #244. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6612 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
879a45eab0
commit
9bbbd9787b
@ -523,6 +523,9 @@ QString QgsVectorLayerProperties::getMetadata()
|
||||
myMetadataQString += "<th bgcolor=\"black\">";
|
||||
myMetadataQString += "<font color=\"white\">" + tr("Precision") + "</font>";
|
||||
myMetadataQString += "</th>";
|
||||
myMetadataQString += "<th bgcolor=\"black\">";
|
||||
myMetadataQString += "<font color=\"white\">" + tr("Comment") + "</font>";
|
||||
myMetadataQString += "</th>";
|
||||
myMetadataQString += "<tr>";
|
||||
|
||||
//get info for each field by looping through them
|
||||
@ -543,6 +546,9 @@ QString QgsVectorLayerProperties::getMetadata()
|
||||
myMetadataQString += "</td>";
|
||||
myMetadataQString += "<td bgcolor=\"white\">";
|
||||
myMetadataQString += QString("%1").arg(myField.precision());
|
||||
myMetadataQString += "</td>";
|
||||
myMetadataQString += "<td bgcolor=\"white\">";
|
||||
myMetadataQString += QString("%1").arg(myField.comment());
|
||||
myMetadataQString += "</td></tr>";
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,10 @@ static const char * const ident_ =
|
||||
"$Id$";
|
||||
|
||||
|
||||
QgsField::QgsField(QString nam, QString typ, int len, int prec, bool num)
|
||||
:mName(nam), mType(typ), mLength(len), mPrecision(prec), mNumeric(num)
|
||||
QgsField::QgsField(QString nam, QString typ, int len, int prec, bool num,
|
||||
QString comment)
|
||||
:mName(nam), mType(typ), mLength(len), mPrecision(prec), mNumeric(num),
|
||||
mComment(comment)
|
||||
{
|
||||
// This function used to lower case the field name since some stores
|
||||
// use upper case (eg. shapefiles), but that caused problems with
|
||||
@ -75,6 +77,11 @@ bool QgsField::isNumeric() const
|
||||
return mNumeric;
|
||||
}
|
||||
|
||||
QString const & QgsField::comment() const
|
||||
{
|
||||
return mComment;
|
||||
}
|
||||
|
||||
void QgsField::setName(QString const & nam)
|
||||
{
|
||||
mName = nam;
|
||||
@ -96,3 +103,7 @@ void QgsField::setNumeric(bool num)
|
||||
{
|
||||
mNumeric = num;
|
||||
}
|
||||
void QgsField::setComment(QString comment)
|
||||
{
|
||||
mComment = comment;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
* used in conjunction with other fields types (eg. variable character fields)
|
||||
* @param num Has to be true if field contains numeric values.
|
||||
*/
|
||||
QgsField(QString nam = "", QString typ = "", int len = 0, int prec = 0, bool num = false);
|
||||
QgsField(QString nam = "", QString typ = "", int len = 0, int prec = 0, bool num = false, QString comment = "");
|
||||
|
||||
//! Destructor
|
||||
~QgsField();
|
||||
@ -80,6 +80,11 @@ public:
|
||||
bool isNumeric() const;
|
||||
|
||||
|
||||
/**
|
||||
Returns the field comment
|
||||
*/
|
||||
QString const & comment() const;
|
||||
|
||||
/**
|
||||
Set the field name.
|
||||
@param nam Name of the field
|
||||
@ -109,6 +114,11 @@ public:
|
||||
*/
|
||||
void setNumeric(bool num);
|
||||
|
||||
/**
|
||||
Set the field comment
|
||||
*/
|
||||
void setComment(QString comment);
|
||||
|
||||
private:
|
||||
|
||||
//! Name
|
||||
@ -126,6 +136,9 @@ private:
|
||||
//! Numeric
|
||||
bool mNumeric;
|
||||
|
||||
//! Comment
|
||||
QString mComment;
|
||||
|
||||
}; // class QgsField
|
||||
|
||||
#endif
|
||||
|
@ -181,6 +181,7 @@ QgsPostgresProvider::QgsPostgresProvider(QString const & uri)
|
||||
int fldtyp = PQftype(result, i);
|
||||
QString typOid = QString().setNum(fldtyp);
|
||||
int fieldModifier = PQfmod(result, i);
|
||||
QString fieldComment = "";
|
||||
|
||||
sql = "select typelem from pg_type where typelem = " + typOid + " and typlen = -1";
|
||||
// //--std::cout << sql << std::endl;
|
||||
@ -214,7 +215,7 @@ QgsPostgresProvider::QgsPostgresProvider(QString const & uri)
|
||||
|
||||
if(fieldName!=geometryColumn)
|
||||
{
|
||||
attributeFields.insert(i, QgsField(fieldName, fieldType, fieldSize.toInt(), fieldModifier));
|
||||
attributeFields.insert(i, QgsField(fieldName, fieldType, fieldSize.toInt(), fieldModifier, false, fieldComment));
|
||||
}
|
||||
}
|
||||
PQclear(result);
|
||||
|
Loading…
x
Reference in New Issue
Block a user