-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnote.cpp
70 lines (60 loc) · 1.48 KB
/
note.cpp
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
#include "note.h"
#include "settings.h"
#include <QTextStream>
#include <QClipboard>
#include <QApplication>
#include <QDir>
#include <QPrinter>
/*
Note is abstract class for notes
*/
Note::Note(const QFileInfo& fileinfo, Note::Type type_new)
: _type(type_new),
file_info(fileinfo),
content_changed(false)
{
updateTitle(settings.getShowExtensions());
}
Note::~Note()
{
file.close();
file.remove();
}
//Setting note title
void Note::updateTitle(bool show_extensions)
{
file.setFileName(file_info.absoluteFilePath());
_title = (show_extensions || (file_info.fileName()[0]=='.'))
? file_info.fileName() : file_info.completeBaseName();
}
//Renaming note
void Note::rename(const QString& new_name)
{
file.close();
QString absolute_file_path = file_info.dir().absoluteFilePath(new_name);
file.rename(absolute_file_path);
file_info.setFile(file);
updateTitle(settings.getShowExtensions());
}
//Moving note to another folder
void Note::move(const QString& new_dirname)
{
file.close();
QString filename = file_info.fileName();
QString absolute_file_path = QDir(new_dirname).absoluteFilePath(filename);
file.rename(absolute_file_path);
file_info.setFile(file);
}
//Searching in a note's content
bool Note::find(const QString& text, bool from_start)
{
Q_UNUSED(text)
Q_UNUSED(from_start)
return false;
}
//------------------------------------------------------------------------------
//On note content changing
void Note::contentChanged()
{
content_changed = true;
}