diff options
author | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-03-24 14:49:23 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-03-25 15:39:22 +0000 |
commit | d8055b62f420f244728aae4069cc2b0a5983afe4 (patch) | |
tree | e38d70ee928f0a7039e5ffa8b298bde6298afdf3 /src/plugins/coreplugin/mimetypemagicdialog.cpp | |
parent | bc7a24afff2a6c4c579b5687f70e0ccb0d178e0a (diff) | |
download | qt-creator-d8055b62f420f244728aae4069cc2b0a5983afe4.tar.gz |
MimeDatabase: Allow regular expressions for magic rules
This extends the freedesktop standard, which really is lacking
in many ways.
Adds a type "regexp", which interprets the "value" as a
QRegularExpression with MultilineOption and DotMatchesEverythingOption.
The range/offset is the range of the sub-string that is matched
against the regular expression. If the value for the end of the
range is omitted, or the same as the start, the whole string is
matched against the regular expression.
The mask is ignored.
Change-Id: Iaaaf769451ed23112f1fbeee254fdff3198b74a2
Reviewed-by: BogDan Vatra <bogdan@kde.org>
Diffstat (limited to 'src/plugins/coreplugin/mimetypemagicdialog.cpp')
-rw-r--r-- | src/plugins/coreplugin/mimetypemagicdialog.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/plugins/coreplugin/mimetypemagicdialog.cpp b/src/plugins/coreplugin/mimetypemagicdialog.cpp index 33be9bd02b..f228609b4a 100644 --- a/src/plugins/coreplugin/mimetypemagicdialog.cpp +++ b/src/plugins/coreplugin/mimetypemagicdialog.cpp @@ -63,9 +63,21 @@ MimeTypeMagicDialog::MimeTypeMagicDialog(QWidget *parent) : connect(ui.informationLabel, &QLabel::linkActivated, this, [](const QString &link) { QDesktopServices::openUrl(QUrl(link)); }); + connect(ui.typeSelector, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), + this, [this]() { + if (ui.useRecommendedGroupBox->isChecked()) + setToRecommendedValues(); + }); ui.valueLineEdit->setFocus(); } +void MimeTypeMagicDialog::setToRecommendedValues() +{ + ui.startRangeSpinBox->setValue(0); + ui.endRangeSpinBox->setValue(ui.typeSelector->currentIndex() == 1/*regexp*/ ? 200 : 0); + ui.prioritySpinBox->setValue(50); +} + void MimeTypeMagicDialog::applyRecommended(bool checked) { if (checked) { @@ -73,9 +85,7 @@ void MimeTypeMagicDialog::applyRecommended(bool checked) m_customRangeStart = ui.startRangeSpinBox->value(); m_customRangeEnd = ui.endRangeSpinBox->value(); m_customPriority = ui.prioritySpinBox->value(); - ui.startRangeSpinBox->setValue(0); - ui.endRangeSpinBox->setValue(0); - ui.prioritySpinBox->setValue(50); + setToRecommendedValues(); } else { // restore previous custom values ui.startRangeSpinBox->setValue(m_customRangeStart); |