Skip to content

Commit

Permalink
Merge pull request #2726 from medspx/bugfix_external_resource
Browse files Browse the repository at this point in the history
External Resource widget multiple fixes (fix Redmine #14178)
  • Loading branch information
3nids committed Jan 27, 2016
2 parents cce4b2d + d6bd8d0 commit ae3cfd4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsexternalresourceconfigdlg.cpp
Expand Up @@ -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" ) )
Expand Down
19 changes: 16 additions & 3 deletions src/gui/editorwidgets/qgsexternalresourcewidgetfactory.cpp
Expand Up @@ -15,6 +15,7 @@
***************************************************************************/

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

QgsExternalResourceWidgetFactory::QgsExternalResourceWidgetFactory( const QString& name )
: QgsEditorWidgetFactory( name )
Expand Down Expand Up @@ -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() );

Expand Down Expand Up @@ -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" ) );

Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp
Expand Up @@ -36,7 +36,7 @@ QVariant QgsExternalResourceWidgetWrapper::value() const
{
if ( mQgsWidget )
{
mQgsWidget->documentPath( field().type() );
return mQgsWidget->documentPath( field().type() );
}

if ( mLineEdit )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsfilewidget.cpp
Expand Up @@ -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 );
Expand Down
11 changes: 9 additions & 2 deletions src/ui/editorwidgets/qgsexternalresourceconfigdlg.ui
Expand Up @@ -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>
Expand Down Expand Up @@ -343,7 +350,7 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="mRelativeButtonGroup"/>
<buttongroup name="mStorageButtonGroup"/>
<buttongroup name="mRelativeButtonGroup"/>
</buttongroups>
</ui>

0 comments on commit ae3cfd4

Please sign in to comment.