20 #include <QFileDialog> 31 mUseLink->setChecked(
false );
32 mFullUrl->setChecked(
false );
33 mDocumentViewerGroupBox->setChecked(
false );
40 connect( mRootPathButton, SIGNAL( clicked() ),
this, SLOT( chooseDefaultPath() ) );
43 connect( mRootPath, SIGNAL( textChanged(
const QString & ) ),
this, SLOT( enableRelativeDefault() ) );
46 connect( mRelativeGroupBox, SIGNAL( toggled(
bool ) ),
this, SLOT( enableRelative(
bool ) ) );
51 mStoreFilesButton->setChecked(
true );
56 mRelativeProject->setChecked(
true );
62 void QgsExternalResourceConfigDlg::chooseDefaultPath()
65 if ( !mRootPath->text().isEmpty() )
67 dir = mRootPath->text();
79 mRootPath->setText( rootName );
82 void QgsExternalResourceConfigDlg::enableRelativeDefault()
85 if ( mRelativeGroupBox->isChecked() )
86 mRelativeDefault->setEnabled( !mRootPath->text().isEmpty() );
89 if ( mRootPath->text().isEmpty() )
90 mRelativeProject->toggle();
93 void QgsExternalResourceConfigDlg::enableRelative(
bool state )
97 mRelativeProject->setEnabled(
true );
98 if ( mRootPath->text().isEmpty() )
99 mRelativeDefault->setEnabled(
false );
101 mRelativeDefault->setEnabled(
true );
105 mRelativeProject->setEnabled(
false );
106 mRelativeDefault->setEnabled(
false );
115 cfg.
insert(
"FileWidget", mFileWidgetGroupBox->isChecked() );
116 cfg.
insert(
"FileWidgetButton", mFileWidgetButtonGroupBox->isChecked() );
117 cfg.
insert(
"FileWidgetFilter", mFileWidgetFilterLineEdit->text() );
119 if ( mUseLink->isChecked() )
121 cfg.
insert(
"UseLink", mUseLink->isChecked() );
122 if ( mFullUrl->isChecked() )
123 cfg.
insert(
"FullUrl", mFullUrl->isChecked() );
126 if ( !mRootPath->text().isEmpty() )
128 cfg.
insert(
"DefaultRoot", mRootPath->text() );
132 cfg.
insert(
"StorageMode", mStorageButtonGroup->checkedId() );
135 if ( mRelativeGroupBox->isChecked() )
137 cfg.
insert(
"RelativeStorage", mRelativeButtonGroup->checkedId() );
144 if ( mDocumentViewerGroupBox->isChecked() )
146 cfg.
insert(
"DocumentViewer", mDocumentViewerContentComboBox->itemData( mDocumentViewerContentComboBox->currentIndex() ).toInt() );
147 cfg.
insert(
"DocumentViewerHeight", mDocumentViewerHeight->value() );
148 cfg.
insert(
"DocumentViewerWidth", mDocumentViewerWidth->value() );
161 if ( config.
contains(
"FileWidget" ) )
163 mFileWidgetGroupBox->setChecked( config.
value(
"FileWidget" ).toBool() );
165 if ( config.
contains(
"FileWidget" ) )
167 mFileWidgetButtonGroupBox->setChecked( config.
value(
"FileWidgetButton" ).toBool() );
169 if ( config.
contains(
"FileWidgetFilter" ) )
171 mFileWidgetFilterLineEdit->setText( config.
value(
"FileWidgetFilter" ).toString() );
176 mUseLink->setChecked( config.
value(
"UseLink" ).toBool() );
178 mFullUrl->setChecked(
true );
181 if ( config.
contains(
"DefaultRoot" ) )
183 mRootPath->setText( config.
value(
"DefaultRoot" ).toString() );
187 if ( config.
contains(
"RelativeStorage" ) )
189 int relative = config.
value(
"RelativeStorage" ).toInt();
192 mRelativeGroupBox->setChecked(
false );
196 mRelativeGroupBox->setChecked(
true );
197 mRelativeButtonGroup->button( relative )->setChecked(
true );
202 if ( config.
contains(
"StorageMode" ) )
204 int mode = config.
value(
"StorageMode" ).toInt();
205 mStorageButtonGroup->button( mode )->setChecked(
true );
209 if ( config.
contains(
"DocumentViewer" ) )
213 int idx = mDocumentViewerContentComboBox->findData( content );
216 mDocumentViewerContentComboBox->setCurrentIndex( idx );
218 if ( config.
contains(
"DocumentViewerHeight" ) )
220 mDocumentViewerHeight->setValue( config.
value(
"DocumentViewerHeight" ).toInt() );
222 if ( config.
contains(
"DocumentViewerWidth" ) )
224 mDocumentViewerWidth->setValue( config.
value(
"DocumentViewerWidth" ).toInt() );
QString toNativeSeparators(const QString &pathName)
QString getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, QFlags< QFileDialog::Option > options)
bool contains(const Key &key) const
void setConfig(const QgsEditorWidgetConfig &config) override
Update the configuration widget to represent the given configuration.
QgsEditorWidgetConfig config() override
Create a configuration from the current GUI state.
QString tr(const char *sourceText, const char *disambiguation, int n)
QString fileName() const
Returns file name.
QgsExternalResourceConfigDlg(QgsVectorLayer *vl, int fieldIdx, QWidget *parent=0)
QString cleanPath(const QString &path)
QVariant value(const QString &key, const QVariant &defaultValue) const
static QgsProject * instance()
access to canonical QgsProject instance
iterator insert(const Key &key, const T &value)
QFileInfo fileInfo() const
Returns QFileInfo object for the project's associated file.
QString absolutePath() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
const T value(const Key &key) const