diff --git a/apps/opencs/view/world/regionmap.cpp b/apps/opencs/view/world/regionmap.cpp index 7e0a30242..5b15cc9a8 100644 --- a/apps/opencs/view/world/regionmap.cpp +++ b/apps/opencs/view/world/regionmap.cpp @@ -36,7 +36,7 @@ void CSVWorld::RegionMap::contextMenuEvent (QContextMenuEvent *event) if (selectedNonExistentCells>0) { if (selectedNonExistentCells==1) - mCreateCellsAction->setText ("Create one cell"); + mCreateCellsAction->setText ("Create one Cell"); else { std::ostringstream stream; @@ -51,13 +51,16 @@ void CSVWorld::RegionMap::contextMenuEvent (QContextMenuEvent *event) { if (!mRegionId.empty()) { - mSetRegionAction->setText (QString::fromUtf8 (("Set region to " + mRegionId).c_str())); + mSetRegionAction->setText (QString::fromUtf8 (("Set Region to " + mRegionId).c_str())); menu.addAction (mSetRegionAction); } menu.addAction (mUnsetRegionAction); } + if (selectionModel()->selectedIndexes().size()>0) + menu.addAction (mViewAction); + menu.exec (event->globalPos()); } @@ -210,6 +213,10 @@ CSVWorld::RegionMap::RegionMap (const CSMWorld::UniversalId& universalId, mUnsetRegionAction = new QAction (tr ("Unset Region"), this); connect (mUnsetRegionAction, SIGNAL (triggered()), this, SLOT (unsetRegion())); addAction (mUnsetRegionAction); + + mViewAction = new QAction (tr ("View Cells"), this); + connect (mViewAction, SIGNAL (triggered()), this, SLOT (view())); + addAction (mViewAction); } void CSVWorld::RegionMap::setEditLock (bool locked) @@ -245,8 +252,6 @@ void CSVWorld::RegionMap::createCells() QModelIndexList selected = getSelectedCells (false, true); - QAbstractItemModel *regionModel = model(); - CSMWorld::IdTable *cellsModel = &dynamic_cast (* mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_Cells)); @@ -255,7 +260,7 @@ void CSVWorld::RegionMap::createCells() for (QModelIndexList::const_iterator iter (selected.begin()); iter!=selected.end(); ++iter) { - std::string cellId = regionModel->data (*iter, CSMWorld::RegionMap::Role_CellId). + std::string cellId = model()->data (*iter, CSMWorld::RegionMap::Role_CellId). toString().toUtf8().constData(); mDocument.getUndoStack().push (new CSMWorld::CreateCommand (*cellsModel, cellId)); @@ -279,4 +284,30 @@ void CSVWorld::RegionMap::unsetRegion() return; setRegion (""); +} + +void CSVWorld::RegionMap::view() +{ + std::ostringstream hint; + hint << "c:"; + + QModelIndexList selected = selectionModel()->selectedIndexes(); + + bool first = true; + + for (QModelIndexList::const_iterator iter (selected.begin()); iter!=selected.end(); ++iter) + { + std::string cellId = model()->data (*iter, CSMWorld::RegionMap::Role_CellId). + toString().toUtf8().constData(); + + if (first) + first = false; + else + hint << "; "; + + hint << cellId; + } + + emit editRequest (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Scene, "sys::default"), + hint.str()); } \ No newline at end of file diff --git a/apps/opencs/view/world/regionmap.hpp b/apps/opencs/view/world/regionmap.hpp index b93a13eb8..12951b459 100644 --- a/apps/opencs/view/world/regionmap.hpp +++ b/apps/opencs/view/world/regionmap.hpp @@ -27,6 +27,7 @@ namespace CSVWorld QAction *mCreateCellsAction; QAction *mSetRegionAction; QAction *mUnsetRegionAction; + QAction *mViewAction; bool mEditLock; CSMDoc::Document& mDocument; std::string mRegionId; @@ -55,6 +56,10 @@ namespace CSVWorld void setEditLock (bool locked); + signals: + + void editRequest (const CSMWorld::UniversalId& id, const std::string& hint); + private slots: void selectAll(); @@ -68,6 +73,8 @@ namespace CSVWorld void setRegion(); void unsetRegion(); + + void view(); }; } diff --git a/apps/opencs/view/world/regionmapsubview.cpp b/apps/opencs/view/world/regionmapsubview.cpp index a966c419f..a7675a4a6 100644 --- a/apps/opencs/view/world/regionmapsubview.cpp +++ b/apps/opencs/view/world/regionmapsubview.cpp @@ -10,9 +10,18 @@ CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId, mRegionMap = new RegionMap (universalId, document, this); setWidget (mRegionMap); + + connect (mRegionMap, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), + this, SLOT (editRequest (const CSMWorld::UniversalId&, const std::string&))); } void CSVWorld::RegionMapSubView::setEditLock (bool locked) { mRegionMap->setEditLock (locked); +} + +void CSVWorld::RegionMapSubView::editRequest (const CSMWorld::UniversalId& id, + const std::string& hint) +{ + focusId (id, hint); } \ No newline at end of file diff --git a/apps/opencs/view/world/regionmapsubview.hpp b/apps/opencs/view/world/regionmapsubview.hpp index f329c7f3b..524727901 100644 --- a/apps/opencs/view/world/regionmapsubview.hpp +++ b/apps/opencs/view/world/regionmapsubview.hpp @@ -25,6 +25,10 @@ namespace CSVWorld RegionMapSubView (CSMWorld::UniversalId universalId, CSMDoc::Document& document); virtual void setEditLock (bool locked); + + private slots: + + void editRequest (const CSMWorld::UniversalId& id, const std::string& hint); }; }