Skip to content

Commit

Permalink
remove usage of QStringRef due to it being missing in Qt6
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed May 27, 2022
1 parent d3050f7 commit a1a409d
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/common/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ bool Utility::isConflictFile(const char *name)

bool Utility::isConflictFile(const QString &name)
{
auto bname = name.midRef(name.lastIndexOf(QLatin1Char('/')) + 1);
auto bname = name.mid(name.lastIndexOf(QLatin1Char('/')) + 1);

if (bname.contains(QStringLiteral("_conflict-")))
return true;
Expand Down
10 changes: 5 additions & 5 deletions src/csync/csync_exclude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static const char *win_reserved_words_n[] = { "CLOCK$", "$Recycle.Bin" };
* @param file_name filename
* @return true if file is reserved, false otherwise
*/
OCSYNC_EXPORT bool csync_is_windows_reserved_word(const QStringRef &filename)
OCSYNC_EXPORT bool csync_is_windows_reserved_word(const QStringView &filename)
{
size_t len_filename = filename.size();

Expand Down Expand Up @@ -132,10 +132,10 @@ OCSYNC_EXPORT bool csync_is_windows_reserved_word(const QStringRef &filename)
static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool excludeConflictFiles)
{
/* split up the path */
QStringRef bname(&path);
QStringView bname(path);
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
if (lastSlash >= 0) {
bname = path.midRef(lastSlash + 1);
bname = path.mid(lastSlash + 1);
}

qsizetype blen = bname.size();
Expand Down Expand Up @@ -441,10 +441,10 @@ CSYNC_EXCLUDE_TYPE ExcludedFiles::traversalPatternMatch(const QString &path, Ite

// Check the bname part of the path to see whether the full
// regex should be run.
QStringRef bnameStr(&path);
QStringView bnameStr(path);
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
if (lastSlash >= 0) {
bnameStr = path.midRef(lastSlash + 1);
bnameStr = path.mid(lastSlash + 1);
}

QString basePath(_localPath + path);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ void Folder::slotWatchedPathChanged(const QString &path, ChangeReason reason)
return;
}

auto relativePath = path.midRef(this->path().size());
auto relativePath = path.mid(this->path().size());

// Add to list of locally modified paths
//
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void Folder::slotFolderConflicts(const QString &folder, const QStringList &confl
r.setNumOldConflictItems(conflictPaths.size() - r.numNewConflictItems());
}

void Folder::warnOnNewExcludedItem(const SyncJournalFileRecord &record, const QStringRef &path)
void Folder::warnOnNewExcludedItem(const SyncJournalFileRecord &record, const QStringView &path)
{
// Never warn for items in the database
if (record.isValid())
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ private slots:
void slotFolderConflicts(const QString &folder, const QStringList &conflictPaths);

/** Warn users if they create a file or folder that is selective-sync excluded */
void warnOnNewExcludedItem(const SyncJournalFileRecord &record, const QStringRef &path);
void warnOnNewExcludedItem(const SyncJournalFileRecord &record, const QStringView &path);

/** Warn users about an unreliable folder watcher */
void slotWatcherUnreliable(const QString &message);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ QStringList FolderMan::findFileInLocalFolders(const QString &relPath, const Acco
continue;

QString path = folder->cleanPath() + '/';
path += serverPath.midRef(folder->remotePathTrailingSlash().length());
path += serverPath.mid(folder->remotePathTrailingSlash().length());
if (QFile::exists(path)) {
re.append(path);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/sharemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void updateFolder(const AccountPtr &account, const QString &path)
if (path.startsWith(folderPath) && (path == folderPath || folderPath.endsWith('/') || path[folderPath.size()] == '/')) {
// Workaround the fact that the server does not invalidate the etags of parent directories
// when something is shared.
auto relative = path.midRef(f->remotePathTrailingSlash().length());
auto relative = path.mid(f->remotePathTrailingSlash().length());
f->journalDb()->schedulePathForRemoteDiscovery(relative.toString());

// Schedule a sync so it can update the remote permission flag and let the socket API
Expand Down
4 changes: 2 additions & 2 deletions src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void SocketApi::slotReadSocket()
const QString line = QString::fromUtf8(socket->readLine().trimmed()).normalized(QString::NormalizationForm_C);
qCInfo(lcSocketApi) << "Received SocketAPI message <--" << line << "from" << socket;
const int argPos = line.indexOf(QLatin1Char(':'));
const QByteArray command = line.midRef(0, argPos).toUtf8().toUpper();
const QByteArray command = line.mid(0, argPos).toUtf8().toUpper();
const int indexOfMethod = [&] {
QByteArray functionWithArguments = QByteArrayLiteral("command_");
if (command.startsWith("ASYNC_")) {
Expand All @@ -380,7 +380,7 @@ void SocketApi::slotReadSocket()
return out;
}();

const auto argument = argPos != -1 ? line.midRef(argPos + 1) : QStringRef();
const auto argument = argPos != -1 ? line.mid(argPos + 1) : QStringView();
if (command.startsWith("ASYNC_")) {
auto arguments = argument.split('|');
if (arguments.size() != 2) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/updater/updateinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ UpdateInfo UpdateInfo::parseString(const QString &xml, bool *ok)
QDomDocument doc;
if (!doc.setContent(xml, false, &errorMsg, &errorLine, &errorCol)) {
qCWarning(lcUpdater).noquote().nospace() << errorMsg << " at " << errorLine << "," << errorCol
<< "\n" << xml.splitRef("\n").value(errorLine-1) << "\n"
<< "\n" << xml.split("\n").value(errorLine-1) << "\n"
<< QString(" ").repeated(errorCol - 1) << "^\n"
<< "->" << xml << "<-";
if (ok)
Expand Down
8 changes: 4 additions & 4 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,20 +489,20 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)

const auto regex = syncOptions().fileRegex();
if (regex.isValid()) {
QSet<QStringRef> names;
QSet<QStringView> names;
for (auto &i : items) {
if (regex.match(i->_file).hasMatch()) {
int index = -1;
QStringRef ref;
QStringView ref;
do {
ref = i->_file.midRef(0, index);
ref = i->_file.mid(0, index);
names.insert(ref);
index = ref.lastIndexOf(QLatin1Char('/'));
} while (index > 0);
}
}
items.erase(std::remove_if(items.begin(), items.end(), [&names](auto i) {
return !names.contains(QStringRef { &i->_file });
return !names.contains(QStringView { i->_file });
}),
items.end());
}
Expand Down
2 changes: 1 addition & 1 deletion test/testexcludedfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ private slots:
{
auto csync_is_windows_reserved_word = [](const char *fn) {
QString s = QString::fromLatin1(fn);
extern bool csync_is_windows_reserved_word(const QStringRef &filename);
extern bool csync_is_windows_reserved_word(const QStringView &filename);
return csync_is_windows_reserved_word(&s);
};

Expand Down

0 comments on commit a1a409d

Please sign in to comment.