mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Provide for a layer comment to be made available for vector layers
For postgres provider, get the layer comment from the table comment (if it exists). Resolves ticket #244 git-svn-id: http://svn.osgeo.org/qgis/trunk@6726 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
6622153f76
commit
617ee8c06a
@ -380,6 +380,15 @@ QString QgsVectorLayerProperties::getMetadata()
|
||||
myMetadataQString += tr("General:");
|
||||
myMetadataQString += "</td></tr>";
|
||||
|
||||
// data comment
|
||||
if (!(layer->dataComment().isEmpty()))
|
||||
{
|
||||
myMetadataQString += "<tr><td bgcolor=\"white\">";
|
||||
myMetadataQString += tr("Layer comment: ") +
|
||||
layer->dataComment();
|
||||
myMetadataQString += "</td></tr>";
|
||||
}
|
||||
|
||||
//storage type
|
||||
myMetadataQString += "<tr><td bgcolor=\"white\">";
|
||||
myMetadataQString += tr("Storage type of this layer : ") +
|
||||
|
@ -59,6 +59,10 @@ void QgsVectorDataProvider::getFeatureGeometry(int key, QgsFeature *f)
|
||||
{
|
||||
}
|
||||
|
||||
QString QgsVectorDataProvider::dataComment() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QgsVectorDataProvider::addFeatures(QgsFeatureList & flist)
|
||||
{
|
||||
|
@ -155,6 +155,12 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
|
||||
*/
|
||||
virtual const QgsFieldMap & fields() const = 0;
|
||||
|
||||
/**
|
||||
* Return a short comment for the data that this provider is
|
||||
* providing access to (e.g. the comment for postgres table).
|
||||
*/
|
||||
virtual QString dataComment() const;
|
||||
|
||||
/**
|
||||
* Reset the layer to clear any spatial filtering or other contstraints that
|
||||
* would prevent the entire record set from being traversed by call to
|
||||
|
@ -165,6 +165,15 @@ QString QgsVectorLayer::capabilitiesString() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString QgsVectorLayer::dataComment() const
|
||||
{
|
||||
if (mDataProvider)
|
||||
{
|
||||
return mDataProvider->dataComment();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
QString QgsVectorLayer::providerType() const
|
||||
{
|
||||
|
@ -82,6 +82,9 @@ public:
|
||||
/** Capabilities for this layer in a friendly format. */
|
||||
QString capabilitiesString() const;
|
||||
|
||||
/** Returns a comment for the data in the layer */
|
||||
QString dataComment() const;
|
||||
|
||||
/** Set the primary display field to be used in the identify results dialog */
|
||||
void setDisplayField(QString fldName=0);
|
||||
|
||||
|
@ -176,17 +176,13 @@ QgsPostgresProvider::QgsPostgresProvider(QString const & uri)
|
||||
QString tableoid = PQgetvalue(tresult, 0, 0);
|
||||
PQclear(tresult);
|
||||
|
||||
/* Code to extrac the table description. Needs a way to make is accesssible
|
||||
to the rest of qgis...
|
||||
|
||||
// Get the table description
|
||||
sql = "SELECT description FROM pg_description WHERE "
|
||||
"classoid = " + tableoid + " AND objsubid = 0";
|
||||
"objoid = " + tableoid + " AND objsubid = 0";
|
||||
tresult = PQexec(pd, (const char*) sql.utf8());
|
||||
if (PQntuples(tresult) > 0)
|
||||
mDescription = PQgetvalue(tresult, 0, 0);
|
||||
mDataComment = PQgetvalue(tresult, 0, 0);
|
||||
PQclear(tresult);
|
||||
*/
|
||||
|
||||
// Populate the field vector for this layer. The field vector contains
|
||||
// field name, type, length, and precision (if numeric)
|
||||
@ -685,6 +681,11 @@ const QgsFieldMap & QgsPostgresProvider::fields() const
|
||||
return attributeFields;
|
||||
}
|
||||
|
||||
QString QgsPostgresProvider::dataComment() const
|
||||
{
|
||||
return mDataComment;
|
||||
}
|
||||
|
||||
void QgsPostgresProvider::reset()
|
||||
{
|
||||
// reset the cursor to the first record
|
||||
|
@ -185,6 +185,12 @@ class QgsPostgresProvider:public QgsVectorDataProvider
|
||||
*/
|
||||
const QgsFieldMap & fields() const;
|
||||
|
||||
/**
|
||||
* Return a short comment for the data that this provider is
|
||||
* providing access to (e.g. the comment for postgres table).
|
||||
*/
|
||||
QString dataComment() const;
|
||||
|
||||
/** Reset the layer - for a PostgreSQL layer, this means clearing the PQresult
|
||||
* pointer and setting it to 0
|
||||
*/
|
||||
@ -335,6 +341,7 @@ class QgsPostgresProvider:public QgsVectorDataProvider
|
||||
std::vector < QgsFeature > features;
|
||||
QgsFieldMap attributeFields;
|
||||
std::map < int, int > attributeFieldsIdMap;
|
||||
QString mDataComment;
|
||||
|
||||
//! Data source URI struct for this layer
|
||||
QgsDataSourceURI mUri;
|
||||
|
Loading…
x
Reference in New Issue
Block a user