# HG changeset patch # User Jacob Dawid # Date 1302605335 -7200 # Node ID 12697e9bb608df604e5218c1a182e57a79911fa3 # Parent 1e76b221bc4aa2c4b5c26a094d9804cfe1dddd09 Files can be edited and saved. diff --git a/gui//src/FileEditorMdiSubWindow.cpp b/gui//src/FileEditorMdiSubWindow.cpp --- a/gui//src/FileEditorMdiSubWindow.cpp +++ b/gui//src/FileEditorMdiSubWindow.cpp @@ -2,6 +2,7 @@ #include #include #include +#include FileEditorMdiSubWindow::FileEditorMdiSubWindow(QWidget *parent) : QMdiSubWindow(parent) { @@ -9,6 +10,7 @@ } void FileEditorMdiSubWindow::loadFile(QString fileName) { + m_fileName = fileName; setWindowTitle(fileName); QFile file(fileName); file.open(QFile::ReadOnly); @@ -18,6 +20,14 @@ file.close(); } +void FileEditorMdiSubWindow::saveFile() { + QString saveFileName = QFileDialog::getSaveFileName(this, "Save File", m_fileName); + QFile file(saveFileName); + file.open(QFile::WriteOnly); + file.write(m_codeEdit->toPlainText().toLocal8Bit()); + file.close(); +} + void FileEditorMdiSubWindow::construct() { QStyle *style = QApplication::style(); setWidget(new QWidget()); @@ -50,4 +60,5 @@ connect(undoAction, SIGNAL(triggered()), m_codeEdit, SLOT(undo())); connect(redoAction, SIGNAL(triggered()), m_codeEdit, SLOT(redo())); + connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile())); } diff --git a/gui//src/FileEditorMdiSubWindow.h b/gui//src/FileEditorMdiSubWindow.h --- a/gui//src/FileEditorMdiSubWindow.h +++ b/gui//src/FileEditorMdiSubWindow.h @@ -7,15 +7,20 @@ #include "CodeEdit.h" class FileEditorMdiSubWindow : public QMdiSubWindow { + Q_OBJECT public: FileEditorMdiSubWindow(QWidget *parent = 0); void loadFile(QString fileName); +public slots: + void saveFile(); + private: void construct(); QToolBar *m_toolBar; CodeEdit *m_codeEdit; QStatusBar *m_statusBar; + QString m_fileName; }; #endif // FILEEDITORMDISUBWINDOW_H