diff --git a/verify/mainwindow.cpp b/verify/mainwindow.cpp index e66947c58..18d5c321f 100644 --- a/verify/mainwindow.cpp +++ b/verify/mainwindow.cpp @@ -28,6 +28,8 @@ #include #include +#include + static void arrayIndex(const Tokenizer &tokenizer, std::set &errorlines); static unsigned char readChar(std::istream &istr) @@ -49,8 +51,22 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); + connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open())); +} - const std::string fileName("../lib/tokenize.cpp"); +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::open() +{ + const std::string fileName = QFileDialog::getOpenFileName(this, + tr("Open File"), + "", + "cpp files (*.cpp)").toStdString(); + if (fileName.empty()) + return; setWindowTitle(fileName.c_str()); @@ -99,11 +115,7 @@ MainWindow::MainWindow(QWidget *parent) } ui->plainTextEdit->setPlainText(QString::fromStdString(report.str())); } -} -MainWindow::~MainWindow() -{ - delete ui; } diff --git a/verify/mainwindow.h b/verify/mainwindow.h index 421b62137..34db65a84 100644 --- a/verify/mainwindow.h +++ b/verify/mainwindow.h @@ -23,7 +23,7 @@ namespace Ui { - class MainWindow; +class MainWindow; } class MainWindow : public QMainWindow @@ -34,6 +34,9 @@ public: MainWindow(QWidget *parent = 0); ~MainWindow(); +private slots: + void open(); + private: Ui::MainWindow *ui; }; diff --git a/verify/mainwindow.ui b/verify/mainwindow.ui index 93a032cf6..5a93f241f 100644 --- a/verify/mainwindow.ui +++ b/verify/mainwindow.ui @@ -33,6 +33,13 @@ 25 + + + File + + + + @@ -43,6 +50,11 @@ + + + Open.. + +