File indexing completed on 2024-11-03 13:52:06
0001 // clang-format off 0002 /* 0003 * KDiff3 - Text Diff And Merge Tool 0004 * 0005 * SPDX-FileCopyrightText: 2018-2020 Michael Reeves reeves.87@gmail.com 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 // clang-format on 0009 0010 #ifndef UTILS_H 0011 #define UTILS_H 0012 0013 #include "TypeUtils.h" 0014 0015 #include <QChar> 0016 #include <QFontMetrics> 0017 #include <QString> 0018 #include <QStringList> 0019 #include <QUrl> 0020 0021 class Utils{ 0022 public: 0023 /* 0024 QUrl::toLocalFile does some special handling for locally visable windows network drives. 0025 If QUrl::isLocal however it returns false we get an empty string back. 0026 */ 0027 static QString urlToString(const QUrl &url); 0028 static bool wildcardMultiMatch(const QString& wildcard, const QString& testString, bool bCaseSensitive); 0029 static QString getArguments(QString cmd, QString& program, QStringList& args); 0030 inline static bool isEndOfLine(QChar c) { return c == '\n'; } //interally all line endings are converted to '\n' 0031 0032 static void calcTokenPos(const QString& s, qint32 posOnScreen, QtSizeType& pos1, QtSizeType& pos2); 0033 static QString calcHistoryLead(const QString& s); 0034 0035 private: 0036 static bool isCTokenChar(QChar c); 0037 }; 0038 0039 #endif