-
Notifications
You must be signed in to change notification settings - Fork 351
/
Copy pathbookmarks.h
70 lines (53 loc) · 1.87 KB
/
bookmarks.h
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
#ifndef Header_Bookmarks
#define Header_Bookmarks
#include "mostQtHeaders.h"
#include "latexeditorview.h"
#include "latexdocument.h"
//class LatexEditorView;
//class LatexDocuments;
//class LatexDocument;
//class QDocumentLineHandle;
struct Bookmark {
Bookmark();
static Bookmark fromStringList(QStringList slist);
QStringList toStringList() const;
static Bookmark fromJSON(QJsonObject input);
QJsonObject toJSON() const;
QString filename;
int lineNumber;
int bookmarkNumber;
QString text;
};
class Bookmarks : public QObject
{
Q_OBJECT
public:
Bookmarks(const LatexDocuments *docs, QObject *parent = nullptr); ///< constructor
void setBookmarks(const QList<Bookmark> &bookmarkList); ///< set list of bookmarks
QList<Bookmark> getBookmarks(); ///< get list of bookmarks
QListWidget *widget() { return bookmarksWidget; } ///< get reference to bookmark list widget
signals:
void loadFileRequest(const QString &fileName); ///< request loading of file in order to jump to a bookmark position there
void gotoLineRequest(int lineNr, int col, LatexEditorView *edView); ///< jump to line of bookmark
public slots:
void bookmarkDeleted(QDocumentLineHandle *dlh);
void bookmarkAdded(QDocumentLineHandle *dlh, int nr);
void updateLineWithBookmark(int lineNr);
void restoreBookmarks(LatexEditorView *edView);
void updateBookmarks(LatexEditorView *edView);
void setDarkMode(bool mode);
protected slots:
void clickedOnBookmark(QListWidgetItem *item);
void moveBookmarkUp();
void moveBookmarkDown();
void removeBookmark();
void removeAllBookmarks();
private:
enum DataRole {FileName = Qt::UserRole, LineNr, DocLineHandle, BookmarkNr};
void initializeWidget();
void createContextMenu();
QListWidget *bookmarksWidget;
const LatexDocuments *documents;
bool m_darkMode;
};
#endif // BOOKMARKS_H