mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
LP-286 change proxy model source instead of recreating it
this also fixes a leak of the previous proxy model
This commit is contained in:
parent
8db244b30a
commit
fa0686eba1
@ -102,22 +102,6 @@ void UAVObjectBrowserWidget::setSplitterState(QByteArray state)
|
||||
m_browser->splitter->restoreState(state);
|
||||
}
|
||||
|
||||
|
||||
void UAVObjectBrowserWidget::resetProxyModel(UAVObjectTreeModel *currentModel)
|
||||
{
|
||||
m_modelProxy = new TreeSortFilterProxyModel(this);
|
||||
m_modelProxy->setSourceModel(currentModel);
|
||||
m_modelProxy->setDynamicSortFilter(true);
|
||||
m_browser->treeView->setModel(m_modelProxy);
|
||||
|
||||
BrowserItemDelegate *m_delegate = new BrowserItemDelegate(m_modelProxy);
|
||||
m_browser->treeView->setItemDelegate(m_delegate);
|
||||
|
||||
if (!m_browser->searchLine->text().isEmpty()) {
|
||||
emit searchLineChanged(m_browser->searchLine->text());
|
||||
}
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::showMetaData(bool show)
|
||||
{
|
||||
QList<QModelIndex> metaIndexes = m_model->getMetaDataIndexes();
|
||||
@ -135,34 +119,42 @@ void UAVObjectBrowserWidget::showDescription(bool show)
|
||||
|
||||
void UAVObjectBrowserWidget::categorize(bool categorize)
|
||||
{
|
||||
UAVObjectTreeModel *model = new UAVObjectTreeModel(0, categorize, m_viewoptions->cbScientific->isChecked());
|
||||
|
||||
model->setRecentlyUpdatedColor(m_recentlyUpdatedColor);
|
||||
model->setManuallyChangedColor(m_manuallyChangedColor);
|
||||
model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout);
|
||||
model->setOnlyHilightChangedValues(m_onlyHilightChangedValues);
|
||||
model->setUnknowObjectColor(m_unknownObjectColor);
|
||||
|
||||
UAVObjectTreeModel *tmpModel = m_model;
|
||||
|
||||
m_model = new UAVObjectTreeModel(0, categorize, m_viewoptions->cbScientific->isChecked());
|
||||
resetProxyModel(m_model);
|
||||
m_model->setRecentlyUpdatedColor(m_recentlyUpdatedColor);
|
||||
m_model->setManuallyChangedColor(m_manuallyChangedColor);
|
||||
m_model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout);
|
||||
m_model->setOnlyHilightChangedValues(m_onlyHilightChangedValues);
|
||||
m_model->setUnknowObjectColor(m_unknownObjectColor);
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
|
||||
|
||||
m_model = model;
|
||||
m_modelProxy->setSourceModel(m_model);
|
||||
delete tmpModel;
|
||||
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
|
||||
// FIXME this causes a collapse all if filter is on
|
||||
searchLineChanged(m_browser->searchLine->text());
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::useScientificNotation(bool scientific)
|
||||
{
|
||||
UAVObjectTreeModel *model = new UAVObjectTreeModel(0, m_viewoptions->cbCategorized->isChecked(), scientific);
|
||||
|
||||
model->setManuallyChangedColor(m_manuallyChangedColor);
|
||||
model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout);
|
||||
model->setUnknowObjectColor(m_unknownObjectColor);
|
||||
|
||||
UAVObjectTreeModel *tmpModel = m_model;
|
||||
|
||||
m_model = new UAVObjectTreeModel(0, m_viewoptions->cbCategorized->isChecked(), scientific);
|
||||
resetProxyModel(m_model);
|
||||
m_model->setManuallyChangedColor(m_manuallyChangedColor);
|
||||
m_model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout);
|
||||
m_model->setUnknowObjectColor(m_unknownObjectColor);
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
|
||||
|
||||
m_model = model;
|
||||
m_modelProxy->setSourceModel(m_model);
|
||||
delete tmpModel;
|
||||
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
|
||||
// FIXME this causes a collapse all if filter is on
|
||||
searchLineChanged(m_browser->searchLine->text());
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::sendUpdate()
|
||||
@ -424,7 +416,6 @@ void UAVObjectBrowserWidget::updateDescription()
|
||||
void UAVObjectBrowserWidget::searchLineChanged(QString searchText)
|
||||
{
|
||||
m_modelProxy->setFilterRegExp(QRegExp(searchText, Qt::CaseInsensitive, QRegExp::FixedString));
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
if (!searchText.isEmpty()) {
|
||||
m_browser->treeView->expandAll();
|
||||
} else {
|
||||
|
@ -126,7 +126,6 @@ private:
|
||||
void updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj);
|
||||
void enableSendRequest(bool enable);
|
||||
void updateDescription();
|
||||
void resetProxyModel(UAVObjectTreeModel *currentModel);
|
||||
ObjectTreeItem *findCurrentObjectTreeItem();
|
||||
QString loadFileIntoString(QString fileName);
|
||||
};
|
||||
|
@ -306,10 +306,11 @@ QModelIndex UAVObjectTreeModel::parent(const QModelIndex &index) const
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
TreeItem *childItem = static_cast<TreeItem *>(index.internalPointer());
|
||||
TreeItem *parentItem = childItem->parent();
|
||||
TreeItem *item = static_cast<TreeItem *>(index.internalPointer());
|
||||
|
||||
if (parentItem == m_rootItem) {
|
||||
TreeItem *parentItem = item->parent();
|
||||
if (!parentItem) {
|
||||
// item is root has no parent...
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user