diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-12-03 14:17:03 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-12-10 13:31:48 +0100 |
commit | deb43b4c8a261855252aeee09fd6df283576932e (patch) | |
tree | a844379f47974fd681b86aa2187735e03639b567 /src/plugins/coreplugin/mimetypesettings.cpp | |
parent | ea1a92484ac99057b06130a012164bf9788650e9 (diff) | |
download | qt-creator-deb43b4c8a261855252aeee09fd6df283576932e.tar.gz |
Preferences: Add default implementation for filtering
The default "matches" method now takes the widget and looks for all
child labels, checkboxes, push buttons and group boxes.
Because of that, the former "createWidget" method
can be called multiple times without creating a new widget
(-->widget()), and the "finished" method must ensure that the created
widget gets deleted, since not all widgets that were created are added
to the UI anymore.
Change-Id: Ia231c7c78dd8819146668e6447d36d22e7836904
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins/coreplugin/mimetypesettings.cpp')
-rw-r--r-- | src/plugins/coreplugin/mimetypesettings.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/plugins/coreplugin/mimetypesettings.cpp b/src/plugins/coreplugin/mimetypesettings.cpp index 07315c389b..5185f554bc 100644 --- a/src/plugins/coreplugin/mimetypesettings.cpp +++ b/src/plugins/coreplugin/mimetypesettings.cpp @@ -41,6 +41,7 @@ #include <QCoreApplication> #include <QHash> #include <QMessageBox> +#include <QPointer> #include <QScopedPointer> #include <QSet> #include <QStringList> @@ -239,7 +240,6 @@ private slots: public: static const QChar kSemiColon; - QString m_keywords; MimeTypeSettingsModel *m_model; QSortFilterProxyModel *m_filterModel; int m_mimeForPatternSync; @@ -249,6 +249,7 @@ public: QList<int> m_modifiedMimeTypes; QString m_filterPattern; Ui::MimeTypeSettingsPage m_ui; + QPointer<QWidget> m_widget; }; const QChar MimeTypeSettingsPrivate::kSemiColon(QLatin1Char(';')); @@ -586,16 +587,13 @@ MimeTypeSettings::~MimeTypeSettings() delete d; } -bool MimeTypeSettings::matches(const QString &s) const +QWidget *MimeTypeSettings::widget() { - return d->m_keywords.contains(s, Qt::CaseInsensitive); -} - -QWidget *MimeTypeSettings::createPage(QWidget *parent) -{ - QWidget *w = new QWidget(parent); - d->configureUi(w); - return w; + if (!d->m_widget) { + d->m_widget = new QWidget; + d->configureUi(d->m_widget); + } + return d->m_widget; } void MimeTypeSettings::apply() @@ -625,6 +623,7 @@ void MimeTypeSettings::finish() d->updateMimeDatabase(); } d->resetState(); + delete d->m_widget; } } // Internal |