2012-11-22 12:30:02 +00:00
|
|
|
|
|
|
|
#include "view.hpp"
|
|
|
|
|
2012-11-22 14:09:04 +00:00
|
|
|
#include <sstream>
|
2012-11-22 13:10:23 +00:00
|
|
|
|
|
|
|
#include <QCloseEvent>
|
2012-11-22 13:49:58 +00:00
|
|
|
#include <QMenuBar>
|
2012-11-22 13:10:23 +00:00
|
|
|
|
|
|
|
#include "viewmanager.hpp"
|
|
|
|
|
|
|
|
void CSVDoc::View::closeEvent (QCloseEvent *event)
|
|
|
|
{
|
|
|
|
if (!mViewManager.closeRequest (this))
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
|
2012-11-22 13:49:58 +00:00
|
|
|
void CSVDoc::View::setupUi()
|
|
|
|
{
|
2012-11-22 14:09:04 +00:00
|
|
|
// view menu
|
2012-11-22 13:49:58 +00:00
|
|
|
QMenu *view = menuBar()->addMenu (tr ("&View"));
|
|
|
|
|
|
|
|
QAction *newWindow = new QAction (tr ("&New View"), this);
|
|
|
|
connect (newWindow, SIGNAL (triggered()), this, SLOT (newView()));
|
|
|
|
|
|
|
|
view->addAction (newWindow);
|
|
|
|
}
|
|
|
|
|
2012-11-22 14:09:04 +00:00
|
|
|
void CSVDoc::View::updateTitle()
|
|
|
|
{
|
|
|
|
std::ostringstream stream;
|
|
|
|
|
|
|
|
stream << "New Document ";
|
|
|
|
|
|
|
|
if (mViewTotal>1)
|
|
|
|
stream << " [" << (mViewIndex+1) << "/" << mViewTotal << "]";
|
|
|
|
|
|
|
|
setWindowTitle (stream.str().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
|
|
|
|
: mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), mViewTotal (totalViews)
|
2012-11-22 12:30:02 +00:00
|
|
|
{
|
2012-11-22 13:49:58 +00:00
|
|
|
setCentralWidget (new QWidget);
|
2012-11-22 12:30:02 +00:00
|
|
|
resize (200, 200);
|
2012-11-22 14:09:04 +00:00
|
|
|
|
|
|
|
updateTitle();
|
2012-11-22 13:49:58 +00:00
|
|
|
|
|
|
|
setupUi();
|
2012-11-22 13:10:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const CSMDoc::Document *CSVDoc::View::getDocument() const
|
|
|
|
{
|
|
|
|
return mDocument;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSMDoc::Document *CSVDoc::View::getDocument()
|
|
|
|
{
|
|
|
|
return mDocument;
|
2012-11-22 13:49:58 +00:00
|
|
|
}
|
|
|
|
|
2012-11-22 14:09:04 +00:00
|
|
|
void CSVDoc::View::setIndex (int viewIndex, int totalViews)
|
|
|
|
{
|
|
|
|
mViewIndex = viewIndex;
|
|
|
|
mViewTotal = totalViews;
|
|
|
|
updateTitle();
|
|
|
|
}
|
|
|
|
|
2012-11-22 13:49:58 +00:00
|
|
|
void CSVDoc::View::newView()
|
|
|
|
{
|
|
|
|
mViewManager.addView (mDocument);
|
2012-11-22 12:30:02 +00:00
|
|
|
}
|