forked from torinkwok/wxNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoteBookTree.cpp
More file actions
176 lines (144 loc) · 7.9 KB
/
Copy pathNoteBookTree.cpp
File metadata and controls
176 lines (144 loc) · 7.9 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
///:
/*****************************************************************************
** **
** .======. **
** | INRI | **
** | | **
** | | **
** .========' '========. **
** | _ xxxx _ | **
** | /_;-.__ / _\ _.-;_\ | **
** | `-._`'`_/'`.-' | **
** '========.`\ /`========' **
** | | / | **
** |/-.( | **
** |\_._\ | **
** | \ \`;| **
** | > |/| **
** | / // | **
** | |// | **
** | \(\ | **
** | `` | **
** | | **
** | | **
** | | **
** | | **
** \\ _ _\\| \// |//_ _ \// _ **
** ^ `^`^ ^`` `^ ^` ``^^` `^^` `^ `^ **
** **
** Copyright © 1997-2013 by Tong G. **
** ALL RIGHTS RESERVED. **
** **
****************************************************************************/
#include "wxNote_Gui/wxNote_Tree/NoteBookTree.h"
#include "wxNote_Global.h"
#include <QTreeWidgetItem>
#include <QStringList>
#include <QAction>
//.._NoteBookTree类实现
int _NoteBookTree::s_AllNotesCnt = 0;
int _NoteBookTree::s_TrashCnt = 0;
/* 构造函数实现 */
_NoteBookTree::_NoteBookTree(QWidget *_Parent)
: QTreeWidget(_Parent)
{
setColumnCount(m_ColumnCnt);
/* "笔记"根 */
m_NoteBookRootItem = new QTreeWidgetItem(this, QStringList() << wxNote::g_NoteBooksName);
m_NoteBookRootItem->setIcon(0, QIcon(":/wxNote_Icons/noteBook.png"));
m_AllNoteBookSubItem = new QTreeWidgetItem(m_NoteBookRootItem,
QStringList() << wxNote::g_AllNotesName);
m_AllNoteBookSubItem->setIcon(0, QIcon(":/wxNote_Icons/allNotes.png"));
/* "标签"根 */
m_LabelRootItem = new QTreeWidgetItem(this, QStringList() << wxNote::g_LabelName);
m_LabelRootItem->setIcon(0, QIcon(":/wxNote_Icons/label.png"));
/* "属性"根 */
m_PropertiesRootItem = new QTreeWidgetItem(this, QStringList() << wxNote::g_PropertiesName);
m_PropertiesRootItem->setIcon(0, QIcon(":/wxNote_Icons/property.png"));
/* "废纸篓"根 */
m_TrashRootItem = new QTreeWidgetItem(this, QStringList() << wxNote::g_TrashName);
m_TrashRootItem->setIcon(0, QIcon(":/wxNote_Icons/trash.png"));
// _CreateContextMenu()存在BUG!
setCurrentItem(m_AllNoteBookSubItem);
setIconSize(QSize(30,30));
setHeaderLabels(QStringList() << wxNote::g_NoteBooksName);
setHeaderHidden(true);
_RestoreUsersNoteBook();
}
/* _NoteBookCountIncreaseSlot()槽实现 */
void _NoteBookTree::_NoteBookCountIncreaseSlot()
{
m_AllNoteBookSubItem->setText(0, wxNote::g_AllNotesName);
}
/* _NoteBookCountDecreaseSlot()槽实现 */
void _NoteBookTree::_NoteBookCountDecreaseSlot()
{
m_AllNoteBookSubItem->setText(0, wxNote::g_AllNotesName);
}
/* _TrashCountIncreaseSlot()槽实现 */
void _NoteBookTree::_TrashCountIncreaseSlot()
{
m_TrashRootItem->setText(0, wxNote::g_TrashName);
}
/* _TrashCountDecreaseSlot()槽实现 */
void _NoteBookTree::_TrashCountDecreaseSlot()
{
m_TrashRootItem->setText(0, wxNote::g_TrashName);
}
/////////////////////////////////////////////////////////////////////////
//..protected部分
/* _CreateActionOnContextMenu()函数实现 */
void _NoteBookTree::_CreateActionsOnContextMenu()
{
/* "新建笔记本"动作 */
m_NewNoteBookAction = new QAction(tr("新建笔记本(&C)"), this);
m_NewNoteBookAction->setShortcut(tr("Insert"));
m_NewNoteBookAction->setToolTip(tr("新建笔记本"));
/* "重命名 笔记本"动作 */
m_RenameAction = new QAction(tr("重命名(&R)"), this);
m_RenameAction->setShortcut(tr("F2"));
m_RenameAction->setToolTip(tr("重命名笔记本"));
/* "删除笔记本" 动作 */
m_DeleteNoteBookAction = new QAction(tr("删除(&D)..."), this);
m_DeleteNoteBookAction->setShortcut(QKeySequence::Delete);
m_DeleteNoteBookAction->setToolTip(tr("删除笔记本"));
}
/* _CreateContextMenu()函数实现 */
void _NoteBookTree::_CreateContextMenu()
{
addAction(m_NewNoteBookAction);
addAction(m_RenameAction);
addAction(m_DeleteNoteBookAction);
setContextMenuPolicy(Qt::ActionsContextMenu);
}
/* _RestoreUsersNoteBook()函数实现 */
void _NoteBookTree::_RestoreUsersNoteBook()
{
using namespace wxNote;
g_Settings.beginGroup("MainWindow");
QStringList _UserNoteBookNameList =
g_Settings.value("UserNoteBookNames").toStringList();
g_Settings.endGroup();
g_UserNoteBookNameList = _UserNoteBookNameList;
for (const QString& _Elem : _UserNoteBookNameList)
{
QTreeWidgetItem* _NewNoteBookItem =
new QTreeWidgetItem(m_NoteBookRootItem, QStringList() << _Elem);
_NewNoteBookItem->setIcon(0, QIcon(":/wxNote_Icons/noteBook.png"));
}
}
////////////////////////////////////////////////////////////////////////////
/***************************************************************************
** **
** _________ _______ **
** |___ ___| / ______ \ **
** | | _______ _______ _______ | / |_| **
** | | || || || || || || | | _ __ **
** | | || || || || || || | | |__ \ **
** | | || || || || || || | \_ _ __| | _ **
** |_| ||_____|| || || ||_____|| \________/ |_| **
** || **
** ||_____|| **
** **
***************************************************************************/
///:~