Commit 19ba04ab authored by Frédéric Larue's avatar Frédéric Larue

updateCurrentProjectContent() and updateTypeFilters() functions of...

updateCurrentProjectContent() and updateTypeFilters() functions of UIMainWindow modified so as to avoid excessive update calls.
parent 1d432861
...@@ -571,6 +571,8 @@ void updateTreeSelection( QTreeWidgetItem* item, QSet<GenericUIData*>& selectedI ...@@ -571,6 +571,8 @@ void updateTreeSelection( QTreeWidgetItem* item, QSet<GenericUIData*>& selectedI
void UIMainWindow::updateCurrentProjectContent() void UIMainWindow::updateCurrentProjectContent()
{ {
disconnect( ui->tableCurrentProjContent, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()) );
UIDataWidget *treeView = ui->tableCurrentProjContent; UIDataWidget *treeView = ui->tableCurrentProjContent;
UIProject *project = getCurrentProject(); UIProject *project = getCurrentProject();
QString typeFilter = ui->comboTypeFilter->currentText(); QString typeFilter = ui->comboTypeFilter->currentText();
...@@ -611,35 +613,41 @@ void UIMainWindow::updateCurrentProjectContent() ...@@ -611,35 +613,41 @@ void UIMainWindow::updateCurrentProjectContent()
scrollBar->setValue( scrollBarValue ); scrollBar->setValue( scrollBarValue );
else else
scrollBar->setValue( scrollBar->maximum() ); scrollBar->setValue( scrollBar->maximum() );
connect( ui->tableCurrentProjContent, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()) );
selectionChanged();
} }
void UIMainWindow::updateTypeFilters() void UIMainWindow::updateTypeFilters()
{ {
QString currentFilterBackup = ui->comboTypeFilter->currentText(); disconnect( ui->comboTypeFilter, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(updateCurrentProjectContent()) );
ui->comboTypeFilter->clear(); QString currentFilterBackup = ui->comboTypeFilter->currentText();
if( getCurrentProject() ) ui->comboTypeFilter->clear();
if( getCurrentProject() )
{ {
auto &data = getCurrentProject()->GetAll(); QSet<QString> usedTypeNames;
std::set<QString> foundTypeNames; for( auto d : getCurrentProject()->GetAll() )
usedTypeNames.insert( d->GetTypeString() );
for( auto d=data.begin(); d!=data.end(); ++d )
foundTypeNames.insert( (*d)->GetTypeString() );
ui->comboTypeFilter->addItem( QString() );
for( auto name=foundTypeNames.begin(); name!=foundTypeNames.end(); ++name )
ui->comboTypeFilter->addItem( *name );
ui->comboTypeFilter->setCurrentIndex( 0 ); ui->comboTypeFilter->addItem( QString() );
for( auto &type : usedTypeNames )
ui->comboTypeFilter->addItem( type );
} }
int backedupFilterId = ui->comboTypeFilter->findText( currentFilterBackup ); int backedupFilterId = ui->comboTypeFilter->findText( currentFilterBackup );
if( backedupFilterId ) if( backedupFilterId >= 0 )
ui->comboTypeFilter->setCurrentIndex( backedupFilterId ); ui->comboTypeFilter->setCurrentIndex( backedupFilterId );
else
{
ui->comboTypeFilter->setCurrentIndex( 0 );
updateCurrentProjectContent();
}
connect( ui->comboTypeFilter, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(updateCurrentProjectContent()) );
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment