Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE]: layer can have abstracts and title (e.g. for the use in WM…
…S server)
  • Loading branch information
mhugent committed Dec 15, 2011
1 parent 5b6ed1e commit 3f7def9
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 63 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
57 changes: 41 additions & 16 deletions src/ui/qgsrasterlayerpropertiesbase.ui
Expand Up @@ -1724,11 +1724,35 @@
<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>
</widget>
</item>
<item row="4" column="0">
<widget class="QTextBrowser" name="txtbMetadata"/>
</item>
</layout>
Expand Down Expand Up @@ -1771,22 +1795,23 @@
<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; 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
121 changes: 74 additions & 47 deletions src/ui/qgsvectorlayerpropertiesbase.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>777</width>
<width>762</width>
<height>672</height>
</rect>
</property>
Expand All @@ -20,49 +20,7 @@
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pbnLoadDefaultStyle">
<property name="text">
<string>Restore Default Style</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnSaveDefaultStyle">
<property name="text">
<string>Save As Default</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnLoadStyle">
<property name="text">
<string>Load Style ...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnSaveStyleAs">
<property name="text">
<string>Save Style ...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
Expand Down Expand Up @@ -372,8 +330,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>755</width>
<height>542</height>
<width>340</width>
<height>445</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
Expand Down Expand Up @@ -590,8 +548,35 @@
<attribute name="title">
<string>Metadata</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<layout class="QGridLayout" name="gridLayout">
<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>
</widget>
</item>
<item row="4" column="0">
<widget class="QTextEdit" name="teMetadata">
<property name="lineWidth">
<number>2</number>
Expand Down Expand Up @@ -1197,6 +1182,48 @@
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pbnLoadDefaultStyle">
<property name="text">
<string>Restore Default Style</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnSaveDefaultStyle">
<property name="text">
<string>Save As Default</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnLoadStyle">
<property name="text">
<string>Load Style ...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnSaveStyleAs">
<property name="text">
<string>Save Style ...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
Expand Down

0 comments on commit 3f7def9

Please sign in to comment.