mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
rename QgsFilePickerWidget to QgsFileWidget
This commit is contained in:
parent
36157d43ac
commit
c063838f52
@ -73,7 +73,7 @@
|
|||||||
%Include qgsfieldproxymodel.sip
|
%Include qgsfieldproxymodel.sip
|
||||||
%Include qgsfieldvalidator.sip
|
%Include qgsfieldvalidator.sip
|
||||||
%Include qgsfiledropedit.sip
|
%Include qgsfiledropedit.sip
|
||||||
%Include qgsfilepickerwidget.sip
|
%Include qgsfilewidget.sip
|
||||||
%Include qgsfilterlineedit.sip
|
%Include qgsfilterlineedit.sip
|
||||||
%Include qgsformannotationitem.sip
|
%Include qgsformannotationitem.sip
|
||||||
%Include qgsgenericprojectionselector.sip
|
%Include qgsgenericprojectionselector.sip
|
||||||
|
@ -14,9 +14,12 @@ class QgsExternalResourceWidget : QWidget
|
|||||||
Web
|
Web
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit QgsExternalResourceWidget( QWidget* parent /TransferThis/ );
|
/**
|
||||||
|
* @brief QgsExternalResourceWidget creates a widget with a file widget and a document viewer
|
||||||
~QgsExternalResourceWidget();
|
* Both part of the widget are optional.
|
||||||
|
* @see QgsFileWidget
|
||||||
|
*/
|
||||||
|
explicit QgsExternalResourceWidget( QWidget *parent = 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief documentPath returns the path of the current document in the widget
|
* @brief documentPath returns the path of the current document in the widget
|
||||||
@ -25,30 +28,38 @@ class QgsExternalResourceWidget : QWidget
|
|||||||
QVariant documentPath( QVariant::Type type = QVariant::String ) const;
|
QVariant documentPath( QVariant::Type type = QVariant::String ) const;
|
||||||
void setDocumentPath( QVariant documentPath );
|
void setDocumentPath( QVariant documentPath );
|
||||||
|
|
||||||
//! access the file picker widget to allow its configuration
|
//! access the file widget to allow its configuration
|
||||||
QgsFilePickerWidget* filePickerwidget();
|
QgsFileWidget* fileWidget();
|
||||||
|
|
||||||
//! returns if the file picker is visible in the widget
|
//! returns if the file widget is visible in the widget
|
||||||
bool filePickerVisible() const;
|
bool fileWidgetVisible() const;
|
||||||
//! set the visiblity of the file picker in the widget
|
//! set the visiblity of the file widget in the layout
|
||||||
void setFilePickerVisible( bool visible );
|
void setFileWidgetVisible( bool visible );
|
||||||
|
|
||||||
//! returns the type of content used in the document viewer
|
//! returns the type of content used in the document viewer
|
||||||
QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
|
QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
|
||||||
//! setDocumentViewerContent defines the type of content to be shown. Widget will be adapated accordingly
|
//! setDocumentViewerContent defines the type of content to be shown. Widget will be adapated accordingly
|
||||||
void setDocumentViewerContent( QgsExternalResourceWidget::DocumentViewerContent content );
|
void setDocumentViewerContent( QgsExternalResourceWidget::DocumentViewerContent content );
|
||||||
|
|
||||||
//! set the configuration of the document viewer
|
//! returns the height of the document viewer
|
||||||
int documentViewerHeight() const;
|
int documentViewerHeight() const;
|
||||||
|
/**
|
||||||
|
* @brief setDocumentViewerWidth set the height of the document viewer.
|
||||||
|
* @param height the height. Use 0 for automatic best display.
|
||||||
|
*/
|
||||||
void setDocumentViewerHeight( int height );
|
void setDocumentViewerHeight( int height );
|
||||||
|
//! returns the width of the document viewer
|
||||||
int documentViewerWidth() const ;
|
int documentViewerWidth() const ;
|
||||||
|
/**
|
||||||
|
* @brief setDocumentViewerWidth set the width of the document viewer.
|
||||||
|
* @param width the width. Use 0 for automatic best display.
|
||||||
|
*/
|
||||||
void setDocumentViewerWidth( int width );
|
void setDocumentViewerWidth( int width );
|
||||||
|
|
||||||
//! defines if the widget is readonly
|
//! defines if the widget is readonly
|
||||||
void setReadOnly( bool readOnly );
|
void setReadOnly( bool readOnly );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
//! emitteed as soon as the current document changes
|
||||||
void valueChanged( QString );
|
void valueChanged( QString );
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
class QgsFilePickerWidget : QWidget
|
class QgsFileWidget : QWidget
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <qgsfilepickerwidget.h>
|
#include <qgsfilewidget.h>
|
||||||
%End
|
%End
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -20,9 +20,9 @@ class QgsFilePickerWidget : QWidget
|
|||||||
RelativeDefaultPath
|
RelativeDefaultPath
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit QgsFilePickerWidget( QWidget* parent /TransferThis/ );
|
explicit QgsFileWidget( QWidget* parent /TransferThis/ );
|
||||||
|
|
||||||
~QgsFilePickerWidget();
|
~QgsFileWidget();
|
||||||
|
|
||||||
//! Returns the current file path
|
//! Returns the current file path
|
||||||
QString filePath();
|
QString filePath();
|
||||||
@ -50,9 +50,9 @@ class QgsFilePickerWidget : QWidget
|
|||||||
void setFilter( const QString &filter );
|
void setFilter( const QString &filter );
|
||||||
|
|
||||||
//! determines if the tool button is shown
|
//! determines if the tool button is shown
|
||||||
bool filePickerButtonVisible() const;
|
bool fileWidgetButtonVisible() const;
|
||||||
//! determines if the tool button is shown
|
//! determines if the tool button is shown
|
||||||
void setFilePickerButtonVisible( bool visible );
|
void setFileWidgetButtonVisible( bool visible );
|
||||||
|
|
||||||
//! determines if the file path will be shown as a link
|
//! determines if the file path will be shown as a link
|
||||||
bool useLink() const;
|
bool useLink() const;
|
||||||
@ -68,12 +68,12 @@ class QgsFilePickerWidget : QWidget
|
|||||||
void setDefaultRoot( QString defaultRoot );
|
void setDefaultRoot( QString defaultRoot );
|
||||||
|
|
||||||
//! determines the storage mode (i.e. file or directory)
|
//! determines the storage mode (i.e. file or directory)
|
||||||
QgsFilePickerWidget::StorageMode storageMode() const;
|
QgsFileWidget::StorageMode storageMode() const;
|
||||||
void setStorageMode( QgsFilePickerWidget::StorageMode storageMode );
|
void setStorageMode( QgsFileWidget::StorageMode storageMode );
|
||||||
|
|
||||||
//! determines if the relative path is with respect to the project path or the default path
|
//! determines if the relative path is with respect to the project path or the default path
|
||||||
QgsFilePickerWidget::RelativeStorage relativeStorage() const;
|
QgsFileWidget::RelativeStorage relativeStorage() const;
|
||||||
void setRelativeStorage( QgsFilePickerWidget::RelativeStorage relativeStorage );
|
void setRelativeStorage( QgsFileWidget::RelativeStorage relativeStorage );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fileChanged( QString );
|
void fileChanged( QString );
|
@ -34,7 +34,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
|
|||||||
qgsexternalresourcewidgetplugin.cpp
|
qgsexternalresourcewidgetplugin.cpp
|
||||||
qgsfieldcomboboxplugin.cpp
|
qgsfieldcomboboxplugin.cpp
|
||||||
qgsfieldexpressionwidgetplugin.cpp
|
qgsfieldexpressionwidgetplugin.cpp
|
||||||
qgsfilepickerwidgetplugin.cpp
|
qgsfilewidgetplugin.cpp
|
||||||
qgsfilterlineeditplugin.cpp
|
qgsfilterlineeditplugin.cpp
|
||||||
qgsmaplayercomboboxplugin.cpp
|
qgsmaplayercomboboxplugin.cpp
|
||||||
qgsprojectionselectionwidgetplugin.cpp
|
qgsprojectionselectionwidgetplugin.cpp
|
||||||
@ -58,7 +58,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
|
|||||||
qgsexternalresourcewidgetplugin.h
|
qgsexternalresourcewidgetplugin.h
|
||||||
qgsfieldcomboboxplugin.h
|
qgsfieldcomboboxplugin.h
|
||||||
qgsfieldexpressionwidgetplugin.h
|
qgsfieldexpressionwidgetplugin.h
|
||||||
qgsfilepickerwidgetplugin.h
|
qgsfilewidgetplugin.h
|
||||||
qgsfilterlineeditplugin.h
|
qgsfilterlineeditplugin.h
|
||||||
qgsmaplayercomboboxplugin.h
|
qgsmaplayercomboboxplugin.h
|
||||||
qgsprojectionselectionwidgetplugin.h
|
qgsprojectionselectionwidgetplugin.h
|
||||||
@ -88,7 +88,7 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
|
|||||||
qgsexternalresourcewidgetplugin.h
|
qgsexternalresourcewidgetplugin.h
|
||||||
qgsfieldcomboboxplugin.h
|
qgsfieldcomboboxplugin.h
|
||||||
qgsfieldexpressionwidgetplugin.h
|
qgsfieldexpressionwidgetplugin.h
|
||||||
qgsfilepickerwidgetplugin.h
|
qgsfilewidgetplugin.h
|
||||||
qgsfilterlineeditplugin.h
|
qgsfilterlineeditplugin.h
|
||||||
qgsmaplayercomboboxplugin.h
|
qgsmaplayercomboboxplugin.h
|
||||||
qgsprojectionselectionwidgetplugin.h
|
qgsprojectionselectionwidgetplugin.h
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
qgsfilepickerwidgetplugin.cpp
|
qgsfilewidgetplugin.cpp
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
Date : 13.01.2016
|
Date : 13.01.2016
|
||||||
Copyright : (C) 2016 Denis Rouzaud
|
Copyright : (C) 2016 Denis Rouzaud
|
||||||
@ -14,52 +14,52 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "qgiscustomwidgets.h"
|
#include "qgiscustomwidgets.h"
|
||||||
#include "qgsfilepickerwidgetplugin.h"
|
#include "qgsfilewidgetplugin.h"
|
||||||
#include "qgsfilepickerwidget.h"
|
#include "qgsfilewidget.h"
|
||||||
|
|
||||||
|
|
||||||
QgsFilePickerWidgetPlugin::QgsFilePickerWidgetPlugin( QObject *parent )
|
QgsFileWidgetPlugin::QgsFileWidgetPlugin( QObject *parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, mInitialized( false )
|
, mInitialized( false )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsFilePickerWidgetPlugin::name() const
|
QString QgsFileWidgetPlugin::name() const
|
||||||
{
|
{
|
||||||
return "QgsFilePickerWidget";
|
return "QgsFileWidget";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsFilePickerWidgetPlugin::group() const
|
QString QgsFileWidgetPlugin::group() const
|
||||||
{
|
{
|
||||||
return QgisCustomWidgets::groupName();
|
return QgisCustomWidgets::groupName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsFilePickerWidgetPlugin::includeFile() const
|
QString QgsFileWidgetPlugin::includeFile() const
|
||||||
{
|
{
|
||||||
return "qgsfilepickerwidget.h";
|
return "qgsfilewidget.h";
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon QgsFilePickerWidgetPlugin::icon() const
|
QIcon QgsFileWidgetPlugin::icon() const
|
||||||
{
|
{
|
||||||
return QIcon( ":/images/icons/qgis-icon-60x60.png" );
|
return QIcon( ":/images/icons/qgis-icon-60x60.png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsFilePickerWidgetPlugin::isContainer() const
|
bool QgsFileWidgetPlugin::isContainer() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *QgsFilePickerWidgetPlugin::createWidget( QWidget *parent )
|
QWidget *QgsFileWidgetPlugin::createWidget( QWidget *parent )
|
||||||
{
|
{
|
||||||
return new QgsFilePickerWidget( parent );
|
return new QgsFileWidget( parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsFilePickerWidgetPlugin::isInitialized() const
|
bool QgsFileWidgetPlugin::isInitialized() const
|
||||||
{
|
{
|
||||||
return mInitialized;
|
return mInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidgetPlugin::initialize( QDesignerFormEditorInterface *core )
|
void QgsFileWidgetPlugin::initialize( QDesignerFormEditorInterface *core )
|
||||||
{
|
{
|
||||||
Q_UNUSED( core );
|
Q_UNUSED( core );
|
||||||
if ( mInitialized )
|
if ( mInitialized )
|
||||||
@ -68,20 +68,20 @@ void QgsFilePickerWidgetPlugin::initialize( QDesignerFormEditorInterface *core )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString QgsFilePickerWidgetPlugin::toolTip() const
|
QString QgsFileWidgetPlugin::toolTip() const
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsFilePickerWidgetPlugin::whatsThis() const
|
QString QgsFileWidgetPlugin::whatsThis() const
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsFilePickerWidgetPlugin::domXml() const
|
QString QgsFileWidgetPlugin::domXml() const
|
||||||
{
|
{
|
||||||
return QString( "<ui language=\"c++\">\n"
|
return QString( "<ui language=\"c++\">\n"
|
||||||
" <widget class=\"%1\" name=\"mQgsFilePickerWidget\">\n"
|
" <widget class=\"%1\" name=\"mQgsFileWidget\">\n"
|
||||||
" <property name=\"geometry\">\n"
|
" <property name=\"geometry\">\n"
|
||||||
" <rect>\n"
|
" <rect>\n"
|
||||||
" <x>0</x>\n"
|
" <x>0</x>\n"
|
@ -1,5 +1,5 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
qgsfilepickerwidgetplugin.h
|
qgsfilewidgetplugin.h
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
Date : 13.01.2016
|
Date : 13.01.2016
|
||||||
Copyright : (C) 2016 Denis Rouzaud
|
Copyright : (C) 2016 Denis Rouzaud
|
||||||
@ -13,8 +13,8 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef QGSFILEPICKERWIDGETPLUGIN_H
|
#ifndef QGSFILEWIDGETPLUGIN_H
|
||||||
#define QGSFILEPICKERWIDGETPLUGIN_H
|
#define QGSFILEWIDGETPLUGIN_H
|
||||||
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
@ -27,13 +27,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class CUSTOMWIDGETS_EXPORT QgsFilePickerWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface
|
class CUSTOMWIDGETS_EXPORT QgsFileWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES( QDesignerCustomWidgetInterface )
|
Q_INTERFACES( QDesignerCustomWidgetInterface )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QgsFilePickerWidgetPlugin( QObject *parent = 0 );
|
explicit QgsFileWidgetPlugin( QObject *parent = 0 );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mInitialized;
|
bool mInitialized;
|
||||||
@ -52,4 +52,4 @@ class CUSTOMWIDGETS_EXPORT QgsFilePickerWidgetPlugin : public QObject, public QD
|
|||||||
QString whatsThis() const override;
|
QString whatsThis() const override;
|
||||||
QString domXml() const override;
|
QString domXml() const override;
|
||||||
};
|
};
|
||||||
#endif // QGSFILEPICKERWIDGETPLUGIN_H
|
#endif // QGSFILEWIDGETPLUGIN_H
|
@ -198,7 +198,7 @@ SET(QGIS_GUI_SRCS
|
|||||||
qgsfieldproxymodel.cpp
|
qgsfieldproxymodel.cpp
|
||||||
qgsfieldvalidator.cpp
|
qgsfieldvalidator.cpp
|
||||||
qgsfiledropedit.cpp
|
qgsfiledropedit.cpp
|
||||||
qgsfilepickerwidget.cpp
|
qgsfilewidget.cpp
|
||||||
qgsfilterlineedit.cpp
|
qgsfilterlineedit.cpp
|
||||||
qgsformannotationitem.cpp
|
qgsformannotationitem.cpp
|
||||||
qgsgenericprojectionselector.cpp
|
qgsgenericprojectionselector.cpp
|
||||||
@ -338,7 +338,7 @@ SET(QGIS_GUI_MOC_HDRS
|
|||||||
qgsfieldproxymodel.h
|
qgsfieldproxymodel.h
|
||||||
qgsfieldvalidator.h
|
qgsfieldvalidator.h
|
||||||
qgsfiledropedit.h
|
qgsfiledropedit.h
|
||||||
qgsfilepickerwidget.h
|
qgsfilewidget.h
|
||||||
qgsfilterlineedit.h
|
qgsfilterlineedit.h
|
||||||
qgsformannotationitem.h
|
qgsformannotationitem.h
|
||||||
qgsgenericprojectionselector.h
|
qgsgenericprojectionselector.h
|
||||||
|
@ -43,13 +43,13 @@ QgsExternalResourceConfigDlg::QgsExternalResourceConfigDlg( QgsVectorLayer* vl,
|
|||||||
connect( mRelativeGroupBox, SIGNAL( toggled( bool ) ), this, SLOT( enableRelative( bool ) ) );
|
connect( mRelativeGroupBox, SIGNAL( toggled( bool ) ), this, SLOT( enableRelative( bool ) ) );
|
||||||
|
|
||||||
// set ids for StorageTypeButtons
|
// set ids for StorageTypeButtons
|
||||||
mStorageButtonGroup->setId( mStoreFilesButton, QgsFilePickerWidget::GetFile );
|
mStorageButtonGroup->setId( mStoreFilesButton, QgsFileWidget::GetFile );
|
||||||
mStorageButtonGroup->setId( mStoreDirsButton, QgsFilePickerWidget::GetDirectory );
|
mStorageButtonGroup->setId( mStoreDirsButton, QgsFileWidget::GetDirectory );
|
||||||
mStoreFilesButton->setChecked( true );
|
mStoreFilesButton->setChecked( true );
|
||||||
|
|
||||||
// set ids for RelativeButtons
|
// set ids for RelativeButtons
|
||||||
mRelativeButtonGroup->setId( mRelativeProject, QgsFilePickerWidget::RelativeProject );
|
mRelativeButtonGroup->setId( mRelativeProject, QgsFileWidget::RelativeProject );
|
||||||
mRelativeButtonGroup->setId( mRelativeDefault, QgsFilePickerWidget::RelativeDefaultPath );
|
mRelativeButtonGroup->setId( mRelativeDefault, QgsFileWidget::RelativeDefaultPath );
|
||||||
mRelativeProject->setChecked( true );
|
mRelativeProject->setChecked( true );
|
||||||
|
|
||||||
mDocumentViewerContentComboBox->addItem( tr( "Image" ), QgsExternalResourceWidget::Image );
|
mDocumentViewerContentComboBox->addItem( tr( "Image" ), QgsExternalResourceWidget::Image );
|
||||||
@ -109,9 +109,9 @@ QgsEditorWidgetConfig QgsExternalResourceConfigDlg::config()
|
|||||||
{
|
{
|
||||||
QgsEditorWidgetConfig cfg;
|
QgsEditorWidgetConfig cfg;
|
||||||
|
|
||||||
cfg.insert( "FilePicker", mFilePickerGroupBox->isChecked() );
|
cfg.insert( "FileWidget", mFileWidgetGroupBox->isChecked() );
|
||||||
cfg.insert( "FilePickerButton", mFilePickerButtonGroupBox->isChecked() );
|
cfg.insert( "FileWidgetButton", mFileWidgetButtonGroupBox->isChecked() );
|
||||||
cfg.insert( "FilePickerFilter", mFilePickerFilterLineEdit->text() );
|
cfg.insert( "FileWidgetFilter", mFileWidgetFilterLineEdit->text() );
|
||||||
|
|
||||||
if ( mUseLink->isChecked() )
|
if ( mUseLink->isChecked() )
|
||||||
{
|
{
|
||||||
@ -135,7 +135,7 @@ QgsEditorWidgetConfig QgsExternalResourceConfigDlg::config()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cfg.insert( "RelativeStorage", ( int )QgsFilePickerWidget::Absolute );
|
cfg.insert( "RelativeStorage", ( int )QgsFileWidget::Absolute );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mDocumentViewerGroupBox->isChecked() )
|
if ( mDocumentViewerGroupBox->isChecked() )
|
||||||
@ -155,17 +155,17 @@ QgsEditorWidgetConfig QgsExternalResourceConfigDlg::config()
|
|||||||
|
|
||||||
void QgsExternalResourceConfigDlg::setConfig( const QgsEditorWidgetConfig& config )
|
void QgsExternalResourceConfigDlg::setConfig( const QgsEditorWidgetConfig& config )
|
||||||
{
|
{
|
||||||
if ( config.contains( "FilePicker" ) )
|
if ( config.contains( "FileWidget" ) )
|
||||||
{
|
{
|
||||||
mFilePickerGroupBox->setChecked( config.value( "FilePicker" ).toBool() );
|
mFileWidgetGroupBox->setChecked( config.value( "FileWidget" ).toBool() );
|
||||||
}
|
}
|
||||||
if ( config.contains( "FilePicker" ) )
|
if ( config.contains( "FileWidget" ) )
|
||||||
{
|
{
|
||||||
mFilePickerButtonGroupBox->setChecked( config.value( "FilePickerButton" ).toBool() );
|
mFileWidgetButtonGroupBox->setChecked( config.value( "FileWidgetButton" ).toBool() );
|
||||||
}
|
}
|
||||||
if ( config.contains( "FilePickerFilter" ) )
|
if ( config.contains( "FileWidgetFilter" ) )
|
||||||
{
|
{
|
||||||
mFilePickerFilterLineEdit->setText( config.value( "Filter" ).toString() );
|
mFileWidgetFilterLineEdit->setText( config.value( "Filter" ).toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.contains( "UseLink" ) )
|
if ( config.contains( "UseLink" ) )
|
||||||
@ -184,7 +184,7 @@ void QgsExternalResourceConfigDlg::setConfig( const QgsEditorWidgetConfig& confi
|
|||||||
if ( config.contains( "RelativeStorage" ) )
|
if ( config.contains( "RelativeStorage" ) )
|
||||||
{
|
{
|
||||||
int relative = config.value( "RelativeStorage" ).toInt();
|
int relative = config.value( "RelativeStorage" ).toInt();
|
||||||
if (( QgsFilePickerWidget::RelativeStorage )relative == QgsFilePickerWidget::Absolute )
|
if (( QgsFileWidget::RelativeStorage )relative == QgsFileWidget::Absolute )
|
||||||
{
|
{
|
||||||
mRelativeGroupBox->setChecked( false );
|
mRelativeGroupBox->setChecked( false );
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ void QgsExternalResourceWidgetFactory::writeConfig( const QgsEditorWidgetConfig&
|
|||||||
Q_UNUSED( layer )
|
Q_UNUSED( layer )
|
||||||
Q_UNUSED( fieldIdx )
|
Q_UNUSED( fieldIdx )
|
||||||
|
|
||||||
configElement.setAttribute( "FilePicker", config.value( "FilePicker", true ).toBool() );
|
configElement.setAttribute( "FileWidget", config.value( "FileWidget", true ).toBool() );
|
||||||
configElement.setAttribute( "FilePickerButton", config.value( "FilePickerButton", true ).toBool() );
|
configElement.setAttribute( "FileWidgetButton", config.value( "FileWidgetButton", true ).toBool() );
|
||||||
|
|
||||||
|
|
||||||
// Non mandatory options are not saved into project file (to save some space).
|
// Non mandatory options are not saved into project file (to save some space).
|
||||||
@ -57,8 +57,8 @@ void QgsExternalResourceWidgetFactory::writeConfig( const QgsEditorWidgetConfig&
|
|||||||
if ( config.contains( "DocumentViewer" ) )
|
if ( config.contains( "DocumentViewer" ) )
|
||||||
configElement.setAttribute( "DocumentViewer", config.value( "DocumentViewer" ).toInt() );
|
configElement.setAttribute( "DocumentViewer", config.value( "DocumentViewer" ).toInt() );
|
||||||
|
|
||||||
if ( config.contains( "FilePickerFilter" ) )
|
if ( config.contains( "FileWidgetFilter" ) )
|
||||||
configElement.setAttribute( "FilePickerFilter", config.value( "FilePickerFilter" ).toString() );
|
configElement.setAttribute( "FileWidgetFilter", config.value( "FileWidgetFilter" ).toString() );
|
||||||
|
|
||||||
configElement.setAttribute( "StorageMode", config.value( "StorageMode" ).toString() );
|
configElement.setAttribute( "StorageMode", config.value( "StorageMode" ).toString() );
|
||||||
}
|
}
|
||||||
@ -70,11 +70,11 @@ QgsEditorWidgetConfig QgsExternalResourceWidgetFactory::readConfig( const QDomEl
|
|||||||
|
|
||||||
QgsEditorWidgetConfig cfg;
|
QgsEditorWidgetConfig cfg;
|
||||||
|
|
||||||
if ( configElement.hasAttribute( "FilePickerButton" ) )
|
if ( configElement.hasAttribute( "FileWidgetButton" ) )
|
||||||
cfg.insert( "FilePickerButton", configElement.attribute( "FilePickerButton" ) == "1" );
|
cfg.insert( "FileWidgetButton", configElement.attribute( "FileWidgetButton" ) == "1" );
|
||||||
|
|
||||||
if ( configElement.hasAttribute( "FilePicker" ) )
|
if ( configElement.hasAttribute( "FileWidget" ) )
|
||||||
cfg.insert( "FilePicker", configElement.attribute( "FilePicker" ) == "1" );
|
cfg.insert( "FileWidget", configElement.attribute( "FileWidget" ) == "1" );
|
||||||
|
|
||||||
if ( configElement.hasAttribute( "UseLink" ) )
|
if ( configElement.hasAttribute( "UseLink" ) )
|
||||||
cfg.insert( "UseLink", configElement.attribute( "UseLink" ) == "1" );
|
cfg.insert( "UseLink", configElement.attribute( "UseLink" ) == "1" );
|
||||||
@ -95,8 +95,8 @@ QgsEditorWidgetConfig QgsExternalResourceWidgetFactory::readConfig( const QDomEl
|
|||||||
if ( configElement.hasAttribute( "DocumentViewer" ) )
|
if ( configElement.hasAttribute( "DocumentViewer" ) )
|
||||||
cfg.insert( "DocumentViewer", configElement.attribute( "DocumentViewer" ) );
|
cfg.insert( "DocumentViewer", configElement.attribute( "DocumentViewer" ) );
|
||||||
|
|
||||||
if ( configElement.hasAttribute( "FilePickerFilter" ) )
|
if ( configElement.hasAttribute( "FileWidgetFilter" ) )
|
||||||
cfg.insert( "FilePickerFilter", configElement.attribute( "FilePickerFilter" ) );
|
cfg.insert( "FileWidgetFilter", configElement.attribute( "FileWidgetFilter" ) );
|
||||||
|
|
||||||
|
|
||||||
cfg.insert( "StorageMode", configElement.attribute( "StorageMode", "Files" ) );
|
cfg.insert( "StorageMode", configElement.attribute( "StorageMode", "Files" ) );
|
||||||
|
@ -82,42 +82,42 @@ void QgsExternalResourceWidgetWrapper::initWidget( QWidget* editor )
|
|||||||
|
|
||||||
if ( mQgsWidget )
|
if ( mQgsWidget )
|
||||||
{
|
{
|
||||||
mQgsWidget->filePickerwidget()->setStorageMode( QgsFilePickerWidget::GetFile );
|
mQgsWidget->fileWidget()->setStorageMode( QgsFileWidget::GetFile );
|
||||||
if ( config().contains( "UseLink" ) )
|
if ( config().contains( "UseLink" ) )
|
||||||
{
|
{
|
||||||
mQgsWidget->filePickerwidget()->setUseLink( config( "UseLink" ).toBool() );
|
mQgsWidget->fileWidget()->setUseLink( config( "UseLink" ).toBool() );
|
||||||
}
|
}
|
||||||
if ( config().contains( "FullUrl" ) )
|
if ( config().contains( "FullUrl" ) )
|
||||||
{
|
{
|
||||||
mQgsWidget->filePickerwidget()->setFullUrl( config( "FullUrl" ).toBool() );
|
mQgsWidget->fileWidget()->setFullUrl( config( "FullUrl" ).toBool() );
|
||||||
}
|
}
|
||||||
if ( config().contains( "DefaultRoot" ) )
|
if ( config().contains( "DefaultRoot" ) )
|
||||||
{
|
{
|
||||||
mQgsWidget->filePickerwidget()->setDefaultRoot( config( "DefaultRoot" ).toString() );
|
mQgsWidget->fileWidget()->setDefaultRoot( config( "DefaultRoot" ).toString() );
|
||||||
}
|
}
|
||||||
if ( config().contains( "StorageMode" ) )
|
if ( config().contains( "StorageMode" ) )
|
||||||
{
|
{
|
||||||
mQgsWidget->filePickerwidget()->setStorageMode(( QgsFilePickerWidget::StorageMode )config( "StorageMode" ).toInt() );
|
mQgsWidget->fileWidget()->setStorageMode(( QgsFileWidget::StorageMode )config( "StorageMode" ).toInt() );
|
||||||
}
|
}
|
||||||
if ( config().contains( "RelativeStorage" ) )
|
if ( config().contains( "RelativeStorage" ) )
|
||||||
{
|
{
|
||||||
mQgsWidget->filePickerwidget()->setRelativeStorage(( QgsFilePickerWidget::RelativeStorage )config( "RelativeStorage" ).toInt() );
|
mQgsWidget->fileWidget()->setRelativeStorage(( QgsFileWidget::RelativeStorage )config( "RelativeStorage" ).toInt() );
|
||||||
}
|
}
|
||||||
if ( config().contains( "FilePicker" ) )
|
if ( config().contains( "FileWidget" ) )
|
||||||
{
|
{
|
||||||
mQgsWidget->setFilePickerVisible( config( "FilePicker" ).toBool() );
|
mQgsWidget->setFileWidgetVisible( config( "FileWidget" ).toBool() );
|
||||||
}
|
}
|
||||||
if ( config().contains( "FilePickerButton" ) )
|
if ( config().contains( "FileWidgetButton" ) )
|
||||||
{
|
{
|
||||||
mQgsWidget->filePickerwidget()->setFilePickerButtonVisible( config( "FilePickerButton" ).toBool() );
|
mQgsWidget->fileWidget()->setFileWidgetButtonVisible( config( "FileWidgetButton" ).toBool() );
|
||||||
}
|
}
|
||||||
if ( config().contains( "DocumentViewer" ) )
|
if ( config().contains( "DocumentViewer" ) )
|
||||||
{
|
{
|
||||||
mQgsWidget->setDocumentViewerContent(( QgsExternalResourceWidget::DocumentViewerContent )config( "DocumentViewer" ).toInt() );
|
mQgsWidget->setDocumentViewerContent(( QgsExternalResourceWidget::DocumentViewerContent )config( "DocumentViewer" ).toInt() );
|
||||||
}
|
}
|
||||||
if ( config().contains( "FilePickerFilter" ) )
|
if ( config().contains( "FileWidgetFilter" ) )
|
||||||
{
|
{
|
||||||
mQgsWidget->filePickerwidget()->setFilter( config( "FilePickerFilter" ).toString() );
|
mQgsWidget->fileWidget()->setFilter( config( "FileWidgetFilter" ).toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
QgsExternalResourceWidget::QgsExternalResourceWidget( QWidget *parent )
|
QgsExternalResourceWidget::QgsExternalResourceWidget( QWidget *parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, mFilePickerVisible( true )
|
, mFileWidgetVisible( true )
|
||||||
, mDocumentViewerContent( NoContent )
|
, mDocumentViewerContent( NoContent )
|
||||||
, mDocumentViewerHeight( 0 )
|
, mDocumentViewerHeight( 0 )
|
||||||
, mDocumentViewerWidth( 0 )
|
, mDocumentViewerWidth( 0 )
|
||||||
@ -39,9 +39,9 @@ QgsExternalResourceWidget::QgsExternalResourceWidget( QWidget *parent )
|
|||||||
QGridLayout* layout = new QGridLayout();
|
QGridLayout* layout = new QGridLayout();
|
||||||
layout->setMargin( 0 );
|
layout->setMargin( 0 );
|
||||||
|
|
||||||
mFilePicker = new QgsFilePickerWidget( this );
|
mFileWidget = new QgsFileWidget( this );
|
||||||
layout->addWidget( mFilePicker, 0, 0 );
|
layout->addWidget( mFileWidget, 0, 0 );
|
||||||
mFilePicker->setVisible( mFilePickerVisible );
|
mFileWidget->setVisible( mFileWidgetVisible );
|
||||||
|
|
||||||
mPixmapLabel = new QgsPixmapLabel( this );
|
mPixmapLabel = new QgsPixmapLabel( this );
|
||||||
layout->addWidget( mPixmapLabel, 1, 0 );
|
layout->addWidget( mPixmapLabel, 1, 0 );
|
||||||
@ -55,12 +55,12 @@ QgsExternalResourceWidget::QgsExternalResourceWidget( QWidget *parent )
|
|||||||
|
|
||||||
setLayout( layout );
|
setLayout( layout );
|
||||||
|
|
||||||
connect( mFilePicker, SIGNAL( fileChanged( QString ) ), this, SLOT( loadDocument( QString ) ) );
|
connect( mFileWidget, SIGNAL( fileChanged( QString ) ), this, SLOT( loadDocument( QString ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QgsExternalResourceWidget::documentPath( QVariant::Type type ) const
|
QVariant QgsExternalResourceWidget::documentPath( QVariant::Type type ) const
|
||||||
{
|
{
|
||||||
QString path = mFilePicker->filePath();
|
QString path = mFileWidget->filePath();
|
||||||
if ( path.isEmpty() )
|
if ( path.isEmpty() )
|
||||||
{
|
{
|
||||||
return QVariant( type );
|
return QVariant( type );
|
||||||
@ -73,23 +73,23 @@ QVariant QgsExternalResourceWidget::documentPath( QVariant::Type type ) const
|
|||||||
|
|
||||||
void QgsExternalResourceWidget::setDocumentPath( QVariant path )
|
void QgsExternalResourceWidget::setDocumentPath( QVariant path )
|
||||||
{
|
{
|
||||||
mFilePicker->setFilePath( path.toString() );
|
mFileWidget->setFilePath( path.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsFilePickerWidget*QgsExternalResourceWidget::filePickerwidget()
|
QgsFileWidget*QgsExternalResourceWidget::fileWidget()
|
||||||
{
|
{
|
||||||
return mFilePicker;
|
return mFileWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsExternalResourceWidget::filePickerVisible() const
|
bool QgsExternalResourceWidget::fileWidgetVisible() const
|
||||||
{
|
{
|
||||||
return mFilePickerVisible;
|
return mFileWidgetVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsExternalResourceWidget::setFilePickerVisible( bool visible )
|
void QgsExternalResourceWidget::setFileWidgetVisible( bool visible )
|
||||||
{
|
{
|
||||||
mFilePickerVisible = visible;
|
mFileWidgetVisible = visible;
|
||||||
mFilePicker->setVisible( visible );
|
mFileWidget->setVisible( visible );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsExternalResourceWidget::DocumentViewerContent QgsExternalResourceWidget::documentViewerContent() const
|
QgsExternalResourceWidget::DocumentViewerContent QgsExternalResourceWidget::documentViewerContent() const
|
||||||
@ -127,7 +127,7 @@ void QgsExternalResourceWidget::setDocumentViewerWidth( int width )
|
|||||||
|
|
||||||
void QgsExternalResourceWidget::setReadOnly( bool readOnly )
|
void QgsExternalResourceWidget::setReadOnly( bool readOnly )
|
||||||
{
|
{
|
||||||
mFilePicker->setReadOnly( readOnly );
|
mFileWidget->setReadOnly( readOnly );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsExternalResourceWidget::updateDocumentViewer()
|
void QgsExternalResourceWidget::updateDocumentViewer()
|
||||||
|
@ -23,7 +23,7 @@ class QgsPixmapLabel;
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "qgsfilepickerwidget.h"
|
#include "qgsfilewidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ class GUI_EXPORT QgsExternalResourceWidget : public QWidget
|
|||||||
{
|
{
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( bool filePickerVisible READ filePickerVisible WRITE setFilePickerVisible )
|
Q_PROPERTY( bool fileWidgetVisible READ fileWidgetVisible WRITE setFileWidgetVisible )
|
||||||
Q_PROPERTY( DocumentViewerContent documentViewerContent READ documentViewerContent WRITE setDocumentViewerContent )
|
Q_PROPERTY( DocumentViewerContent documentViewerContent READ documentViewerContent WRITE setDocumentViewerContent )
|
||||||
Q_PROPERTY( int documentViewerHeight READ documentViewerHeight WRITE setDocumentViewerHeight )
|
Q_PROPERTY( int documentViewerHeight READ documentViewerHeight WRITE setDocumentViewerHeight )
|
||||||
Q_PROPERTY( int documentViewerWidth READ documentViewerWidth WRITE setDocumentViewerWidth )
|
Q_PROPERTY( int documentViewerWidth READ documentViewerWidth WRITE setDocumentViewerWidth )
|
||||||
@ -50,9 +50,9 @@ class GUI_EXPORT QgsExternalResourceWidget : public QWidget
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QgsExternalResourceWidget creates a widget with a file picker and a document viewer
|
* @brief QgsExternalResourceWidget creates a widget with a file widget and a document viewer
|
||||||
* Both part of the widget are optional.
|
* Both part of the widget are optional.
|
||||||
* @see QgsFilePickerwidget
|
* @see QgsFileWidget
|
||||||
*/
|
*/
|
||||||
explicit QgsExternalResourceWidget( QWidget *parent = 0 );
|
explicit QgsExternalResourceWidget( QWidget *parent = 0 );
|
||||||
|
|
||||||
@ -63,13 +63,13 @@ class GUI_EXPORT QgsExternalResourceWidget : public QWidget
|
|||||||
QVariant documentPath( QVariant::Type type = QVariant::String ) const;
|
QVariant documentPath( QVariant::Type type = QVariant::String ) const;
|
||||||
void setDocumentPath( QVariant documentPath );
|
void setDocumentPath( QVariant documentPath );
|
||||||
|
|
||||||
//! access the file picker widget to allow its configuration
|
//! access the file widget to allow its configuration
|
||||||
QgsFilePickerWidget* filePickerwidget();
|
QgsFileWidget* fileWidget();
|
||||||
|
|
||||||
//! returns if the file picker is visible in the widget
|
//! returns if the file widget is visible in the widget
|
||||||
bool filePickerVisible() const;
|
bool fileWidgetVisible() const;
|
||||||
//! set the visiblity of the file picker in the widget
|
//! set the visiblity of the file widget in the layout
|
||||||
void setFilePickerVisible( bool visible );
|
void setFileWidgetVisible( bool visible );
|
||||||
|
|
||||||
//! returns the type of content used in the document viewer
|
//! returns the type of content used in the document viewer
|
||||||
QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
|
QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
|
||||||
@ -105,13 +105,13 @@ class GUI_EXPORT QgsExternalResourceWidget : public QWidget
|
|||||||
void updateDocumentViewer();
|
void updateDocumentViewer();
|
||||||
|
|
||||||
//! properties
|
//! properties
|
||||||
bool mFilePickerVisible;
|
bool mFileWidgetVisible;
|
||||||
DocumentViewerContent mDocumentViewerContent;
|
DocumentViewerContent mDocumentViewerContent;
|
||||||
int mDocumentViewerHeight;
|
int mDocumentViewerHeight;
|
||||||
int mDocumentViewerWidth;
|
int mDocumentViewerWidth;
|
||||||
|
|
||||||
//! UI objects
|
//! UI objects
|
||||||
QgsFilePickerWidget* mFilePicker;
|
QgsFileWidget* mFileWidget;
|
||||||
QgsPixmapLabel* mPixmapLabel;
|
QgsPixmapLabel* mPixmapLabel;
|
||||||
#ifdef WITH_QTWEBKIT
|
#ifdef WITH_QTWEBKIT
|
||||||
//! This webview is used as a container to display the picture
|
//! This webview is used as a container to display the picture
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
qgsfilepickerwidget.cpp
|
qgsfilewidget.cpp
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
begin : 17.12.2015
|
begin : 17.12.2015
|
||||||
@ -14,7 +14,7 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "qgsfilepickerwidget.h"
|
#include "qgsfilewidget.h"
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
#include "qgslogger.h"
|
#include "qgslogger.h"
|
||||||
#include "qgsproject.h"
|
#include "qgsproject.h"
|
||||||
|
|
||||||
QgsFilePickerWidget::QgsFilePickerWidget( QWidget *parent )
|
QgsFileWidget::QgsFileWidget( QWidget *parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, mFilePath( QString() )
|
, mFilePath( QString() )
|
||||||
, mButtonVisible( true )
|
, mButtonVisible( true )
|
||||||
@ -62,24 +62,24 @@ QgsFilePickerWidget::QgsFilePickerWidget( QWidget *parent )
|
|||||||
connect( mLineEdit, SIGNAL( textEdited( QString ) ), this, SLOT( textEdited( QString ) ) );
|
connect( mLineEdit, SIGNAL( textEdited( QString ) ), this, SLOT( textEdited( QString ) ) );
|
||||||
layout->addWidget( mLineEdit, 1, 0 );
|
layout->addWidget( mLineEdit, 1, 0 );
|
||||||
|
|
||||||
mFilePickerButton = new QToolButton( this );
|
mFileWidgetButton = new QToolButton( this );
|
||||||
mFilePickerButton->setText( "..." );
|
mFileWidgetButton->setText( "..." );
|
||||||
connect( mFilePickerButton, SIGNAL( clicked() ), this, SLOT( openFileDialog() ) );
|
connect( mFileWidgetButton, SIGNAL( clicked() ), this, SLOT( openFileDialog() ) );
|
||||||
layout->addWidget( mFilePickerButton, 0, 1, 2, 1 );
|
layout->addWidget( mFileWidgetButton, 0, 1, 2, 1 );
|
||||||
|
|
||||||
setLayout( layout );
|
setLayout( layout );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsFilePickerWidget::~QgsFilePickerWidget()
|
QgsFileWidget::~QgsFileWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsFilePickerWidget::filePath()
|
QString QgsFileWidget::filePath()
|
||||||
{
|
{
|
||||||
return mFilePath;
|
return mFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setFilePath( QString path )
|
void QgsFileWidget::setFilePath( QString path )
|
||||||
{
|
{
|
||||||
if ( path == QSettings().value( "qgis/nullValue", "NULL" ) )
|
if ( path == QSettings().value( "qgis/nullValue", "NULL" ) )
|
||||||
{
|
{
|
||||||
@ -91,103 +91,103 @@ void QgsFilePickerWidget::setFilePath( QString path )
|
|||||||
emit fileChanged( mFilePath );
|
emit fileChanged( mFilePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setReadOnly( bool readOnly )
|
void QgsFileWidget::setReadOnly( bool readOnly )
|
||||||
{
|
{
|
||||||
mFilePickerButton->setEnabled( !readOnly );
|
mFileWidgetButton->setEnabled( !readOnly );
|
||||||
mLineEdit->setEnabled( !readOnly );
|
mLineEdit->setEnabled( !readOnly );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsFilePickerWidget::dialogTitle() const
|
QString QgsFileWidget::dialogTitle() const
|
||||||
{
|
{
|
||||||
return mDialogTitle;
|
return mDialogTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setDialogTitle( QString title )
|
void QgsFileWidget::setDialogTitle( QString title )
|
||||||
{
|
{
|
||||||
mDialogTitle = title;
|
mDialogTitle = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsFilePickerWidget::filter() const
|
QString QgsFileWidget::filter() const
|
||||||
{
|
{
|
||||||
return mFilter;
|
return mFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setFilter( const QString& filters )
|
void QgsFileWidget::setFilter( const QString& filters )
|
||||||
{
|
{
|
||||||
mFilter = filters;
|
mFilter = filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsFilePickerWidget::filePickerButtonVisible() const
|
bool QgsFileWidget::fileWidgetButtonVisible() const
|
||||||
{
|
{
|
||||||
return mButtonVisible;
|
return mButtonVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setFilePickerButtonVisible( bool visible )
|
void QgsFileWidget::setFileWidgetButtonVisible( bool visible )
|
||||||
{
|
{
|
||||||
mButtonVisible = visible;
|
mButtonVisible = visible;
|
||||||
mFilePickerButton->setVisible( visible );
|
mFileWidgetButton->setVisible( visible );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::textEdited( QString path )
|
void QgsFileWidget::textEdited( QString path )
|
||||||
{
|
{
|
||||||
mFilePath = path;
|
mFilePath = path;
|
||||||
mLinkLabel->setText( toUrl( path ) );
|
mLinkLabel->setText( toUrl( path ) );
|
||||||
emit fileChanged( mFilePath );
|
emit fileChanged( mFilePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsFilePickerWidget::useLink() const
|
bool QgsFileWidget::useLink() const
|
||||||
{
|
{
|
||||||
return mUseLink;
|
return mUseLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setUseLink( bool useLink )
|
void QgsFileWidget::setUseLink( bool useLink )
|
||||||
{
|
{
|
||||||
mUseLink = useLink;
|
mUseLink = useLink;
|
||||||
mLinkLabel->setVisible( mUseLink );
|
mLinkLabel->setVisible( mUseLink );
|
||||||
mLineEdit->setVisible( !mUseLink );
|
mLineEdit->setVisible( !mUseLink );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsFilePickerWidget::fullUrl() const
|
bool QgsFileWidget::fullUrl() const
|
||||||
{
|
{
|
||||||
return mFullUrl;
|
return mFullUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setFullUrl( bool fullUrl )
|
void QgsFileWidget::setFullUrl( bool fullUrl )
|
||||||
{
|
{
|
||||||
mFullUrl = fullUrl;
|
mFullUrl = fullUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsFilePickerWidget::defaultRoot() const
|
QString QgsFileWidget::defaultRoot() const
|
||||||
{
|
{
|
||||||
return mDefaultRoot;
|
return mDefaultRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setDefaultRoot( QString defaultRoot )
|
void QgsFileWidget::setDefaultRoot( QString defaultRoot )
|
||||||
{
|
{
|
||||||
mDefaultRoot = defaultRoot;
|
mDefaultRoot = defaultRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsFilePickerWidget::StorageMode QgsFilePickerWidget::storageMode() const
|
QgsFileWidget::StorageMode QgsFileWidget::storageMode() const
|
||||||
{
|
{
|
||||||
return mStorageMode;
|
return mStorageMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setStorageMode( QgsFilePickerWidget::StorageMode storageMode )
|
void QgsFileWidget::setStorageMode( QgsFileWidget::StorageMode storageMode )
|
||||||
{
|
{
|
||||||
mStorageMode = storageMode;
|
mStorageMode = storageMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsFilePickerWidget::RelativeStorage QgsFilePickerWidget::relativeStorage() const
|
QgsFileWidget::RelativeStorage QgsFileWidget::relativeStorage() const
|
||||||
{
|
{
|
||||||
return mRelativeStorage;
|
return mRelativeStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::setRelativeStorage( QgsFilePickerWidget::RelativeStorage relativeStorage )
|
void QgsFileWidget::setRelativeStorage( QgsFileWidget::RelativeStorage relativeStorage )
|
||||||
{
|
{
|
||||||
mRelativeStorage = relativeStorage;
|
mRelativeStorage = relativeStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsFilePickerWidget::openFileDialog()
|
void QgsFileWidget::openFileDialog()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString oldPath;
|
QString oldPath;
|
||||||
@ -253,7 +253,7 @@ void QgsFilePickerWidget::openFileDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString QgsFilePickerWidget::relativePath( QString filePath, bool removeRelative ) const
|
QString QgsFileWidget::relativePath( QString filePath, bool removeRelative ) const
|
||||||
{
|
{
|
||||||
QString RelativePath;
|
QString RelativePath;
|
||||||
if ( mRelativeStorage == RelativeProject )
|
if ( mRelativeStorage == RelativeProject )
|
||||||
@ -281,7 +281,7 @@ QString QgsFilePickerWidget::relativePath( QString filePath, bool removeRelative
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString QgsFilePickerWidget::toUrl( const QString& path ) const
|
QString QgsFileWidget::toUrl( const QString& path ) const
|
||||||
{
|
{
|
||||||
QString rep;
|
QString rep;
|
||||||
if ( path.isEmpty() )
|
if ( path.isEmpty() )
|
@ -1,5 +1,5 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
qgsfilepickerwidget.h
|
qgsfilewidget.h
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
begin : 17.12.2015
|
begin : 17.12.2015
|
||||||
@ -14,8 +14,8 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef QGSFILEPICKERWIDGET_H
|
#ifndef QGSFILEWIDGET_H
|
||||||
#define QGSFILEPICKERWIDGET_H
|
#define QGSFILEWIDGET_H
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
@ -26,12 +26,12 @@ class QgsFilterLineEdit;
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The QgsFilePickerWidget class creates a widget for selecting a file or a folder.
|
* @brief The QgsFileWidget class creates a widget for selecting a file or a folder.
|
||||||
*/
|
*/
|
||||||
class GUI_EXPORT QgsFilePickerWidget : public QWidget
|
class GUI_EXPORT QgsFileWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( bool filePickerButtonVisible READ filePickerButtonVisible WRITE setFilePickerButtonVisible )
|
Q_PROPERTY( bool fileWidgetButtonVisible READ fileWidgetButtonVisible WRITE setFileWidgetButtonVisible )
|
||||||
Q_PROPERTY( bool useLink READ useLink WRITE setUseLink )
|
Q_PROPERTY( bool useLink READ useLink WRITE setUseLink )
|
||||||
Q_PROPERTY( bool fullUrl READ fullUrl WRITE setFullUrl )
|
Q_PROPERTY( bool fullUrl READ fullUrl WRITE setFullUrl )
|
||||||
Q_PROPERTY( QString dialogTitle READ dialogTitle WRITE setDialogTitle )
|
Q_PROPERTY( QString dialogTitle READ dialogTitle WRITE setDialogTitle )
|
||||||
@ -61,11 +61,11 @@ class GUI_EXPORT QgsFilePickerWidget : public QWidget
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QgsFilePickerWidget creates a widget for selecting a file or a folder.
|
* @brief QgsFileWidget creates a widget for selecting a file or a folder.
|
||||||
*/
|
*/
|
||||||
explicit QgsFilePickerWidget( QWidget *parent = 0 );
|
explicit QgsFileWidget( QWidget *parent = 0 );
|
||||||
|
|
||||||
~QgsFilePickerWidget();
|
~QgsFileWidget();
|
||||||
|
|
||||||
//! Returns the current file path
|
//! Returns the current file path
|
||||||
QString filePath();
|
QString filePath();
|
||||||
@ -93,9 +93,9 @@ class GUI_EXPORT QgsFilePickerWidget : public QWidget
|
|||||||
void setFilter( const QString &filter );
|
void setFilter( const QString &filter );
|
||||||
|
|
||||||
//! determines if the tool button is shown
|
//! determines if the tool button is shown
|
||||||
bool filePickerButtonVisible() const;
|
bool fileWidgetButtonVisible() const;
|
||||||
//! determines if the tool button is shown
|
//! determines if the tool button is shown
|
||||||
void setFilePickerButtonVisible( bool visible );
|
void setFileWidgetButtonVisible( bool visible );
|
||||||
|
|
||||||
//! determines if the file path will be shown as a link
|
//! determines if the file path will be shown as a link
|
||||||
bool useLink() const;
|
bool useLink() const;
|
||||||
@ -113,14 +113,14 @@ class GUI_EXPORT QgsFilePickerWidget : public QWidget
|
|||||||
void setDefaultRoot( QString defaultRoot );
|
void setDefaultRoot( QString defaultRoot );
|
||||||
|
|
||||||
//! returns the storage mode (i.e. file or directory)
|
//! returns the storage mode (i.e. file or directory)
|
||||||
QgsFilePickerWidget::StorageMode storageMode() const;
|
QgsFileWidget::StorageMode storageMode() const;
|
||||||
//! determines the storage mode (i.e. file or directory)
|
//! determines the storage mode (i.e. file or directory)
|
||||||
void setStorageMode( QgsFilePickerWidget::StorageMode storageMode );
|
void setStorageMode( QgsFileWidget::StorageMode storageMode );
|
||||||
|
|
||||||
//! returns if the relative path is with respect to the project path or the default path
|
//! returns if the relative path is with respect to the project path or the default path
|
||||||
QgsFilePickerWidget::RelativeStorage relativeStorage() const;
|
QgsFileWidget::RelativeStorage relativeStorage() const;
|
||||||
//! determines if the relative path is with respect to the project path or the default path
|
//! determines if the relative path is with respect to the project path or the default path
|
||||||
void setRelativeStorage( QgsFilePickerWidget::RelativeStorage relativeStorage );
|
void setRelativeStorage( QgsFileWidget::RelativeStorage relativeStorage );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! emitted as soon as the current file or directory is changed
|
//! emitted as soon as the current file or directory is changed
|
||||||
@ -143,7 +143,7 @@ class GUI_EXPORT QgsFilePickerWidget : public QWidget
|
|||||||
|
|
||||||
QLabel* mLinkLabel;
|
QLabel* mLinkLabel;
|
||||||
QgsFilterLineEdit* mLineEdit;
|
QgsFilterLineEdit* mLineEdit;
|
||||||
QToolButton* mFilePickerButton;
|
QToolButton* mFileWidgetButton;
|
||||||
|
|
||||||
//! returns a HTML code with a link to the given file path
|
//! returns a HTML code with a link to the given file path
|
||||||
QString toUrl( const QString& path ) const;
|
QString toUrl( const QString& path ) const;
|
||||||
@ -151,7 +151,7 @@ class GUI_EXPORT QgsFilePickerWidget : public QWidget
|
|||||||
//! Returns a filePath with relative path options applied (or not) !
|
//! Returns a filePath with relative path options applied (or not) !
|
||||||
QString relativePath( QString filePath, bool removeRelative ) const;
|
QString relativePath( QString filePath, bool removeRelative ) const;
|
||||||
|
|
||||||
friend class TestQgsFilePickerWidget;
|
friend class TestQgsFileWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QGSFILEPICKERWIDGET_H
|
#endif // QGSFILEWIDGET_H
|
@ -192,7 +192,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="mFilePickerGroupBox">
|
<widget class="QGroupBox" name="mFileWidgetGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Display resource path</string>
|
<string>Display resource path</string>
|
||||||
</property>
|
</property>
|
||||||
@ -235,7 +235,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QGroupBox" name="mFilePickerButtonGroupBox">
|
<widget class="QGroupBox" name="mFileWidgetButtonGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Display button to open file dialog</string>
|
<string>Display button to open file dialog</string>
|
||||||
</property>
|
</property>
|
||||||
@ -251,7 +251,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="mFilePickerFilterLineEdit"/>
|
<widget class="QLineEdit" name="mFileWidgetFilterLineEdit"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -123,7 +123,7 @@ ADD_QGIS_TEST(zoomtest testqgsmaptoolzoom.cpp)
|
|||||||
#ADD_QGIS_TEST(histogramtest testqgsrasterhistogram.cpp)
|
#ADD_QGIS_TEST(histogramtest testqgsrasterhistogram.cpp)
|
||||||
ADD_QGIS_TEST(doublespinbox testqgsdoublespinbox.cpp)
|
ADD_QGIS_TEST(doublespinbox testqgsdoublespinbox.cpp)
|
||||||
ADD_QGIS_TEST(dualviewtest testqgsdualview.cpp )
|
ADD_QGIS_TEST(dualviewtest testqgsdualview.cpp )
|
||||||
ADD_QGIS_TEST(filepickerwidget testqgsfilepickerwidget.cpp )
|
ADD_QGIS_TEST(filewidget testqgsfilewidget.cpp )
|
||||||
ADD_QGIS_TEST(mapcanvastest testqgsmapcanvas.cpp )
|
ADD_QGIS_TEST(mapcanvastest testqgsmapcanvas.cpp )
|
||||||
ADD_QGIS_TEST(projectionissues testprojectionissues.cpp)
|
ADD_QGIS_TEST(projectionissues testprojectionissues.cpp)
|
||||||
ADD_QGIS_TEST(qgsguitest testqgsgui.cpp)
|
ADD_QGIS_TEST(qgsguitest testqgsgui.cpp)
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
#include "qgsfilepickerwidget.h"
|
#include "qgsfilewidget.h"
|
||||||
|
|
||||||
class TestQgsFilePickerWidget: public QObject
|
class TestQgsFileWidget: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private slots:
|
private slots:
|
||||||
@ -32,47 +32,47 @@ class TestQgsFilePickerWidget: public QObject
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TestQgsFilePickerWidget::initTestCase()
|
void TestQgsFileWidget::initTestCase()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsFilePickerWidget::cleanupTestCase()
|
void TestQgsFileWidget::cleanupTestCase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsFilePickerWidget::init()
|
void TestQgsFileWidget::init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsFilePickerWidget::cleanup()
|
void TestQgsFileWidget::cleanup()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsFilePickerWidget::relativePath()
|
void TestQgsFileWidget::relativePath()
|
||||||
{
|
{
|
||||||
QgsFilePickerWidget* w = new QgsFilePickerWidget();
|
QgsFileWidget* w = new QgsFileWidget();
|
||||||
w->setDefaultRoot( "/home/test" );
|
w->setDefaultRoot( "/home/test" );
|
||||||
w->setRelativeStorage( QgsFilePickerWidget::Absolute );
|
w->setRelativeStorage( QgsFileWidget::Absolute );
|
||||||
QCOMPARE( w->relativePath( "/home/test2/file1.ext", true ), QString( "/home/test2/file1.ext" ) );
|
QCOMPARE( w->relativePath( "/home/test2/file1.ext", true ), QString( "/home/test2/file1.ext" ) );
|
||||||
QCOMPARE( w->relativePath( "/home/test2/file2.ext", false ), QString( "/home/test2/file2.ext" ) );
|
QCOMPARE( w->relativePath( "/home/test2/file2.ext", false ), QString( "/home/test2/file2.ext" ) );
|
||||||
w->setRelativeStorage( QgsFilePickerWidget::RelativeDefaultPath );
|
w->setRelativeStorage( QgsFileWidget::RelativeDefaultPath );
|
||||||
QCOMPARE( w->relativePath( "/home/test2/file3.ext", true ), QString( "../test2/file3.ext" ) );
|
QCOMPARE( w->relativePath( "/home/test2/file3.ext", true ), QString( "../test2/file3.ext" ) );
|
||||||
QCOMPARE( w->relativePath( "../test2/file4.ext", true ), QString( "../test2/file4.ext" ) );
|
QCOMPARE( w->relativePath( "../test2/file4.ext", true ), QString( "../test2/file4.ext" ) );
|
||||||
QCOMPARE( w->relativePath( "/home/test2/file5.ext", false ), QString( "/home/test2/file5.ext" ) );
|
QCOMPARE( w->relativePath( "/home/test2/file5.ext", false ), QString( "/home/test2/file5.ext" ) );
|
||||||
QCOMPARE( w->relativePath( "../test2/file6.ext", false ), QString( "/home/test2/file6.ext" ) );
|
QCOMPARE( w->relativePath( "../test2/file6.ext", false ), QString( "/home/test2/file6.ext" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsFilePickerWidget::toUrl()
|
void TestQgsFileWidget::toUrl()
|
||||||
{
|
{
|
||||||
QgsFilePickerWidget* w = new QgsFilePickerWidget();
|
QgsFileWidget* w = new QgsFileWidget();
|
||||||
w->setDefaultRoot( "/home/test" );
|
w->setDefaultRoot( "/home/test" );
|
||||||
w->setRelativeStorage( QgsFilePickerWidget::Absolute );
|
w->setRelativeStorage( QgsFileWidget::Absolute );
|
||||||
w->setFullUrl( true );
|
w->setFullUrl( true );
|
||||||
QCOMPARE( w->toUrl( "/home/test2/file1.ext" ), QString( "<a href=\"file:///home/test2/file1.ext\">/home/test2/file1.ext</a>" ) );
|
QCOMPARE( w->toUrl( "/home/test2/file1.ext" ), QString( "<a href=\"file:///home/test2/file1.ext\">/home/test2/file1.ext</a>" ) );
|
||||||
w->setFullUrl( false );
|
w->setFullUrl( false );
|
||||||
QCOMPARE( w->toUrl( "/home/test2/file2.ext" ), QString( "<a href=\"file:///home/test2/file2.ext\">file2.ext</a>" ) );
|
QCOMPARE( w->toUrl( "/home/test2/file2.ext" ), QString( "<a href=\"file:///home/test2/file2.ext\">file2.ext</a>" ) );
|
||||||
w->setRelativeStorage( QgsFilePickerWidget::RelativeDefaultPath );
|
w->setRelativeStorage( QgsFileWidget::RelativeDefaultPath );
|
||||||
w->setFullUrl( true );
|
w->setFullUrl( true );
|
||||||
QCOMPARE( w->toUrl( "/home/test2/file3.ext" ), QString( "<a href=\"file:///home/test2/file3.ext\">/home/test2/file3.ext</a>" ) );
|
QCOMPARE( w->toUrl( "/home/test2/file3.ext" ), QString( "<a href=\"file:///home/test2/file3.ext\">/home/test2/file3.ext</a>" ) );
|
||||||
QCOMPARE( w->toUrl( "../test2/file4.ext" ), QString( "<a href=\"file:///home/test2/file4.ext\">../test2/file4.ext</a>" ) );
|
QCOMPARE( w->toUrl( "../test2/file4.ext" ), QString( "<a href=\"file:///home/test2/file4.ext\">../test2/file4.ext</a>" ) );
|
||||||
@ -83,5 +83,5 @@ void TestQgsFilePickerWidget::toUrl()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
QTEST_MAIN( TestQgsFilePickerWidget )
|
QTEST_MAIN( TestQgsFileWidget )
|
||||||
#include "testqgsfilepickerwidget.moc"
|
#include "testqgsfilewidget.moc"
|
Loading…
x
Reference in New Issue
Block a user