Commit 1b3d637c authored by Christian Kandeler's avatar Christian Kandeler Committed by hjk

Replace qVariantValue() with qvariant_cast().

qVariantvalue() is deprecated in Qt 5. qvariant_cast() does
the same thing and works in Qt 4 and Qt 5.

Change-Id: I922329d3a47fe394669f5d97a25f0825d3d2dea5
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 5f6f880a
......@@ -2252,11 +2252,11 @@ static void qDumpQVariantHelper(const QVariant *v, QString *value,
# endif
default: {
static const char *qTypeFormat = sizeof(void *) == sizeof(long)
? "'" NS "%s " NS "qVariantValue<" NS "%s >'(*('" NS "QVariant'*)0x%lx)"
: "'" NS "%s " NS "qVariantValue<" NS "%s >'(*('" NS "QVariant'*)0x%llx)";
? "'" NS "%s " NS "qvariant_cast<" NS "%s >'(*('" NS "QVariant'*)0x%lx)"
: "'" NS "%s " NS "qvariant_cast<" NS "%s >'(*('" NS "QVariant'*)0x%llx)";
static const char *nonQTypeFormat = sizeof(void *) == sizeof(long)
? "'%s " NS "qVariantValue<%s >'(*('" NS "QVariant'*)0x%lx)"
: "'%s " NS "qVariantValue<%s >'(*('" NS "QVariant'*)0x%llx)";
? "'%s " NS "qvariant_cast<%s >'(*('" NS "QVariant'*)0x%lx)"
: "'%s " NS "qvariant_cast<%s >'(*('" NS "QVariant'*)0x%llx)";
char buf[1000];
const char *format = (v->typeName()[0] == 'Q') ? qTypeFormat : nonQTypeFormat;
qsnprintf(buf, sizeof(buf) - 1, format, v->typeName(), v->typeName(), v);
......
......@@ -142,7 +142,7 @@ void ShortcutSettings::commandChanged(QTreeWidgetItem *current)
CommandMappings::commandChanged(current);
if (!current || !current->data(0, Qt::UserRole).isValid())
return;
ShortcutItem *scitem = qVariantValue<ShortcutItem *>(current->data(0, Qt::UserRole));
ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole));
setKeySequence(scitem->m_key);
}
......@@ -150,7 +150,7 @@ void ShortcutSettings::targetIdentifierChanged()
{
QTreeWidgetItem *current = commandList()->currentItem();
if (current && current->data(0, Qt::UserRole).isValid()) {
ShortcutItem *scitem = qVariantValue<ShortcutItem *>(current->data(0, Qt::UserRole));
ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole));
scitem->m_key = QKeySequence(m_key[0], m_key[1], m_key[2], m_key[3]);
if (scitem->m_cmd->defaultKeySequence() != scitem->m_key)
setModified(current, true);
......@@ -176,7 +176,7 @@ void ShortcutSettings::resetTargetIdentifier()
{
QTreeWidgetItem *current = commandList()->currentItem();
if (current && current->data(0, Qt::UserRole).isValid()) {
ShortcutItem *scitem = qVariantValue<ShortcutItem *>(current->data(0, Qt::UserRole));
ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole));
setKeySequence(scitem->m_cmd->defaultKeySequence());
}
}
......
......@@ -1363,7 +1363,7 @@ void DocumentManager::executeOpenWithMenuAction(QAction *action)
{
QTC_ASSERT(action, return);
const QVariant data = action->data();
OpenWithEntry entry = qVariantValue<OpenWithEntry>(data);
OpenWithEntry entry = qvariant_cast<OpenWithEntry>(data);
if (entry.editorFactory) {
// close any open editors that have this file open, but have a different type.
EditorManager *em = EditorManager::instance();
......
......@@ -3103,12 +3103,12 @@ void CdbEngine::postWidgetAtCommand()
void CdbEngine::handleCustomSpecialStop(const QVariant &v)
{
if (qVariantCanConvert<MemoryChangeCookie>(v)) {
const MemoryChangeCookie changeData = qVariantValue<MemoryChangeCookie>(v);
const MemoryChangeCookie changeData = qvariant_cast<MemoryChangeCookie>(v);
postCommand(cdbWriteMemoryCommand(changeData.address, changeData.data), 0);
return;
}
if (qVariantCanConvert<MemoryViewCookie>(v)) {
postFetchMemory(qVariantValue<MemoryViewCookie>(v));
postFetchMemory(qvariant_cast<MemoryViewCookie>(v));
return;
}
}
......
......@@ -1232,7 +1232,7 @@ void GdbEngine::handleStackListLocalsClassic(const GdbResponse &response)
if (debuggerCore()->action(UseCodeModel)->isChecked()) {
const StackFrame frame =
qVariantCanConvert<Debugger::Internal::StackFrame>(response.cookie)
? qVariantValue<Debugger::Internal::StackFrame>(response.cookie)
? qvariant_cast<Debugger::Internal::StackFrame>(response.cookie)
: stackHandler()->currentFrame();
if (frame.isUsable())
getUninitializedVariables(debuggerCore()->cppCodeModelSnapshot(),
......
......@@ -815,7 +815,7 @@ static inline GitClientMemberFunc memberFunctionFromAction(const QObject *o)
if (const QAction *action = qobject_cast<const QAction *>(o)) {
const QVariant v = action->data();
if (qVariantCanConvert<GitClientMemberFunc>(v))
return qVariantValue<GitClientMemberFunc>(v);
return qvariant_cast<GitClientMemberFunc>(v);
}
}
return 0;
......
......@@ -80,7 +80,7 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
m_ui->styleComboBox->setEditable(false);
Core::HelpManager *manager = Core::HelpManager::instance();
m_font = qVariantValue<QFont>(manager->customValue(QLatin1String("font"),
m_font = qvariant_cast<QFont>(manager->customValue(QLatin1String("font"),
m_font));
updateFontSize();
......
......@@ -774,7 +774,7 @@ void HelpPlugin::fontChanged()
createRightPaneContextViewer();
const QHelpEngine &engine = LocalHelpManager::helpEngine();
QFont font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
QFont font = qvariant_cast<QFont>(engine.customValue(QLatin1String("font"),
m_helpViewerForSideBar->viewerFont()));
m_helpViewerForSideBar->setFont(font);
......
......@@ -82,7 +82,7 @@ HelpViewer::~HelpViewer()
QFont HelpViewer::viewerFont() const
{
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
return qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
return qvariant_cast<QFont>(engine.customValue(QLatin1String("font"),
qApp->font()));
}
......
......@@ -393,7 +393,7 @@ QFont HelpViewer::viewerFont() const
QFont font(QApplication::font().family(),
webSettings->fontSize(QWebSettings::DefaultFontSize));
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
return qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
return qvariant_cast<QFont>(engine.customValue(QLatin1String("font"),
font));
}
......
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