Skip to content

Commit

Permalink
Merge branch 'wms_layer_title_abstract'
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Dec 16, 2011
2 parents c336eca + dcae360 commit 88c9d5b
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 81 deletions.
6 changes: 6 additions & 0 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -860,6 +860,9 @@ void QgsRasterLayerProperties::sync()
txtbMetadata->document()->setDefaultStyleSheet( myStyle );
txtbMetadata->setHtml( mRasterLayer->metadata() );

mLayerTitleLineEdit->setText( mRasterLayer->title() );
mLayerAbstractTextEdit->setPlainText( mRasterLayer->abstract() );

} // QgsRasterLayerProperties::sync()

void QgsRasterLayerProperties::syncColormapTab()
Expand Down Expand Up @@ -1442,6 +1445,9 @@ void QgsRasterLayerProperties::apply()
mRasterLayer->thumbnailAsPixmap( &myQPixmap );
pixmapThumbnail->setPixmap( myQPixmap );

mRasterLayer->setTitle( mLayerTitleLineEdit->text() );
mRasterLayer->setAbstract( mLayerAbstractTextEdit->toPlainText() );

// update symbology
emit refreshLegend( mRasterLayer->id(), false );

Expand Down
11 changes: 11 additions & 0 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -178,6 +178,13 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
mOverlayDialogs.push_back( d );
}

//layer title and abstract
if ( layer )
{
mLayerTitleLineEdit->setText( layer->title() );
mLayerAbstractTextEdit->setPlainText( layer->abstract() );
}

tabWidget->setCurrentIndex( 0 );

QSettings settings;
Expand Down Expand Up @@ -815,6 +822,10 @@ void QgsVectorLayerProperties::apply()
( *it )->apply();
}

//layer title and abstract
layer->setTitle( mLayerTitleLineEdit->text() );
layer->setAbstract( mLayerAbstractTextEdit->toPlainText() );

// update symbology
emit refreshLegend( layer->id(), false );

Expand Down
26 changes: 26 additions & 0 deletions src/core/qgsmaplayer.cpp
Expand Up @@ -255,6 +255,20 @@ bool QgsMapLayer::readXML( const QDomNode& layer_node )
mne = mnl.toElement();
setLayerName( mne.text() );

//title
QDomElement titleElem = layer_node.firstChildElement( "title" );
if ( !titleElem.isNull() )
{
mTitle = titleElem.text();
}

//abstract
QDomElement abstractElem = layer_node.firstChildElement( "abstract" );
if ( !abstractElem.isNull() )
{
mAbstract = abstractElem.text();
}

//read transparency level
QDomNode transparencyNode = layer_node.namedItem( "transparencyLevelInt" );
if ( ! transparencyNode.isNull() )
Expand Down Expand Up @@ -340,7 +354,19 @@ bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )
QDomText layerNameText = document.createTextNode( name() );
layerName.appendChild( layerNameText );

// layer title
QDomElement layerTitle = document.createElement( "title" ) ;
QDomText layerTitleText = document.createTextNode( title() );
layerTitle.appendChild( layerTitleText );

// layer abstract
QDomElement layerAbstract = document.createElement( "abstract" );
QDomText layerAbstractText = document.createTextNode( abstract() );
layerAbstract.appendChild( layerAbstractText );

maplayer.appendChild( layerName );
maplayer.appendChild( layerTitle );
maplayer.appendChild( layerAbstract );

// timestamp if supported
if ( timestamp() > QDateTime() )
Expand Down
11 changes: 11 additions & 0 deletions src/core/qgsmaplayer.h
Expand Up @@ -87,6 +87,12 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
QString const & name() const;

void setTitle( const QString& title ) { mTitle = title; }
const QString& title() const { return mTitle; }

void setAbstract( const QString& abstract ) { mAbstract = abstract; }
const QString& abstract() const { return mAbstract; }

/**Synchronises with changes in the datasource
@note added in version 1.6*/
virtual void reload() {}
Expand Down Expand Up @@ -415,6 +421,11 @@ class CORE_EXPORT QgsMapLayer : public QObject
/** layer's Spatial reference system */
QgsCoordinateReferenceSystem* mCRS;

QString mTitle;

/**Description of the layer*/
QString mAbstract;

private:

/** private copy constructor - QgsMapLayer not copyable */
Expand Down
22 changes: 6 additions & 16 deletions src/mapserver/qgsconfigparser.cpp
Expand Up @@ -363,44 +363,34 @@ void QgsConfigParser::appendCRSElementsToLayer( QDomElement& layerElement, QDomD

//insert the CRS elements after the title element to be in accordance with the WMS 1.3 specification
QDomElement titleElement = layerElement.firstChildElement( "Title" );
QDomElement abstractElement = layerElement.firstChildElement( "Abstract" );
QDomElement CRSPrecedingElement = abstractElement.isNull() ? titleElement : abstractElement; //last element before the CRS elements

//In case the number of advertised CRS is constrained
QStringList constrainedCrsList = supportedOutputCrsList();
if ( constrainedCrsList.size() > 0 )
{
for ( int i = constrainedCrsList.size() - 1; i >= 0; --i )
{
appendCRSElementToLayer( layerElement, titleElement, constrainedCrsList.at( i ), doc );
#if 0
QDomElement crsElement = doc.createElement( "CRS" );
QDomText crsText = doc.createTextNode( constrainedCrsList.at( i ) );
crsElement.appendChild( crsText );
layerElement.insertAfter( crsElement, titleElement );
#endif
appendCRSElementToLayer( layerElement, CRSPrecedingElement, constrainedCrsList.at( i ), doc );
}
}
else //no crs constraint
{
foreach( QString crs, crsList )
{
appendCRSElementToLayer( layerElement, titleElement, crs, doc );
#if 0
QDomElement crsElement = doc.createElement( "CRS" );
QDomText crsText = doc.createTextNode( *crsIt );
crsElement.appendChild( crsText );
layerElement.insertAfter( crsElement, titleElement );
#endif
appendCRSElementToLayer( layerElement, CRSPrecedingElement, crs, doc );
}
}
}

void QgsConfigParser::appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& titleElement, const QString& crsText, QDomDocument& doc ) const
void QgsConfigParser::appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& precedingElement, const QString& crsText, QDomDocument& doc ) const
{
QString version = doc.documentElement().attribute( "version" );
QDomElement crsElement = doc.createElement( version == "1.1.1" ? "SRS" : "CRS" );
QDomText crsTextNode = doc.createTextNode( crsText );
crsElement.appendChild( crsTextNode );
layerElement.insertAfter( crsElement, titleElement );
layerElement.insertAfter( crsElement, precedingElement );
}

QgsComposition* QgsConfigParser::createPrintComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, const QMap< QString, QString >& parameterMap ) const
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgsconfigparser.h
Expand Up @@ -170,7 +170,7 @@ class QgsConfigParser
@return true in case of success*/
bool crsSetForLayer( const QDomElement& layerElement, QSet<QString> &crsSet ) const;
void appendCRSElementsToLayer( QDomElement& layerElement, QDomDocument& doc, const QStringList &crsList ) const;
void appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& titleElement, const QString& crsText, QDomDocument& doc ) const;
void appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& precedingElement, const QString& crsText, QDomDocument& doc ) const;

void setDefaultLegendSettings();
};
Expand Down
16 changes: 15 additions & 1 deletion src/mapserver/qgsprojectparser.cpp
Expand Up @@ -239,10 +239,24 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
layerElem.appendChild( nameElem );

QDomElement titleElem = doc.createElement( "Title" );
QDomText titleText = doc.createTextNode( currentLayer->name() );
QString titleName = currentLayer->title();
if ( titleName.isEmpty() )
{
titleName = currentLayer->name();
}
QDomText titleText = doc.createTextNode( titleName );
titleElem.appendChild( titleText );
layerElem.appendChild( titleElem );

QString abstract = currentLayer->abstract();
if ( !abstract.isEmpty() )
{
QDomElement abstractElem = doc.createElement( "Abstract" );
QDomText abstractText = doc.createTextNode( abstract );
abstractElem.appendChild( abstractText );
layerElem.appendChild( abstractElem );
}

//CRS
QStringList crsList = createCRSListForLayer( currentLayer );
appendCRSElementsToLayer( layerElem, doc, crsList );
Expand Down
64 changes: 48 additions & 16 deletions src/ui/qgsrasterlayerpropertiesbase.ui
Expand Up @@ -1724,11 +1724,41 @@
<attribute name="title">
<string>Metadata</string>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="mLayerTitleLabel">
<property name="text">
<string>Title</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="mLayerTitleLineEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mLayerAbstractLabel">
<property name="text">
<string>Abstract</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QTextEdit" name="mLayerAbstractTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QTextBrowser" name="txtbMetadata"/>
</item>
</layout>
Expand Down Expand Up @@ -1771,22 +1801,24 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;table border=&quot;0&quot; style=&quot;-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;&quot;&gt;
&lt;tr&gt;
&lt;td style=&quot;border: none;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 88c9d5b

Please sign in to comment.