libquentier  0.5.0
The library for rich desktop clients of Evernote service
Utility.h
1 /*
2  * Copyright 2016-2020 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LIB_QUENTIER_UTILITY_UTILITY_H
20 #define LIB_QUENTIER_UTILITY_UTILITY_H
21 
22 #include <quentier/types/ErrorString.h>
23 #include <quentier/utility/Linkage.h>
24 
25 #include <qt5qevercloud/QEverCloud.h>
26 
27 #include <QByteArray>
28 #include <QFileDialog>
29 #include <QFlags>
30 #include <QString>
31 #include <QStyle>
32 #include <QUrl>
33 #include <QtGlobal>
34 
35 #include <cstdint>
36 
40 #define SEC_TO_MSEC(sec) (sec * 1000)
41 
42 namespace quentier {
43 
48 void QUENTIER_EXPORT initializeLibquentier();
49 
57 bool QUENTIER_EXPORT checkGuid(const QString & guid);
58 
68 bool QUENTIER_EXPORT
69 checkUpdateSequenceNumber(const int32_t updateSequenceNumber);
70 
75 class QUENTIER_EXPORT DateTimePrint
76 {
77 public:
81  enum Option
82  {
87  IncludeNumericTimestamp = 1 << 1,
91  IncludeMilliseconds = 1 << 2,
97  IncludeTimezone = 1 << 3
98  };
99  Q_DECLARE_FLAGS(Options, Option)
100 };
101 
102 Q_DECLARE_OPERATORS_FOR_FLAGS(DateTimePrint::Options)
103 
104 
121 const QString QUENTIER_EXPORT printableDateTimeFromTimestamp(
122  const qint64 timestamp,
123  DateTimePrint::Options options = DateTimePrint::Options(
126  const char * customFormat = nullptr);
127 
137 const QString QUENTIER_EXPORT humanReadableSize(const quint64 bytes);
138 
153 const QString QUENTIER_EXPORT relativePathFromAbsolutePath(
154  const QString & absolutePath, const QString & relativePathRootFolderPath);
155 
159 QString QUENTIER_EXPORT getCurrentUserName();
160 
164 QString QUENTIER_EXPORT getCurrentUserFullName();
165 
169 void QUENTIER_EXPORT openUrl(const QUrl & url);
170 
179 bool QUENTIER_EXPORT removeFile(const QString & filePath);
180 
190 bool QUENTIER_EXPORT removeDir(const QString & dirPath);
191 
203 QByteArray QUENTIER_EXPORT
204 readFileContents(const QString & filePath, ErrorString & errorDescription);
205 
220 bool QUENTIER_EXPORT renameFile(
221  const QString & from, const QString & to, ErrorString & errorDescription);
222 
223 } // namespace quentier
224 
225 #endif // LIB_QUENTIER_UTILITY_UTILITY_H
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:43
Definition: DecryptedTextManager.h:26
Option
Definition: DateTime.h:43