forked from vnotex/vnote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvhistoryentry.h
More file actions
64 lines (53 loc) · 1.68 KB
/
vhistoryentry.h
File metadata and controls
64 lines (53 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef VHISTORYENTRY_H
#define VHISTORYENTRY_H
#include <QDate>
#include <QSettings>
namespace HistoryConfig
{
static const QString c_file = "file";
static const QString c_date = "date";
static const QString c_pinned = "pinned";
static const QString c_isFolder = "is_folder";
}
class VHistoryEntry
{
public:
VHistoryEntry()
: m_isPinned(false),
m_isFolder(false)
{
}
VHistoryEntry(const QString &p_file,
const QDate &p_date,
bool p_isPinned = false,
bool p_isFolder = false)
: m_file(p_file), m_isPinned(p_isPinned), m_isFolder(p_isFolder)
{
m_date = p_date.toString(Qt::ISODate);
}
// Fetch VHistoryEntry from @p_settings.
static VHistoryEntry fromSettings(const QSettings *p_settings)
{
VHistoryEntry entry;
entry.m_file = p_settings->value(HistoryConfig::c_file).toString();
entry.m_date = p_settings->value(HistoryConfig::c_date).toString();
entry.m_isPinned = p_settings->value(HistoryConfig::c_pinned).toBool();
entry.m_isFolder = p_settings->value(HistoryConfig::c_isFolder).toBool();
return entry;
}
void toSettings(QSettings *p_settings) const
{
p_settings->setValue(HistoryConfig::c_file, m_file);
p_settings->setValue(HistoryConfig::c_date, m_date);
p_settings->setValue(HistoryConfig::c_pinned, m_isPinned);
p_settings->setValue(HistoryConfig::c_isFolder, m_isFolder);
}
// File path.
QString m_file;
// Accessed date.
// UTC in Qt::ISODate format.
QString m_date;
bool m_isPinned;
bool m_isFolder;
};
#endif // VHISTORYENTRY_H