mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 07:16:11 -05:00
fixed loading of already selected ids in FriendSelectionDialog and automatically display existing GxsGroupDialog moderators
This commit is contained in:
parent
89843a6cbe
commit
80b7f2a3cd
@ -100,7 +100,7 @@ FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& head
|
||||
friends_widget->setModus(modus) ;
|
||||
friends_widget->setShowType(show_type) ;
|
||||
friends_widget->start() ;
|
||||
friends_widget->setSelectedIds(pre_selected_id_type, pre_selected_ids, false);
|
||||
friends_widget->setSelectedIdsFromString(pre_selected_id_type, pre_selected_ids, false);
|
||||
|
||||
QLayout *l = new QVBoxLayout ;
|
||||
setLayout(l) ;
|
||||
|
@ -278,18 +278,35 @@ void FriendSelectionWidget::secured_fillList()
|
||||
|
||||
// get selected items
|
||||
std::set<RsPeerId> sslIdsSelected;
|
||||
if (mShowTypes & SHOW_SSL) {
|
||||
if (mShowTypes & SHOW_SSL)
|
||||
{
|
||||
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
||||
for(auto& s:mPreSelectedIds)
|
||||
sslIdsSelected.insert(RsPeerId(s));
|
||||
|
||||
selectedIds<RsPeerId,IDTYPE_SSL>(sslIdsSelected,true);
|
||||
}
|
||||
|
||||
std::set<RsNodeGroupId> groupIdsSelected;
|
||||
if (mShowTypes & SHOW_GROUP) {
|
||||
|
||||
if (mShowTypes & SHOW_GROUP)
|
||||
{
|
||||
selectedIds<RsNodeGroupId,IDTYPE_GROUP>(groupIdsSelected,true);
|
||||
|
||||
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
||||
for(auto& s:mPreSelectedIds)
|
||||
groupIdsSelected.insert(RsNodeGroupId(s));
|
||||
}
|
||||
|
||||
std::set<RsPgpId> gpgIdsSelected;
|
||||
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
|
||||
|
||||
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG))
|
||||
{
|
||||
selectedIds<RsPgpId,IDTYPE_GPG>(gpgIdsSelected,true);
|
||||
|
||||
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
||||
for(auto& s:mPreSelectedIds)
|
||||
gpgIdsSelected.insert(RsPgpId(s));
|
||||
}
|
||||
|
||||
std::set<RsGxsId> gxsIdsSelected;
|
||||
@ -299,7 +316,8 @@ void FriendSelectionWidget::secured_fillList()
|
||||
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
|
||||
|
||||
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
||||
gxsIdsSelected = mPreSelectedGxsIds;
|
||||
for(auto& s:mPreSelectedIds)
|
||||
gxsIdsSelected.insert(RsGxsId(s));
|
||||
}
|
||||
|
||||
std::set<RsGxsId> gxsIdsSelected2;
|
||||
@ -678,7 +696,12 @@ void FriendSelectionWidget::updateDisplay(bool)
|
||||
// This call is inlined so that there's no linking conflict with MinGW on Windows
|
||||
template<> inline void FriendSelectionWidget::setSelectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(const std::set<RsGxsId>& ids, bool add)
|
||||
{
|
||||
mPreSelectedGxsIds = ids ;
|
||||
if(!add)
|
||||
mPreSelectedIds.clear();
|
||||
|
||||
for(auto& gxsId:ids)
|
||||
mPreSelectedIds.insert(gxsId.toStdString());
|
||||
|
||||
loadIdentities();
|
||||
}
|
||||
|
||||
@ -981,7 +1004,7 @@ std::string FriendSelectionWidget::selectedId(IdType &idType)
|
||||
return idFromItem(item);
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::selectedIds(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected)
|
||||
void FriendSelectionWidget::selectedIds_internal(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected)
|
||||
{
|
||||
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
||||
QTreeWidgetItem *item;
|
||||
@ -1055,11 +1078,21 @@ void FriendSelectionWidget::selectAll()
|
||||
setSelected(mListModus, *itemIterator, true);
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::setSelectedIds(IdType idType, const std::set<std::string> &ids, bool add)
|
||||
void FriendSelectionWidget::setSelectedIdsFromString(IdType type, const std::set<std::string>& ids, bool add)
|
||||
{
|
||||
setSelectedIds_internal(type,ids,add);
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::setSelectedIds_internal(IdType idType, const std::set<std::string> &ids, bool add)
|
||||
{
|
||||
mPreSelectedIds = ids;
|
||||
|
||||
// if items are already loaded, check them
|
||||
|
||||
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
||||
QTreeWidgetItem *item;
|
||||
while ((item = *itemIterator) != NULL) {
|
||||
while ((item = *itemIterator) != NULL)
|
||||
{
|
||||
++itemIterator;
|
||||
|
||||
std::string id = idFromItem(item);
|
||||
|
@ -85,10 +85,12 @@ public:
|
||||
int selectedItemCount();
|
||||
std::string selectedId(IdType &idType);
|
||||
|
||||
void setSelectedIdsFromString(IdType type,const std::set<std::string>& ids,bool add);
|
||||
|
||||
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void selectedIds(std::set<ID_CLASS>& ids, bool onlyDirectSelected)
|
||||
{
|
||||
std::set<std::string> tmpids ;
|
||||
selectedIds(TYPE, tmpids, onlyDirectSelected);
|
||||
selectedIds_internal(TYPE, tmpids, onlyDirectSelected);
|
||||
ids.clear() ;
|
||||
for(std::set<std::string>::const_iterator it(tmpids.begin());it!=tmpids.end();++it)
|
||||
ids.insert(ID_CLASS(*it)) ;
|
||||
@ -98,7 +100,7 @@ public:
|
||||
std::set<std::string> tmpids ;
|
||||
for(typename std::set<ID_CLASS>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
tmpids.insert((*it).toStdString()) ;
|
||||
setSelectedIds(TYPE, tmpids, add);
|
||||
setSelectedIds_internal(TYPE, tmpids, add);
|
||||
}
|
||||
|
||||
void itemsFromId(IdType idType, const std::string &id, QList<QTreeWidgetItem*> &items);
|
||||
@ -145,8 +147,8 @@ private:
|
||||
void fillList();
|
||||
void secured_fillList();
|
||||
|
||||
void selectedIds(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);
|
||||
void setSelectedIds(IdType idType, const std::set<std::string> &ids, bool add);
|
||||
void selectedIds_internal(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);
|
||||
void setSelectedIds_internal(IdType idType, const std::set<std::string> &ids, bool add);
|
||||
|
||||
private:
|
||||
bool mStarted;
|
||||
@ -170,7 +172,7 @@ private:
|
||||
std::vector<RsGxsGroupId> gxsIds ;
|
||||
QList<QAction*> mContextMenuActions;
|
||||
|
||||
std::set<RsGxsId> mPreSelectedGxsIds; // because loading of GxsIds is asynchroneous we keep selected Ids from the client in a list here and use it to initialize after loading them.
|
||||
std::set<std::string> mPreSelectedIds; // because loading of GxsIds is asynchroneous we keep selected Ids from the client in a list here and use it to initialize after loading them.
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)
|
||||
|
@ -892,6 +892,10 @@ void GxsGroupDialog::getSelectedModerators(std::set<RsGxsId>& ids)
|
||||
|
||||
void GxsGroupDialog::setSelectedModerators(const std::set<RsGxsId>& ids)
|
||||
{
|
||||
ui.addAdmins_cb->setChecked(true);
|
||||
ui.adminsList->show();
|
||||
ui.filtercomboBox->show();
|
||||
|
||||
ui.adminsList->setSelectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(ids, false);
|
||||
|
||||
QString moderatorsListString ;
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>563</height>
|
||||
<width>1231</width>
|
||||
<height>967</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -223,14 +223,14 @@
|
||||
<item>
|
||||
<widget class="QRadioButton" name="publish_required">
|
||||
<property name="text">
|
||||
<string>Required</string>
|
||||
<string>Re&quired</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="publish_encrypt">
|
||||
<property name="text">
|
||||
<string>Encrypted Msgs</string>
|
||||
<string>Encrypted &Msgs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -856,7 +856,6 @@
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user