diff options
Diffstat (limited to 'qtmips_gui/srceditor.cpp')
-rw-r--r-- | qtmips_gui/srceditor.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/qtmips_gui/srceditor.cpp b/qtmips_gui/srceditor.cpp index 2f4d3a6..e8bdb85 100644 --- a/qtmips_gui/srceditor.cpp +++ b/qtmips_gui/srceditor.cpp @@ -41,12 +41,21 @@ #include "srceditor.h" -SrcEditor::SrcEditor(QWidget *parent) : Super(parent) { +void SrcEditor::setup_common() { + QFont font; + font.setFamily("Courier"); + font.setFixedPitch(true); + font.setPointSize(10); + setFont(font); tname = "Unknown"; } +SrcEditor::SrcEditor(QWidget *parent) : Super(parent) { + setup_common(); +} + SrcEditor::SrcEditor(const QString &text, QWidget *parent) : Super(text, parent) { - tname = "Unknown"; + setup_common(); } SrcEditor::~SrcEditor() { @@ -74,6 +83,16 @@ bool SrcEditor::loadFile(QString filename) { } } +bool SrcEditor::loadByteArray(const QByteArray &content, QString filename) { + setPlainText(QString::fromUtf8(content.data(), content.size())); + if (!filename.isEmpty()) { + QFileInfo fi(filename); + fname = filename; + tname = fi.fileName(); + } + return true; +} + bool SrcEditor::saveFile(QString filename) { if (filename.isEmpty()) filename = this->filename(); |