added main menu and implemented new view function

actorid
Marc Zinnschlag 12 years ago
parent 758371d7e4
commit 789cecb9df

@ -4,6 +4,7 @@
#include <iostream> #include <iostream>
#include <QCloseEvent> #include <QCloseEvent>
#include <QMenuBar>
#include "viewmanager.hpp" #include "viewmanager.hpp"
@ -13,11 +14,25 @@ void CSVDoc::View::closeEvent (QCloseEvent *event)
event->ignore(); 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) CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document)
: mViewManager (viewManager), mDocument (document) : mViewManager (viewManager), mDocument (document)
{ {
setCentralWidget (new QWidget);
resize (200, 200); resize (200, 200);
setWindowTitle ("New Document"); setWindowTitle ("New Document");
setupUi();
} }
const CSMDoc::Document *CSVDoc::View::getDocument() const const CSMDoc::Document *CSVDoc::View::getDocument() const
@ -28,4 +43,9 @@ const CSMDoc::Document *CSVDoc::View::getDocument() const
CSMDoc::Document *CSVDoc::View::getDocument() CSMDoc::Document *CSVDoc::View::getDocument()
{ {
return mDocument; return mDocument;
}
void CSVDoc::View::newView()
{
mViewManager.addView (mDocument);
} }

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

Loading…
Cancel
Save