-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditorview.cpp
More file actions
executable file
·52 lines (41 loc) · 1.2 KB
/
editorview.cpp
File metadata and controls
executable file
·52 lines (41 loc) · 1.2 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
#include <QWidget>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QMessageBox>
#include <QDir>
#include <QScrollArea>
#include <QTextStream>
#include "editorview.h"
#include "detailview.h"
#include "axsyntaxhighlighter.h"
EditorView::EditorView(DetailView *parent) :
QWidget(parent)
{
detailView = parent;
QFont font;
font.setFamily("Courier");
font.setFixedPitch(true);
font.setPointSize(10);
QVBoxLayout* mainVStack = new QVBoxLayout();
mainVStack->setMargin(0);
mainVStack->setSpacing(0);
textEdit = new QTextEdit(this);
textEdit->setFont(font);
textEdit->setLineWrapMode(QTextEdit::NoWrap);
mainVStack->addWidget(textEdit);
highlighter = new AXSyntaxHighlighter(textEdit->document());
this->setLayout(mainVStack);
}
void EditorView::readRecipeFile(QString path) {
QFile file (path);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in (&file);
this->textEdit->setPlainText(in.readAll());
file.close();
} else {
qDebug() << "File \"" << path << "\" cannot be read!";
}
}