Commit f77cd29e authored by hjk's avatar hjk Committed by Eike Ziller

IOptionsPage: replace virtual fuctions by data members

Change-Id: I8297df85109b67b79f90c33263a5dc7b89efbb60
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent 444445ce
......@@ -40,10 +40,7 @@
#include <coreplugin/icore.h>
#include <QCoreApplication>
#include <QLatin1String>
#include <QDebug>
#include <QIcon>
#include <QWidget>
using namespace Analyzer;
......@@ -53,31 +50,11 @@ AnalyzerOptionsPage::AnalyzerOptionsPage(AbstractAnalyzerSubConfig *config, QObj
Core::IOptionsPage(parent),
m_config(config)
{
}
QString AnalyzerOptionsPage::id() const
{
return m_config->id();
}
QString AnalyzerOptionsPage::displayName() const
{
return m_config->displayName();
}
QString AnalyzerOptionsPage::category() const
{
return QLatin1String("T.Analyzer");
}
QString AnalyzerOptionsPage::displayCategory() const
{
return QCoreApplication::translate("Analyzer", "Analyzer");
}
QIcon AnalyzerOptionsPage::categoryIcon() const
{
return QIcon(QLatin1String(":/images/analyzer_category.png"));
setId(m_config->id());
setDisplayName(m_config->displayName());
setCategory(QLatin1String("T.Analyzer"));
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
setCategoryIcon(QLatin1String(":/images/analyzer_category.png"));
}
QWidget *AnalyzerOptionsPage::createPage(QWidget *parent)
......
......@@ -50,13 +50,6 @@ class AnalyzerOptionsPage : public Core::IOptionsPage
public:
explicit AnalyzerOptionsPage(AbstractAnalyzerSubConfig *config, QObject *parent = 0);
// IOptionsPage implementation
QString id() const;
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
void finish();
......
......@@ -33,11 +33,9 @@
#include "androidsettingspage.h"
#include "androidsettingswidget.h"
#include "androidconstants.h"
#include <QCoreApplication>
#include <QIcon>
namespace Android {
namespace Internal {
......@@ -45,35 +43,12 @@ namespace Internal {
AndroidSettingsPage::AndroidSettingsPage(QObject *parent)
: Core::IOptionsPage(parent)
{
}
AndroidSettingsPage::~AndroidSettingsPage()
{
}
QString AndroidSettingsPage::id() const
{
return QLatin1String(Constants::ANDROID_SETTINGS_ID);
}
QString AndroidSettingsPage::displayName() const
{
return tr("Android Configurations");
}
QString AndroidSettingsPage::category() const
{
return QLatin1String(Constants::ANDROID_SETTINGS_CATEGORY);
}
QString AndroidSettingsPage::displayCategory() const
{
return QCoreApplication::translate("Android", Constants::ANDROID_SETTINGS_TR_CATEGORY);
}
QIcon AndroidSettingsPage::categoryIcon() const
{
return QIcon(QLatin1String(Constants::ANDROID_SETTINGS_CATEGORY_ICON));
setId(QLatin1String(Constants::ANDROID_SETTINGS_ID));
setDisplayName(tr("Android Configurations"));
setCategory(QLatin1String(Constants::ANDROID_SETTINGS_CATEGORY));
setDisplayCategory(QCoreApplication::translate("Android",
Constants::ANDROID_SETTINGS_TR_CATEGORY));
setCategoryIcon(QLatin1String(Constants::ANDROID_SETTINGS_CATEGORY_ICON));
}
bool AndroidSettingsPage::matches(const QString &searchKeyWord) const
......
......@@ -43,19 +43,14 @@ class AndroidSettingsWidget;
class AndroidSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
explicit AndroidSettingsPage(QObject *parent = 0);
~AndroidSettingsPage();
virtual QString id() const;
virtual QString displayName() const;
virtual QString category() const;
virtual QString displayCategory() const;
virtual QIcon categoryIcon() const;
virtual bool matches(const QString &searchKeyWord) const;
virtual QWidget *createPage(QWidget *parent);
virtual void apply();
virtual void finish();
bool matches(const QString &searchKeyWord) const;
QWidget *createPage(QWidget *parent);
void apply();
void finish();
private:
QString m_keywords;
......
......@@ -95,16 +95,8 @@ QString OptionsPageWidget::searchKeywords() const
OptionsPage::OptionsPage()
{
}
QString OptionsPage::id() const
{
return QLatin1String(VcsBase::Constants::VCS_ID_BAZAAR);
}
QString OptionsPage::displayName() const
{
return tr("Bazaar");
setId(QLatin1String(VcsBase::Constants::VCS_ID_BAZAAR));
setDisplayName(tr("Bazaar"));
}
QWidget *OptionsPage::createPage(QWidget *parent)
......
......@@ -67,8 +67,6 @@ class OptionsPage : public VcsBase::VcsBaseOptionsPage
public:
OptionsPage();
QString id() const;
QString displayName() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -246,6 +246,13 @@ QString CMakeManager::qtVersionForQMake(const QString &qmakePath)
CMakeSettingsPage::CMakeSettingsPage()
: m_pathchooser(0)
{
setId(QLatin1String("Z.CMake"));
setDisplayName(tr("CMake"));
setCategory(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY));
setDisplayCategory(QCoreApplication::translate("ProjectExplorer",
ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_TR_CATEGORY));
setCategoryIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
m_userCmake.process = 0;
m_pathCmake.process = 0;
m_userCmake.hasCodeBlocksMsvcGenerator = false;
......@@ -347,32 +354,6 @@ QString CMakeSettingsPage::findCmakeExecutable() const
return env.searchInPath(QLatin1String("cmake"));
}
QString CMakeSettingsPage::id() const
{
return QLatin1String("Z.CMake");
}
QString CMakeSettingsPage::displayName() const
{
return tr("CMake");
}
QString CMakeSettingsPage::category() const
{
return QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
}
QString CMakeSettingsPage::displayCategory() const
{
return QCoreApplication::translate("ProjectExplorer",
ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_TR_CATEGORY);
}
QIcon CMakeSettingsPage::categoryIcon() const
{
return QIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
}
QWidget *CMakeSettingsPage::createPage(QWidget *parent)
{
QWidget *outerWidget = new QWidget(parent);
......
......@@ -110,26 +110,24 @@ struct CMakeValidator
class CMakeSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
CMakeSettingsPage();
virtual ~CMakeSettingsPage();
virtual QString id() const;
virtual QString displayName() const;
virtual QString category() const;
virtual QString displayCategory() const;
virtual QIcon categoryIcon() const;
~CMakeSettingsPage();
virtual QWidget *createPage(QWidget *parent);
virtual void apply();
virtual void finish();
QWidget *createPage(QWidget *parent);
void apply();
void finish();
QString cmakeExecutable() const;
void setCMakeExecutable(const QString &executable);
bool isCMakeExecutableValid() const;
bool hasCodeBlocksMsvcGenerator() const;
private slots:
void userCmakeFinished();
void pathCmakeFinished();
private:
void cmakeFinished(CMakeValidator *cmakeValidator) const;
void saveSettings() const;
......
......@@ -62,10 +62,6 @@ CommandMappings::CommandMappings(QObject *parent)
{
}
CommandMappings::~CommandMappings()
{
}
// IOptionsPage
QWidget *CommandMappings::createPage(QWidget *parent)
......
......@@ -45,16 +45,7 @@ QT_END_NAMESPACE
namespace Core {
class Command;
namespace Internal {
namespace Ui { class CommandMappings; }
class ActionManagerPrivate;
class MainWindow;
}
namespace Internal { namespace Ui { class CommandMappings; } }
class CORE_EXPORT CommandMappings : public Core::IOptionsPage
{
......@@ -62,7 +53,6 @@ class CORE_EXPORT CommandMappings : public Core::IOptionsPage
public:
CommandMappings(QObject *parent = 0);
~CommandMappings();
protected slots:
void commandChanged(QTreeWidgetItem *current);
......
......@@ -35,13 +35,9 @@
#include <coreplugin/core_global.h>
#include <QIcon>
#include <QObject>
QT_BEGIN_NAMESPACE
class QIcon;
class QWidget;
QT_END_NAMESPACE
namespace Core {
class CORE_EXPORT IOptionsPage : public QObject
......@@ -50,18 +46,30 @@ class CORE_EXPORT IOptionsPage : public QObject
public:
IOptionsPage(QObject *parent = 0) : QObject(parent) {}
virtual ~IOptionsPage() {}
virtual QString id() const = 0;
virtual QString displayName() const = 0;
virtual QString category() const = 0;
virtual QString displayCategory() const = 0;
virtual QIcon categoryIcon() const = 0;
virtual bool matches(const QString & /* searchKeyWord*/) const { return false; }
QString id() const { return m_id; }
QString displayName() const { return m_displayName; }
QString category() const { return m_category; }
QString displayCategory() const { return m_displayCategory; }
QIcon categoryIcon() const { return QIcon(m_categoryIcon); }
virtual bool matches(const QString & /* searchKeyWord*/) const { return false; }
virtual QWidget *createPage(QWidget *parent) = 0;
virtual void apply() = 0;
virtual void finish() = 0;
protected:
void setId(const QString &id) { m_id = id; }
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
void setCategory(const QString &category) { m_category = category; }
void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
void setCategoryIcon(const QString &categoryIcon) { m_categoryIcon = categoryIcon; }
QString m_id;
QString m_displayName;
QString m_category;
QString m_displayCategory;
QString m_categoryIcon;
};
/*
......@@ -78,13 +86,21 @@ class CORE_EXPORT IOptionsPageProvider : public QObject
public:
IOptionsPageProvider(QObject *parent = 0) : QObject(parent) {}
virtual ~IOptionsPageProvider() {}
virtual QString category() const = 0;
virtual QString displayCategory() const = 0;
virtual QIcon categoryIcon() const = 0;
QString category() const { return m_category; }
QString displayCategory() const { return m_displayCategory; }
QIcon categoryIcon() const { return QIcon(m_categoryIcon); }
virtual QList<IOptionsPage *> pages() const = 0;
protected:
void setCategory(const QString &category) { m_category = category; }
void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
void setCategoryIcon(const QString &categoryIcon) { m_categoryIcon = categoryIcon; }
QString m_category;
QString m_displayCategory;
QString m_categoryIcon;
};
} // namespace Core
......
......@@ -63,38 +63,12 @@ ShortcutSettings::ShortcutSettings(QObject *parent)
{
Core::Internal::ActionManagerPrivate *am = ActionManagerPrivate::instance();
connect(am, SIGNAL(commandListChanged()), this, SLOT(initialize()));
}
ShortcutSettings::~ShortcutSettings()
{
}
// IOptionsPage
QString ShortcutSettings::id() const
{
return QLatin1String(Core::Constants::SETTINGS_ID_SHORTCUTS);
}
QString ShortcutSettings::displayName() const
{
return tr("Keyboard");
}
QString ShortcutSettings::category() const
{
return QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE);
}
QString ShortcutSettings::displayCategory() const
{
return QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE);
}
QIcon ShortcutSettings::categoryIcon() const
{
return QIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
setId(QLatin1String(Core::Constants::SETTINGS_ID_SHORTCUTS));
setDisplayName(tr("Keyboard"));
setCategory(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE));
setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
QWidget *ShortcutSettings::createPage(QWidget *parent)
......
......@@ -64,14 +64,6 @@ class ShortcutSettings : public Core::CommandMappings
public:
ShortcutSettings(QObject *parent = 0);
~ShortcutSettings();
// IOptionsPage
QString id() const;
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -58,31 +58,11 @@ using namespace Core::Internal;
GeneralSettings::GeneralSettings():
m_page(0), m_dialog(0)
{
}
QString GeneralSettings::id() const
{
return QLatin1String(Core::Constants::SETTINGS_ID_ENVIRONMENT);
}
QString GeneralSettings::displayName() const
{
return tr("General");
}
QString GeneralSettings::category() const
{
return QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE);
}
QString GeneralSettings::displayCategory() const
{
return QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE);
}
QIcon GeneralSettings::categoryIcon() const
{
return QIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
setId(QLatin1String(Core::Constants::SETTINGS_ID_ENVIRONMENT));
setDisplayName(tr("General"));
setCategory(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE));
setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
static bool hasQmFilesForLocale(const QString &locale, const QString &creatorTrPath)
......
......@@ -54,11 +54,6 @@ class GeneralSettings : public IOptionsPage
public:
GeneralSettings();
QString id() const;
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget* createPage(QWidget *parent);
void apply();
void finish();
......
......@@ -43,14 +43,11 @@
#include <extensionsystem/pluginmanager.h>
#include <QCoreApplication>
#include <QLatin1String>
#include <QStringList>
#include <QVector>
#include <QSet>
#include <QScopedPointer>
#include <QAbstractTableModel>
#include <QHash>
#include <QIcon>
#include <QTableWidgetItem>
#include <QMessageBox>
#include <QtAlgorithms>
......@@ -548,36 +545,18 @@ void MimeTypeSettingsPrivate::resetMimeTypes()
MimeTypeSettings::MimeTypeSettings(QObject *parent)
: IOptionsPage(parent)
, d(new MimeTypeSettingsPrivate)
{}
MimeTypeSettings::~MimeTypeSettings()
{
delete d;
}
QString MimeTypeSettings::id() const
{
return QLatin1String(Core::Constants::SETTINGS_ID_MIMETYPES);
}
QString MimeTypeSettings::displayName() const
{
return tr("MIME Types");
setId(QLatin1String(Core::Constants::SETTINGS_ID_MIMETYPES));
setDisplayName(tr("MIME Types"));
setCategory(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE));
setDisplayCategory(QCoreApplication::translate("Core",
Core::Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
QString MimeTypeSettings::category() const
{
return QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE);
}
QString MimeTypeSettings::displayCategory() const
{
return QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE);
}
QIcon MimeTypeSettings::categoryIcon() const
MimeTypeSettings::~MimeTypeSettings()
{
return QIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
delete d;
}
bool MimeTypeSettings::matches(const QString &s) const
......
......@@ -48,13 +48,7 @@ public:
MimeTypeSettings(QObject *parent = 0);
virtual ~MimeTypeSettings();
virtual QString id() const;
virtual QString displayName() const;
virtual QString category() const;
virtual QString displayCategory() const;
virtual QIcon categoryIcon() const;
virtual bool matches(const QString &s) const;
virtual QWidget *createPage(QWidget *parent);
virtual void apply();
virtual void finish();
......
......@@ -53,39 +53,11 @@ using namespace Core::Internal;
ToolSettings::ToolSettings(QObject *parent) :
IOptionsPage(parent)
{
}
ToolSettings::~ToolSettings()
{
}
QString ToolSettings::id() const
{
return QLatin1String(Core::Constants::SETTINGS_ID_TOOLS);
}
QString ToolSettings::displayName() const
{
return tr("External Tools");
}
QString ToolSettings::category() const
{
return QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE);
}
QString ToolSettings::displayCategory() const
{
return QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE);
}