fixed bug causing IdChooser to reset the current id

This commit is contained in:
csoler 2018-11-03 20:24:24 +01:00
parent 1f8ecc024d
commit d711e09b68
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C

View File

@ -127,10 +127,13 @@ void GxsIdChooser::setDefaultId(const RsGxsId &defId)
static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &/*data*/)
{
GxsIdChooser *chooser = dynamic_cast<GxsIdChooser*>(object);
if (!chooser) {
return;
}
if (!chooser)
return;
int current_index = chooser->currentIndex();
QString current_id = (current_index >= 0)? chooser->itemData(current_index).toString() : "" ;
// this prevents the objects that depend on what's in the combo-box to activate and
// perform any change.Only user-changes should cause this.
@ -186,6 +189,16 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
chooser->model()->sort(0);
// now restore the current item. Problem is, we cannot use the ID position because it may have changed.
if(!current_id.isNull())
for(int indx=0;indx<chooser->count();++indx)
if(chooser->itemData(indx).toString() == current_id)
{
chooser->setCurrentIndex(indx);
break;
}
chooser->blockSignals(false) ;
}