keep track of active cells in PagedWorldspaceWidget and update SubView title accordingly

actorid
Marc Zinnschlag 11 years ago
parent 12e46c5dc7
commit 5b5069535e

@ -1,6 +1,39 @@
#include "pagedworldspacewidget.hpp"
#include <sstream>
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget *parent)
: WorldspaceWidget (parent)
{}
: WorldspaceWidget (parent), mMin (std::make_pair (0, 0)), mMax (std::make_pair (-1, -1))
{}
void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint)
{
if (!hint.empty())
{
if (hint[0]=='c')
{
char ignore1, ignore2, ignore3;
std::pair<int, int> cellIndex;
std::istringstream stream (hint.c_str());
if (stream >> ignore1 >> ignore2 >> ignore3 >> cellIndex.first >> cellIndex.second)
{
setCellIndex (cellIndex, cellIndex);
/// \todo adjust camera position
}
}
/// \todo implement 'r' type hints
}
}
void CSVRender::PagedWorldspaceWidget::setCellIndex (const std::pair<int, int>& min,
const std::pair<int, int>& max)
{
mMin = min;
mMax = max;
emit cellIndexChanged (mMin, mMax);
}

@ -9,9 +9,23 @@ namespace CSVRender
{
Q_OBJECT
std::pair<int, int> mMin;
std::pair<int, int> mMax;
public:
PagedWorldspaceWidget (QWidget *parent);
///< \note Sets the cell area selection to an invalid value to indicate that currently
/// no cells are displayed. The cells to be displayed will be specified later through
/// hint system.
virtual void useViewHint (const std::string& hint);
void setCellIndex (const std::pair<int, int>& min, const std::pair<int, int>& max);
signals:
void cellIndexChanged (const std::pair<int, int>& min, const std::pair<int, int>& max);
};
}

@ -26,6 +26,8 @@ void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode)
setNavigation (&mOrbit);
}
void CSVRender::WorldspaceWidget::useViewHint (const std::string& hint) {}
void CSVRender::WorldspaceWidget::selectDefaultNavigationMode()
{
setNavigation (&m1st);

@ -33,6 +33,9 @@ namespace CSVRender
void selectDefaultNavigationMode();
virtual void useViewHint (const std::string& hint);
///< Default-implementation: ignored.
private slots:
void selectNavigationMode (const std::string& mode);

@ -1,6 +1,8 @@
#include "scenesubview.hpp"
#include <sstream>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
@ -35,7 +37,14 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
SceneToolbar *toolbar = new SceneToolbar (48, this);
if (id.getId()=="sys::default")
mScene = new CSVRender::PagedWorldspaceWidget (this);
{
CSVRender::PagedWorldspaceWidget *widget = new CSVRender::PagedWorldspaceWidget (this);
mScene = widget;
connect (widget,
SIGNAL (cellIndexChanged (const std::pair<int, int>&, const std::pair<int, int>&)),
this,
SLOT (cellIndexChanged (const std::pair<int, int>&, const std::pair<int, int>&)));
}
else
mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
@ -83,7 +92,26 @@ void CSVWorld::SceneSubView::setStatusBar (bool show)
mBottom->setStatusBar (show);
}
void CSVWorld::SceneSubView::useHint (const std::string& hint)
{
mScene->useViewHint (hint);
}
void CSVWorld::SceneSubView::closeRequest()
{
deleteLater();
}
void CSVWorld::SceneSubView::cellIndexChanged (const std::pair<int, int>& min,
const std::pair<int, int>& max)
{
std::ostringstream stream;
stream << "Scene: " << getUniversalId().getId() << " (" << min.first << ", " << min.second;
if (min!=max)
stream << " to " << max.first << ", " << max.second;
stream << ")";
setWindowTitle (QString::fromUtf8 (stream.str().c_str()));
}

@ -38,9 +38,13 @@ namespace CSVWorld
virtual void setStatusBar (bool show);
virtual void useHint (const std::string& hint);
private slots:
void closeRequest();
void cellIndexChanged (const std::pair<int, int>& min, const std::pair<int, int>& max);
};
}

Loading…
Cancel
Save