forked from teamnwah/openmw-tes3coop
keep track of active cells in PagedWorldspaceWidget and update SubView title accordingly
This commit is contained in:
parent
12e46c5dc7
commit
5b5069535e
6 changed files with 87 additions and 3 deletions
|
@ -1,6 +1,39 @@
|
||||||
|
|
||||||
#include "pagedworldspacewidget.hpp"
|
#include "pagedworldspacewidget.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget *parent)
|
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
|
Q_OBJECT
|
||||||
|
|
||||||
|
std::pair<int, int> mMin;
|
||||||
|
std::pair<int, int> mMax;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PagedWorldspaceWidget (QWidget *parent);
|
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);
|
setNavigation (&mOrbit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::WorldspaceWidget::useViewHint (const std::string& hint) {}
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::selectDefaultNavigationMode()
|
void CSVRender::WorldspaceWidget::selectDefaultNavigationMode()
|
||||||
{
|
{
|
||||||
setNavigation (&m1st);
|
setNavigation (&m1st);
|
||||||
|
|
|
@ -33,6 +33,9 @@ namespace CSVRender
|
||||||
|
|
||||||
void selectDefaultNavigationMode();
|
void selectDefaultNavigationMode();
|
||||||
|
|
||||||
|
virtual void useViewHint (const std::string& hint);
|
||||||
|
///< Default-implementation: ignored.
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void selectNavigationMode (const std::string& mode);
|
void selectNavigationMode (const std::string& mode);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#include "scenesubview.hpp"
|
#include "scenesubview.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -35,7 +37,14 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
||||||
|
|
||||||
if (id.getId()=="sys::default")
|
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
|
else
|
||||||
mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
|
mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
|
||||||
|
|
||||||
|
@ -83,7 +92,26 @@ void CSVWorld::SceneSubView::setStatusBar (bool show)
|
||||||
mBottom->setStatusBar (show);
|
mBottom->setStatusBar (show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::SceneSubView::useHint (const std::string& hint)
|
||||||
|
{
|
||||||
|
mScene->useViewHint (hint);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::SceneSubView::closeRequest()
|
void CSVWorld::SceneSubView::closeRequest()
|
||||||
{
|
{
|
||||||
deleteLater();
|
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 setStatusBar (bool show);
|
||||||
|
|
||||||
|
virtual void useHint (const std::string& hint);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
|
|
||||||
|
void cellIndexChanged (const std::pair<int, int>& min, const std::pair<int, int>& max);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue