Some Qt6 porting

- new ambiguous overloads for mapToGlobal
- some functions now return qsizetype instead of int

Task-number: QTCREATORBUG-24098
Change-Id: I0020e5689e093653e9e0e6f0d6263720bc2e003b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-07-21 15:47:35 +02:00
parent affd4ee658
commit 2d78bd4b19
13 changed files with 17 additions and 15 deletions

View File

@@ -171,7 +171,7 @@ public:
template<typename String> template<typename String>
static NativeFilePath fromFilePath(String filePath) static NativeFilePath fromFilePath(String filePath)
{ {
Utils::PathString nativePath{filePath.data(), filePath.size()}; Utils::PathString nativePath{filePath.data(), size_type(filePath.size())};
if (Utils::HostOsInfo::isWindowsHost()) if (Utils::HostOsInfo::isWindowsHost())
nativePath.replace('/', '\\'); nativePath.replace('/', '\\');

View File

@@ -184,13 +184,13 @@ void FancyTabBar::leaveEvent(QEvent *event)
QSize FancyTabBar::sizeHint() const QSize FancyTabBar::sizeHint() const
{ {
const QSize sh = tabSizeHint(); const QSize sh = tabSizeHint();
return {sh.width(), sh.height() * m_tabs.count()}; return {sh.width(), sh.height() * int(m_tabs.count())};
} }
QSize FancyTabBar::minimumSizeHint() const QSize FancyTabBar::minimumSizeHint() const
{ {
const QSize sh = tabSizeHint(true); const QSize sh = tabSizeHint(true);
return {sh.width(), sh.height() * m_tabs.count()}; return {sh.width(), sh.height() * int(m_tabs.count())};
} }
QRect FancyTabBar::tabRect(int index) const QRect FancyTabBar::tabRect(int index) const

View File

@@ -90,7 +90,7 @@ QList<LocatorFilterEntry> CommandLocator::matchesFor(QFutureInterface<LocatorFil
const int index = text.indexOf(entry, 0, entryCaseSensitivity); const int index = text.indexOf(entry, 0, entryCaseSensitivity);
if (index >= 0) { if (index >= 0) {
LocatorFilterEntry filterEntry(this, text, QVariant(i)); LocatorFilterEntry filterEntry(this, text, QVariant(i));
filterEntry.highlightInfo = {index, entry.length()}; filterEntry.highlightInfo = {index, int(entry.length())};
if (index == 0) if (index == 0)
betterEntries.append(filterEntry); betterEntries.append(filterEntry);

View File

@@ -69,7 +69,7 @@ QList<LocatorFilterEntry> ExecuteFilter::matchesFor(QFutureInterface<LocatorFilt
LocatorFilterEntry filterEntry(this, cmd, QVariant()); LocatorFilterEntry filterEntry(this, cmd, QVariant());
const int index = cmd.indexOf(entry, 0, entryCaseSensitivity); const int index = cmd.indexOf(entry, 0, entryCaseSensitivity);
if (index >= 0) { if (index >= 0) {
filterEntry.highlightInfo = {index, entry.length()}; filterEntry.highlightInfo = {index, int(entry.length())};
value.append(filterEntry); value.append(filterEntry);
} else { } else {
others.append(filterEntry); others.append(filterEntry);

View File

@@ -319,8 +319,9 @@ void CenteredLocatorPopup::updateGeometry()
QTC_ASSERT(parentWidget(), return); QTC_ASSERT(parentWidget(), return);
const QSize size = preferredSize(); const QSize size = preferredSize();
const QSize parentSize = parentWidget()->size(); const QSize parentSize = parentWidget()->size();
const QPoint pos = parentWidget()->mapToGlobal({(parentSize.width() - size.width()) / 2, const QPoint local((parentSize.width() - size.width()) / 2,
parentSize.height() / 2 - size.height()}); parentSize.height() / 2 - size.height());
const QPoint pos = parentWidget()->mapToGlobal(local);
QRect rect(pos, size); QRect rect(pos, size);
// invisible widget doesn't have the right screen set yet, so use the parent widget to // invisible widget doesn't have the right screen set yet, so use the parent widget to
// check for available geometry // check for available geometry

View File

@@ -152,7 +152,7 @@ QList<Core::LocatorFilterEntry> UrlLocatorFilter::matchesFor(
break; break;
const QString name = url.arg(entry); const QString name = url.arg(entry);
Core::LocatorFilterEntry filterEntry(this, name, QVariant(), m_icon); Core::LocatorFilterEntry filterEntry(this, name, QVariant(), m_icon);
filterEntry.highlightInfo = {name.lastIndexOf(entry), entry.length()}; filterEntry.highlightInfo = {int(name.lastIndexOf(entry)), int(entry.length())};
entries.append(filterEntry); entries.append(filterEntry);
} }
return entries; return entries;

View File

@@ -202,7 +202,7 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi
for (const QString &keyword : qAsConst(m_lastIndicesCache)) { for (const QString &keyword : qAsConst(m_lastIndicesCache)) {
const int index = keyword.indexOf(entry, 0, cs); const int index = keyword.indexOf(entry, 0, cs);
LocatorFilterEntry filterEntry(this, keyword, QVariant(), m_icon); LocatorFilterEntry filterEntry(this, keyword, QVariant(), m_icon);
filterEntry.highlightInfo = {index, entry.length()}; filterEntry.highlightInfo = {index, int(entry.length())};
entries.append(filterEntry); entries.append(filterEntry);
} }

View File

@@ -28,6 +28,7 @@
#include <coreplugin/locator/ilocatorfilter.h> #include <coreplugin/locator/ilocatorfilter.h>
#include <QIcon> #include <QIcon>
#include <QMultiMap>
#include <QMutex> #include <QMutex>
namespace Help { namespace Help {

View File

@@ -108,7 +108,7 @@ void OutputTaskParser::setDetailsFormat(Task &task, const LinkSpecs &linkSpecs)
task.formats.clear(); task.formats.clear();
int offset = task.summary.length() + 1; int offset = task.summary.length() + 1;
for (const Utils::FormattedText &ft : linkifiedText) { for (const Utils::FormattedText &ft : linkifiedText) {
task.formats << QTextLayout::FormatRange{offset, ft.text.length(), ft.format}; task.formats << QTextLayout::FormatRange{offset, int(ft.text.length()), ft.format};
offset += ft.text.length(); offset += ft.text.length();
} }
} }

View File

@@ -99,7 +99,7 @@ Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander *
result = scan(project.absolutePath(), project); result = scan(project.absolutePath(), project);
static const auto getDepth = [](const QString &filePath) { return filePath.count('/'); }; static const auto getDepth = [](const QString &filePath) { return int(filePath.count('/')); };
int minDepth = std::numeric_limits<int>::max(); int minDepth = std::numeric_limits<int>::max();
for (auto it = result.begin(); it != result.end(); ++it) { for (auto it = result.begin(); it != result.end(); ++it) {
const QString relPath = project.relativeFilePath(it->path()); const QString relPath = project.relativeFilePath(it->path());

View File

@@ -93,7 +93,7 @@ private:
const QStringList elements = line.split(QLatin1Char('\n')); const QStringList elements = line.split(QLatin1Char('\n'));
if (elements.count() < 4) { if (elements.count() < 4) {
qDebug("%s: Expected four list elements, got %d. Line was '%s'.", Q_FUNC_INFO, qDebug("%s: Expected four list elements, got %d. Line was '%s'.", Q_FUNC_INFO,
elements.count(), qPrintable(visualizeNull(line))); int(elements.count()), qPrintable(visualizeNull(line)));
continue; continue;
} }
bool ok; bool ok;

View File

@@ -475,7 +475,7 @@ void SyntaxHighlighter::formatSpaces(const QString &text, int start, int count)
{ {
Q_D(const SyntaxHighlighter); Q_D(const SyntaxHighlighter);
int offset = start; int offset = start;
const int end = std::min(start + count, text.length()); const int end = std::min(start + count, int(text.length()));
while (offset < end) { while (offset < end) {
if (text.at(offset).isSpace()) { if (text.at(offset).isSpace()) {
int start = offset++; int start = offset++;
@@ -503,7 +503,7 @@ void SyntaxHighlighter::setFormatWithSpaces(const QString &text, int start, int
QTextCharFormat visualSpaceFormat = d->whitespaceFormat; QTextCharFormat visualSpaceFormat = d->whitespaceFormat;
visualSpaceFormat.setBackground(format.background()); visualSpaceFormat.setBackground(format.background());
const int end = std::min(start + count, text.length()); const int end = std::min(start + count, int(text.length()));
int index = start; int index = start;
while (index != end) { while (index != end) {

View File

@@ -284,7 +284,7 @@ void IntroductionWidget::paintEvent(QPaintEvent *)
p.setOpacity(.87); p.setOpacity(.87);
const QColor backgroundColor = Qt::black; const QColor backgroundColor = Qt::black;
if (m_stepPointerAnchor) { if (m_stepPointerAnchor) {
const QPoint anchorPos = m_stepPointerAnchor->mapTo(parentWidget(), {0, 0}); const QPoint anchorPos = m_stepPointerAnchor->mapTo(parentWidget(), QPoint{0, 0});
const QRect anchorRect(anchorPos, m_stepPointerAnchor->size()); const QRect anchorRect(anchorPos, m_stepPointerAnchor->size());
const QRect spotlightRect = anchorRect.adjusted(-SPOTLIGHTMARGIN, const QRect spotlightRect = anchorRect.adjusted(-SPOTLIGHTMARGIN,
-SPOTLIGHTMARGIN, -SPOTLIGHTMARGIN,