mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
LP-286 minor optimization: replace map contains+get with get
This commit is contained in:
parent
947dbf88ab
commit
29b33453f3
@ -259,7 +259,7 @@ public:
|
|||||||
|
|
||||||
DataObjectTreeItem *findDataObjectTreeItemByObjectId(quint32 objectId)
|
DataObjectTreeItem *findDataObjectTreeItemByObjectId(quint32 objectId)
|
||||||
{
|
{
|
||||||
return m_objectTreeItemsPerObjectIds.contains(objectId) ? m_objectTreeItemsPerObjectIds[objectId] : 0;
|
return m_objectTreeItemsPerObjectIds.value(objectId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMetaObjectTreeItem(quint32 objectId, MetaObjectTreeItem *oti)
|
void addMetaObjectTreeItem(quint32 objectId, MetaObjectTreeItem *oti)
|
||||||
@ -269,7 +269,7 @@ public:
|
|||||||
|
|
||||||
MetaObjectTreeItem *findMetaObjectTreeItemByObjectId(quint32 objectId)
|
MetaObjectTreeItem *findMetaObjectTreeItemByObjectId(quint32 objectId)
|
||||||
{
|
{
|
||||||
return m_metaObjectTreeItemsPerObjectIds.contains(objectId) ? m_metaObjectTreeItemsPerObjectIds[objectId] : 0;
|
return m_metaObjectTreeItemsPerObjectIds.value(objectId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<MetaObjectTreeItem *> getMetaObjectItems();
|
QList<MetaObjectTreeItem *> getMetaObjectItems();
|
||||||
|
@ -115,6 +115,7 @@ void UAVObjectBrowserWidget::setSplitterState(QByteArray state)
|
|||||||
|
|
||||||
void UAVObjectBrowserWidget::showMetaData(bool show)
|
void UAVObjectBrowserWidget::showMetaData(bool show)
|
||||||
{
|
{
|
||||||
|
// TODO update the model directly instead of hiding rows...
|
||||||
QList<QModelIndex> metaIndexes = m_model->getMetaDataIndexes();
|
QList<QModelIndex> metaIndexes = m_model->getMetaDataIndexes();
|
||||||
foreach(QModelIndex modelIndex, metaIndexes) {
|
foreach(QModelIndex modelIndex, metaIndexes) {
|
||||||
QModelIndex proxyModelIndex = m_modelProxy->mapFromSource(modelIndex);
|
QModelIndex proxyModelIndex = m_modelProxy->mapFromSource(modelIndex);
|
||||||
@ -130,6 +131,8 @@ void UAVObjectBrowserWidget::showDescription(bool show)
|
|||||||
|
|
||||||
void UAVObjectBrowserWidget::categorize(bool categorize)
|
void UAVObjectBrowserWidget::categorize(bool categorize)
|
||||||
{
|
{
|
||||||
|
// TODO we should update the model instead of rebuilding it
|
||||||
|
// a side effect of rebuilding is that some state is lost (expand state, ...)
|
||||||
UAVObjectTreeModel *model = new UAVObjectTreeModel(0, categorize, m_viewoptions->cbScientific->isChecked());
|
UAVObjectTreeModel *model = new UAVObjectTreeModel(0, categorize, m_viewoptions->cbScientific->isChecked());
|
||||||
|
|
||||||
model->setRecentlyUpdatedColor(m_recentlyUpdatedColor);
|
model->setRecentlyUpdatedColor(m_recentlyUpdatedColor);
|
||||||
@ -145,13 +148,16 @@ void UAVObjectBrowserWidget::categorize(bool categorize)
|
|||||||
|
|
||||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||||
|
|
||||||
// FIXME this causes a collapse all if filter is on
|
// force an expand all if search text is not empty
|
||||||
searchLineChanged(m_browser->searchLine->text());
|
if (!m_browser->searchLine->text().isEmpty()) {
|
||||||
|
searchLineChanged(m_browser->searchLine->text());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVObjectBrowserWidget::useScientificNotation(bool scientific)
|
void UAVObjectBrowserWidget::useScientificNotation(bool scientific)
|
||||||
{
|
{
|
||||||
// TODO we should have the model update itself instead of rebuilding it
|
// TODO we should update the model instead of rebuilding it
|
||||||
|
// a side effect of rebuilding is that some state is lost (expand state, ...)
|
||||||
UAVObjectTreeModel *model = new UAVObjectTreeModel(0, m_viewoptions->cbCategorized->isChecked(), scientific);
|
UAVObjectTreeModel *model = new UAVObjectTreeModel(0, m_viewoptions->cbCategorized->isChecked(), scientific);
|
||||||
|
|
||||||
model->setManuallyChangedColor(m_manuallyChangedColor);
|
model->setManuallyChangedColor(m_manuallyChangedColor);
|
||||||
@ -165,14 +171,19 @@ void UAVObjectBrowserWidget::useScientificNotation(bool scientific)
|
|||||||
|
|
||||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||||
|
|
||||||
// FIXME this causes a collapse all if filter is on
|
// force an expand all if search text is not empty
|
||||||
searchLineChanged(m_browser->searchLine->text());
|
if (!m_browser->searchLine->text().isEmpty()) {
|
||||||
|
searchLineChanged(m_browser->searchLine->text());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVObjectBrowserWidget::sendUpdate()
|
void UAVObjectBrowserWidget::sendUpdate()
|
||||||
{
|
{
|
||||||
|
// TODO why steal focys ?
|
||||||
this->setFocus();
|
this->setFocus();
|
||||||
|
|
||||||
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
|
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
|
||||||
|
|
||||||
if (objItem != NULL) {
|
if (objItem != NULL) {
|
||||||
objItem->apply();
|
objItem->apply();
|
||||||
UAVObject *obj = objItem->object();
|
UAVObject *obj = objItem->object();
|
||||||
@ -221,12 +232,15 @@ QString UAVObjectBrowserWidget::loadFileIntoString(QString fileName)
|
|||||||
|
|
||||||
void UAVObjectBrowserWidget::saveObject()
|
void UAVObjectBrowserWidget::saveObject()
|
||||||
{
|
{
|
||||||
|
// TODO why steal focys ?
|
||||||
this->setFocus();
|
this->setFocus();
|
||||||
|
|
||||||
// Send update so that the latest value is saved
|
// Send update so that the latest value is saved
|
||||||
sendUpdate();
|
sendUpdate();
|
||||||
|
|
||||||
// Save object
|
// Save object
|
||||||
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
|
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
|
||||||
|
|
||||||
if (objItem != NULL) {
|
if (objItem != NULL) {
|
||||||
UAVObject *obj = objItem->object();
|
UAVObject *obj = objItem->object();
|
||||||
Q_ASSERT(obj);
|
Q_ASSERT(obj);
|
||||||
|
Loading…
Reference in New Issue
Block a user