forked from teamnwah/openmw-tes3coop
added view action to region map
This commit is contained in:
parent
1892550833
commit
2eca9e72fd
4 changed files with 56 additions and 5 deletions
|
@ -36,7 +36,7 @@ void CSVWorld::RegionMap::contextMenuEvent (QContextMenuEvent *event)
|
||||||
if (selectedNonExistentCells>0)
|
if (selectedNonExistentCells>0)
|
||||||
{
|
{
|
||||||
if (selectedNonExistentCells==1)
|
if (selectedNonExistentCells==1)
|
||||||
mCreateCellsAction->setText ("Create one cell");
|
mCreateCellsAction->setText ("Create one Cell");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
@ -51,13 +51,16 @@ void CSVWorld::RegionMap::contextMenuEvent (QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
if (!mRegionId.empty())
|
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 (mSetRegionAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.addAction (mUnsetRegionAction);
|
menu.addAction (mUnsetRegionAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selectionModel()->selectedIndexes().size()>0)
|
||||||
|
menu.addAction (mViewAction);
|
||||||
|
|
||||||
menu.exec (event->globalPos());
|
menu.exec (event->globalPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,6 +213,10 @@ CSVWorld::RegionMap::RegionMap (const CSMWorld::UniversalId& universalId,
|
||||||
mUnsetRegionAction = new QAction (tr ("Unset Region"), this);
|
mUnsetRegionAction = new QAction (tr ("Unset Region"), this);
|
||||||
connect (mUnsetRegionAction, SIGNAL (triggered()), this, SLOT (unsetRegion()));
|
connect (mUnsetRegionAction, SIGNAL (triggered()), this, SLOT (unsetRegion()));
|
||||||
addAction (mUnsetRegionAction);
|
addAction (mUnsetRegionAction);
|
||||||
|
|
||||||
|
mViewAction = new QAction (tr ("View Cells"), this);
|
||||||
|
connect (mViewAction, SIGNAL (triggered()), this, SLOT (view()));
|
||||||
|
addAction (mViewAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::RegionMap::setEditLock (bool locked)
|
void CSVWorld::RegionMap::setEditLock (bool locked)
|
||||||
|
@ -245,8 +252,6 @@ void CSVWorld::RegionMap::createCells()
|
||||||
|
|
||||||
QModelIndexList selected = getSelectedCells (false, true);
|
QModelIndexList selected = getSelectedCells (false, true);
|
||||||
|
|
||||||
QAbstractItemModel *regionModel = model();
|
|
||||||
|
|
||||||
CSMWorld::IdTable *cellsModel = &dynamic_cast<CSMWorld::IdTable&> (*
|
CSMWorld::IdTable *cellsModel = &dynamic_cast<CSMWorld::IdTable&> (*
|
||||||
mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
|
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)
|
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();
|
toString().toUtf8().constData();
|
||||||
|
|
||||||
mDocument.getUndoStack().push (new CSMWorld::CreateCommand (*cellsModel, cellId));
|
mDocument.getUndoStack().push (new CSMWorld::CreateCommand (*cellsModel, cellId));
|
||||||
|
@ -279,4 +284,30 @@ void CSVWorld::RegionMap::unsetRegion()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setRegion ("");
|
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());
|
||||||
}
|
}
|
|
@ -27,6 +27,7 @@ namespace CSVWorld
|
||||||
QAction *mCreateCellsAction;
|
QAction *mCreateCellsAction;
|
||||||
QAction *mSetRegionAction;
|
QAction *mSetRegionAction;
|
||||||
QAction *mUnsetRegionAction;
|
QAction *mUnsetRegionAction;
|
||||||
|
QAction *mViewAction;
|
||||||
bool mEditLock;
|
bool mEditLock;
|
||||||
CSMDoc::Document& mDocument;
|
CSMDoc::Document& mDocument;
|
||||||
std::string mRegionId;
|
std::string mRegionId;
|
||||||
|
@ -55,6 +56,10 @@ namespace CSVWorld
|
||||||
|
|
||||||
void setEditLock (bool locked);
|
void setEditLock (bool locked);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void selectAll();
|
void selectAll();
|
||||||
|
@ -68,6 +73,8 @@ namespace CSVWorld
|
||||||
void setRegion();
|
void setRegion();
|
||||||
|
|
||||||
void unsetRegion();
|
void unsetRegion();
|
||||||
|
|
||||||
|
void view();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,18 @@ CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId,
|
||||||
mRegionMap = new RegionMap (universalId, document, this);
|
mRegionMap = new RegionMap (universalId, document, this);
|
||||||
|
|
||||||
setWidget (mRegionMap);
|
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)
|
void CSVWorld::RegionMapSubView::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
mRegionMap->setEditLock (locked);
|
mRegionMap->setEditLock (locked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::RegionMapSubView::editRequest (const CSMWorld::UniversalId& id,
|
||||||
|
const std::string& hint)
|
||||||
|
{
|
||||||
|
focusId (id, hint);
|
||||||
}
|
}
|
|
@ -25,6 +25,10 @@ namespace CSVWorld
|
||||||
RegionMapSubView (CSMWorld::UniversalId universalId, CSMDoc::Document& document);
|
RegionMapSubView (CSMWorld::UniversalId universalId, CSMDoc::Document& document);
|
||||||
|
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue