File indexing completed on 2024-04-28 04:52:48
0001 /* 0002 SPDX-FileCopyrightText: 2023 Julius Künzel <jk.kdedev@smartlab.uber.space> 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #pragma once 0007 0008 #include <QString> 0009 #include <QStringList> 0010 0011 class QStringUtils 0012 { 0013 public: 0014 /** @returns a name based on @param name that is unique in @param names. 0015 * This is achieved by adding a number as suffix to the @param name in case name 0016 * does already exist in @param names. 0017 */ 0018 static QString getUniqueName(const QStringList &names, const QString &name); 0019 /** @returns a file name based on @param name that is unique in @param names. 0020 * This is achieved by adding a number as suffix before the extension to the @param name in case name 0021 * does already exist in @param names. 0022 */ 0023 static QString getUniqueFileName(const QStringList &names, const QString &name); 0024 /** Append @param appendix to @param filename before the file extension. 0025 * The part of the string after the last dot will be treated as file extension. 0026 * Hence it does not work with extensions like .tar.gz 0027 */ 0028 static QString appendToFilename(const QString &filename, const QString &appendix); 0029 };