1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 18:19:55 +00:00

replaced rectangular cell selection with a CellSelection object

This commit is contained in:
Marc Zinnschlag 2014-04-07 14:16:02 +02:00
parent 67965ec10c
commit 0d352cb883
4 changed files with 44 additions and 25 deletions

View file

@ -4,36 +4,37 @@
#include <sstream>
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget *parent)
: WorldspaceWidget (parent), mMin (std::make_pair (0, 0)), mMax (std::make_pair (-1, -1))
: WorldspaceWidget (parent)
{}
void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint)
{
if (!hint.empty())
{
CSMWorld::CellSelection selection;
if (hint[0]=='c')
{
char ignore1, ignore2, ignore3;
std::pair<int, int> cellIndex;
int x, y;
std::istringstream stream (hint.c_str());
if (stream >> ignore1 >> ignore2 >> ignore3 >> cellIndex.first >> cellIndex.second)
if (stream >> ignore1 >> ignore2 >> ignore3 >> x >> y)
{
setCellIndex (cellIndex, cellIndex);
selection.add (CSMWorld::CellCoordinates (x, y));
/// \todo adjust camera position
}
}
/// \todo implement 'r' type hints
setCellSelection (selection);
}
}
void CSVRender::PagedWorldspaceWidget::setCellIndex (const std::pair<int, int>& min,
const std::pair<int, int>& max)
void CSVRender::PagedWorldspaceWidget::setCellSelection (const CSMWorld::CellSelection& selection)
{
mMin = min;
mMax = max;
emit cellIndexChanged (mMin, mMax);
mSelection = selection;
emit cellSelectionChanged (mSelection);
}

View file

@ -1,6 +1,8 @@
#ifndef OPENCS_VIEW_PAGEDWORLDSPACEWIDGET_H
#define OPENCS_VIEW_PAGEDWORLDSPACEWIDGET_H
#include "../../model/world/cellselection.hpp"
#include "worldspacewidget.hpp"
namespace CSVRender
@ -9,8 +11,7 @@ namespace CSVRender
{
Q_OBJECT
std::pair<int, int> mMin;
std::pair<int, int> mMax;
CSMWorld::CellSelection mSelection;
public:
@ -21,11 +22,11 @@ namespace CSVRender
virtual void useViewHint (const std::string& hint);
void setCellIndex (const std::pair<int, int>& min, const std::pair<int, int>& max);
void setCellSelection (const CSMWorld::CellSelection& selection);
signals:
void cellIndexChanged (const std::pair<int, int>& min, const std::pair<int, int>& max);
void cellSelectionChanged (const CSMWorld::CellSelection& selection);
};
}

View file

@ -9,6 +9,8 @@
#include "../../model/doc/document.hpp"
#include "../../model/world/cellselection.hpp"
#include "../filter/filterbox.hpp"
#include "../render/pagedworldspacewidget.hpp"
@ -40,10 +42,8 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
{
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>&)));
connect (widget, SIGNAL (cellSelectionChanged (const CSMWorld::CellSelection&)),
this, SLOT (cellSelectionChanged (const CSMWorld::CellSelection&)));
}
else
mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
@ -102,16 +102,28 @@ void CSVWorld::SceneSubView::closeRequest()
deleteLater();
}
void CSVWorld::SceneSubView::cellIndexChanged (const std::pair<int, int>& min,
const std::pair<int, int>& max)
void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::CellSelection& selection)
{
int size = selection.getSize();
std::ostringstream stream;
stream << "Scene: " << getUniversalId().getId() << " (" << min.first << ", " << min.second;
stream << "Scene: " << getUniversalId().getId();
if (min!=max)
stream << " to " << max.first << ", " << max.second;
if (size==0)
stream << " (empty)";
else if (size==1)
{
stream << " (" << *selection.begin() << ")";
}
else
{
stream << " (" << selection.getCentre() << " and " << size-1 << " more ";
stream << ")";
if (size>1)
stream << "cells around it)";
else
stream << "cell around it)";
}
setWindowTitle (QString::fromUtf8 (stream.str().c_str()));
}

View file

@ -5,6 +5,11 @@
class QModelIndex;
namespace CSMWorld
{
class CellSelection;
}
namespace CSMDoc
{
class Document;
@ -44,7 +49,7 @@ namespace CSVWorld
void closeRequest();
void cellIndexChanged (const std::pair<int, int>& min, const std::pair<int, int>& max);
void cellSelectionChanged (const CSMWorld::CellSelection& selection);
};
}