From 5b5069535eff4df7d97eafe9912235dd35823bad Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 1 Apr 2014 10:04:14 +0200 Subject: [PATCH] keep track of active cells in PagedWorldspaceWidget and update SubView title accordingly --- .../view/render/pagedworldspacewidget.cpp | 37 ++++++++++++++++++- .../view/render/pagedworldspacewidget.hpp | 14 +++++++ apps/opencs/view/render/worldspacewidget.cpp | 2 + apps/opencs/view/render/worldspacewidget.hpp | 3 ++ apps/opencs/view/world/scenesubview.cpp | 30 ++++++++++++++- apps/opencs/view/world/scenesubview.hpp | 4 ++ 6 files changed, 87 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index fa32e3959..96d44543e 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -1,6 +1,39 @@ #include "pagedworldspacewidget.hpp" +#include + CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget *parent) -: WorldspaceWidget (parent) -{} \ No newline at end of file +: 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 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& min, + const std::pair& max) +{ + mMin = min; + mMax = max; + + emit cellIndexChanged (mMin, mMax); +} \ No newline at end of file diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index 172e2477a..9a4b79c3a 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -9,9 +9,23 @@ namespace CSVRender { Q_OBJECT + std::pair mMin; + std::pair 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& min, const std::pair& max); + + signals: + + void cellIndexChanged (const std::pair& min, const std::pair& max); }; } diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 9959c5a67..4d2442c89 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -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); diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 7921c3560..f7208d7a1 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -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); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 10e8b4071..c075cb4d6 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -1,6 +1,8 @@ #include "scenesubview.hpp" +#include + #include #include #include @@ -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&, const std::pair&)), + this, + SLOT (cellIndexChanged (const std::pair&, const std::pair&))); + } 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& min, + const std::pair& 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())); } \ No newline at end of file diff --git a/apps/opencs/view/world/scenesubview.hpp b/apps/opencs/view/world/scenesubview.hpp index ecf3fe4e4..ee5b7b41f 100644 --- a/apps/opencs/view/world/scenesubview.hpp +++ b/apps/opencs/view/world/scenesubview.hpp @@ -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& min, const std::pair& max); }; }