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 connect( mFileWidgetGroupBox, SIGNAL( toggled(
bool ) ),
this, SIGNAL(
changed() ) );
63 connect( mFileWidgetButtonGroupBox, SIGNAL( toggled(
bool ) ),
this, SIGNAL(
changed() ) );
65 connect( mUseLink, SIGNAL( toggled(
bool ) ),
this, SIGNAL(
changed() ) );
66 connect( mFullUrl, SIGNAL( toggled(
bool ) ),
this, SIGNAL(
changed() ) );
68 connect( mStorageButtonGroup, SIGNAL( buttonClicked(
int ) ),
this, SIGNAL(
changed() ) );
69 connect( mRelativeGroupBox, SIGNAL( toggled(
bool ) ),
this, SIGNAL(
changed() ) );
70 connect( mDocumentViewerGroupBox, SIGNAL( toggled(
bool ) ),
this, SIGNAL(
changed() ) );
71 connect( mDocumentViewerContentComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SIGNAL(
changed() ) );
76 void QgsExternalResourceConfigDlg::chooseDefaultPath()
79 if ( !mRootPath->text().isEmpty() )
81 dir = mRootPath->text();
93 mRootPath->setText( rootName );
96 void QgsExternalResourceConfigDlg::enableRelativeDefault()
99 if ( mRelativeGroupBox->isChecked() )
100 mRelativeDefault->setEnabled( !mRootPath->text().isEmpty() );
103 if ( mRootPath->text().isEmpty() )
104 mRelativeProject->toggle();
107 void QgsExternalResourceConfigDlg::enableRelative(
bool state )
111 mRelativeProject->setEnabled(
true );
112 if ( mRootPath->text().isEmpty() )
113 mRelativeDefault->setEnabled(
false );
115 mRelativeDefault->setEnabled(
true );
119 mRelativeProject->setEnabled(
false );
120 mRelativeDefault->setEnabled(
false );
129 cfg.insert(
"FileWidget", mFileWidgetGroupBox->isChecked() );
130 cfg.insert(
"FileWidgetButton", mFileWidgetButtonGroupBox->isChecked() );
131 cfg.insert(
"FileWidgetFilter", mFileWidgetFilterLineEdit->text() );
133 if ( mUseLink->isChecked() )
135 cfg.insert(
"UseLink", mUseLink->isChecked() );
136 if ( mFullUrl->isChecked() )
137 cfg.insert(
"FullUrl", mFullUrl->isChecked() );
140 if ( !mRootPath->text().isEmpty() )
142 cfg.insert(
"DefaultRoot", mRootPath->text() );
146 cfg.insert(
"StorageMode", mStorageButtonGroup->checkedId() );
149 if ( mRelativeGroupBox->isChecked() )
151 cfg.insert(
"RelativeStorage", mRelativeButtonGroup->checkedId() );
158 if ( mDocumentViewerGroupBox->isChecked() )
160 cfg.insert(
"DocumentViewer", mDocumentViewerContentComboBox->itemData( mDocumentViewerContentComboBox->currentIndex() ).toInt() );
161 cfg.insert(
"DocumentViewerHeight", mDocumentViewerHeight->value() );
162 cfg.insert(
"DocumentViewerWidth", mDocumentViewerWidth->value() );
175 if ( config.contains(
"FileWidget" ) )
177 mFileWidgetGroupBox->setChecked( config.value(
"FileWidget" ).toBool() );
179 if ( config.contains(
"FileWidget" ) )
181 mFileWidgetButtonGroupBox->setChecked( config.value(
"FileWidgetButton" ).toBool() );
183 if ( config.contains(
"FileWidgetFilter" ) )
185 mFileWidgetFilterLineEdit->setText( config.value(
"FileWidgetFilter" ).toString() );
188 if ( config.contains(
"UseLink" ) )
190 mUseLink->setChecked( config.value(
"UseLink" ).toBool() );
191 if ( config.contains(
"FullUrl" ) )
192 mFullUrl->setChecked(
true );
195 if ( config.contains(
"DefaultRoot" ) )
197 mRootPath->setText( config.value(
"DefaultRoot" ).toString() );
201 if ( config.contains(
"RelativeStorage" ) )
203 int relative = config.value(
"RelativeStorage" ).toInt();
206 mRelativeGroupBox->setChecked(
false );
210 mRelativeGroupBox->setChecked(
true );
211 mRelativeButtonGroup->button( relative )->setChecked(
true );
216 if ( config.contains(
"StorageMode" ) )
218 int mode = config.value(
"StorageMode" ).toInt();
219 mStorageButtonGroup->button( mode )->setChecked(
true );
223 if ( config.contains(
"DocumentViewer" ) )
227 int idx = mDocumentViewerContentComboBox->findData( content );
230 mDocumentViewerContentComboBox->setCurrentIndex( idx );
232 if ( config.contains(
"DocumentViewerHeight" ) )
234 mDocumentViewerHeight->setValue( config.value(
"DocumentViewerHeight" ).toInt() );
236 if ( config.contains(
"DocumentViewerWidth" ) )
238 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)
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)
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
QgsExternalResourceConfigDlg(QgsVectorLayer *vl, int fieldIdx, QWidget *parent=0)
QString cleanPath(const QString &path)
QVariant value(const QString &key, const QVariant &defaultValue) const
QFileInfo fileInfo() const
Returns QFileInfo object for the project's associated file.
static QgsProject * instance()
Returns the QgsProject singleton instance.
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.