forked from proton/zNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
note.h
78 lines (65 loc) · 1.61 KB
/
note.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
71
72
73
74
75
76
77
78
#ifndef NOTE_H
#define NOTE_H
#include "settings.h"
#include <QFileInfo>
#include <QFile>
#include <QTextCharFormat>
#include <QPrinter>
class Note : public QObject
{
Q_OBJECT
public:
enum Type
{
type_text,
type_html,
type_picture,
#ifdef NOTE_TODO_FORMAT
type_todo,
#endif
#ifdef NOTE_XML_FORMAT
type_xml,
#endif
//type_count
};
public:
Note(const QFileInfo& fileinfo, Note::Type type_new);
virtual ~Note();
inline const QString& title() const { return _title; }
inline const QString absolutePath() const { return file_info.absoluteFilePath(); }
inline const QString fileName() const { return file_info.fileName(); }
inline Type type() const { return _type; }
virtual QWidget* widget() = 0;
void updateTitle(bool show_extensions);
virtual void load() = 0; //Reading note's content
virtual void save(bool forced = false) = 0; //Saving note's content
void rename(const QString& new_name);
void move(const QString& new_dir);
virtual void copy() const = 0; //Coping note's content to clipboard
virtual bool find(const QString& text, bool from_start=false); //Searching text in a note's content
virtual void setSelFormat(const QTextCharFormat& format)
{
Q_UNUSED(format)
}
virtual QTextCharFormat getSelFormat() const
{
return QTextCharFormat();
}
virtual void retranslate(const QLocale& locale)
{
Q_UNUSED(locale)
}
virtual bool isDocumentSupported() const = 0;
virtual QTextDocument * document() const = 0;
private:
Type _type;
QString _title;
QFileInfo file_info;
protected:
QFile file;
//
bool content_changed;
protected slots:
void contentChanged();
};
#endif // NOTE_H