mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
fixed auto-switching bug in GxsIdChooser
This commit is contained in:
parent
266edf06aa
commit
396d58da58
@ -128,10 +128,6 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
|
|||||||
if (!chooser)
|
if (!chooser)
|
||||||
return;
|
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
|
// 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.
|
// perform any change.Only user-changes should cause this.
|
||||||
chooser->blockSignals(true) ;
|
chooser->blockSignals(true) ;
|
||||||
@ -187,15 +183,29 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
|
|||||||
chooser->model()->sort(0);
|
chooser->model()->sort(0);
|
||||||
|
|
||||||
// now restore the current item. Problem is, we cannot use the ID position because it may have changed.
|
// now restore the current item. Problem is, we cannot use the ID position because it may have changed.
|
||||||
|
#ifdef IDCHOOSER_DEBUG
|
||||||
if(current_id != "")
|
std::cerr << "GxsIdChooser: default ID = " << chooser->defaultId() << std::endl;
|
||||||
|
#endif
|
||||||
|
if(!chooser->defaultId().isNull())
|
||||||
|
{
|
||||||
for(int indx=0;indx<chooser->count();++indx)
|
for(int indx=0;indx<chooser->count();++indx)
|
||||||
if(chooser->itemData(indx).toString() == current_id)
|
if(RsGxsId(chooser->itemData(indx).toString().toStdString()) == chooser->defaultId())
|
||||||
{
|
{
|
||||||
chooser->setCurrentIndex(indx);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RsGxsId id;
|
||||||
|
GxsIdChooser::ChosenId_Ret cid = chooser->getChosenId(id) ;
|
||||||
|
|
||||||
|
if(cid == GxsIdChooser::UnKnowId || cid == GxsIdChooser::KnowId)
|
||||||
|
chooser->setDefaultId(id) ;
|
||||||
|
}
|
||||||
|
|
||||||
chooser->blockSignals(false) ;
|
chooser->blockSignals(false) ;
|
||||||
}
|
}
|
||||||
@ -395,6 +405,11 @@ void GxsIdChooser::myCurrentIndexChanged(int index)
|
|||||||
} else {
|
} else {
|
||||||
setToolTip("");
|
setToolTip("");
|
||||||
}
|
}
|
||||||
|
QVariant var = itemData(index);
|
||||||
|
RsGxsId gxsId(var.toString().toStdString());
|
||||||
|
|
||||||
|
if(!gxsId.isNull())
|
||||||
|
mDefaultId = gxsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsIdChooser::indexActivated(int index)
|
void GxsIdChooser::indexActivated(int index)
|
||||||
|
@ -50,15 +50,17 @@ public:
|
|||||||
|
|
||||||
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
|
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
|
||||||
void loadIds(uint32_t chooserFlags, const RsGxsId &defId);
|
void loadIds(uint32_t chooserFlags, const RsGxsId &defId);
|
||||||
|
|
||||||
void setDefaultId(const RsGxsId &defId);
|
void setDefaultId(const RsGxsId &defId);
|
||||||
|
const RsGxsId defaultId() const { return mDefaultId ; }
|
||||||
|
|
||||||
bool setChosenId(const RsGxsId &gxsId);
|
bool setChosenId(const RsGxsId &gxsId);
|
||||||
ChosenId_Ret getChosenId(RsGxsId &gxsId);
|
ChosenId_Ret getChosenId(RsGxsId &gxsId);
|
||||||
|
|
||||||
void setEntryEnabled(int index, bool enabled);
|
void setEntryEnabled(int index, bool enabled);
|
||||||
|
|
||||||
void setIdConstraintSet(const std::set<RsGxsId>& s) ;
|
void setIdConstraintSet(const std::set<RsGxsId>& s) ;
|
||||||
bool isInConstraintSet(const RsGxsId& id) const ;
|
bool isInConstraintSet(const RsGxsId& id) const ;
|
||||||
|
|
||||||
uint32_t countEnabledEntries() const ;
|
uint32_t countEnabledEntries() const ;
|
||||||
signals:
|
signals:
|
||||||
|
Loading…
Reference in New Issue
Block a user