Core: Remove Core::Id(QByteArray) constructor

This was mostly used to disambiguate the char * and the QString
constructors.

Change-Id: Ib6923ef8e8c0e5d514a883e73aa001a1cd9fb534
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
hjk
2013-03-19 18:27:04 +01:00
parent 52575f1c62
commit fe29d6a8a3
19 changed files with 30 additions and 39 deletions

View File

@@ -47,14 +47,14 @@ Id IAnalyzerTool::defaultMenuGroup(StartMode mode)
Id IAnalyzerTool::defaultActionId(const IAnalyzerTool *tool, StartMode mode) Id IAnalyzerTool::defaultActionId(const IAnalyzerTool *tool, StartMode mode)
{ {
Id id = tool->id(); Id id = Id("Analyzer").withSuffix(tool->id().toString());
switch (mode) { switch (mode) {
case StartLocal: case StartLocal:
return Id(QByteArray("Analyzer." + id.name() + ".Local")); return id.withSuffix(".Local");
case StartRemote: case StartRemote:
return Id(QByteArray("Analyzer." + id.name() + ".Remote")); return id.withSuffix(".Remote");
case StartQml: case StartQml:
return Id(QByteArray("Analyzer." + id.name() + ".Qml")); return id.withSuffix(".Qml");
} }
return Id(); return Id();
} }

View File

@@ -1291,7 +1291,7 @@ Core::IEditor *ClearCasePlugin::showOutputInEditor(const QString& title, const Q
{ {
const VcsBase::VcsBaseEditorParameters *params = findType(editorType); const VcsBase::VcsBaseEditorParameters *params = findType(editorType);
QTC_ASSERT(params, return 0); QTC_ASSERT(params, return 0);
const Core::Id id = Core::Id(QByteArray(params->id)); const Core::Id id = params->id;
if (ClearCase::Constants::debug) if (ClearCase::Constants::debug)
qDebug() << "ClearCasePlugin::showOutputInEditor" << title << id.name() qDebug() << "ClearCasePlugin::showOutputInEditor" << title << id.name()
<< "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);

View File

@@ -1349,4 +1349,3 @@ void CMakeBuildTarget::clear()
title.clear(); title.clear();
library = false; library = false;
} }

View File

@@ -160,14 +160,6 @@ Id::Id(const char *name)
: m_id(theId(name, 0)) : m_id(theId(name, 0))
{} {}
/*!
\overload
*/
Id::Id(const QByteArray &name)
: m_id(theId(name))
{}
/*! /*!
Returns an internal representation of the id. Returns an internal representation of the id.
*/ */

View File

@@ -47,7 +47,6 @@ public:
Id() : m_id(0) {} Id() : m_id(0) {}
Id(int uid) : m_id(uid) {} Id(int uid) : m_id(uid) {}
Id(const char *name); Id(const char *name);
explicit Id(const QByteArray &name);
Id withSuffix(int suffix) const; Id withSuffix(int suffix) const;
Id withSuffix(const char *suffix) const; Id withSuffix(const char *suffix) const;

View File

@@ -1270,7 +1270,7 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp
{ {
const VcsBaseEditorParameters *params = findType(editorType); const VcsBaseEditorParameters *params = findType(editorType);
QTC_ASSERT(params, return 0); QTC_ASSERT(params, return 0);
const Id id = Core::Id(QByteArray(params->id)); const Id id = params->id;
if (Cvs::Constants::debug) if (Cvs::Constants::debug)
qDebug() << "CVSPlugin::showOutputInEditor" << title << id.name() qDebug() << "CVSPlugin::showOutputInEditor" << title << id.name()
<< "source=" << source << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); << "source=" << source << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);

View File

@@ -48,7 +48,6 @@
#include <QHBoxLayout> #include <QHBoxLayout>
static const int SEARCHRESULT_WARNING_LIMIT = 200000; static const int SEARCHRESULT_WARNING_LIMIT = 200000;
static const char UNDO_WARNING_ID[] = "warninglabel";
static const char SIZE_WARNING_ID[] = "sizeWarningLabel"; static const char SIZE_WARNING_ID[] = "sizeWarningLabel";
namespace Find { namespace Find {
@@ -232,7 +231,7 @@ void SearchResultWidget::addResults(const QList<SearchResultItem> &items, Search
updateMatchesFoundLabel(); updateMatchesFoundLabel();
if (firstItems) { if (firstItems) {
if (!m_dontAskAgainGroup.isEmpty()) { if (!m_dontAskAgainGroup.isEmpty()) {
Core::Id undoWarningId(QByteArray(UNDO_WARNING_ID) + '/' + m_dontAskAgainGroup.toLatin1()); Core::Id undoWarningId = Core::Id("warninglabel/").withSuffix(m_dontAskAgainGroup);
if (m_infoBar.canInfoBeAdded(undoWarningId)) { if (m_infoBar.canInfoBeAdded(undoWarningId)) {
Core::InfoBarEntry info(undoWarningId, tr("This change cannot be undone."), Core::InfoBarEntry info(undoWarningId, tr("This change cannot be undone."),
Core::InfoBarEntry::GlobalSuppressionEnabled); Core::InfoBarEntry::GlobalSuppressionEnabled);

View File

@@ -100,7 +100,7 @@ void MacroEvent::load(QDataStream &stream)
{ {
QByteArray ba; QByteArray ba;
stream >> ba; stream >> ba;
d->id = Core::Id(ba); d->id = Core::Id::fromName(ba);
int count; int count;
stream >> count; stream >> count;
quint8 id; quint8 id;

View File

@@ -1170,7 +1170,7 @@ Core::IEditor *PerforcePlugin::showOutputInEditor(const QString &title, const QS
{ {
const VcsBase::VcsBaseEditorParameters *params = findType(editorType); const VcsBase::VcsBaseEditorParameters *params = findType(editorType);
QTC_ASSERT(params, return 0); QTC_ASSERT(params, return 0);
const Core::Id id = Core::Id(QByteArray(params->id)); const Core::Id id = params->id;
if (Perforce::Constants::debug) if (Perforce::Constants::debug)
qDebug() << "PerforcePlugin::showOutputInEditor" << title << id.name() qDebug() << "PerforcePlugin::showOutputInEditor" << title << id.name()
<< "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);

View File

@@ -294,7 +294,9 @@ void IDevice::fromMap(const QVariantMap &map)
{ {
d->type = typeFromMap(map); d->type = typeFromMap(map);
d->displayName = map.value(QLatin1String(DisplayNameKey)).toString(); d->displayName = map.value(QLatin1String(DisplayNameKey)).toString();
d->id = Core::Id(map.value(QLatin1String(IdKey), newId().name()).toByteArray()); d->id = Core::Id::fromSetting(map.value(QLatin1String(IdKey)));
if (!d->id.isValid())
d->id = newId();
d->origin = static_cast<Origin>(map.value(QLatin1String(OriginKey), ManuallyAdded).toInt()); d->origin = static_cast<Origin>(map.value(QLatin1String(OriginKey), ManuallyAdded).toInt());
d->sshParameters.host = map.value(QLatin1String(HostKey)).toString(); d->sshParameters.host = map.value(QLatin1String(HostKey)).toString();
@@ -317,7 +319,7 @@ QVariantMap IDevice::toMap() const
QVariantMap map; QVariantMap map;
map.insert(QLatin1String(DisplayNameKey), d->displayName); map.insert(QLatin1String(DisplayNameKey), d->displayName);
map.insert(QLatin1String(TypeKey), d->type.toString()); map.insert(QLatin1String(TypeKey), d->type.toString());
map.insert(QLatin1String(IdKey), d->id.name()); map.insert(QLatin1String(IdKey), d->id.toSetting());
map.insert(QLatin1String(OriginKey), d->origin); map.insert(QLatin1String(OriginKey), d->origin);
map.insert(QLatin1String(MachineTypeKey), d->machineType); map.insert(QLatin1String(MachineTypeKey), d->machineType);

View File

@@ -184,7 +184,7 @@ QVariantMap EditorConfiguration::toMap() const
while (itCodeStyle.hasNext()) { while (itCodeStyle.hasNext()) {
itCodeStyle.next(); itCodeStyle.next();
QVariantMap settingsIdMap; QVariantMap settingsIdMap;
settingsIdMap.insert(QLatin1String("language"), itCodeStyle.key().name()); settingsIdMap.insert(QLatin1String("language"), itCodeStyle.key().toSetting());
QVariantMap value; QVariantMap value;
itCodeStyle.value()->toMap(QString(), &value); itCodeStyle.value()->toMap(QString(), &value);
settingsIdMap.insert(QLatin1String("value"), value); settingsIdMap.insert(QLatin1String("value"), value);
@@ -217,7 +217,7 @@ void EditorConfiguration::fromMap(const QVariantMap &map)
qWarning() << "No data for code style settings list" << i << "found!"; qWarning() << "No data for code style settings list" << i << "found!";
continue; continue;
} }
Core::Id languageId(settingsIdMap.value(QLatin1String("language")).toByteArray()); Core::Id languageId = Core::Id::fromSetting(settingsIdMap.value(QLatin1String("language")));
QVariantMap value = settingsIdMap.value(QLatin1String("value")).toMap(); QVariantMap value = settingsIdMap.value(QLatin1String("value")).toMap();
ICodeStylePreferences *preferences = d->m_languageCodeStylePreferences.value(languageId); ICodeStylePreferences *preferences = d->m_languageCodeStylePreferences.value(languageId);
if (preferences) if (preferences)

View File

@@ -93,7 +93,7 @@ bool ProjectConfiguration::usesDefaultDisplayName() const
QVariantMap ProjectConfiguration::toMap() const QVariantMap ProjectConfiguration::toMap() const
{ {
QVariantMap map; QVariantMap map;
map.insert(QLatin1String(CONFIGURATION_ID_KEY), m_id.name()); map.insert(QLatin1String(CONFIGURATION_ID_KEY), m_id.toSetting());
map.insert(QLatin1String(DISPLAY_NAME_KEY), m_displayName); map.insert(QLatin1String(DISPLAY_NAME_KEY), m_displayName);
map.insert(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), m_defaultDisplayName); map.insert(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), m_defaultDisplayName);
return map; return map;
@@ -101,7 +101,7 @@ QVariantMap ProjectConfiguration::toMap() const
bool ProjectConfiguration::fromMap(const QVariantMap &map) bool ProjectConfiguration::fromMap(const QVariantMap &map)
{ {
m_id = Core::Id(map.value(QLatin1String(CONFIGURATION_ID_KEY), QByteArray()).toByteArray()); m_id = Core::Id::fromSetting(map.value(QLatin1String(CONFIGURATION_ID_KEY)));
m_displayName = map.value(QLatin1String(DISPLAY_NAME_KEY), QString()).toString(); m_displayName = map.value(QLatin1String(DISPLAY_NAME_KEY), QString()).toString();
m_defaultDisplayName = map.value(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), m_defaultDisplayName = map.value(QLatin1String(DEFAULT_DISPLAY_NAME_KEY),
m_defaultDisplayName.isEmpty() ? m_defaultDisplayName.isEmpty() ?

View File

@@ -2425,7 +2425,7 @@ QVariantMap Version11Handler::update(Project *project, const QVariantMap &map)
QByteArray devId = dc.value(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.DeviceId")).toByteArray(); QByteArray devId = dc.value(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.DeviceId")).toByteArray();
if (devId.isEmpty()) if (devId.isEmpty())
devId = QByteArray("Desktop Device"); devId = QByteArray("Desktop Device");
if (!devId.isEmpty() && !DeviceManager::instance()->find(Core::Id(devId))) // We do not know that device if (!devId.isEmpty() && !DeviceManager::instance()->find(Core::Id::fromName(devId))) // We do not know that device
devId.clear(); devId.clear();
tmpKit->setValue(Core::Id("PE.Profile.Device"), devId); tmpKit->setValue(Core::Id("PE.Profile.Device"), devId);

View File

@@ -540,32 +540,32 @@ void TaskWindow::setShowWarnings(bool show)
void TaskWindow::updateCategoriesMenu() void TaskWindow::updateCategoriesMenu()
{ {
typedef QMap<QString, QByteArray>::ConstIterator NameToIdsConstIt; typedef QMap<QString, Core::Id>::ConstIterator NameToIdsConstIt;
d->m_categoriesMenu->clear(); d->m_categoriesMenu->clear();
const QList<Core::Id> filteredCategories = d->m_filter->filteredCategories(); const QList<Core::Id> filteredCategories = d->m_filter->filteredCategories();
QMap<QString, QByteArray> nameToIds; QMap<QString, Core::Id> nameToIds;
foreach (const Core::Id &categoryId, d->m_model->categoryIds()) foreach (const Core::Id &categoryId, d->m_model->categoryIds())
nameToIds.insert(d->m_model->categoryDisplayName(categoryId), categoryId.name()); nameToIds.insert(d->m_model->categoryDisplayName(categoryId), categoryId);
const NameToIdsConstIt cend = nameToIds.constEnd(); const NameToIdsConstIt cend = nameToIds.constEnd();
for (NameToIdsConstIt it = nameToIds.constBegin(); it != cend; ++it) { for (NameToIdsConstIt it = nameToIds.constBegin(); it != cend; ++it) {
const QString &displayName = it.key(); const QString &displayName = it.key();
const QByteArray categoryId = it.value(); const Core::Id categoryId = it.value();
QAction *action = new QAction(d->m_categoriesMenu); QAction *action = new QAction(d->m_categoriesMenu);
action->setCheckable(true); action->setCheckable(true);
action->setText(displayName); action->setText(displayName);
action->setData(categoryId); action->setData(categoryId.toSetting());
action->setChecked(!filteredCategories.contains(Core::Id(categoryId))); action->setChecked(!filteredCategories.contains(categoryId));
d->m_categoriesMenu->addAction(action); d->m_categoriesMenu->addAction(action);
} }
} }
void TaskWindow::filterCategoryTriggered(QAction *action) void TaskWindow::filterCategoryTriggered(QAction *action)
{ {
Core::Id categoryId(action->data().toByteArray()); Core::Id categoryId = Core::Id::fromSetting(action->data());
QTC_CHECK(categoryId.uniqueIdentifier() != 0); QTC_CHECK(categoryId.uniqueIdentifier() != 0);
setCategoryVisibility(categoryId, action->isChecked()); setCategoryVisibility(categoryId, action->isChecked());

View File

@@ -1149,7 +1149,7 @@ Core::IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const
{ {
const VcsBase::VcsBaseEditorParameters *params = findType(editorType); const VcsBase::VcsBaseEditorParameters *params = findType(editorType);
QTC_ASSERT(params, return 0); QTC_ASSERT(params, return 0);
const Core::Id id = Core::Id(QByteArray(params->id)); const Core::Id id = params->id;
if (Subversion::Constants::debug) if (Subversion::Constants::debug)
qDebug() << "SubversionPlugin::showOutputInEditor" << title << id.name() qDebug() << "SubversionPlugin::showOutputInEditor" << title << id.name()
<< "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);

View File

@@ -61,7 +61,7 @@ public:
BaseVcsEditorFactoryPrivate::BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t) : BaseVcsEditorFactoryPrivate::BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t) :
m_type(t), m_type(t),
m_id(QByteArray(t->id)), m_id(t->id),
m_mimeTypes(QStringList(QLatin1String(t->mimeType))), m_mimeTypes(QStringList(QLatin1String(t->mimeType))),
m_editorHandler(new TextEditor::TextEditorActionHandler(t->context)) m_editorHandler(new TextEditor::TextEditorActionHandler(t->context))
{ {

View File

@@ -47,7 +47,7 @@ public:
BaseVcsSubmitEditorFactoryPrivate::BaseVcsSubmitEditorFactoryPrivate(const VcsBaseSubmitEditorParameters *parameters) : BaseVcsSubmitEditorFactoryPrivate::BaseVcsSubmitEditorFactoryPrivate(const VcsBaseSubmitEditorParameters *parameters) :
m_parameters(parameters), m_parameters(parameters),
m_id(QByteArray(parameters->id)), m_id(parameters->id),
m_displayName(QLatin1String(parameters->displayName)), m_displayName(QLatin1String(parameters->displayName)),
m_mimeTypes(QLatin1String(parameters->mimeType)) m_mimeTypes(QLatin1String(parameters->mimeType))
{ {

View File

@@ -164,7 +164,7 @@ private:
VcsBaseEditor::VcsBaseEditor(VcsBaseEditorWidget *widget, VcsBaseEditor::VcsBaseEditor(VcsBaseEditorWidget *widget,
const VcsBaseEditorParameters *type) : const VcsBaseEditorParameters *type) :
BaseTextEditor(widget), BaseTextEditor(widget),
m_id(QByteArray(type->id)), m_id(type->id),
m_temporary(false) m_temporary(false)
{ {
setContext(Core::Context(type->context, TextEditor::Constants::C_TEXTEDITOR)); setContext(Core::Context(type->context, TextEditor::Constants::C_TEXTEDITOR));

View File

@@ -412,7 +412,7 @@ Core::IEditor *VcsBaseSubmitEditor::duplicate(QWidget * /*parent*/)
Core::Id VcsBaseSubmitEditor::id() const Core::Id VcsBaseSubmitEditor::id() const
{ {
return Core::Id(QByteArray(d->m_parameters->id)); return d->m_parameters->id;
} }
static QToolBar *createToolBar(const QWidget *someWidget, QAction *submitAction, QAction *diffAction) static QToolBar *createToolBar(const QWidget *someWidget, QAction *submitAction, QAction *diffAction)