-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcoursewindow.cpp
More file actions
60 lines (52 loc) · 1.34 KB
/
coursewindow.cpp
File metadata and controls
60 lines (52 loc) · 1.34 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
#include "coursewindow.h"
#include "ui_coursewindow.h"
#include <QFileDialog>
#include <QDir>
#include "differenceswidget.h"
#include "change.h"
#include <QDebug>
#include <QFile>
CourseWindow::CourseWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::CourseWindow)
{
ui->setupUi(this);
mergeNote = NULL;
chapter = NULL;
differences = new DifferencesWidget();
ui->verticalLayout->addWidget(differences);
}
CourseWindow::~CourseWindow()
{
delete ui;
}
void CourseWindow::setChapter(Chapter* chapter){
this->chapter = chapter;
}
void CourseWindow::setMergeNote(Note *note){
mergeNote = note;
}
Chapter* CourseWindow::getChapter(){
return chapter;
}
void CourseWindow::displayDifferences(){
if(chapter != NULL && mergeNote != NULL
&& !(mergeNote->getText().isEmpty())
){
mergeNote->clearChangeLog();
chapter->findDifferences(mergeNote);
QVector<Change*> changeLog = mergeNote->getChangeLog();
differences->addDifferences(changeLog, chapter);
mergeNote->clearChangeLog();
}
}
void CourseWindow::on_confirmBtn_clicked()
{
QFile file(chapter->getMainNote()->getFilePath());
if (file.open(QIODevice::WriteOnly | QIODevice::Text)){
QTextStream out(&file);
out << chapter->getMainNote()->getText();
}
file.close();
close();
}