Commit 89fa7823 authored by Christian Kandeler's avatar Christian Kandeler Committed by hjk
Browse files

Replace all remaining functions deprecated in Qt 5, if possible.



These are:
    - QInputDialog::getInteger() [-> getInt()]
    - QKeySequence::operator QString() [-> toString()]
    - QRegion::intersect() [-> intersected()]
    - qVariantCanConvert() [-> QVariant::canConvert()]

Plus some left-over occurrences of qFindChild() and
QAbstractItemModel::reset() that were missed by the
respective earlier patches.

All deprecated features still left are not trivially
replaceable, i.e. the code using them cannot be made
to compile with both Qt 4 and Qt 5.

Change-Id: I32541681bbf66b0fef78f5c7025521f9ff84f463
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent aef4280b
......@@ -156,7 +156,7 @@ void ShortcutSettings::targetIdentifierChanged()
setModified(current, true);
else
setModified(current, false);
current->setText(2, scitem->m_key);
current->setText(2, scitem->m_key.toString(QKeySequence::NativeText));
resetCollisionMarker(scitem);
markPossibleCollisions(scitem);
}
......@@ -169,7 +169,7 @@ void ShortcutSettings::setKeySequence(const QKeySequence &key)
for (int i = 0; i < m_keyNum; ++i) {
m_key[i] = key[i];
}
targetEdit()->setText(key);
targetEdit()->setText(key.toString(QKeySequence::NativeText));
}
void ShortcutSettings::resetTargetIdentifier()
......@@ -201,7 +201,7 @@ void ShortcutSettings::importAction()
QString sid = item->m_cmd->id().toString();
if (mapping.contains(sid)) {
item->m_key = mapping.value(sid);
item->m_item->setText(2, item->m_key);
item->m_item->setText(2, item->m_key.toString(QKeySequence::NativeText));
if (item->m_item == commandList()->currentItem())
commandChanged(item->m_item);
......@@ -223,7 +223,7 @@ void ShortcutSettings::defaultAction()
{
foreach (ShortcutItem *item, m_scitems) {
item->m_key = item->m_cmd->defaultKeySequence();
item->m_item->setText(2, item->m_key);
item->m_item->setText(2, item->m_key.toString(QKeySequence::NativeText));
setModified(item->m_item, false);
if (item->m_item == commandList()->currentItem())
commandChanged(item->m_item);
......@@ -294,7 +294,7 @@ void ShortcutSettings::initialize()
s->m_key = c->keySequence();
item->setText(0, subId);
item->setText(1, c->description());
item->setText(2, s->m_key);
item->setText(2, s->m_key.toString(QKeySequence::NativeText));
if (s->m_cmd->defaultKeySequence() != s->m_key)
setModified(item, true);
......@@ -334,7 +334,7 @@ void ShortcutSettings::handleKeyEvent(QKeyEvent *e)
}
m_keyNum++;
QKeySequence ks(m_key[0], m_key[1], m_key[2], m_key[3]);
targetEdit()->setText(ks);
targetEdit()->setText(ks.toString(QKeySequence::NativeText));
e->accept();
}
......
......@@ -96,7 +96,7 @@ static QScriptValue inputDialogGetInteger(QScriptContext *context, QScriptEngine
const int maxValue = argumentCount > 5 ? context->argument(5).toInt32() : INT_MAX;
bool ok;
const int rc = QInputDialog::getInteger(parent, title, label, defaultValue, minValue, maxValue, 1, &ok);
const int rc = QInputDialog::getInt(parent, title, label, defaultValue, minValue, maxValue, 1, &ok);
if (!ok)
return QScriptValue(engine, QScriptValue::NullValue);
return QScriptValue(engine, rc);
......
......@@ -1250,7 +1250,7 @@ void CdbEngine::handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &cm
bool ok;
const quint64 address = answer.toLongLong(&ok, 16);
if (ok && address) {
QTC_ASSERT(qVariantCanConvert<ContextData>(cmd->cookie), return);
QTC_ASSERT(cmd->cookie.canConvert<ContextData>(), return);
const ContextData cookie = qvariant_cast<ContextData>(cmd->cookie);
jumpToAddress(address);
gotoLocation(Location(cookie.fileName, cookie.lineNumber));
......@@ -1683,7 +1683,7 @@ void CdbEngine::handleResolveSymbol(const QList<quint64> &addresses, const QVari
{
// Disassembly mode: Determine suitable range containing the
// agent's address within the function to display.
if (qVariantCanConvert<DisassemblerAgent*>(cookie)) {
if (cookie.canConvert<DisassemblerAgent*>()) {
DisassemblerAgent *agent = cookie.value<DisassemblerAgent *>();
const quint64 agentAddress = agent->address();
quint64 functionAddress = 0;
......@@ -1722,7 +1722,7 @@ void CdbEngine::handleResolveSymbol(const QList<quint64> &addresses, const QVari
// Parse: "00000000`77606060 cc int 3"
void CdbEngine::handleDisassembler(const CdbBuiltinCommandPtr &command)
{
QTC_ASSERT(qVariantCanConvert<DisassemblerAgent*>(command->cookie), return);
QTC_ASSERT(command->cookie.canConvert<DisassemblerAgent*>(), return);
DisassemblerAgent *agent = qvariant_cast<DisassemblerAgent*>(command->cookie);
agent->setContents(parseCdbDisassembler(command->reply));
}
......@@ -1761,7 +1761,7 @@ void CdbEngine::changeMemory(Internal::MemoryAgent *, QObject *, quint64 addr, c
void CdbEngine::handleMemory(const CdbExtensionCommandPtr &command)
{
QTC_ASSERT(qVariantCanConvert<MemoryViewCookie>(command->cookie), return);
QTC_ASSERT(command->cookie.canConvert<MemoryViewCookie>(), return);
const MemoryViewCookie memViewCookie = qvariant_cast<MemoryViewCookie>(command->cookie);
if (command->success) {
const QByteArray data = QByteArray::fromBase64(command->reply);
......@@ -2893,7 +2893,7 @@ void CdbEngine::handleExpression(const CdbExtensionCommandPtr &command)
showMessage(QString::fromLocal8Bit(command->errorMessage), LogError);
}
// Is this a conditional breakpoint?
if (command->cookie.isValid() && qVariantCanConvert<ConditionalBreakPointCookie>(command->cookie)) {
if (command->cookie.isValid() && command->cookie.canConvert<ConditionalBreakPointCookie>()) {
const ConditionalBreakPointCookie cookie = qvariant_cast<ConditionalBreakPointCookie>(command->cookie);
const QString message = value ?
tr("Value %1 obtained from evaluating the condition of breakpoint %2, stopping.").
......@@ -3102,12 +3102,12 @@ void CdbEngine::postWidgetAtCommand()
void CdbEngine::handleCustomSpecialStop(const QVariant &v)
{
if (qVariantCanConvert<MemoryChangeCookie>(v)) {
if (v.canConvert<MemoryChangeCookie>()) {
const MemoryChangeCookie changeData = qvariant_cast<MemoryChangeCookie>(v);
postCommand(cdbWriteMemoryCommand(changeData.address, changeData.data), 0);
return;
}
if (qVariantCanConvert<MemoryViewCookie>(v)) {
if (v.canConvert<MemoryViewCookie>()) {
postFetchMemory(qvariant_cast<MemoryViewCookie>(v));
return;
}
......
......@@ -1231,7 +1231,7 @@ void GdbEngine::handleStackListLocalsClassic(const GdbResponse &response)
QStringList uninitializedVariables;
if (debuggerCore()->action(UseCodeModel)->isChecked()) {
const StackFrame frame =
qVariantCanConvert<Debugger::Internal::StackFrame>(response.cookie)
response.cookie.canConvert<Debugger::Internal::StackFrame>()
? qvariant_cast<Debugger::Internal::StackFrame>(response.cookie)
: stackHandler()->currentFrame();
if (frame.isUsable())
......
......@@ -179,7 +179,7 @@ bool FormWindowEditor::open(QString *errorString, const QString &fileName, const
d->m_file.setFileName(absfileName);
d->m_file.setShouldAutoSave(false);
if (Internal::ResourceHandler *rh = qFindChild<Designer::Internal::ResourceHandler*>(form))
if (Internal::ResourceHandler *rh = form->findChild<Designer::Internal::ResourceHandler*>())
rh->updateResources();
emit changed();
......
......@@ -814,7 +814,7 @@ static inline GitClientMemberFunc memberFunctionFromAction(const QObject *o)
if (o) {
if (const QAction *action = qobject_cast<const QAction *>(o)) {
const QVariant v = action->data();
if (qVariantCanConvert<GitClientMemberFunc>(v))
if (v.canConvert<GitClientMemberFunc>())
return qvariant_cast<GitClientMemberFunc>(v);
}
}
......
......@@ -88,7 +88,7 @@ bool inputText(QWidget *parent, const QString &title, const QString &prompt, QSt
dialog.setLabelText(prompt);
dialog.setTextValue(*s);
// Nasty hack:
if (QLineEdit *le = qFindChild<QLineEdit*>(&dialog))
if (QLineEdit *le = dialog.findChild<QLineEdit*>())
le->setMinimumWidth(500);
if (dialog.exec() != QDialog::Accepted)
return false;
......
......@@ -186,8 +186,9 @@ void RemoteModel::clear()
{
if (m_remotes.isEmpty())
return;
beginResetModel();
m_remotes.clear();
reset();
endResetModel();
}
bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage)
......@@ -200,6 +201,7 @@ bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage
return false;
// Parse output
m_workingDirectory = workingDirectory;
beginResetModel();
m_remotes.clear();
const QStringList lines = output.split(QLatin1Char('\n'));
for (int r = 0; r < lines.count(); ++r) {
......@@ -207,7 +209,7 @@ bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage
if (newRemote.parse(lines.at(r)))
m_remotes.push_back(newRemote);
}
reset();
endResetModel();
return true;
}
......
......@@ -214,7 +214,7 @@ void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr docum
rect.setHeight(widget()->height() + 10);
rect.setWidth(reg.boundingRect().width() - reg.boundingRect().left());
rect.moveTo(reg.boundingRect().topLeft());
reg = reg.intersect(rect);
reg = reg.intersected(rect);
if (contextWidget()->acceptsType(m_prototypes)) {
m_node = 0;
......
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