forked from qt-creator/qt-creator
IOptionsPage: replace virtual fuctions by data members
Change-Id: I8297df85109b67b79f90c33263a5dc7b89efbb60 Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -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;
|
||||
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,38 +545,20 @@ void MimeTypeSettingsPrivate::resetMimeTypes()
|
||||
MimeTypeSettings::MimeTypeSettings(QObject *parent)
|
||||
: IOptionsPage(parent)
|
||||
, d(new MimeTypeSettingsPrivate)
|
||||
{}
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
MimeTypeSettings::~MimeTypeSettings()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
QString MimeTypeSettings::id() const
|
||||
{
|
||||
return QLatin1String(Core::Constants::SETTINGS_ID_MIMETYPES);
|
||||
}
|
||||
|
||||
QString MimeTypeSettings::displayName() const
|
||||
{
|
||||
return tr("MIME Types");
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return QIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
|
||||
}
|
||||
|
||||
bool MimeTypeSettings::matches(const QString &s) const
|
||||
{
|
||||
return d->m_keywords.contains(s, Qt::CaseInsensitive);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
QIcon ToolSettings::categoryIcon() const
|
||||
{
|
||||
return QIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
|
||||
setId(QLatin1String(Core::Constants::SETTINGS_ID_TOOLS));
|
||||
setDisplayName(tr("External Tools"));
|
||||
setCategory(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE));
|
||||
setDisplayCategory(QCoreApplication::translate("Core", Constants::SETTINGS_TR_CATEGORY_CORE));
|
||||
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,17 +45,11 @@ class ExternalToolConfig;
|
||||
class ToolSettings : public IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ToolSettings(QObject *parent = 0);
|
||||
~ToolSettings();
|
||||
|
||||
QString id() const;
|
||||
QString displayName() const;
|
||||
QString category() const;
|
||||
QString displayCategory() const;
|
||||
QIcon categoryIcon() const;
|
||||
bool matches(const QString & searchKeyWord) const;
|
||||
|
||||
QWidget *createPage(QWidget *parent);
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
Reference in New Issue
Block a user