added main menu and implemented new view function

pull/16/head
Marc Zinnschlag 12 years ago
parent 758371d7e4
commit 789cecb9df

@ -4,6 +4,7 @@
#include <iostream>
#include <QCloseEvent>
#include <QMenuBar>
#include "viewmanager.hpp"
@ -13,11 +14,25 @@ void CSVDoc::View::closeEvent (QCloseEvent *event)
event->ignore();
}
void CSVDoc::View::setupUi()
{
// window menu
QMenu *view = menuBar()->addMenu (tr ("&View"));
QAction *newWindow = new QAction (tr ("&New View"), this);
connect (newWindow, SIGNAL (triggered()), this, SLOT (newView()));
view->addAction (newWindow);
}
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document)
: mViewManager (viewManager), mDocument (document)
{
setCentralWidget (new QWidget);
resize (200, 200);
setWindowTitle ("New Document");
setupUi();
}
const CSMDoc::Document *CSVDoc::View::getDocument() const
@ -28,4 +43,9 @@ const CSMDoc::Document *CSVDoc::View::getDocument() const
CSMDoc::Document *CSVDoc::View::getDocument()
{
return mDocument;
}
void CSVDoc::View::newView()
{
mViewManager.addView (mDocument);
}

@ -1,7 +1,9 @@
#ifndef CSV_DOC_VIEW_H
#define CSV_DOC_VIEW_H
#include <QWidget>
#include <QMainWindow>
class QAction;
namespace CSMDoc
{
@ -12,7 +14,7 @@ namespace CSVDoc
{
class ViewManager;
class View : public QWidget
class View : public QMainWindow
{
Q_OBJECT
@ -27,6 +29,8 @@ namespace CSVDoc
void closeEvent (QCloseEvent *event);
void setupUi();
public:
View (ViewManager& viewManager, CSMDoc::Document *document);
@ -35,6 +39,10 @@ namespace CSVDoc
const CSMDoc::Document *getDocument() const;
CSMDoc::Document *getDocument();
private slots:
void newView();
};
}

Loading…
Cancel
Save