Commit 028fc3dd authored by hjk's avatar hjk Committed by Christian Kandeler
Browse files

Use Id::fromString instead of the constructor.



Change-Id: Ie18714ac2872a085e8c20d445472901cc9f6b6c5
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
parent b7faf4d6
......@@ -836,7 +836,7 @@ void SplitterOrView::restoreState(const QByteArray &state)
stream >> fileName >> id >> editorState;
if (!QFile::exists(fileName))
return;
IEditor *e = em->openEditor(view(), fileName, Id(id), Core::EditorManager::IgnoreNavigationHistory
IEditor *e = em->openEditor(view(), fileName, Id::fromString(id), Core::EditorManager::IgnoreNavigationHistory
| Core::EditorManager::NoActivate);
if (!e) {
......
......@@ -814,7 +814,8 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
const QString externalToolsPrefix = QLatin1String("Tools.External.");
while (remainingActions.hasNext()) {
remainingActions.next();
ActionManager::unregisterAction(remainingActions.value(), Id(externalToolsPrefix + remainingActions.key()));
ActionManager::unregisterAction(remainingActions.value(),
Id::fromString(externalToolsPrefix + remainingActions.key()));
delete remainingActions.value();
}
m_actions.clear();
......@@ -836,7 +837,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
if (m_containers.contains(containerName))
container = m_containers.take(containerName); // remove to avoid deletion below
else
container = ActionManager::createMenu(Id(QLatin1String("Tools.External.Category.") + containerName));
container = ActionManager::createMenu(Id::fromString(QLatin1String("Tools.External.Category.") + containerName));
newContainers.insert(containerName, container);
mexternaltools->addMenu(container, Constants::G_DEFAULT_ONE);
container->menu()->setTitle(containerName);
......@@ -848,13 +849,13 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
Command *command = 0;
if (m_actions.contains(toolId)) {
action = m_actions.value(toolId);
command = ActionManager::command(Id(externalToolsPrefix + toolId));
command = ActionManager::command(Id::fromString(externalToolsPrefix + toolId));
} else {
action = new QAction(tool->displayName(), this);
action->setData(toolId);
m_actions.insert(toolId, action);
connect(action, SIGNAL(triggered()), this, SLOT(menuActivated()));
command = ActionManager::registerAction(action, Id(externalToolsPrefix + toolId), Context(Constants::C_GLOBAL));
command = ActionManager::registerAction(action, Id::fromString(externalToolsPrefix + toolId), Context(Constants::C_GLOBAL));
command->setAttribute(Command::CA_UpdateText);
}
action->setText(tool->displayName());
......
......@@ -174,7 +174,7 @@ void NavigationSubWidget::restoreSettings()
Core::Command *NavigationSubWidget::command(const QString &title) const
{
const QHash<Id, Command *> commandMap = m_parentWidget->commandMap();
QHash<Id, Command *>::const_iterator r = commandMap.find(Id(title));
QHash<Id, Command *>::const_iterator r = commandMap.find(Id::fromString(title));
if (r != commandMap.end())
return r.value();
return 0;
......
......@@ -339,7 +339,7 @@ void NavigationWidget::restoreSettings(QSettings *settings)
int position = 0;
foreach (const QString &id, viewIds) {
int index = factoryIndex(Id(id));
int index = factoryIndex(Id::fromString(id));
if (index >= 0) {
// Only add if the id was actually found!
insertSubItem(position, index);
......
......@@ -275,7 +275,7 @@ void OutputPaneManager::init()
QString actionId = QLatin1String("QtCreator.Pane.") + outPane->displayName().simplified();
actionId.remove(QLatin1Char(' '));
Id id(actionId);
Id id = Id::fromString(actionId);
QAction *action = new QAction(outPane->displayName(), this);
Command *cmd = ActionManager::registerAction(action, id, globalContext);
......
......@@ -169,7 +169,7 @@ bool Protocol::showConfigurationError(const Protocol *p,
bool rc = false;
if (mb.clickedButton() == settingsButton)
rc = Core::ICore::showOptionsDialog(Core::Id(p->settingsPage()->category()),
Core::Id(p->settingsPage()->id()),
Core::Id::fromString(p->settingsPage()->id()),
parent);
return rc;
}
......
......@@ -234,7 +234,8 @@ void FindPlugin::setupFilterMenuItems()
haveEnabledFilters = true;
action->setEnabled(isEnabled);
action->setData(qVariantFromValue(filter));
cmd = Core::ActionManager::registerAction(action, Core::Id(QLatin1String("FindFilter.")+filter->id()), globalcontext);
cmd = Core::ActionManager::registerAction(action,
Core::Id::fromString(QLatin1String("FindFilter.")+filter->id()), globalcontext);
cmd->setDefaultKeySequence(filter->defaultShortcut());
mfindadvanced->addAction(cmd);
d->m_filterActions.insert(filter, action);
......
......@@ -323,7 +323,7 @@ void LocatorWidget::updateFilterList()
foreach (ILocatorFilter *filter, m_locatorPlugin->filters()) {
if (filter->shortcutString().isEmpty() || filter->isHidden())
continue;
Core::Id locatorId = Core::Id(QLatin1String("Locator.") + filter->id());
Core::Id locatorId = Core::Id::fromString(QLatin1String("Locator.") + filter->id());
QAction *action = 0;
Core::Command *cmd = 0;
if (!actionCopy.contains(filter->id())) {
......@@ -345,7 +345,8 @@ void LocatorWidget::updateFilterList()
// unregister actions that are deleted now
foreach (const QString &id, actionCopy.keys()) {
Core::ActionManager::unregisterAction(actionCopy.value(id), Core::Id(QLatin1String("Locator.") + id));
Core::ActionManager::unregisterAction(actionCopy.value(id),
Core::Id::fromString(QLatin1String("Locator.") + id));
}
qDeleteAll(actionCopy);
......
......@@ -155,14 +155,18 @@ void MacroManager::MacroManagerPrivate::initialize()
}
}
static Core::Id makeId(const QString &name)
{
return Core::Id::fromString(QLatin1String(Constants::PREFIX_MACRO) + name);
}
void MacroManager::MacroManagerPrivate::addMacro(Macro *macro)
{
// Add sortcut
Core::Context context(TextEditor::Constants::C_TEXTEDITOR);
QShortcut *shortcut = new QShortcut(Core::ICore::mainWindow());
shortcut->setWhatsThis(macro->description());
const Core::Id macroId(QLatin1String(Constants::PREFIX_MACRO) + macro->displayName());
Core::ActionManager::registerShortcut(shortcut, macroId, context);
Core::ActionManager::registerShortcut(shortcut, makeId(macro->displayName()), context);
connect(shortcut, SIGNAL(activated()), mapper, SLOT(map()));
mapper->setMapping(shortcut, macro->displayName());
......@@ -175,7 +179,7 @@ void MacroManager::MacroManagerPrivate::removeMacro(const QString &name)
if (!macros.contains(name))
return;
// Remove shortcut
Core::ActionManager::unregisterShortcut(Core::Id(QLatin1String(Constants::PREFIX_MACRO) + name));
Core::ActionManager::unregisterShortcut(makeId(name));
// Remove macro from the map
Macro *macro = macros.take(name);
......@@ -190,8 +194,7 @@ void MacroManager::MacroManagerPrivate::changeMacroDescription(Macro *macro, con
macro->save(macro->fileName(), Core::ICore::mainWindow());
// Change shortcut what's this
Core::Command *command = Core::ActionManager::command(
Core::Id(QLatin1String(Constants::PREFIX_MACRO)+macro->displayName()));
Core::Command *command = Core::ActionManager::command(makeId(macro->displayName()));
if (command && command->shortcut())
command->shortcut()->setWhatsThis(description);
}
......
......@@ -111,7 +111,7 @@ void MacroOptionsWidget::createTable()
macroItem->setData(0, WRITE_ROLE, it.value()->isWritable());
Core::Command *command =
Core::ActionManager::command(Core::Id(QLatin1String(Constants::PREFIX_MACRO)
Core::ActionManager::command(Core::Id::fromString(QLatin1String(Constants::PREFIX_MACRO)
+ it.value()->displayName()));
if (command && command->shortcut())
macroItem->setText(2, command->shortcut()->key().toString());
......
Markdown is supported
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