1 /*
2     Copyright (c) 2020, Lukas Holecek <hluk@email.cz>
3 
4     This file is part of CopyQ.
5 
6     CopyQ is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     CopyQ is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with CopyQ.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef TEXTDATA_H
21 #define TEXTDATA_H
22 
23 #include <QVariantMap>
24 
25 class QByteArray;
26 class QString;
27 
28 uint hash(const QVariantMap &data);
29 
30 QString quoteString(const QString &str);
31 
32 QString escapeHtml(const QString &str);
33 
34 QString getTextData(const QByteArray &bytes);
35 
36 /**
37  * Get given text format from data; null string if not available.
38  * Assumes that text data is UTF8 encoded.
39  */
40 QString getTextData(const QVariantMap &data, const QString &mime);
41 
42 /** Helper function that calls getTextData(data, "text/plain"). */
43 QString getTextData(const QVariantMap &data);
44 
45 void setTextData(QVariantMap *data, const QString &text, const QString &mime);
46 
47 void setTextData(QVariantMap *data, const QString &text);
48 
49 QVariantMap createDataMap(const QString &format, const QVariant &value);
50 
51 QVariantMap createDataMap(const QString &format, const QByteArray &value);
52 
53 QVariantMap createDataMap(const QString &format, const QString &value);
54 
55 /// Returns text without accents/diacritics.
56 QString accentsRemoved(const QString &text);
57 
58 #endif // TEXTDATA_H
59