#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QFileDialog>
#include <QFile>

MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	ui->setupUi(this);
	connect(ui->actionOpen, SIGNAL(triggered(bool)), this, SLOT(openFile()));
}

MainWindow::~MainWindow()
{
	delete ui;
}

bool MainWindow::openFile()
{
	QString fileName = QFileDialog::getOpenFileName(this);
	if ( fileName.isEmpty() ) return false;

	QFile file(fileName);
	if ( ! file.open(QIODevice::ReadOnly | QIODevice::Text) )
		return false;

	ui->textEdit->setPlainText( QString( file.readAll() ) );
	return true;
}
