Fix warnings about implicit conversions when compiling against Qt 6
This commit is contained in:
parent
1cb6e06f31
commit
4a3aa9c1c1
|
@ -189,7 +189,7 @@ QVariant QueryResultsModel::headerData(int section, Qt::Orientation orientation,
|
|||
|
||||
int QueryResultsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return parent.isValid() ? 0 : m_results.size();
|
||||
return parent.isValid() ? 0 : Utility::containerSizeToInt(m_results.size());
|
||||
}
|
||||
|
||||
int QueryResultsModel::columnCount(const QModelIndex &parent) const
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../application/settings.h"
|
||||
#include "../misc/networkaccessmanager.h"
|
||||
#include "../misc/utility.h"
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
|
@ -141,7 +142,7 @@ void LyricsWikiaResultsModel::parseInitialResults(const QByteArray &data)
|
|||
iftag("item") {
|
||||
songs << SongDescription();
|
||||
songs.back().title = text;
|
||||
songs.back().track = songs.size();
|
||||
songs.back().track = Utility::containerSizeToInt(songs.size());
|
||||
}
|
||||
else_skip
|
||||
}
|
||||
|
@ -157,7 +158,7 @@ void LyricsWikiaResultsModel::parseInitialResults(const QByteArray &data)
|
|||
&& (!m_initialDescription.track || m_initialDescription.track == song.track)) {
|
||||
song.album = album;
|
||||
song.year = year;
|
||||
song.totalTracks = songs.size();
|
||||
song.totalTracks = Utility::containerSizeToInt(songs.size());
|
||||
m_results << std::move(song);
|
||||
}
|
||||
}
|
||||
|
@ -376,14 +377,14 @@ void LyricsWikiaResultsModel::parseAlbumDetailsAndFetchCover(int row, const QByt
|
|||
SongDescription &assocDesc = m_results[row];
|
||||
|
||||
// convert data to QString
|
||||
const QString html(data);
|
||||
const auto html = QString(data);
|
||||
|
||||
// parse cover URL from HTML
|
||||
const int coverDivStart = html.indexOf(QLatin1String("<div class=\"plainlinks\" style=\"clear:right; float:right;")) + 56;
|
||||
const auto coverDivStart = html.indexOf(QLatin1String("<div class=\"plainlinks\" style=\"clear:right; float:right;")) + 56;
|
||||
if (coverDivStart > 56) {
|
||||
const int coverHrefStart = html.indexOf(QLatin1String("href=\""), coverDivStart) + 6;
|
||||
const auto coverHrefStart = html.indexOf(QLatin1String("href=\""), coverDivStart) + 6;
|
||||
if (coverHrefStart > coverDivStart + 6) {
|
||||
const int coverHrefEnd = html.indexOf(QLatin1String("\""), coverHrefStart);
|
||||
const auto coverHrefEnd = html.indexOf(QLatin1String("\""), coverHrefStart);
|
||||
if (coverHrefEnd > 0) {
|
||||
assocDesc.coverUrl = html.mid(coverHrefStart, coverHrefEnd - coverHrefStart);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "./attachmentsmodel.h"
|
||||
|
||||
#include "../misc/utility.h"
|
||||
|
||||
#include <tagparser/abstractattachment.h>
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
@ -233,7 +235,7 @@ int AttachmentsModel::rowCount(const QModelIndex &parent) const
|
|||
if (parent.isValid()) {
|
||||
return 0;
|
||||
} else {
|
||||
return m_attachments.size();
|
||||
return Utility::containerSizeToInt(m_attachments.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,7 +253,7 @@ void AttachmentsModel::revert()
|
|||
for (auto &item : m_attachments) {
|
||||
item.revert();
|
||||
}
|
||||
emit dataChanged(index(0, 0), index(m_attachments.size() - 1, 0), QVector<int>() << Qt::CheckStateRole);
|
||||
emit dataChanged(index(0, 0), index(Utility::containerSizeToInt(m_attachments.size()) - 1, 0), QVector<int>() << Qt::CheckStateRole);
|
||||
}
|
||||
|
||||
bool AttachmentsModel::submit()
|
||||
|
@ -268,7 +270,7 @@ void AttachmentsModel::repealSelection()
|
|||
for (auto &item : m_attachments) {
|
||||
item.setActivated(false);
|
||||
}
|
||||
emit dataChanged(index(0, 0), index(m_attachments.size() - 1, 0), QVector<int>() << Qt::CheckStateRole);
|
||||
emit dataChanged(index(0, 0), index(Utility::containerSizeToInt(m_attachments.size()) - 1, 0), QVector<int>() << Qt::CheckStateRole);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,7 +285,7 @@ AbstractAttachment *AttachmentsModel::attachment(const QModelIndex &index)
|
|||
void AttachmentsModel::addAttachment(int row, AbstractAttachment *attachment, bool activated, const QString &location)
|
||||
{
|
||||
if (row < 0 || row > m_attachments.size()) {
|
||||
row = m_attachments.size();
|
||||
row = Utility::containerSizeToInt(m_attachments.size());
|
||||
}
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
m_attachments.insert(row, AttachmentItem(attachment, activated, location));
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "./codeedit.h"
|
||||
|
||||
#include "../misc/utility.h"
|
||||
|
||||
#include <QTextBlock>
|
||||
#include <QTextDocumentFragment>
|
||||
|
||||
|
@ -49,7 +51,7 @@ void CodeEdit::handleReturn(QKeyEvent *)
|
|||
if (index < line.size() && line.at(index) == QChar('}')) {
|
||||
if (index > 0) {
|
||||
int beg = index;
|
||||
index -= m_indentation.size();
|
||||
index -= Utility::containerSizeToInt(m_indentation.size());
|
||||
cursor.select(QTextCursor::BlockUnderCursor);
|
||||
cursor.deleteChar();
|
||||
cursor.insertBlock();
|
||||
|
|
|
@ -279,7 +279,7 @@ void DbQueryWidget::showResults()
|
|||
if (m_model->results().isEmpty()) {
|
||||
m_ui->notificationLabel->setText(tr("No results available"));
|
||||
} else {
|
||||
m_ui->notificationLabel->setText(tr("%1 result(s) available", nullptr, m_model->results().size()).arg(m_model->results().size()));
|
||||
m_ui->notificationLabel->setText(tr("%1 result(s) available", nullptr, Utility::containerSizeToInt(m_model->results().size())).arg(m_model->results().size()));
|
||||
}
|
||||
} else {
|
||||
m_ui->notificationLabel->setNotificationType(NotificationType::Critical);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "./javascripthighlighter.h"
|
||||
|
||||
#include "../misc/utility.h"
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
JavaScriptHighlighter::JavaScriptHighlighter(QTextDocument *parent)
|
||||
|
@ -55,8 +57,8 @@ void JavaScriptHighlighter::highlightBlock(const QString &text)
|
|||
const auto &expression(rule.pattern);
|
||||
auto match = expression.match(text);
|
||||
while (match.hasMatch()) {
|
||||
const auto index = match.capturedStart();
|
||||
const auto length = match.capturedLength();
|
||||
const auto index = Utility::containerSizeToInt(match.capturedStart());
|
||||
const auto length = Utility::containerSizeToInt(match.capturedLength());
|
||||
setFormat(index, length, rule.format);
|
||||
match = expression.match(text, index + length);
|
||||
}
|
||||
|
@ -65,21 +67,21 @@ void JavaScriptHighlighter::highlightBlock(const QString &text)
|
|||
|
||||
auto startIndex = 0;
|
||||
if (previousBlockState() != 1) {
|
||||
startIndex = m_commentStartExpression.match(text).capturedStart();
|
||||
startIndex = Utility::containerSizeToInt(m_commentStartExpression.match(text).capturedStart());
|
||||
}
|
||||
|
||||
while (startIndex >= 0) {
|
||||
const auto endMatch = m_commentEndExpression.match(text, startIndex);
|
||||
const auto endIndex = endMatch.capturedStart();
|
||||
const auto endIndex = Utility::containerSizeToInt(endMatch.capturedStart());
|
||||
const auto commentLength = [&] {
|
||||
if (endIndex >= 0) {
|
||||
return endIndex - startIndex + endMatch.capturedLength();
|
||||
return endIndex - startIndex + Utility::containerSizeToInt(endMatch.capturedLength());
|
||||
}
|
||||
setCurrentBlockState(1);
|
||||
return text.length() - startIndex;
|
||||
return Utility::containerSizeToInt(text.length()) - startIndex;
|
||||
}();
|
||||
setFormat(startIndex, commentLength, m_multiLineCommentFormat);
|
||||
startIndex = m_commentStartExpression.match(text, startIndex + commentLength).capturedStart();
|
||||
startIndex = Utility::containerSizeToInt(m_commentStartExpression.match(text, startIndex + commentLength).capturedStart());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -191,9 +191,9 @@ void NotificationLabel::applyMaxLineCount()
|
|||
return;
|
||||
}
|
||||
|
||||
int newStart = 0;
|
||||
auto newStart = QString::size_type();
|
||||
for (; m_currentLineCount > m_maxLineCount; --m_currentLineCount) {
|
||||
const int nextBullet = m_text.indexOf(s_bulletLine, newStart);
|
||||
const auto nextBullet = m_text.indexOf(s_bulletLine, newStart);
|
||||
if (nextBullet < 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -362,14 +362,14 @@ void TagEditorWidget::updateTagEditsAndAttachmentEdits(bool updateUi, PreviousVa
|
|||
// add/update TagEdit widgets
|
||||
if (m_tags.size()) {
|
||||
// create a lists of the targets and tags
|
||||
QList<TagTarget> targets;
|
||||
QList<QList<Tag *>> tagsByTarget;
|
||||
for (Tag *tag : m_tags) {
|
||||
const TagTarget &target = tag->target();
|
||||
int index = targets.indexOf(target);
|
||||
auto targets = QList<TagTarget>();
|
||||
auto tagsByTarget = QList<QList<Tag *>>();
|
||||
for (auto *const tag : m_tags) {
|
||||
const auto &target = tag->target();
|
||||
auto index = targets.indexOf(target);
|
||||
if (index < 0) {
|
||||
targets << target;
|
||||
tagsByTarget << (QList<Tag *>() << tag);
|
||||
tagsByTarget << QList<Tag *>({tag});
|
||||
} else {
|
||||
tagsByTarget[index] << tag;
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ void TagEditorWidget::updateTagEditsAndAttachmentEdits(bool updateUi, PreviousVa
|
|||
switch (Settings::values().editor.multipleTagHandling) {
|
||||
case Settings::MultipleTagHandling::SingleEditorPerTarget:
|
||||
// iterate through all targets in both cases
|
||||
for (int targetIndex = 0, targetCount = targets.size(); targetIndex < targetCount; ++targetIndex) {
|
||||
for (auto targetIndex = QList<TagTarget>::size_type(), targetCount = targets.size(); targetIndex < targetCount; ++targetIndex) {
|
||||
fetchNextEdit();
|
||||
edit->setTags(tagsByTarget.at(targetIndex), updateUi); // set all tags with the same target to a single edit
|
||||
if (!hasAutoCorrectionBeenApplied) {
|
||||
|
@ -390,7 +390,7 @@ void TagEditorWidget::updateTagEditsAndAttachmentEdits(bool updateUi, PreviousVa
|
|||
break;
|
||||
case Settings::MultipleTagHandling::SeparateEditors:
|
||||
// iterate through all targets in both cases
|
||||
for (int targetIndex = 0, targetCount = targets.size(); targetIndex < targetCount; ++targetIndex) {
|
||||
for (auto targetIndex = QList<TagTarget>::size_type(), targetCount = targets.size(); targetIndex < targetCount; ++targetIndex) {
|
||||
for (Tag *tag : tagsByTarget.at(targetIndex)) {
|
||||
fetchNextEdit();
|
||||
edit->setTag(tag, updateUi); // use a separate edit for each tag
|
||||
|
|
|
@ -165,10 +165,10 @@ QString elementPositionToQString(ElementPosition elementPosition)
|
|||
|
||||
QString formatName(const QString &str, bool underscoreToWhitespace)
|
||||
{
|
||||
QString res;
|
||||
auto res = QString();
|
||||
res.reserve(str.size());
|
||||
bool whitespace = true;
|
||||
for (int i = 0, size = str.size(); i != size; ++i) {
|
||||
auto whitespace = true;
|
||||
for (auto i = QString::size_type(), size = str.size(); i != size; ++i) {
|
||||
const QChar current = str.at(i);
|
||||
if (current.isSpace() || current == QChar('(') || current == QChar('[')) {
|
||||
whitespace = true;
|
||||
|
@ -228,7 +228,7 @@ void parseFileName(const QString &fileName, QString &title, int &trackNumber)
|
|||
{
|
||||
title = fileName.trimmed();
|
||||
trackNumber = 0;
|
||||
int lastPoint = title.lastIndexOf(QChar('.'));
|
||||
auto lastPoint = title.lastIndexOf(QChar('.'));
|
||||
if (lastPoint > 0) {
|
||||
title.truncate(lastPoint);
|
||||
} else if (lastPoint == 0) {
|
||||
|
@ -236,13 +236,13 @@ void parseFileName(const QString &fileName, QString &title, int &trackNumber)
|
|||
}
|
||||
static const QLatin1String delims[] = { QLatin1String(" - "), QLatin1String(", "), QLatin1String("-"), QLatin1String(" ") };
|
||||
for (const auto &delim : delims) {
|
||||
int lastDelimIndex = 0;
|
||||
int delimIndex = title.indexOf(delim);
|
||||
auto lastDelimIndex = QString::size_type();
|
||||
auto delimIndex = title.indexOf(delim);
|
||||
while (delimIndex > lastDelimIndex) {
|
||||
bool ok = false;
|
||||
trackNumber = QtUtilities::midRef(title, lastDelimIndex, delimIndex - lastDelimIndex).toInt(&ok);
|
||||
if (ok) {
|
||||
int titleStart = delimIndex + delim.size();
|
||||
auto titleStart = delimIndex + delim.size();
|
||||
for (const auto &delim2 : delims) {
|
||||
if (QtUtilities::midRef(title, titleStart).startsWith(delim2)) {
|
||||
titleStart += delim2.size();
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
#include <tagparser/tagvalue.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <type_traits>
|
||||
#include <limits>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QDir)
|
||||
QT_FORWARD_DECLARE_CLASS(QAbstractItemModel)
|
||||
|
@ -35,6 +39,15 @@ constexpr int sizeToInt(std::size_t size)
|
|||
return size > std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : static_cast<int>(size);
|
||||
}
|
||||
|
||||
constexpr int containerSizeToInt(typename QStringList::size_type size)
|
||||
{
|
||||
if constexpr (std::is_same_v<decltype(size), int>) {
|
||||
return size;
|
||||
} else {
|
||||
return size > std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : static_cast<int>(size);
|
||||
}
|
||||
}
|
||||
|
||||
constexpr int trQuandity(quint64 quandity)
|
||||
{
|
||||
return quandity > std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : static_cast<int>(quandity);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef FILESYSTEMITEM_H
|
||||
#define FILESYSTEMITEM_H
|
||||
|
||||
#include "../misc/utility.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
|
@ -188,7 +190,7 @@ inline void FileSystemItem::setCheckable(bool checkable)
|
|||
|
||||
inline int FileSystemItem::row() const
|
||||
{
|
||||
return m_parent ? m_parent->children().indexOf(const_cast<FileSystemItem *>(this)) : -1;
|
||||
return m_parent ? Utility::containerSizeToInt(m_parent->children().indexOf(const_cast<FileSystemItem *>(this))) : -1;
|
||||
}
|
||||
|
||||
} // namespace RenamingUtility
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "./filesystemitemmodel.h"
|
||||
#include "./filesystemitem.h"
|
||||
|
||||
#include "../misc/utility.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBrush>
|
||||
#include <QFont>
|
||||
|
@ -232,7 +234,7 @@ QModelIndex FileSystemItemModel::counterpart(const QModelIndex &index, int colum
|
|||
int FileSystemItemModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (const auto *const parentItem = (parent.isValid() ? reinterpret_cast<FileSystemItem *>(parent.internalPointer()) : m_rootItem)) {
|
||||
return parentItem->children().size();
|
||||
return Utility::containerSizeToInt(parentItem->children().size());
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ void RenamingEngine::applyChangings(FileSystemItem *parentItem)
|
|||
applyChangings(item);
|
||||
}
|
||||
}
|
||||
m_itemsProcessed += parentItem->children().size();
|
||||
m_itemsProcessed += Utility::containerSizeToInt(parentItem->children().size());
|
||||
emit progress(m_itemsProcessed, m_errorsOccured);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue