-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoteeditor.cpp
More file actions
47 lines (37 loc) · 1 KB
/
Copy pathnoteeditor.cpp
File metadata and controls
47 lines (37 loc) · 1 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
#include <string>
#include <QString>
#include "ui_noteeditor.h"
#include "noteeditor.h"
#include "notepad.h"
NoteEditor::NoteEditor(Notepad* parent, Note* note, bool readonly)
: QDialog(), ui(new Ui::NoteEditor)
{
ui->setupUi(this);
currentNote = note;
QString s = QString::fromStdString(currentNote->getBody());
ui->textEdit->insertPlainText(s);
if(readonly)
{
ui->textEdit->setReadOnly(true);
ui->saveButton->setEnabled(false);
ui->cancelButton->setEnabled(false);
}
connect(this, &NoteEditor::done_editing, parent, &Notepad::editor_closed);
}
NoteEditor::~NoteEditor()
{
delete ui;
}
void NoteEditor::on_saveButton_clicked()
{
QString saved_text = ui->textEdit->toPlainText();
std::string saved_str = saved_text.toStdString();
currentNote->setBody(saved_str);
emit done_editing();
this->close();
}
void NoteEditor::on_cancelButton_clicked()
{
emit done_editing();
this->close();
}