mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-07 05:31:25 -07:00
Improve function interface
`SettingsStorage` methods require `QString` so make `SettingValue` follow it. `Path::operator+` can use `QStringView` to accept wider audience.
This commit is contained in:
parent
11cfe38d1c
commit
c6b772da11
33 changed files with 222 additions and 239 deletions
|
@ -37,6 +37,7 @@
|
|||
#include <QList>
|
||||
#include <QMimeDatabase>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringView>
|
||||
|
||||
#include "base/global.h"
|
||||
|
||||
|
@ -202,17 +203,12 @@ Path &Path::operator/=(const Path &other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
Path &Path::operator+=(const QString &str)
|
||||
Path &Path::operator+=(const QStringView str)
|
||||
{
|
||||
*this = *this + str;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Path &Path::operator+=(const std::string &str)
|
||||
{
|
||||
return (*this += QString::fromStdString(str));
|
||||
}
|
||||
|
||||
Path Path::commonPath(const Path &left, const Path &right)
|
||||
{
|
||||
if (left.isEmpty() || right.isEmpty())
|
||||
|
@ -305,19 +301,9 @@ Path operator/(const Path &lhs, const Path &rhs)
|
|||
return Path(lhs.m_pathStr + u'/' + rhs.m_pathStr);
|
||||
}
|
||||
|
||||
Path operator+(const Path &lhs, const QString &rhs)
|
||||
Path operator+(const Path &lhs, const QStringView rhs)
|
||||
{
|
||||
return Path(lhs.m_pathStr + rhs);
|
||||
}
|
||||
|
||||
Path operator+(const Path &lhs, const char rhs[])
|
||||
{
|
||||
return lhs + QString::fromLatin1(rhs);
|
||||
}
|
||||
|
||||
Path operator+(const Path &lhs, const std::string &rhs)
|
||||
{
|
||||
return lhs + QString::fromStdString(rhs);
|
||||
return Path(lhs.data() + rhs);
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const Path &path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue