-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.h
More file actions
168 lines (151 loc) · 4.15 KB
/
mainwindow.h
File metadata and controls
168 lines (151 loc) · 4.15 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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "notewidget.h"
#include <QVector>
#include <QSettings>
#include <QFont>
#include <QListWidgetItem>
#include "finddialog.h"
#include <QSystemTrayIcon>
#include "qxtglobalshortcut.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
enum {
FILE_CREATE_TIME = Qt::UserRole + 1,
FILE_MODIFY_TIME
};
enum SortType {
SORT_BY_NAME,
SORT_BY_CREAT_AORDER,
SORT_BY_CREAT_DORDER,
SORT_BY_MODIFY_AORDER,
SORT_BY_MODIFY_DORDER
};
class MyListWidgetItem : public QListWidgetItem
{
public:
MyListWidgetItem(QListWidget *parent=0):QListWidgetItem(parent){}
bool operator<(const QListWidgetItem &other) const
{
bool ret = false;
switch (m_sort_type)
{
case SORT_BY_NAME:
{
ret = QListWidgetItem::operator<(other);
}
break;
case SORT_BY_CREAT_AORDER:
case SORT_BY_CREAT_DORDER:
{
uint32_t a, b;
a = this->data(FILE_CREATE_TIME).toUInt();
b = other.data(FILE_CREATE_TIME).toUInt();
ret = a < b;
}
break;
case SORT_BY_MODIFY_AORDER:
case SORT_BY_MODIFY_DORDER:
{
uint32_t a, b;
a = this->data(FILE_MODIFY_TIME).toUInt();
b = other.data(FILE_MODIFY_TIME).toUInt();
ret = a < b;
}
break;
default:
{
ret = QListWidgetItem::operator<(other);
}
break;
}
return(ret);
}
void setSortType(SortType t)
{
m_sort_type = t;
}
private:
SortType m_sort_type;
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
protected:
bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
public slots:
void sltActionFontClick();
void sltLeftDoubleClicked(QListWidgetItem *item);
void sltRemoveTab(int index);
void sltTabDoubleClicked(int index);
void sltActionFind();
void sltActionReplace();
void sltActionSave();
void sltHotKey();
void sltTrayActived(QSystemTrayIcon::ActivationReason reason);
void sltExit();
void sltSet();
void sltKeepTop();
void sltDarkMode();
void sltAbout();
void sltTabMenuRequested(const QPoint &pos);
void sltActionDelete();
void sltActionRename();
void sltActionCloseLeft();
void sltActionCloseRight();
void sltActionCloseOther();
void sltActionNew();
void sltActionHelp();
void sltComboboxMenuRequested(const QPoint &pos);
void sltComboActionNew();
void sltComboActionRename();
void sltComboActionDelete();
void sltCurrentIndexChanged(const QString &text);
void sltListActonDelete();
void sltListMenuRequested(const QPoint &pos);
void sltListActionMove();
void sltTabActionMove();
public:
bool find(QString& text,QTextDocument::FindFlags flags);
bool replace(QString& findText, QString& replaceText, QTextDocument::FindFlags flags, bool replaceAll = false);
void newTab();
void renameTab(int tabIndex, QString& newName);
void save();
void initNoteBook();
void refreshMenu();
void sortFileList();
private:
Ui::MainWindow *ui;
QVector<NoteWidget*> m_vecNoteWidget;
QSettings* m_setting;
QFont m_editor_font;
FindDialog* m_findDlg;
QSystemTrayIcon* m_pTrayIcon;
QxtGlobalShortcut* m_shortcut;
QAction* m_action_exit;
QString m_hotkey;
bool m_can_exit;
QAction* m_action_new;
QAction* m_action_rename;
QAction* m_action_delete;
QAction* m_action_close_left;
QAction* m_action_close_right;
QAction* m_action_close_other;
QMenu* m_tabMenu;
QMenu* m_comboMenu;
QAction* m_combo_action_new;
QAction* m_combo_action_rename;
QAction* m_combo_action_delete;
QString m_notebook;
QMenu* m_listMenu;
QAction* m_list_action_delete;
QMenu* m_listMoveMenu;
QMenu* m_tabMoveMenu;
SortType m_sort_type;
};
#endif // MAINWINDOW_H