added delete selection item to selection mode button menu

coverity_scan
Marc Zinnschlag 9 years ago
parent 45e6974266
commit c1f0aa7260

@ -276,3 +276,16 @@ bool CSVRender::Cell::isDeleted() const
{
return mDeleted;
}
std::vector<osg::ref_ptr<CSVRender::TagBase> > CSVRender::Cell::getSelection (unsigned int elementMask) const
{
std::vector<osg::ref_ptr<TagBase> > result;
if (elementMask & Mask_Reference)
for (std::map<std::string, Object *>::const_iterator iter (mObjects.begin());
iter!=mObjects.end(); ++iter)
if (iter->second->getSelected())
result.push_back (iter->second->getTag());
return result;
}

@ -31,6 +31,8 @@ namespace CSMWorld
namespace CSVRender
{
class TagBase;
class Cell
{
CSMWorld::Data& mData;
@ -99,6 +101,8 @@ namespace CSVRender
CSMWorld::CellCoordinates getCoordinates() const;
bool isDeleted() const;
std::vector<osg::ref_ptr<TagBase> > getSelection (unsigned int elementMask) const;
};
}

@ -4,7 +4,11 @@
#include <QMenu>
#include <QAction>
#include "../../model/world/idtable.hpp"
#include "../../model/world/commands.hpp"
#include "worldspacewidget.hpp"
#include "object.hpp"
bool CSVRender::InstanceSelectionMode::createContextMenu (QMenu *menu)
{
@ -12,6 +16,7 @@ bool CSVRender::InstanceSelectionMode::createContextMenu (QMenu *menu)
{
menu->addAction (mSelectAll);
menu->addAction (mDeselectAll);
menu->addAction (mDeleteSelection);
}
return true;
@ -44,9 +49,11 @@ CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar
mSelectAll = new QAction ("Select all Instances", this);
mDeselectAll = new QAction ("Clear selection", this);
mDeleteSelection = new QAction ("Delete selection", this);
connect (mSelectAll, SIGNAL (triggered ()), this, SLOT (selectAll()));
connect (mDeselectAll, SIGNAL (triggered ()), this, SLOT (clearSelection()));
connect (mDeleteSelection, SIGNAL (triggered ()), this, SLOT (deleteSelection()));
}
void CSVRender::InstanceSelectionMode::selectAll()
@ -58,3 +65,22 @@ void CSVRender::InstanceSelectionMode::clearSelection()
{
mWorldspaceWidget.clearSelection (Mask_Reference);
}
void CSVRender::InstanceSelectionMode::deleteSelection()
{
std::vector<osg::ref_ptr<TagBase> > selection =
mWorldspaceWidget.getSelection (Mask_Reference);
CSMWorld::IdTable& referencesTable =
dynamic_cast<CSMWorld::IdTable&> (*mWorldspaceWidget.getDocument().getData().
getTableModel (CSMWorld::UniversalId::Type_References));
for (std::vector<osg::ref_ptr<TagBase> >::iterator iter (selection.begin());
iter!=selection.end(); ++iter)
{
CSMWorld::DeleteCommand *command = new CSMWorld::DeleteCommand (referencesTable,
static_cast<ObjectTag *> (iter->get())->mObject->getReferenceId());
mWorldspaceWidget.getDocument().getUndoStack().push (command);
}
}

@ -16,6 +16,7 @@ namespace CSVRender
WorldspaceWidget& mWorldspaceWidget;
QAction *mSelectAll;
QAction *mDeselectAll;
QAction *mDeleteSelection;
/// Add context menu items to \a menu.
///
@ -34,6 +35,8 @@ namespace CSVRender
void selectAll();
void clearSelection();
void deleteSelection();
};
}

@ -284,3 +284,8 @@ std::string CSVRender::Object::getReferenceableId() const
{
return mReferenceableId;
}
osg::ref_ptr<CSVRender::TagBase> CSVRender::Object::getTag() const
{
return static_cast<CSVRender::TagBase *> (mBaseNode->getUserData());
}

@ -114,6 +114,8 @@ namespace CSVRender
std::string getReferenceId() const;
std::string getReferenceableId() const;
osg::ref_ptr<TagBase> getTag() const;
};
}

@ -529,6 +529,23 @@ std::string CSVRender::PagedWorldspaceWidget::getCellId (const osg::Vec3f& point
return cellCoordinates.getId (mWorldspace);
}
std::vector<osg::ref_ptr<CSVRender::TagBase> > CSVRender::PagedWorldspaceWidget::getSelection (
unsigned int elementMask) const
{
std::vector<osg::ref_ptr<CSVRender::TagBase> > result;
for (std::map<CSMWorld::CellCoordinates, Cell *>::const_iterator iter = mCells.begin();
iter!=mCells.end(); ++iter)
{
std::vector<osg::ref_ptr<CSVRender::TagBase> > cellResult =
iter->second->getSelection (elementMask);
result.insert (result.end(), cellResult.begin(), cellResult.end());
}
return result;
}
CSVWidget::SceneToolToggle *CSVRender::PagedWorldspaceWidget::makeControlVisibilitySelector (
CSVWidget::SceneToolbar *parent)
{

@ -103,6 +103,9 @@ namespace CSVRender
virtual std::string getCellId (const osg::Vec3f& point) const;
virtual std::vector<osg::ref_ptr<TagBase> > getSelection (unsigned int elementMask)
const;
protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool);

@ -119,6 +119,12 @@ std::string CSVRender::UnpagedWorldspaceWidget::getCellId (const osg::Vec3f& poi
return mCellId;
}
std::vector<osg::ref_ptr<CSVRender::TagBase> > CSVRender::UnpagedWorldspaceWidget::getSelection (
unsigned int elementMask) const
{
return mCell->getSelection (elementMask);
}
void CSVRender::UnpagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft,
const QModelIndex& bottomRight)
{

@ -51,6 +51,9 @@ namespace CSVRender
virtual std::string getCellId (const osg::Vec3f& point) const;
virtual std::vector<osg::ref_ptr<TagBase> > getSelection (unsigned int elementMask)
const;
private:
virtual void referenceableDataChanged (const QModelIndex& topLeft,

@ -143,6 +143,9 @@ namespace CSVRender
virtual std::string getCellId (const osg::Vec3f& point) const = 0;
virtual std::vector<osg::ref_ptr<TagBase> > getSelection (unsigned int elementMask)
const = 0;
protected:
/// Visual elements in a scene

Loading…
Cancel
Save