The DtEntityList class is a Qt-based dialog/ widget class that displays all existing entities as well as their current task and, if available, their destination.
#include <vlpi/appearance.h>
#include <QtGui/QPixmap>
using namespace makVrf;
namespace makVrfEntityListExample
{
DtEntityList::DtEntityList(
makVrv::DtDe& de, QWidget* parent, Qt ::WindowFlags flags)
: DtPage(de, parent, flags)
{
setObjectName(tr("Entity List"));
setupUi(this);
myUi.myEntityTree->setRootIsDecorated(false);
mySimulatedEntityStateView = DtVrfStateViewCollectionManager::instance(de).simulatedEntityStateViewCollection();
populateEntityList();
mySimulatedEntityStateView->signal_stateViewAdded.connect(
boost::bind(&DtEntityList::slot_onObjectAdded,
this, _1));
mySimulatedEntityStateView->signal_stateViewAboutToBeRemoved.connect(
boost::bind(&DtEntityList::slot_onObjectAboutToBeRemoved,
this, _1));
boost::bind(&DtEntityList::slot_onCurrentTaskChanged,
this, _1));
}
DtEntityList::~DtEntityList()
{
mySimulatedEntityStateView->signal_stateViewAdded.disconnect(
boost::bind(&DtEntityList::slot_onObjectAdded,
this, _1));
mySimulatedEntityStateView->signal_stateViewAboutToBeRemoved.disconnect(
boost::bind(&DtEntityList::slot_onObjectAboutToBeRemoved,
this, _1));
boost::bind(&DtEntityList::slot_onCurrentTaskChanged,
this, _1));
}
{
return QIcon();
}
{
return tr("Entity List");
}
{
static std::string theClassName = "DtEntityList";
return theClassName;
}
{
}
{
}
std::string DtEntityList::thePageClassName()
{
return "DtEntityList";
}
void DtEntityList::setupUi(QWidget* p)
{
myUi.setupUi(this);
}
void DtEntityList::clear()
{
myUi.myEntityTree->clear();
}
void DtEntityList::populateEntityList()
{
DtVrfSimulatedEntityStateViewCollection::StateViewMap::const_iterator iter =
mySimulatedEntityStateView->stateViewMap().begin();
while (iter != mySimulatedEntityStateView->stateViewMap().end())
{
slot_onObjectAdded(*entityState);
++iter;
}
}
{
if(myLineToStateViewMap[nonConstStateView] != 0)
{
return;
}
boost::bind(&DtEntityList::slot_onObjectUpdated,
this, _1));
myLineToStateViewMap[nonConstStateView] = displayEntityItem;
}
{
boost::bind(&DtEntityList::slot_onObjectUpdated,
this, _1));
QTreeWidgetItem* displayEntityItem = myLineToStateViewMap[nonConstStateView];
if(displayEntityItem)
{
myUi.myEntityTree->takeTopLevelItem(
myUi.myEntityTree->indexOfTopLevelItem(displayEntityItem));
myLineToStateViewMap[nonConstStateView] = 0;
}
}
{
!DtVrfStateViewCollectionManager::instance(myDe).objectUUID(entityState->
id()).isValid())
{
return;
}
if(displayEntityItem)
{
if(displayEntityItem->text(0).isEmpty())
{
DtVrfCurrentTaskManager::instance(myDe).requestCurrentTasksFor(entityState->
id(),
boost::bind(&DtEntityList::slot_onCurrentTaskChanged,
this, _1));
}
if(displayEntityItem->text(0).toLatin1().constData() != entityState->
state().
myMarkingText)
{
}
bool destroyed = false;
if (key.kind() == 11)
{
}
else
{
destroyed = (app.damageState() == DtDamageDestroyed);
}
key, destroyed, 48,
false, &entityState->
state());
if (pMap.cacheKey() != displayEntityItem->icon(0).cacheKey())
{
displayEntityItem->setIcon(0, pMap);
}
}
}
void DtEntityList::slot_onCurrentTaskChanged(
DtUUID entityName)
{
DtVrfStateViewCollectionManager::instance(myDe).lookupIdByUUID(entityName)));
if (!entityState)
{
return;
}
if(displayEntityItem)
{
if (allTasks)
{
if(allTasks->size() == 0)
{
displayEntityItem->setText(1,"");
displayEntityItem->setText(2,"");
}
else
{
displayEntityItem->setText(1,QString::fromUtf8(taskType.
type().c_str()));
fillDestinationLine(((*allTasks)[0]).
task.get(),displayEntityItem);
}
}
}
}
{
{
if (locTask)
{
}
else
{
if (stt)
{
if (rwv)
{
}
}
}
}
{
if (locTask)
{
}
else
{
if (stt)
{
if (cp)
{
controlPoint = *cp;
}
}
}
if (!controlPoint.isValid())
{
return;
}
if (sv)
{
if (ep)
{
QString destinationText =
displayEntityItem->setText(2,destinationText);
}
}
}
}
}