mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 14:12:43 -04:00
added widget for group selection. Used it in share dialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-FileSharingPermissions@5761 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
bd37e78884
commit
ccd08df35d
8 changed files with 99 additions and 55 deletions
37
retroshare-gui/src/gui/common/GroupSelectionBox.cpp
Normal file
37
retroshare-gui/src/gui/common/GroupSelectionBox.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include <retroshare/rspeers.h>
|
||||
#include "GroupSelectionBox.h"
|
||||
|
||||
GroupSelectionBox::GroupSelectionBox(QWidget *parent)
|
||||
: QListWidget(parent)
|
||||
{
|
||||
setSelectionMode(QAbstractItemView::ExtendedSelection) ;
|
||||
|
||||
// Fill with available groups
|
||||
|
||||
std::list<RsGroupInfo> lst ;
|
||||
rsPeers->getGroupInfoList(lst) ;
|
||||
|
||||
for(std::list<RsGroupInfo>::const_iterator it(lst.begin());it!=lst.end();++it)
|
||||
addItem(QString::fromStdString(it->id)) ;
|
||||
}
|
||||
|
||||
std::list<std::string> GroupSelectionBox::selectedGroups() const
|
||||
{
|
||||
QList<QListWidgetItem*> selected_items = selectedItems() ;
|
||||
std::list<std::string> out ;
|
||||
|
||||
for(QList<QListWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||
out.push_back((*it)->text().toStdString()) ;
|
||||
|
||||
return out ;
|
||||
}
|
||||
|
||||
void GroupSelectionBox::setSelectedGroups(const std::list<std::string>& group_ids)
|
||||
{
|
||||
for(std::list<std::string>::const_iterator it(group_ids.begin());it!=group_ids.end();++it)
|
||||
{
|
||||
QList<QListWidgetItem*> lst = findItems(QString::fromStdString(*it),Qt::MatchExactly) ;
|
||||
|
||||
setCurrentItem(*lst.begin(),QItemSelectionModel::Select) ;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue