mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-09-25 19:01:09 -04:00
fixed loading of already selected ids in FriendSelectionDialog and automatically display existing GxsGroupDialog moderators
This commit is contained in:
parent
89843a6cbe
commit
80b7f2a3cd
5 changed files with 57 additions and 19 deletions
|
@ -100,7 +100,7 @@ FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& head
|
||||||
friends_widget->setModus(modus) ;
|
friends_widget->setModus(modus) ;
|
||||||
friends_widget->setShowType(show_type) ;
|
friends_widget->setShowType(show_type) ;
|
||||||
friends_widget->start() ;
|
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 ;
|
QLayout *l = new QVBoxLayout ;
|
||||||
setLayout(l) ;
|
setLayout(l) ;
|
||||||
|
|
|
@ -278,18 +278,35 @@ void FriendSelectionWidget::secured_fillList()
|
||||||
|
|
||||||
// get selected items
|
// get selected items
|
||||||
std::set<RsPeerId> sslIdsSelected;
|
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);
|
selectedIds<RsPeerId,IDTYPE_SSL>(sslIdsSelected,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<RsNodeGroupId> groupIdsSelected;
|
std::set<RsNodeGroupId> groupIdsSelected;
|
||||||
if (mShowTypes & SHOW_GROUP) {
|
|
||||||
|
if (mShowTypes & SHOW_GROUP)
|
||||||
|
{
|
||||||
selectedIds<RsNodeGroupId,IDTYPE_GROUP>(groupIdsSelected,true);
|
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;
|
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);
|
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;
|
std::set<RsGxsId> gxsIdsSelected;
|
||||||
|
@ -299,7 +316,8 @@ void FriendSelectionWidget::secured_fillList()
|
||||||
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
|
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
|
||||||
|
|
||||||
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
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;
|
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
|
// 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)
|
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();
|
loadIdentities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -981,7 +1004,7 @@ std::string FriendSelectionWidget::selectedId(IdType &idType)
|
||||||
return idFromItem(item);
|
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);
|
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
|
@ -1055,11 +1078,21 @@ void FriendSelectionWidget::selectAll()
|
||||||
setSelected(mListModus, *itemIterator, true);
|
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);
|
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
while ((item = *itemIterator) != NULL) {
|
while ((item = *itemIterator) != NULL)
|
||||||
|
{
|
||||||
++itemIterator;
|
++itemIterator;
|
||||||
|
|
||||||
std::string id = idFromItem(item);
|
std::string id = idFromItem(item);
|
||||||
|
|
|
@ -85,10 +85,12 @@ public:
|
||||||
int selectedItemCount();
|
int selectedItemCount();
|
||||||
std::string selectedId(IdType &idType);
|
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)
|
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void selectedIds(std::set<ID_CLASS>& ids, bool onlyDirectSelected)
|
||||||
{
|
{
|
||||||
std::set<std::string> tmpids ;
|
std::set<std::string> tmpids ;
|
||||||
selectedIds(TYPE, tmpids, onlyDirectSelected);
|
selectedIds_internal(TYPE, tmpids, onlyDirectSelected);
|
||||||
ids.clear() ;
|
ids.clear() ;
|
||||||
for(std::set<std::string>::const_iterator it(tmpids.begin());it!=tmpids.end();++it)
|
for(std::set<std::string>::const_iterator it(tmpids.begin());it!=tmpids.end();++it)
|
||||||
ids.insert(ID_CLASS(*it)) ;
|
ids.insert(ID_CLASS(*it)) ;
|
||||||
|
@ -98,7 +100,7 @@ public:
|
||||||
std::set<std::string> tmpids ;
|
std::set<std::string> tmpids ;
|
||||||
for(typename std::set<ID_CLASS>::const_iterator it(ids.begin());it!=ids.end();++it)
|
for(typename std::set<ID_CLASS>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||||
tmpids.insert((*it).toStdString()) ;
|
tmpids.insert((*it).toStdString()) ;
|
||||||
setSelectedIds(TYPE, tmpids, add);
|
setSelectedIds_internal(TYPE, tmpids, add);
|
||||||
}
|
}
|
||||||
|
|
||||||
void itemsFromId(IdType idType, const std::string &id, QList<QTreeWidgetItem*> &items);
|
void itemsFromId(IdType idType, const std::string &id, QList<QTreeWidgetItem*> &items);
|
||||||
|
@ -145,8 +147,8 @@ private:
|
||||||
void fillList();
|
void fillList();
|
||||||
void secured_fillList();
|
void secured_fillList();
|
||||||
|
|
||||||
void selectedIds(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);
|
void selectedIds_internal(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);
|
||||||
void setSelectedIds(IdType idType, const std::set<std::string> &ids, bool add);
|
void setSelectedIds_internal(IdType idType, const std::set<std::string> &ids, bool add);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mStarted;
|
bool mStarted;
|
||||||
|
@ -170,7 +172,7 @@ private:
|
||||||
std::vector<RsGxsGroupId> gxsIds ;
|
std::vector<RsGxsGroupId> gxsIds ;
|
||||||
QList<QAction*> mContextMenuActions;
|
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)
|
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)
|
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);
|
ui.adminsList->setSelectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(ids, false);
|
||||||
|
|
||||||
QString moderatorsListString ;
|
QString moderatorsListString ;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>1231</width>
|
||||||
<height>563</height>
|
<height>967</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -223,14 +223,14 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="publish_required">
|
<widget class="QRadioButton" name="publish_required">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Required</string>
|
<string>Re&quired</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="publish_encrypt">
|
<widget class="QRadioButton" name="publish_encrypt">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Encrypted Msgs</string>
|
<string>Encrypted &Msgs</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -856,7 +856,6 @@
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
<include location="../images.qrc"/>
|
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue