diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index 919b19fa7..260121c7e 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -128,10 +128,6 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail 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. chooser->blockSignals(true) ; @@ -187,15 +183,29 @@ 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 != "") +#ifdef IDCHOOSER_DEBUG + std::cerr << "GxsIdChooser: default ID = " << chooser->defaultId() << std::endl; +#endif + if(!chooser->defaultId().isNull()) + { for(int indx=0;indxcount();++indx) - if(chooser->itemData(indx).toString() == current_id) + if(RsGxsId(chooser->itemData(indx).toString().toStdString()) == chooser->defaultId()) { chooser->setCurrentIndex(indx); - std::cerr << "GxsIdChooser-003" << (void*)chooser << " setting current index to " << indx << std::endl; +#ifdef IDCHOOSER_DEBUG + std::cerr << "GxsIdChooser-003 " << (void*)chooser << " setting current index to " << indx << " because it has ID=" << chooser->defaultId() << std::endl; +#endif break; } + } + else + { + RsGxsId id; + GxsIdChooser::ChosenId_Ret cid = chooser->getChosenId(id) ; + + if(cid == GxsIdChooser::UnKnowId || cid == GxsIdChooser::KnowId) + chooser->setDefaultId(id) ; + } chooser->blockSignals(false) ; } @@ -395,6 +405,11 @@ void GxsIdChooser::myCurrentIndexChanged(int index) } else { setToolTip(""); } + QVariant var = itemData(index); + RsGxsId gxsId(var.toString().toStdString()); + + if(!gxsId.isNull()) + mDefaultId = gxsId; } void GxsIdChooser::indexActivated(int index) diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.h b/retroshare-gui/src/gui/gxs/GxsIdChooser.h index a5a946e8d..2677a8233 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.h +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.h @@ -50,15 +50,17 @@ public: enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ; void loadIds(uint32_t chooserFlags, const RsGxsId &defId); + void setDefaultId(const RsGxsId &defId); + const RsGxsId defaultId() const { return mDefaultId ; } bool setChosenId(const RsGxsId &gxsId); ChosenId_Ret getChosenId(RsGxsId &gxsId); void setEntryEnabled(int index, bool enabled); - void setIdConstraintSet(const std::set& s) ; - bool isInConstraintSet(const RsGxsId& id) const ; + void setIdConstraintSet(const std::set& s) ; + bool isInConstraintSet(const RsGxsId& id) const ; uint32_t countEnabledEntries() const ; signals: