Welcome: Use Core::Id instead of enum

Change-Id: Id65eb262d02bb4db765abefa361d407837b45782
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Eike Ziller
2014-12-16 12:01:35 +01:00
parent dfa76d74e0
commit 4cf7742fed
6 changed files with 11 additions and 17 deletions

View File

@@ -33,6 +33,8 @@
#include "utils_global.h" #include "utils_global.h"
#include <coreplugin/id.h>
#include <QObject> #include <QObject>
QT_FORWARD_DECLARE_CLASS(QUrl) QT_FORWARD_DECLARE_CLASS(QUrl)
@@ -50,14 +52,6 @@ class QTCREATOR_UTILS_EXPORT IWelcomePage : public QObject
Q_PROPERTY(bool hasSearchBar READ hasSearchBar CONSTANT) Q_PROPERTY(bool hasSearchBar READ hasSearchBar CONSTANT)
public: public:
enum Id {
GettingStarted = 0,
Develop = 1,
Examples = 2,
Tutorials = 3,
UserDefined = 32
};
IWelcomePage(); IWelcomePage();
virtual ~IWelcomePage(); virtual ~IWelcomePage();
@@ -66,7 +60,7 @@ public:
virtual int priority() const { return 0; } virtual int priority() const { return 0; }
virtual void facilitateQml(QQmlEngine *) {} virtual void facilitateQml(QQmlEngine *) {}
virtual bool hasSearchBar() const { return false; } virtual bool hasSearchBar() const { return false; }
virtual Id id() const = 0; virtual Core::Id id() const = 0;
}; };
} }

View File

@@ -236,9 +236,9 @@ QUrl ProjectWelcomePage::pageLocation() const
return QUrl::fromLocalFile(resourcePath + QLatin1String("/welcomescreen/develop.qml")); return QUrl::fromLocalFile(resourcePath + QLatin1String("/welcomescreen/develop.qml"));
} }
ProjectWelcomePage::Id ProjectWelcomePage::id() const Core::Id ProjectWelcomePage::id() const
{ {
return Develop; return "Develop";
} }
void ProjectWelcomePage::reloadWelcomeScreenData() void ProjectWelcomePage::reloadWelcomeScreenData()

View File

@@ -89,7 +89,7 @@ public:
QWidget *page() { return 0; } QWidget *page() { return 0; }
QString title() const { return tr("Projects"); } QString title() const { return tr("Projects"); }
int priority() const { return 20; } int priority() const { return 20; }
Id id() const; Core::Id id() const;
void reloadWelcomeScreenData(); void reloadWelcomeScreenData();

View File

@@ -275,9 +275,9 @@ void ExamplesWelcomePage::facilitateQml(QQmlEngine *engine)
rootContenxt->setContextProperty(QLatin1String("gettingStarted"), this); rootContenxt->setContextProperty(QLatin1String("gettingStarted"), this);
} }
ExamplesWelcomePage::Id ExamplesWelcomePage::id() const Core::Id ExamplesWelcomePage::id() const
{ {
return m_showExamples ? Examples : Tutorials; return m_showExamples ? "Examples" : "Tutorials";
} }
void ExamplesWelcomePage::openHelpInExtraWindow(const QUrl &help) void ExamplesWelcomePage::openHelpInExtraWindow(const QUrl &help)

View File

@@ -58,7 +58,7 @@ public:
int priority() const; int priority() const;
bool hasSearchBar() const; bool hasSearchBar() const;
void facilitateQml(QQmlEngine *); void facilitateQml(QQmlEngine *);
Id id() const; Core::Id id() const;
Q_INVOKABLE void openUrl(const QUrl &url); Q_INVOKABLE void openUrl(const QUrl &url);
public slots: public slots:

View File

@@ -216,7 +216,7 @@ void WelcomeMode::initPlugins()
}); });
QList<Utils::IWelcomePage*> plugins; QList<Utils::IWelcomePage*> plugins;
QHash<Utils::IWelcomePage::Id, Utils::IWelcomePage*> pluginHash; QHash<Core::Id, Utils::IWelcomePage*> pluginHash;
//avoid duplicate ids - choose by priority //avoid duplicate ids - choose by priority
foreach (Utils::IWelcomePage* plugin, duplicatePlugins) { foreach (Utils::IWelcomePage* plugin, duplicatePlugins) {
@@ -270,7 +270,7 @@ void WelcomeMode::initPlugins()
void WelcomeMode::welcomePluginAdded(QObject *obj) void WelcomeMode::welcomePluginAdded(QObject *obj)
{ {
QHash<Utils::IWelcomePage::Id, Utils::IWelcomePage*> pluginHash; QHash<Core::Id, Utils::IWelcomePage*> pluginHash;
foreach (QObject *obj, m_pluginList) { foreach (QObject *obj, m_pluginList) {
Utils::IWelcomePage *plugin = qobject_cast<Utils::IWelcomePage*>(obj); Utils::IWelcomePage *plugin = qobject_cast<Utils::IWelcomePage*>(obj);