forked from vnotex/vnote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvhistorylist.h
More file actions
102 lines (66 loc) · 2.28 KB
/
vhistorylist.h
File metadata and controls
102 lines (66 loc) · 2.28 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef VHISTORYLIST_H
#define VHISTORYLIST_H
#include <QWidget>
#include <QLinkedList>
#include "vhistoryentry.h"
#include "vnavigationmode.h"
class QPushButton;
class VListWidget;
class QListWidgetItem;
class QShowEvent;
class QFocusEvent;
class VHistoryList : public QWidget, public VNavigationMode
{
Q_OBJECT
public:
explicit VHistoryList(QWidget *p_parent = nullptr);
void pinFiles(const QStringList &p_files);
void pinFolder(const QString &p_folder);
const QLinkedList<VHistoryEntry> &getHistoryEntries() const;
// Implementations for VNavigationMode.
void showNavigation() Q_DECL_OVERRIDE;
bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
public slots:
void addFile(const QString &p_filePath);
protected:
void showEvent(QShowEvent *p_event) Q_DECL_OVERRIDE;
void focusInEvent(QFocusEvent *p_event) Q_DECL_OVERRIDE;
private slots:
void handleContextMenuRequested(QPoint p_pos);
void openSelectedItems() const;
void openItem(const QListWidgetItem *p_item) const;
void pinSelectedItems();
void unpinSelectedItems();
void locateCurrentItem() const;
// Add selected files to Cart.
void addFileToCart() const;
private:
void setupUI();
// Read data from config file.
void init();
void updateList();
QLinkedList<VHistoryEntry>::iterator findFileInHistory(const QString &p_file);
QString getFilePath(const QListWidgetItem *p_item) const;
VHistoryEntry *getHistoryEntry(const QListWidgetItem *p_item) const;
bool isFolder(const QListWidgetItem *p_item) const;
// @p_isPinned won't change it if an item is pinned already.
void addFilesInternal(const QStringList &p_files, bool p_isPinned);
void unpinFiles(const QStringList &p_files);
void checkHistorySize();
QPushButton *m_clearBtn;
VListWidget *m_itemList;
// Whether data is loaded.
bool m_initialized;
bool m_uiInitialized;
// New files are appended to the end.
QLinkedList<VHistoryEntry> m_histories;
// Whether we need to update the list.
bool m_updatePending;
QDate m_currentDate;
};
inline const QLinkedList<VHistoryEntry> &VHistoryList::getHistoryEntries() const
{
const_cast<VHistoryList *>(this)->init();
return m_histories;
}
#endif // VHISTORYLIST_H