Merge pull request #15181 from glassez/qt5

Raise minimum Qt version to 5.15.2
This commit is contained in:
Vladimir Golovnev
2021-07-23 06:22:57 +03:00
committed by GitHub
38 changed files with 120 additions and 146 deletions

View File

@@ -75,10 +75,10 @@ DownloadFromURLDialog::DownloadFromURLDialog(QWidget *parent)
// Paste clipboard if there is an URL in it
const QString clipboardText = qApp->clipboard()->text();
const QVector<QStringRef> clipboardList = clipboardText.splitRef('\n');
const QList<QStringView> clipboardList = QStringView(clipboardText).split(u'\n');
QSet<QString> uniqueURLs;
for (QStringRef strRef : clipboardList)
for (QStringView strRef : clipboardList)
{
strRef = strRef.trimmed();
if (strRef.isEmpty()) continue;
@@ -107,10 +107,10 @@ DownloadFromURLDialog::~DownloadFromURLDialog()
void DownloadFromURLDialog::downloadButtonClicked()
{
const QString plainText = m_ui->textUrls->toPlainText();
const QVector<QStringRef> urls = plainText.splitRef('\n');
const QList<QStringView> urls = QStringView(plainText).split(u'\n');
QSet<QString> uniqueURLs;
for (QStringRef url : urls)
for (QStringView url : urls)
{
url = url.trimmed();
if (url.isEmpty()) continue;

View File

@@ -107,30 +107,32 @@ QValidator::State Private::FileSystemPathValidator::validate(QString &input, int
// we test path components from beginning to the one with cursor location in strict mode
// and the one with cursor and beyond in non-strict mode
QVector<QStringRef> components = input.splitRef(QDir::separator(), Qt::KeepEmptyParts);
QList<QStringView> components = QStringView(input).split(QDir::separator(), Qt::KeepEmptyParts);
// find index of the component that contains pos
int componentWithCursorIndex = 0;
int componentWithCursorPosition = 0;
int pathLength = 0;
// components.size() - 1 because when path ends with QDir::separator(), we will not see the last
// character in the components array, yet everything past the one before the last delimiter
// belongs to the last component
for (; (componentWithCursorIndex < components.size() - 1) && (pathLength < pos); ++componentWithCursorIndex)
for (; (componentWithCursorIndex < (components.size() - 1)) && (pathLength < pos); ++componentWithCursorIndex)
{
pathLength = components[componentWithCursorIndex].position() + components[componentWithCursorIndex].size();
pathLength = componentWithCursorPosition + components[componentWithCursorIndex].size();
componentWithCursorPosition += components[componentWithCursorIndex].size() + 1;
}
Q_ASSERT(componentWithCursorIndex < components.size());
m_lastValidationState = QValidator::Acceptable;
if (componentWithCursorIndex > 0)
m_lastValidationState = validate(input, components, m_strictMode, 0, componentWithCursorIndex - 1);
m_lastValidationState = validate(components, m_strictMode, 0, componentWithCursorIndex - 1);
if ((m_lastValidationState == QValidator::Acceptable) && (componentWithCursorIndex < components.size()))
m_lastValidationState = validate(input, components, false, componentWithCursorIndex, components.size() - 1);
m_lastValidationState = validate(components, false, componentWithCursorIndex, components.size() - 1);
return m_lastValidationState;
}
QValidator::State Private::FileSystemPathValidator::validate(const QString &path, const QVector<QStringRef> &pathComponents, bool strict,
QValidator::State Private::FileSystemPathValidator::validate(const QList<QStringView> &pathComponents, bool strict,
int firstComponentToTest, int lastComponentToTest) const
{
Q_ASSERT(firstComponentToTest >= 0);
@@ -141,12 +143,13 @@ QValidator::State Private::FileSystemPathValidator::validate(const QString &path
if (pathComponents.empty())
return strict ? QValidator::Invalid : QValidator::Intermediate;
for (int i = firstComponentToTest; i < lastComponentToTest; ++i)
for (int i = firstComponentToTest; i <= lastComponentToTest; ++i)
{
if (pathComponents[i].isEmpty()) continue;
const bool isFinalPath = (i == (pathComponents.size() - 1));
const QStringView componentPath = pathComponents[i];
if (componentPath.isEmpty()) continue;
QStringRef componentPath(&path, 0, pathComponents[i].position() + pathComponents[i].size());
m_lastTestResult = testPath(componentPath, false);
m_lastTestResult = testPath(pathComponents[i], isFinalPath);
if (m_lastTestResult != TestResult::OK)
{
m_lastTestedPath = componentPath.toString();
@@ -154,20 +157,11 @@ QValidator::State Private::FileSystemPathValidator::validate(const QString &path
}
}
const bool finalPath = (lastComponentToTest == (pathComponents.size() - 1));
QStringRef componentPath(&path, 0, pathComponents[lastComponentToTest].position()
+ pathComponents[lastComponentToTest].size());
m_lastTestResult = testPath(componentPath, finalPath);
if (m_lastTestResult != TestResult::OK)
{
m_lastTestedPath = componentPath.toString();
return strict ? QValidator::Invalid : QValidator::Intermediate;
}
return QValidator::Acceptable;
}
Private::FileSystemPathValidator::TestResult
Private::FileSystemPathValidator::testPath(const QStringRef &path, bool pathIsComplete) const
Private::FileSystemPathValidator::testPath(const QStringView path, bool pathIsComplete) const
{
QFileInfo fi(path.toString());
if (m_existingOnly && !fi.exists())

View File

@@ -39,7 +39,6 @@ class QCompleter;
class QContextMenuEvent;
class QFileSystemModel;
class QKeyEvent;
class QStringRef;
namespace Private
{
@@ -82,10 +81,10 @@ namespace Private
QString lastTestedPath() const;
private:
QValidator::State validate(const QString &path, const QVector<QStringRef> &pathComponents, bool strict,
QValidator::State validate(const QList<QStringView> &pathComponents, bool strict,
int firstComponentToTest, int lastComponentToTest) const;
TestResult testPath(const QStringRef &path, bool pathIsComplete) const;
TestResult testPath(QStringView path, bool pathIsComplete) const;
bool m_strictMode;
bool m_existingOnly;

View File

@@ -2184,8 +2184,9 @@ void MainWindow::pythonDownloadFinished(const Net::DownloadResult &result)
QProcess installer;
qDebug("Launching Python installer in passive mode...");
QFile::rename(result.filePath, result.filePath + ".exe");
installer.start('"' + Utils::Fs::toNativePath(result.filePath) + ".exe\" /passive");
const QString exePath = result.filePath + QLatin1String(".exe");
QFile::rename(result.filePath, exePath);
installer.start(Utils::Fs::toNativePath(exePath), {"/passive"});
// Wait for setup to complete
installer.waitForFinished(10 * 60 * 1000);
@@ -2195,7 +2196,7 @@ void MainWindow::pythonDownloadFinished(const Net::DownloadResult &result)
qDebug("Setup should be complete!");
// Delete temp file
Utils::Fs::forceRemove(result.filePath + ".exe");
Utils::Fs::forceRemove(exePath);
// Reload search engine
if (Utils::ForeignApps::pythonInfo().isSupportedVersion())

View File

@@ -100,13 +100,8 @@ PropTabBar::PropTabBar(QWidget *parent)
addWidget(speedButton);
m_btnGroup->addButton(speedButton, SpeedTab);
// SIGNAL/SLOT
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
connect(m_btnGroup, &QButtonGroup::idClicked
, this, &PropTabBar::setCurrentIndex);
#else
connect(m_btnGroup, qOverload<int>(&QButtonGroup::buttonClicked)
, this, &PropTabBar::setCurrentIndex);
#endif
// Disable buttons focus
for (QAbstractButton *btn : asConst(m_btnGroup->buttons()))
btn->setFocusPolicy(Qt::NoFocus);

View File

@@ -59,7 +59,7 @@ QStringList TrackersAdditionDialog::newTrackers() const
const QString plainText = m_ui->textEditTrackersList->toPlainText();
QStringList cleanTrackers;
for (QStringRef url : asConst(plainText.splitRef('\n')))
for (QStringView url : asConst(QStringView(plainText).split(u'\n')))
{
url = url.trimmed();
if (!url.isEmpty())

View File

@@ -504,16 +504,16 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info)
const QString path = Utils::Fs::toUniformPath(info.filePath(i));
// Iterate of parts of the path to create necessary folders
QVector<QStringRef> pathFolders = path.splitRef('/', Qt::SkipEmptyParts);
QList<QStringView> pathFolders = QStringView(path).split(u'/', Qt::SkipEmptyParts);
pathFolders.removeLast();
for (const QStringRef &pathPartRef : asConst(pathFolders))
for (const QStringView pathPart : asConst(pathFolders))
{
const QString pathPart = pathPartRef.toString();
TorrentContentModelFolder *newParent = currentParent->childFolderWithName(pathPart);
const QString folderPath = pathPart.toString();
TorrentContentModelFolder *newParent = currentParent->childFolderWithName(folderPath);
if (!newParent)
{
newParent = new TorrentContentModelFolder(pathPart, currentParent);
newParent = new TorrentContentModelFolder(folderPath, currentParent);
currentParent->appendChild(newParent);
}
currentParent = newParent;

View File

@@ -263,12 +263,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
connect(m_ui->checkMaxRatio, &QCheckBox::toggled, m_ui->spinRatioLimit, &QDoubleSpinBox::setEnabled);
connect(m_ui->checkMaxTime, &QCheckBox::toggled, m_ui->spinTimeLimit, &QSpinBox::setEnabled);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
connect(m_ui->buttonGroup, &QButtonGroup::idClicked, this, &TorrentOptionsDialog::handleRatioTypeChanged);
#else
connect(m_ui->buttonGroup, qOverload<int>(&QButtonGroup::buttonClicked)
, this, &TorrentOptionsDialog::handleRatioTypeChanged);
#endif
Utils::Gui::resize(this, m_storeDialogSize);
}

View File

@@ -81,13 +81,13 @@ void TrackerEntriesDialog::setTrackers(const QVector<BitTorrent::TrackerEntry> &
QVector<BitTorrent::TrackerEntry> TrackerEntriesDialog::trackers() const
{
const QString plainText = m_ui->plainTextEdit->toPlainText();
const QVector<QStringRef> lines = plainText.splitRef('\n');
const QList<QStringView> lines = QStringView(plainText).split(u'\n');
QVector<BitTorrent::TrackerEntry> entries;
entries.reserve(lines.size());
int tier = 0;
for (QStringRef line : lines)
for (QStringView line : lines)
{
line = line.trimmed();