Skip to content
Permalink
Browse files

External Resource widget multiple fixes (fix Redmine #14178)

  • Loading branch information
Médéric RIBREUX
Médéric RIBREUX committed Jan 27, 2016
1 parent c7204cc commit d6bd8d0c328a77196b8f71b14689ae17449c2a7b
@@ -165,7 +165,7 @@ void QgsExternalResourceConfigDlg::setConfig( const QgsEditorWidgetConfig& confi
}
if ( config.contains( "FileWidgetFilter" ) )
{
mFileWidgetFilterLineEdit->setText( config.value( "Filter" ).toString() );
mFileWidgetFilterLineEdit->setText( config.value( "FileWidgetFilter" ).toString() );
}

if ( config.contains( "UseLink" ) )
@@ -15,6 +15,7 @@
***************************************************************************/

#include "qgsexternalresourcewidgetfactory.h"
#include "qgsfilewidget.h"

QgsExternalResourceWidgetFactory::QgsExternalResourceWidgetFactory( const QString& name )
: QgsEditorWidgetFactory( name )
@@ -57,6 +58,12 @@ void QgsExternalResourceWidgetFactory::writeConfig( const QgsEditorWidgetConfig&
if ( config.contains( "DocumentViewer" ) )
configElement.setAttribute( "DocumentViewer", config.value( "DocumentViewer" ).toInt() );

if ( config.contains( "DocumentViewerWidth" ) )
configElement.setAttribute( "DocumentViewerWidth", config.value( "DocumentViewerWidth" ).toInt() );

if ( config.contains( "DocumentViewerHeight" ) )
configElement.setAttribute( "DocumentViewerHeight", config.value( "DocumentViewerHeight" ).toInt() );

if ( config.contains( "FileWidgetFilter" ) )
configElement.setAttribute( "FileWidgetFilter", config.value( "FileWidgetFilter" ).toString() );

@@ -87,14 +94,20 @@ QgsEditorWidgetConfig QgsExternalResourceWidgetFactory::readConfig( const QDomEl

if ( configElement.hasAttribute( "RelativeStorage" ) )
{
if (( configElement.attribute( "RelativeStorage" ) == "Default" && configElement.hasAttribute( "DefaultRoot" ) ) ||
configElement.attribute( "RelativeStorage" ) == "Project" )
cfg.insert( "RelativeStorage" , configElement.attribute( "RelativeStorage" ) );
if (( configElement.attribute( "RelativeStorage" ).toInt() == QgsFileWidget::RelativeStorage::RelativeDefaultPath && configElement.hasAttribute( "DefaultRoot" ) ) ||
configElement.attribute( "RelativeStorage" ).toInt() == QgsFileWidget::RelativeStorage::RelativeProject )
cfg.insert( "RelativeStorage" , configElement.attribute( "RelativeStorage" ).toInt() );
}

if ( configElement.hasAttribute( "DocumentViewer" ) )
cfg.insert( "DocumentViewer", configElement.attribute( "DocumentViewer" ) );

if ( configElement.hasAttribute( "DocumentViewerWidth" ) )
cfg.insert( "DocumentViewerWidth", configElement.attribute( "DocumentViewerWidth" ) );

if ( configElement.hasAttribute( "DocumentViewerHeight" ) )
cfg.insert( "DocumentViewerHeight", configElement.attribute( "DocumentViewerHeight" ) );

if ( configElement.hasAttribute( "FileWidgetFilter" ) )
cfg.insert( "FileWidgetFilter", configElement.attribute( "FileWidgetFilter" ) );

@@ -36,7 +36,7 @@ QVariant QgsExternalResourceWidgetWrapper::value() const
{
if ( mQgsWidget )
{
mQgsWidget->documentPath( field().type() );
return mQgsWidget->documentPath( field().type() );
}

if ( mLineEdit )
@@ -287,7 +287,7 @@ QString QgsFileWidget::toUrl( const QString& path ) const
QString rep;
if ( path.isEmpty() )
{
rep = QSettings().value( "qgis/nullValue", "NULL" ).toString();
return QSettings().value( "qgis/nullValue", "NULL" ).toString();
}

QString urlStr = relativePath( path, false );
@@ -251,7 +251,14 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mFileWidgetFilterLineEdit"/>
<widget class="QLineEdit" name="mFileWidgetFilterLineEdit">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Filter syntax is borrowed from Qt &lt;a href=&quot;http://doc.qt.io/qt-4.8/qfiledialog.html#getOpenFileName&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;QFileDialog::getOpenFileName&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Courier New,courier';&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;If you want simple filter on all pdf files, just use:&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Courier New,courier';&quot;&gt;*.pdf&lt;/span&gt;&lt;/p&gt;&lt;p&gt;If you want one filter for multiple file extensions (on .pdf, .odt and .doc files):&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Courier New,courier';&quot;&gt;*.pdf *.odt *.doc&lt;/span&gt;&lt;/p&gt;&lt;p&gt;If you want to describe your filter, use parentheses:&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Courier New,courier';&quot;&gt;Text documents (*.pdf, *.odt, *.doc)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;If you want multiple filters, separate them with ';;':&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Courier New,courier';&quot;&gt;&amp;quot;Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
@@ -343,7 +350,7 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="mRelativeButtonGroup"/>
<buttongroup name="mStorageButtonGroup"/>
<buttongroup name="mRelativeButtonGroup"/>
</buttongroups>
</ui>

0 comments on commit d6bd8d0

Please sign in to comment.
You can’t perform that action at this time.