Commit 7e47a8a4 authored by Tobias Hunger's avatar Tobias Hunger

Cleanup: Remove searchKeywords from optionspage widgets

If no specialization is provided then the UI strings are searched.

So get rid of extra code collecting all those strings in a lot of
places.

Change-Id: Ibcb48a67e5c7b74e5960fe38b1cb2f74259b503a
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 88456831
......@@ -66,20 +66,6 @@ ArtisticStyleOptionsPageWidget::~ArtisticStyleOptionsPageWidget()
delete ui;
}
QString ArtisticStyleOptionsPageWidget::searchKeywords() const
{
QString keywords;
const QLatin1Char sep(' ');
QTextStream(&keywords) << sep << ui->configuration->title()
<< sep << ui->commandLabel->text()
<< sep << ui->options->title()
<< sep << ui->useOtherFiles->text()
<< sep << ui->useHomeFile->text()
<< sep << ui->useCustomStyle->text();
keywords.remove(QLatin1Char('&'));
return keywords;
}
void ArtisticStyleOptionsPageWidget::restore()
{
ui->command->setPath(m_settings->command());
......@@ -104,8 +90,7 @@ void ArtisticStyleOptionsPageWidget::apply()
ArtisticStyleOptionsPage::ArtisticStyleOptionsPage(ArtisticStyleSettings *settings, QObject *parent) :
IOptionsPage(parent),
m_widget(0),
m_settings(settings),
m_searchKeywords()
m_settings(settings)
{
setId(Constants::ArtisticStyle::OPTION_ID);
setDisplayName(tr("Artistic Style"));
......@@ -118,11 +103,8 @@ QWidget *ArtisticStyleOptionsPage::widget()
{
m_settings->read();
if (!m_widget) {
if (!m_widget)
m_widget = new ArtisticStyleOptionsPageWidget(m_settings);
if (m_searchKeywords.isEmpty())
m_searchKeywords = m_widget->searchKeywords();
}
m_widget->restore();
return m_widget;
......@@ -138,11 +120,6 @@ void ArtisticStyleOptionsPage::finish()
{
}
bool ArtisticStyleOptionsPage::matches(const QString &searchKeyWord) const
{
return m_searchKeywords.contains(searchKeyWord, Qt::CaseInsensitive);
}
} // namespace ArtisticStyle
} // namespace Internal
} // namespace Beautifier
......@@ -51,7 +51,6 @@ class ArtisticStyleOptionsPageWidget : public QWidget
public:
explicit ArtisticStyleOptionsPageWidget(ArtisticStyleSettings *settings, QWidget *parent = 0);
virtual ~ArtisticStyleOptionsPageWidget();
QString searchKeywords() const;
void restore();
void apply();
......@@ -69,12 +68,10 @@ public:
QWidget *widget() QTC_OVERRIDE;
void apply() QTC_OVERRIDE;
void finish() QTC_OVERRIDE;
bool matches(const QString &searchKeywords) const QTC_OVERRIDE;
private:
QPointer<ArtisticStyleOptionsPageWidget> m_widget;
ArtisticStyleSettings *m_settings;
QString m_searchKeywords;
};
} // namespace ArtisticStyle
......
......@@ -65,20 +65,6 @@ ClangFormatOptionsPageWidget::~ClangFormatOptionsPageWidget()
delete ui;
}
QString ClangFormatOptionsPageWidget::searchKeywords() const
{
QString keywords;
const QLatin1Char sep(' ');
QTextStream(&keywords) << sep << ui->configuration->title()
<< sep << ui->commandLabel->text()
<< sep << ui->options->title()
<< sep << ui->usePredefinedStyle->text()
<< sep << ui->useCustomizedStyle->text()
<< sep << ui->formatEntireFileFallback->text();
keywords.remove(QLatin1Char('&'));
return keywords;
}
void ClangFormatOptionsPageWidget::restore()
{
ui->command->setPath(m_settings->command());
......@@ -110,8 +96,7 @@ void ClangFormatOptionsPageWidget::apply()
ClangFormatOptionsPage::ClangFormatOptionsPage(ClangFormatSettings *settings, QObject *parent) :
IOptionsPage(parent),
m_widget(0),
m_settings(settings),
m_searchKeywords()
m_settings(settings)
{
setId(Constants::ClangFormat::OPTION_ID);
setDisplayName(tr("Clang Format"));
......@@ -124,11 +109,8 @@ QWidget *ClangFormatOptionsPage::widget()
{
m_settings->read();
if (!m_widget) {
if (!m_widget)
m_widget = new ClangFormatOptionsPageWidget(m_settings);
if (m_searchKeywords.isEmpty())
m_searchKeywords = m_widget->searchKeywords();
}
m_widget->restore();
return m_widget;
......@@ -144,11 +126,6 @@ void ClangFormatOptionsPage::finish()
{
}
bool ClangFormatOptionsPage::matches(const QString &searchKeyWord) const
{
return m_searchKeywords.contains(searchKeyWord, Qt::CaseInsensitive);
}
} // namespace ClangFormat
} // namespace Internal
} // namespace Beautifier
......@@ -51,7 +51,6 @@ class ClangFormatOptionsPageWidget : public QWidget
public:
explicit ClangFormatOptionsPageWidget(ClangFormatSettings *settings, QWidget *parent = 0);
virtual ~ClangFormatOptionsPageWidget();
QString searchKeywords() const;
void restore();
void apply();
......@@ -69,12 +68,10 @@ public:
QWidget *widget() QTC_OVERRIDE;
void apply() QTC_OVERRIDE;
void finish() QTC_OVERRIDE;
bool matches(const QString &searchKeywords) const QTC_OVERRIDE;
private:
QPointer<ClangFormatOptionsPageWidget> m_widget;
ClangFormatSettings *m_settings;
QString m_searchKeywords;
};
} // namespace ClangFormat
......
......@@ -66,20 +66,6 @@ UncrustifyOptionsPageWidget::~UncrustifyOptionsPageWidget()
delete ui;
}
QString UncrustifyOptionsPageWidget::searchKeywords() const
{
QString keywords;
const QLatin1Char sep(' ');
QTextStream(&keywords) << sep << ui->configuration->title()
<< sep << ui->commandLabel->text()
<< sep << ui->options->title()
<< sep << ui->useOtherFiles->text()
<< sep << ui->useHomeFile->text()
<< sep << ui->useCustomStyle->text();
keywords.remove(QLatin1Char('&'));
return keywords;
}
void UncrustifyOptionsPageWidget::restore()
{
ui->command->setPath(m_settings->command());
......@@ -104,8 +90,7 @@ void UncrustifyOptionsPageWidget::apply()
UncrustifyOptionsPage::UncrustifyOptionsPage(UncrustifySettings *settings, QObject *parent) :
IOptionsPage(parent),
m_widget(0),
m_settings(settings),
m_searchKeywords()
m_settings(settings)
{
setId(Constants::Uncrustify::OPTION_ID);
setDisplayName(tr("Uncrustify"));
......@@ -118,11 +103,8 @@ QWidget *UncrustifyOptionsPage::widget()
{
m_settings->read();
if (!m_widget) {
if (!m_widget)
m_widget = new UncrustifyOptionsPageWidget(m_settings);
if (m_searchKeywords.isEmpty())
m_searchKeywords = m_widget->searchKeywords();
}
m_widget->restore();
return m_widget;
......@@ -138,11 +120,6 @@ void UncrustifyOptionsPage::finish()
{
}
bool UncrustifyOptionsPage::matches(const QString &searchKeyWord) const
{
return m_searchKeywords.contains(searchKeyWord, Qt::CaseInsensitive);
}
} // namespace Uncrustify
} // namespace Internal
} // namespace Beautifier
......@@ -51,7 +51,6 @@ class UncrustifyOptionsPageWidget : public QWidget
public:
explicit UncrustifyOptionsPageWidget(UncrustifySettings *settings, QWidget *parent = 0);
virtual ~UncrustifyOptionsPageWidget();
QString searchKeywords() const;
void restore();
void apply();
......@@ -69,12 +68,10 @@ public:
QWidget *widget() QTC_OVERRIDE;
void apply() QTC_OVERRIDE;
void finish() QTC_OVERRIDE;
bool matches(const QString &searchKeywords) const QTC_OVERRIDE;
private:
QPointer<UncrustifyOptionsPageWidget> m_widget;
UncrustifySettings *m_settings;
QString m_searchKeywords;
};
} // namespace Uncrustify
......
......@@ -448,21 +448,6 @@ ExternalToolConfig::~ExternalToolConfig()
delete ui;
}
QString ExternalToolConfig::searchKeywords() const
{
QString keywords;
QTextStream(&keywords)
<< ui->descriptionLabel->text()
<< ui->executableLabel->text()
<< ui->argumentsLabel->text()
<< ui->workingDirectoryLabel->text()
<< ui->outputLabel->text()
<< ui->errorOutputLabel->text()
<< ui->modifiesDocumentCheckbox->text()
<< ui->inputLabel->text();
return keywords;
}
void ExternalToolConfig::setTools(const QMap<QString, QList<ExternalTool *> > &tools)
{
QMap<QString, QList<ExternalTool *> > toolsCopy;
......
......@@ -94,8 +94,6 @@ public:
QMap<QString, QList<ExternalTool *> > tools() const;
void apply();
QString searchKeywords() const;
private slots:
void handleCurrentChanged(const QModelIndex &now, const QModelIndex &previous);
void showInfoForItem(const QModelIndex &index);
......
......@@ -45,15 +45,6 @@ SettingsWidget::SettingsWidget(const QStringList &protocols, QWidget *parent) :
m_ui.defaultProtocol->addItems(protocols);
}
QString SettingsWidget::searchKeywords() const
{
QString rc;
QTextStream(&rc) << m_ui.protocolLabel->text() << ' '
<< m_ui.userNameLabel->text();
rc.remove(QLatin1Char('&'));
return rc;
}
void SettingsWidget::setSettings(const Settings &settings)
{
m_ui.userEdit->setText(settings.username);
......
......@@ -52,8 +52,6 @@ public:
void setSettings(const Settings &);
Settings settings();
QString searchKeywords() const;
private:
Internal::Ui::SettingsPage m_ui;
};
......
......@@ -70,7 +70,6 @@ public:
void finish();
private:
QString m_searchKeywords;
QPointer<SettingsPageWidget> m_widget;
};
......
......@@ -116,27 +116,6 @@ void SettingsPageWidget::setStatusError(const QString &t)
m_ui.errorLabel->setText(t);
}
QString SettingsPageWidget::searchKeywords() const
{
QString rc;
QLatin1Char sep(' ');
QTextStream(&rc)
<< sep << m_ui.configGroupBox->title()
<< sep << m_ui.commandLabel->text()
<< sep << m_ui.environmentGroupBox->title()
<< sep << m_ui.portLabel->text()
<< sep << m_ui.clientLabel->text()
<< sep << m_ui.userLabel->text()
<< sep << m_ui.miscGroupBox->title()
<< sep << m_ui.logCountLabel->text()
<< sep << m_ui.timeOutLabel->text()
<< sep << m_ui.promptToSubmitCheckBox->text()
<< sep << m_ui.autoOpenCheckBox->text()
;
rc.remove(QLatin1Char('&'));
return rc;
}
SettingsPage::SettingsPage()
{
setId(VcsBase::Constants::VCS_ID_PERFORCE);
......
......@@ -54,8 +54,6 @@ public:
void setSettings(const PerforceSettings &);
Settings settings() const;
QString searchKeywords() const;
private slots:
void slotTest();
void setStatusText(const QString &);
......
......@@ -109,16 +109,6 @@ DeviceSettingsWidget::~DeviceSettingsWidget()
delete m_ui;
}
QString DeviceSettingsWidget::searchKeywords() const
{
QString rc;
QTextStream(&rc) << m_ui->configurationLabel->text()
<< ' ' << m_ui->deviceNameLabel->text()
<< ' ' << m_ui->nameLineEdit->text()
<< ' ' << m_ui->autoDetectionKeyLabel->text();
return rc.remove(QLatin1Char('&'));
}
void DeviceSettingsWidget::initGui()
{
m_ui->setupUi(this);
......
......@@ -59,7 +59,6 @@ public:
~DeviceSettingsWidget();
void saveSettings();
QString searchKeywords() const;
private slots:
void handleDeviceUpdated(Core::Id id);
......
......@@ -432,10 +432,4 @@ QString CodeStyleSelectorWidget::displayName(ICodeStylePreferences *codeStyle) c
return name;
}
QString CodeStyleSelectorWidget::searchKeywords() const
{
// no useful keywords here
return QString();
}
#include "codestyleselectorwidget.moc"
......@@ -57,7 +57,6 @@ public:
~CodeStyleSelectorWidget();
void setCodeStyle(TextEditor::ICodeStylePreferences *codeStyle);
QString searchKeywords() const;
private slots:
void slotComboBoxActivated(int index);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment