Commit 7c4e2b6c authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Id: Add QByteArray constructor



Distinguish from const char * one.

QString ctor is yet to be removed

Change-Id: I2da231036c6417353b0566d39666d918ad141c6d
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent f31da9ac
......@@ -42,8 +42,8 @@ IAnalyzerTool::IAnalyzerTool(QObject *parent)
Id IAnalyzerTool::defaultMenuGroup(StartMode mode)
{
if (mode == StartRemote)
return Constants::G_ANALYZER_REMOTE_TOOLS;
return Constants::G_ANALYZER_TOOLS;
return Id(Constants::G_ANALYZER_REMOTE_TOOLS);
return Id(Constants::G_ANALYZER_TOOLS);
}
Id IAnalyzerTool::defaultActionId(const IAnalyzerTool *tool, StartMode mode)
......@@ -51,11 +51,11 @@ Id IAnalyzerTool::defaultActionId(const IAnalyzerTool *tool, StartMode mode)
Id id = tool->id();
switch (mode) {
case StartLocal:
return Id(QByteArray("Analyzer." + id.name() + ".Local").data());
return Id(QByteArray("Analyzer." + id.name() + ".Local"));
case StartRemote:
return Id(QByteArray("Analyzer." + id.name() + ".Remote").data());
return Id(QByteArray("Analyzer." + id.name() + ".Remote"));
case StartQml:
return Id(QByteArray("Analyzer." + id.name() + ".Qml").data());
return Id(QByteArray("Analyzer." + id.name() + ".Qml"));
}
return Id();
}
......
......@@ -51,7 +51,7 @@ QString BazaarControl::displayName() const
Core::Id BazaarControl::id() const
{
return VcsBase::Constants::VCS_ID_BAZAAR;
return Core::Id(VcsBase::Constants::VCS_ID_BAZAAR);
}
bool BazaarControl::managesDirectory(const QString &directory, QString *topLevel) const
......
......@@ -373,7 +373,7 @@ public:
return m_file->open(errorString, fileName);
}
Core::IDocument *document() { return m_file; }
Core::Id id() const { return Core::Constants::K_DEFAULT_BINARY_EDITOR_ID; }
Core::Id id() const { return Core::Id(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); }
QString displayName() const { return m_displayName; }
void setDisplayName(const QString &title) { m_displayName = title; emit changed(); }
......@@ -417,7 +417,7 @@ BinEditorFactory::BinEditorFactory(BinEditorPlugin *owner) :
Core::Id BinEditorFactory::id() const
{
return Core::Constants::K_DEFAULT_BINARY_EDITOR_ID;
return Core::Id(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
}
QString BinEditorFactory::displayName() const
......
......@@ -52,7 +52,7 @@ QString ClearCaseControl::displayName() const
Core::Id ClearCaseControl::id() const
{
return ClearCase::Constants::VCS_ID_CLEARCASE;
return Core::Id(ClearCase::Constants::VCS_ID_CLEARCASE);
}
bool ClearCaseControl::isConfigured() const
......
......@@ -1261,7 +1261,7 @@ Core::IEditor *ClearCasePlugin::showOutputInEditor(const QString& title, const Q
{
const VcsBase::VcsBaseEditorParameters *params = findType(editorType);
QTC_ASSERT(params, return 0);
const Core::Id id = params->id;
const Core::Id id = Core::Id(QByteArray(params->id));
if (ClearCase::Constants::debug)
qDebug() << "ClearCasePlugin::showOutputInEditor" << title << id.name()
<< "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
......
......@@ -74,7 +74,7 @@ Core::IEditor *CMakeEditor::duplicate(QWidget *parent)
Core::Id CMakeEditor::id() const
{
return CMakeProjectManager::Constants::CMAKE_EDITOR_ID;
return Core::Id(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
}
void CMakeEditor::markAsChanged()
......
......@@ -69,7 +69,7 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
Core::Id CMakeEditorFactory::id() const
{
return CMakeProjectManager::Constants::CMAKE_EDITOR_ID;
return Core::Id(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
}
QString CMakeEditorFactory::displayName() const
......
......@@ -565,5 +565,5 @@ QString CMakeRunConfigurationFactory::buildTargetFromId(Core::Id id)
Core::Id CMakeRunConfigurationFactory::idFromBuildTarget(const QString &target)
{
QString id = QString::fromLatin1(CMAKE_RC_PREFIX) + target;
return Core::Id(id.toUtf8().constData());
return Core::Id(id.toUtf8());
}
......@@ -63,7 +63,7 @@ class CORE_EXPORT Feature : public Id
{
friend class FeatureSet;
public:
Feature(const char *name) : Id(name) {}
Feature(const char *name) : Id(QByteArray(name)) {}
explicit Feature(const QString &name) : Id(name) {}
};
......
......@@ -42,12 +42,12 @@ Context::Context(const char *id, int offset)
void Context::add(const char *id)
{
d.append(Id(id).uniqueIdentifier());
d.append(Id(QByteArray(id)).uniqueIdentifier());
}
bool Context::contains(const char *id) const
{
return d.contains(Id(id).uniqueIdentifier());
return d.contains(Id(QByteArray(id)).uniqueIdentifier());
}
} // namespace Core
......@@ -52,13 +52,13 @@ namespace Core {
class StringHolder
{
public:
explicit StringHolder(const char *s)
: str(s)
StringHolder(const char *s, int length)
: n(length), str(s)
{
n = strlen(s);
int m = n;
if (!n)
length = n = strlen(s);
h = 0;
while (m--) {
while (length--) {
h = (h << 4) + *s++;
h ^= (h & 0xf0000000) >> 23;
h &= 0x0fffffff;
......@@ -97,10 +97,10 @@ static int lastUid = 0;
static QVector<QByteArray> stringFromId;
static IdCache idFromString;
static int theId(const char *str)
static int theId(const char *str, int n = 0)
{
QTC_ASSERT(str && *str, return 0);
StringHolder sh(str);
StringHolder sh(str, n);
int res = idFromString.value(sh, 0);
if (res == 0) {
if (lastUid == 0)
......@@ -113,8 +113,17 @@ static int theId(const char *str)
return res;
}
static int theId(const QByteArray &ba)
{
return theId(ba.constData(), ba.size());
}
Id::Id(const char *name)
: m_id(theId(name))
: m_id(theId(name, 0))
{}
Id::Id(const QByteArray &name)
: m_id(theId(name))
{}
Id::Id(const QString &name)
......
......@@ -43,7 +43,8 @@ class CORE_EXPORT Id
public:
Id() : m_id(0) {}
Id(const char *name);
// FIXME: Replace with QByteArray
explicit Id(const QByteArray &name);
// FIXME: Remove
explicit Id(const QString &name);
QByteArray name() const;
QString toString() const;
......
......@@ -1743,7 +1743,7 @@ Core::IEditor *CPPEditor::duplicate(QWidget *parent)
Core::Id CPPEditor::id() const
{
return CppEditor::Constants::CPPEDITOR_ID;
return Core::Id(CppEditor::Constants::CPPEDITOR_ID);
}
bool CPPEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
......
......@@ -98,7 +98,7 @@ CppEditorFactory::CppEditorFactory(CppPlugin *owner) :
Core::Id CppEditorFactory::id() const
{
return CppEditor::Constants::CPPEDITOR_ID;
return Core::Id(CppEditor::Constants::CPPEDITOR_ID);
}
QString CppEditorFactory::displayName() const
......
......@@ -50,7 +50,7 @@ QString CvsControl::displayName() const
Core::Id CvsControl::id() const
{
return VcsBase::Constants::VCS_ID_CVS;
return Core::Id(VcsBase::Constants::VCS_ID_CVS);
}
bool CvsControl::isConfigured() const
......
......@@ -1269,7 +1269,7 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp
{
const VcsBaseEditorParameters *params = findType(editorType);
QTC_ASSERT(params, return 0);
const Id id = params->id;
const Id id = Core::Id(QByteArray(params->id));
if (Cvs::Constants::debug)
qDebug() << "CVSPlugin::showOutputInEditor" << title << id.name()
<< "source=" << source << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
......
......@@ -463,12 +463,12 @@ static QToolButton *toolButton(QAction *action)
return button;
}
static void setProxyAction(ProxyAction *proxy, const char *id)
static void setProxyAction(ProxyAction *proxy, Core::Id id)
{
proxy->setAction(ActionManager::command(id)->action());
}
static QToolButton *toolButton(const char *id)
static QToolButton *toolButton(Core::Id id)
{
return toolButton(ActionManager::command(id)->action());
}
......@@ -1562,7 +1562,7 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
m_exitAction->setEnabled(false);
m_startAction->setEnabled(true);
m_debugWithoutDeployAction->setEnabled(true);
setProxyAction(m_visibleStartAction, Constants::DEBUG);
setProxyAction(m_visibleStartAction, Core::Id(Constants::DEBUG));
}
void DebuggerPluginPrivate::languagesChanged()
......@@ -2233,7 +2233,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_exitAction->setEnabled(false);
m_startAction->setEnabled(true);
m_debugWithoutDeployAction->setEnabled(true);
setProxyAction(m_visibleStartAction, Constants::DEBUG);
setProxyAction(m_visibleStartAction, Core::Id(Constants::DEBUG));
m_hiddenStopAction->setAction(m_undisturbableAction);
} else if (state == InferiorStopOk) {
// F5 continues, Shift-F5 kills. It is "continuable".
......@@ -2242,7 +2242,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_exitAction->setEnabled(true);
m_startAction->setEnabled(false);
m_debugWithoutDeployAction->setEnabled(false);
setProxyAction(m_visibleStartAction, Constants::CONTINUE);
setProxyAction(m_visibleStartAction, Core::Id(Constants::CONTINUE));
m_hiddenStopAction->setAction(m_exitAction);
m_localsAndExpressionsWindow->setShowLocals(true);
} else if (state == InferiorRunOk) {
......@@ -2252,7 +2252,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_exitAction->setEnabled(true);
m_startAction->setEnabled(false);
m_debugWithoutDeployAction->setEnabled(false);
setProxyAction(m_visibleStartAction, Constants::INTERRUPT);
setProxyAction(m_visibleStartAction, Core::Id(Constants::INTERRUPT));
m_hiddenStopAction->setAction(m_interruptAction);
m_localsAndExpressionsWindow->setShowLocals(false);
} else if (state == DebuggerFinished) {
......@@ -2262,7 +2262,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_exitAction->setEnabled(false);
m_startAction->setEnabled(true);
m_debugWithoutDeployAction->setEnabled(true);
setProxyAction(m_visibleStartAction, Constants::DEBUG);
setProxyAction(m_visibleStartAction, Core::Id(Constants::DEBUG));
m_hiddenStopAction->setAction(m_undisturbableAction);
m_codeModelSnapshot = CPlusPlus::Snapshot();
setBusyCursor(false);
......
......@@ -61,7 +61,7 @@ FormEditorFactory::FormEditorFactory()
Core::Id FormEditorFactory::id() const
{
return K_DESIGNER_XML_EDITOR_ID;
return Core::Id(K_DESIGNER_XML_EDITOR_ID);
}
QString FormEditorFactory::displayName() const
......
......@@ -208,7 +208,7 @@ Core::IDocument *FormWindowEditor::document()
Core::Id FormWindowEditor::id() const
{
return Designer::Constants::K_DESIGNER_XML_EDITOR_ID;
return Core::Id(Designer::Constants::K_DESIGNER_XML_EDITOR_ID);
}
QString FormWindowEditor::displayName() const
......@@ -278,7 +278,7 @@ TextEditor::PlainTextEditor *FormWindowEditor::textEditor()
Core::Id FormWindowEditor::preferredModeType() const
{
return Core::Constants::MODE_DESIGN_TYPE;
return Core::Id(Core::Constants::MODE_DESIGN_TYPE);
}
} // namespace Designer
......
......@@ -72,7 +72,7 @@ QStringList ProjectFilesFactory::mimeTypes() const
Core::Id ProjectFilesFactory::id() const
{
return Constants::FILES_EDITOR_ID;
return Core::Id(Constants::FILES_EDITOR_ID);
}
QString ProjectFilesFactory::displayName() const
......@@ -94,7 +94,7 @@ ProjectFilesEditor::ProjectFilesEditor(ProjectFilesEditorWidget *editor)
Core::Id ProjectFilesEditor::id() const
{
return Constants::FILES_EDITOR_ID;
return Core::Id(Constants::FILES_EDITOR_ID);
}
bool ProjectFilesEditor::duplicateSupported() const
......
Supports Markdown
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