From 9ea334d08f42f3c362e86499dc3c0ed658bb428c Mon Sep 17 00:00:00 2001 From: keshavbhatt Date: Mon, 5 Apr 2021 02:11:25 +0530 Subject: src init --- src/utils.h | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/utils.h (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..9d2520f --- /dev/null +++ b/src/utils.h @@ -0,0 +1,85 @@ +#ifndef UTILS_H +#define UTILS_H + +#include +#include +#include +#include +#include +#include +#include + +class utils : public QObject +{ + Q_OBJECT + +public: + utils(QObject* parent=0); + virtual ~utils(); +public slots: + static QString refreshCacheSize(const QString cache_dir); + static bool delete_cache(const QString cache_dir); + static QString toCamelCase(const QString &s); + static QString generateRandomId(int length); + static QString genRand(int length); + static QString convertSectoDay(qint64 secs); + static QString returnPath(QString pathname); + + static QString EncodeXML ( const QString& encodeMe ){ + + QString temp; + int length = encodeMe.size(); + for (int index = 0; index < length; index++) + { + QChar character(encodeMe.at(index)); + + switch (character.unicode()) + { + case '&': + temp += "&"; break; + + case '\'': + temp += "'"; break; + + case '"': + temp += """; break; + + case '<': + temp += "<"; break; + + case '>': + temp += ">"; break; + + default: + temp += character; + break; + } + } + + return temp; + } + + static QString DecodeXML ( const QString& decodeMe ) { + + QString temp(decodeMe); + + temp.replace("&", "&"); + temp.replace("'", "'"); + temp.replace(""", "\""); + temp.replace("<", "<"); + temp.replace(">", ">"); + + return temp; + } + + static QString htmlToPlainText(QString str); + +private slots: + //use refreshCacheSize + static quint64 dir_size(const QString &directory); + + + +}; + +#endif // UTILS_H -- cgit v1.2.3