mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 16:09:37 -05:00
Added new level gpg id to FriendSelectionWidget (groups, gpg id, ssl id).
Added friend selection to the group dialog for better assigning of friends to groups. Updated english translation. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5881 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0adff2d02a
commit
09f42dbc3c
@ -1592,6 +1592,8 @@ bool p3PeerMgrIMPL::addGroup(RsGroupInfo &groupInfo)
|
||||
groupItem->PeerId(getOwnId());
|
||||
|
||||
groupList.push_back(groupItem);
|
||||
|
||||
groupInfo.id = groupItem->id;
|
||||
}
|
||||
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_ADD);
|
||||
|
@ -47,6 +47,7 @@ FriendRecommendDialog::FriendRecommendDialog() :
|
||||
|
||||
ui->recommendList->setHeaderText(tr("Recommend friends"));
|
||||
ui->recommendList->setModus(FriendSelectionWidget::MODUS_CHECK);
|
||||
ui->recommendList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
|
||||
ui->recommendList->start();
|
||||
|
||||
ui->toList->setHeaderText(tr("To"));
|
||||
|
@ -60,6 +60,7 @@ CreateChannel::CreateChannel()
|
||||
/* initialize key share list */
|
||||
ui.keyShareList->setHeaderText(tr("Contacts:"));
|
||||
ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
|
||||
ui.keyShareList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
|
||||
ui.keyShareList->start();
|
||||
|
||||
newChannel();
|
||||
|
@ -45,6 +45,7 @@ ShareKey::ShareKey(QWidget *parent, std::string grpId, int grpType) :
|
||||
/* initialize key share list */
|
||||
ui->keyShareList->setHeaderText(tr("Contacts:"));
|
||||
ui->keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
|
||||
ui->keyShareList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
|
||||
ui->keyShareList->start();
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ CreateLobbyDialog::CreateLobbyDialog(const std::list<std::string>& peer_list, in
|
||||
/* initialize key share list */
|
||||
ui->keyShareList->setHeaderText(tr("Contacts:"));
|
||||
ui->keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
|
||||
ui->keyShareList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
|
||||
ui->keyShareList->start();
|
||||
ui->keyShareList->setSelectedSslIds(peer_list, false);
|
||||
|
||||
|
@ -338,10 +338,9 @@ void FriendList::peerTreeWidgetCostumPopupMenu()
|
||||
|
||||
contextMnu.addSeparator();
|
||||
|
||||
QAction *action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
|
||||
action->setDisabled(standard);
|
||||
contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
|
||||
|
||||
action = contextMnu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
|
||||
QAction *action = contextMnu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
|
||||
action->setDisabled(standard);
|
||||
|
||||
lobbyMenu = contextMnu.addMenu(QIcon(IMAGE_CHAT), tr("Chat lobbies")) ;
|
||||
|
@ -78,8 +78,10 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) :
|
||||
|
||||
started = false;
|
||||
listModus = MODUS_SINGLE;
|
||||
showGroups = true;
|
||||
inItemChanged = false;
|
||||
showTypes = SHOW_GROUP | SHOW_SSL;
|
||||
inGroupItemChanged = false;
|
||||
inGpgItemChanged = false;
|
||||
inSslItemChanged = false;
|
||||
|
||||
connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
|
||||
connect(ui->friendList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
|
||||
@ -142,9 +144,9 @@ void FriendSelectionWidget::setModus(Modus modus)
|
||||
fillList();
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::setShowGroups(bool show)
|
||||
void FriendSelectionWidget::setShowType(ShowTypes types)
|
||||
{
|
||||
showGroups = show;
|
||||
showTypes = types;
|
||||
|
||||
fillList();
|
||||
}
|
||||
@ -155,6 +157,31 @@ void FriendSelectionWidget::start()
|
||||
fillList();
|
||||
}
|
||||
|
||||
static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, const std::list<StatusInfo> &statusInfo, QColor textColorOnline)
|
||||
{
|
||||
QString name = PeerDefs::nameWithLocation(detail);
|
||||
item->setText(COLUMN_NAME, name);
|
||||
|
||||
int state = RS_STATUS_OFFLINE;
|
||||
if (detail.state & RS_PEER_STATE_CONNECTED) {
|
||||
std::list<StatusInfo>::const_iterator it;
|
||||
for (it = statusInfo.begin(); it != statusInfo.end() ; it++) {
|
||||
if (it->id == detail.id) {
|
||||
state = it->status;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state != (int) RS_STATUS_OFFLINE) {
|
||||
item->setTextColor(COLUMN_NAME, textColorOnline);
|
||||
}
|
||||
|
||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
||||
item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
|
||||
item->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::fillList()
|
||||
{
|
||||
if (!started) {
|
||||
@ -163,10 +190,19 @@ void FriendSelectionWidget::fillList()
|
||||
|
||||
// get selected items
|
||||
std::list<std::string> sslIdsSelected;
|
||||
selectedSslIds(sslIdsSelected, true);
|
||||
if (showTypes & SHOW_SSL) {
|
||||
selectedSslIds(sslIdsSelected, true);
|
||||
}
|
||||
|
||||
std::list<std::string> groupIdsSelected;
|
||||
selectedGroupIds(groupIdsSelected);
|
||||
if (showTypes & SHOW_GROUP) {
|
||||
selectedGroupIds(groupIdsSelected);
|
||||
}
|
||||
|
||||
std::list<std::string> gpgIdsSelected;
|
||||
if (showTypes & SHOW_GPG) {
|
||||
selectedGpgIds(gpgIdsSelected, true);
|
||||
}
|
||||
|
||||
// remove old items
|
||||
ui->friendList->clear();
|
||||
@ -176,22 +212,30 @@ void FriendSelectionWidget::fillList()
|
||||
std::list<RsGroupInfo>::iterator groupIt;
|
||||
rsPeers->getGroupInfoList(groupInfoList);
|
||||
|
||||
std::list<std::string> gpgIds;
|
||||
std::list<std::string>::iterator gpgIt;
|
||||
rsPeers->getGPGAcceptedList(gpgIds);
|
||||
|
||||
std::list<std::string> sslIds;
|
||||
std::list<std::string>::iterator sslIt;
|
||||
rsPeers->getFriendList(sslIds);
|
||||
if ((showTypes & (SHOW_SSL | SHOW_GPG)) == SHOW_SSL) {
|
||||
rsPeers->getFriendList(sslIds);
|
||||
}
|
||||
|
||||
std::list<StatusInfo> statusInfo;
|
||||
std::list<StatusInfo>::iterator statusIt;
|
||||
rsStatus->getStatusList(statusInfo);
|
||||
|
||||
std::list<std::string> filledSslIds;
|
||||
std::list<std::string> filledIds; // gpg or ssl id
|
||||
|
||||
// start with groups
|
||||
groupIt = groupInfoList.begin();
|
||||
while (true) {
|
||||
QTreeWidgetItem *groupItem = NULL;
|
||||
QTreeWidgetItem *gpgItem = NULL;
|
||||
RsGroupInfo *groupInfo = NULL;
|
||||
|
||||
if (showGroups && groupIt != groupInfoList.end()) {
|
||||
if ((showTypes & SHOW_GROUP) && groupIt != groupInfoList.end()) {
|
||||
groupInfo = &(*groupIt);
|
||||
|
||||
if (groupInfo->peerIds.size() == 0) {
|
||||
@ -228,67 +272,144 @@ void FriendSelectionWidget::fillList()
|
||||
}
|
||||
}
|
||||
|
||||
// iterate through ssl ids
|
||||
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*sslIt, detail)) {
|
||||
continue; /* BAD */
|
||||
}
|
||||
|
||||
if (groupInfo) {
|
||||
// we fill a group, check if gpg id is assigned
|
||||
if (std::find(groupInfo->peerIds.begin(), groupInfo->peerIds.end(), detail.gpg_id) == groupInfo->peerIds.end()) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// we fill the not assigned ssl ids
|
||||
if (std::find(filledSslIds.begin(), filledSslIds.end(), *sslIt) != filledSslIds.end()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// add equal too, its no problem
|
||||
filledSslIds.push_back(detail.id);
|
||||
|
||||
// make a widget per friend
|
||||
QTreeWidgetItem *item = new RSTreeWidgetItem(compareRole, IDTYPE_SSL);
|
||||
|
||||
QString name = PeerDefs::nameWithLocation(detail);
|
||||
item->setText(COLUMN_NAME, name);
|
||||
|
||||
int state = RS_STATUS_OFFLINE;
|
||||
if (detail.state & RS_PEER_STATE_CONNECTED) {
|
||||
std::list<StatusInfo>::iterator it;
|
||||
for (it = statusInfo.begin(); it != statusInfo.end() ; it++) {
|
||||
if (it->id == detail.id) {
|
||||
state = it->status;
|
||||
break;
|
||||
if (showTypes & SHOW_GPG) {
|
||||
// iterate through gpg ids
|
||||
for (gpgIt = gpgIds.begin(); gpgIt != gpgIds.end(); gpgIt++) {
|
||||
if (groupInfo) {
|
||||
// we fill a group, check if gpg id is assigned
|
||||
if (std::find(groupInfo->peerIds.begin(), groupInfo->peerIds.end(), *gpgIt) == groupInfo->peerIds.end()) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// we fill the not assigned gpg ids
|
||||
if (std::find(filledIds.begin(), filledIds.end(), *gpgIt) != filledIds.end()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// add equal too, its no problem
|
||||
filledIds.push_back(*gpgIt);
|
||||
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*gpgIt, detail)) {
|
||||
continue; /* BAD */
|
||||
}
|
||||
|
||||
// make a widget per friend
|
||||
gpgItem = new RSTreeWidgetItem(compareRole, IDTYPE_GPG);
|
||||
|
||||
QString name = QString::fromUtf8(detail.name.c_str());
|
||||
gpgItem->setText(COLUMN_NAME, name);
|
||||
|
||||
sslIds.clear();
|
||||
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
|
||||
|
||||
int state = RS_STATUS_OFFLINE;
|
||||
for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; statusIt++) {
|
||||
if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) {
|
||||
if (statusIt->status != RS_STATUS_OFFLINE) {
|
||||
state = RS_STATUS_ONLINE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state != (int) RS_STATUS_OFFLINE) {
|
||||
gpgItem->setTextColor(COLUMN_NAME, textColorOnline());
|
||||
}
|
||||
|
||||
gpgItem->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
||||
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id));
|
||||
gpgItem->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
|
||||
|
||||
if (listModus == MODUS_CHECK) {
|
||||
gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags());
|
||||
gpgItem->setCheckState(0, Qt::Unchecked);
|
||||
}
|
||||
|
||||
// add to the list
|
||||
if (groupItem) {
|
||||
groupItem->addChild(gpgItem);
|
||||
} else {
|
||||
ui->friendList->addTopLevelItem(gpgItem);
|
||||
}
|
||||
|
||||
gpgItem->setExpanded(true);
|
||||
|
||||
if (showTypes & SHOW_SSL) {
|
||||
// iterate through associated ssl ids
|
||||
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*sslIt, detail)) {
|
||||
continue; /* BAD */
|
||||
}
|
||||
|
||||
// make a widget per friend
|
||||
QTreeWidgetItem *item = new RSTreeWidgetItem(compareRole, IDTYPE_SSL);
|
||||
|
||||
initSslItem(item, detail, statusInfo, textColorOnline());
|
||||
|
||||
if (listModus == MODUS_CHECK) {
|
||||
item->setFlags(Qt::ItemIsUserCheckable | item->flags());
|
||||
item->setCheckState(0, Qt::Unchecked);
|
||||
}
|
||||
|
||||
// add to the list
|
||||
gpgItem->addChild(item);
|
||||
|
||||
if (std::find(sslIdsSelected.begin(), sslIdsSelected.end(), detail.id) != sslIdsSelected.end()) {
|
||||
setSelected(listModus, item, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (std::find(gpgIdsSelected.begin(), gpgIdsSelected.end(), detail.gpg_id) != gpgIdsSelected.end()) {
|
||||
setSelected(listModus, gpgItem, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// iterate through ssl ids
|
||||
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*sslIt, detail)) {
|
||||
continue; /* BAD */
|
||||
}
|
||||
|
||||
if (state != (int) RS_STATUS_OFFLINE) {
|
||||
item->setTextColor(COLUMN_NAME, textColorOnline());
|
||||
}
|
||||
if (groupInfo) {
|
||||
// we fill a group, check if gpg id is assigned
|
||||
if (std::find(groupInfo->peerIds.begin(), groupInfo->peerIds.end(), detail.gpg_id) == groupInfo->peerIds.end()) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// we fill the not assigned ssl ids
|
||||
if (std::find(filledIds.begin(), filledIds.end(), *sslIt) != filledIds.end()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
||||
item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
|
||||
item->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
|
||||
// add equal too, its no problem
|
||||
filledIds.push_back(detail.id);
|
||||
|
||||
if (listModus == MODUS_CHECK) {
|
||||
item->setFlags(Qt::ItemIsUserCheckable | item->flags());
|
||||
item->setCheckState(0, Qt::Unchecked);
|
||||
}
|
||||
// make a widget per friend
|
||||
QTreeWidgetItem *item = new RSTreeWidgetItem(compareRole, IDTYPE_SSL);
|
||||
|
||||
// add to the list
|
||||
if (groupItem) {
|
||||
groupItem->addChild(item);
|
||||
} else {
|
||||
ui->friendList->addTopLevelItem(item);
|
||||
}
|
||||
initSslItem(item, detail, statusInfo, textColorOnline());
|
||||
|
||||
if (std::find(sslIdsSelected.begin(), sslIdsSelected.end(), detail.id) != sslIdsSelected.end()) {
|
||||
setSelected(listModus, item, true);
|
||||
if (listModus == MODUS_CHECK) {
|
||||
item->setFlags(Qt::ItemIsUserCheckable | item->flags());
|
||||
item->setCheckState(0, Qt::Unchecked);
|
||||
}
|
||||
|
||||
// add to the list
|
||||
if (groupItem) {
|
||||
groupItem->addChild(item);
|
||||
} else {
|
||||
ui->friendList->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
if (std::find(sslIdsSelected.begin(), sslIdsSelected.end(), detail.id) != sslIdsSelected.end()) {
|
||||
setSelected(listModus, item, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,21 +432,79 @@ void FriendSelectionWidget::fillList()
|
||||
|
||||
void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
||||
{
|
||||
QString gpgId;
|
||||
int gpgStatus = RS_STATUS_OFFLINE;
|
||||
|
||||
if (showTypes & SHOW_GPG) {
|
||||
/* need gpg id and online state */
|
||||
RsPeerDetails detail;
|
||||
if (rsPeers->getPeerDetails(peerId.toStdString(), detail)) {
|
||||
gpgId = QString::fromStdString(detail.gpg_id);
|
||||
|
||||
if (status == (int) RS_STATUS_OFFLINE) {
|
||||
/* try other locations */
|
||||
std::list<std::string> sslIds;
|
||||
rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds);
|
||||
|
||||
std::list<StatusInfo> statusInfo;
|
||||
std::list<StatusInfo>::iterator statusIt;
|
||||
rsStatus->getStatusList(statusInfo);
|
||||
|
||||
for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; statusIt++) {
|
||||
if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) {
|
||||
if (statusIt->status != RS_STATUS_OFFLINE) {
|
||||
gpgStatus = RS_STATUS_ONLINE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* one location is online */
|
||||
gpgStatus = RS_STATUS_ONLINE;
|
||||
}
|
||||
}
|
||||
}
|
||||
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
||||
QTreeWidgetItem *item;
|
||||
while ((item = *itemIterator) != NULL) {
|
||||
itemIterator++;
|
||||
|
||||
if (item->data(COLUMN_DATA, ROLE_ID).toString() == peerId) {
|
||||
QColor color;
|
||||
if (status != (int) RS_STATUS_OFFLINE) {
|
||||
color = textColorOnline();
|
||||
}
|
||||
switch ((IdType) item->type()) {
|
||||
case IDTYPE_NONE:
|
||||
case IDTYPE_GROUP:
|
||||
break;
|
||||
case IDTYPE_GPG:
|
||||
{
|
||||
if (item->data(COLUMN_DATA, ROLE_ID).toString() == gpgId) {
|
||||
QColor color;
|
||||
if (status != (int) RS_STATUS_OFFLINE) {
|
||||
color = textColorOnline();
|
||||
} else {
|
||||
color = ui->friendList->palette().color(QPalette::Text);
|
||||
}
|
||||
|
||||
item->setTextColor(COLUMN_NAME, color);
|
||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status)));
|
||||
//break; no break, friend can assigned to groups more than one
|
||||
item->setTextColor(COLUMN_NAME, color);
|
||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(gpgStatus)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDTYPE_SSL:
|
||||
{
|
||||
if (item->data(COLUMN_DATA, ROLE_ID).toString() == peerId) {
|
||||
QColor color;
|
||||
if (status != (int) RS_STATUS_OFFLINE) {
|
||||
color = textColorOnline();
|
||||
} else {
|
||||
color = ui->friendList->palette().color(QPalette::Text);
|
||||
}
|
||||
|
||||
item->setTextColor(COLUMN_NAME, color);
|
||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
// friend can assigned to groups more than one
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,10 +524,6 @@ void FriendSelectionWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*colum
|
||||
|
||||
void FriendSelectionWidget::itemChanged(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
if (inItemChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (listModus != MODUS_CHECK) {
|
||||
return;
|
||||
}
|
||||
@ -357,46 +532,87 @@ void FriendSelectionWidget::itemChanged(QTreeWidgetItem *item, int column)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!showGroups) {
|
||||
return;
|
||||
}
|
||||
|
||||
inItemChanged = true;
|
||||
|
||||
switch ((IdType) item->type()) {
|
||||
case IDTYPE_NONE:
|
||||
break;
|
||||
case IDTYPE_GROUP:
|
||||
{
|
||||
if (inGroupItemChanged || inGpgItemChanged || inSslItemChanged) {
|
||||
break;
|
||||
}
|
||||
|
||||
inGroupItemChanged = true;
|
||||
|
||||
bool selected = isSelected(listModus, item);
|
||||
|
||||
int childCount = item->childCount();
|
||||
for (int i = 0; i < childCount; ++i) {
|
||||
setSelected(listModus, item->child(i), selected);
|
||||
}
|
||||
|
||||
inGroupItemChanged = false;
|
||||
}
|
||||
break;
|
||||
case IDTYPE_GPG:
|
||||
{
|
||||
if (inGpgItemChanged) {
|
||||
break;
|
||||
}
|
||||
|
||||
inGpgItemChanged = true;
|
||||
|
||||
if (!inSslItemChanged) {
|
||||
bool selected = isSelected(listModus, item);
|
||||
|
||||
int childCount = item->childCount();
|
||||
for (int i = 0; i < childCount; ++i) {
|
||||
setSelected(listModus, item->child(i), selected);
|
||||
}
|
||||
}
|
||||
|
||||
if (!inGroupItemChanged) {
|
||||
QTreeWidgetItem *itemParent = item->parent();
|
||||
if (itemParent) {
|
||||
int childCount = itemParent->childCount();
|
||||
bool foundUnselected = false;
|
||||
for (int index = 0; index < childCount; ++index) {
|
||||
if (!isSelected(listModus, itemParent->child(index))) {
|
||||
foundUnselected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setSelected(listModus, itemParent, !foundUnselected);
|
||||
}
|
||||
}
|
||||
|
||||
inGpgItemChanged = false;
|
||||
}
|
||||
break;
|
||||
case IDTYPE_SSL:
|
||||
{
|
||||
QTreeWidgetItem *itemParent = item->parent();
|
||||
if (itemParent == NULL) {
|
||||
if (inGroupItemChanged || inGpgItemChanged || inSslItemChanged) {
|
||||
break;
|
||||
}
|
||||
|
||||
int childCount = itemParent->childCount();
|
||||
bool foundUnselected = false;
|
||||
for (int index = 0; index < childCount; ++index) {
|
||||
if (!isSelected(listModus, itemParent->child(index))) {
|
||||
foundUnselected = true;
|
||||
break;
|
||||
inSslItemChanged = true;
|
||||
|
||||
QTreeWidgetItem *itemParent = item->parent();
|
||||
if (itemParent) {
|
||||
int childCount = itemParent->childCount();
|
||||
bool foundUnselected = false;
|
||||
for (int index = 0; index < childCount; ++index) {
|
||||
if (!isSelected(listModus, itemParent->child(index))) {
|
||||
foundUnselected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setSelected(listModus, itemParent, !foundUnselected);
|
||||
}
|
||||
setSelected(listModus, itemParent, !foundUnselected);
|
||||
|
||||
inSslItemChanged = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
inItemChanged = false;
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::filterItems(const QString& text)
|
||||
@ -470,15 +686,35 @@ void FriendSelectionWidget::selectedIds(IdType idType, std::list<std::string> &i
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDTYPE_GPG:
|
||||
if (idType == IDTYPE_GPG) {
|
||||
if (isSelected(listModus, item)) {
|
||||
id = item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
} else {
|
||||
if (!onlyDirectSelected) {
|
||||
QTreeWidgetItem *itemParent = item;
|
||||
while ((itemParent = itemParent->parent()) != NULL) {
|
||||
if (isSelected(listModus, itemParent)) {
|
||||
id = item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDTYPE_SSL:
|
||||
if (idType == IDTYPE_SSL) {
|
||||
if (isSelected(listModus, item)) {
|
||||
id = item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
} else {
|
||||
if (!onlyDirectSelected) {
|
||||
QTreeWidgetItem *itemParent = item->parent();
|
||||
if (itemParent && isSelected(listModus, itemParent)) {
|
||||
id = item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
QTreeWidgetItem *itemParent = item;
|
||||
while ((itemParent = itemParent->parent()) != NULL) {
|
||||
if (isSelected(listModus, itemParent)) {
|
||||
id = item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -505,6 +741,7 @@ void FriendSelectionWidget::setSelectedIds(IdType idType, const std::list<std::s
|
||||
case IDTYPE_NONE:
|
||||
break;
|
||||
case IDTYPE_GROUP:
|
||||
case IDTYPE_GPG:
|
||||
case IDTYPE_SSL:
|
||||
if (idType == itemType) {
|
||||
if (std::find(ids.begin(), ids.end(), id) != ids.end()) {
|
||||
|
@ -43,7 +43,8 @@ public:
|
||||
{
|
||||
IDTYPE_NONE,
|
||||
IDTYPE_GROUP,
|
||||
IDTYPE_SSL
|
||||
IDTYPE_SSL,
|
||||
IDTYPE_GPG
|
||||
};
|
||||
|
||||
enum Modus
|
||||
@ -53,21 +54,31 @@ public:
|
||||
MODUS_CHECK
|
||||
};
|
||||
|
||||
enum ShowType {
|
||||
SHOW_GROUP = 1,
|
||||
SHOW_GPG = 2,
|
||||
SHOW_SSL = 4
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(ShowTypes, ShowType)
|
||||
|
||||
public:
|
||||
explicit FriendSelectionWidget(QWidget *parent = 0);
|
||||
~FriendSelectionWidget();
|
||||
|
||||
void setHeaderText(const QString &text);
|
||||
void setModus(Modus modus);
|
||||
void setShowGroups(bool show);
|
||||
void setShowType(ShowTypes types);
|
||||
void start();
|
||||
|
||||
int selectedItemCount();
|
||||
QString selectedId(IdType &idType);
|
||||
void selectedSslIds(std::list<std::string> &sslIds, bool onlyDirectSelected) { selectedIds(IDTYPE_SSL, sslIds, onlyDirectSelected); }
|
||||
void selectedGpgIds(std::list<std::string> &gpgIds, bool onlyDirectSelected) { selectedIds(IDTYPE_GPG, gpgIds, onlyDirectSelected); }
|
||||
void selectedGroupIds(std::list<std::string> &groupIds) { selectedIds(IDTYPE_GROUP, groupIds, true); }
|
||||
|
||||
void setSelectedSslIds(const std::list<std::string> &sslIds, bool add) { setSelectedIds(IDTYPE_SSL, sslIds, add); }
|
||||
void setSelectedGpgIds(const std::list<std::string> &gpgIds, bool add) { setSelectedIds(IDTYPE_GPG, gpgIds, add); }
|
||||
void setSelectedGroupIds(const std::list<std::string> &groupIds, bool add) { setSelectedIds(IDTYPE_GROUP, groupIds, add); }
|
||||
|
||||
QColor textColorOnline() const { return mTextColorOnline; }
|
||||
@ -99,8 +110,10 @@ private:
|
||||
bool started;
|
||||
RSTreeWidgetItemCompareRole *compareRole;
|
||||
Modus listModus;
|
||||
bool showGroups;
|
||||
bool inItemChanged;
|
||||
ShowTypes showTypes;
|
||||
bool inGroupItemChanged;
|
||||
bool inGpgItemChanged;
|
||||
bool inSslItemChanged;
|
||||
|
||||
/* Color definitions (for standard see qss.default) */
|
||||
QColor mTextColorOnline;
|
||||
@ -108,4 +121,6 @@ private:
|
||||
Ui::FriendSelectionWidget *ui;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)
|
||||
|
||||
#endif // FRIENDSELECTIONWIDGET_H
|
||||
|
@ -55,6 +55,7 @@ CreateForum::CreateForum()
|
||||
/* initialize key share list */
|
||||
ui.keyShareList->setHeaderText(tr("Contacts:"));
|
||||
ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
|
||||
ui.keyShareList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
|
||||
ui.keyShareList->start();
|
||||
|
||||
newForum();
|
||||
|
@ -23,81 +23,128 @@
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include "util/misc.h"
|
||||
|
||||
#include "CreateGroup.h"
|
||||
#include "gui/common/GroupDefs.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
/** Default constructor */
|
||||
CreateGroup::CreateGroup(const std::string groupId, QWidget *parent)
|
||||
CreateGroup::CreateGroup(const std::string &groupId, QWidget *parent)
|
||||
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/user/add_group256.png"));
|
||||
Settings->loadWidgetInformation(this);
|
||||
|
||||
m_groupId = groupId;
|
||||
mIsStandard = false;
|
||||
|
||||
if (m_groupId.empty() == false) {
|
||||
/* edit exisiting group */
|
||||
RsGroupInfo groupInfo;
|
||||
if (rsPeers->getGroupInfo(m_groupId, groupInfo)) {
|
||||
ui.groupname->setText(misc::removeNewLine(groupInfo.name));
|
||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/user/add_group256.png"));
|
||||
|
||||
setWindowTitle(tr("Edit Group"));
|
||||
ui.headerFrame->setHeaderText(tr("Edit Group"));
|
||||
} else {
|
||||
/* Group not found, create new */
|
||||
m_groupId.clear();
|
||||
}
|
||||
} else {
|
||||
ui.headerFrame->setHeaderText(tr("Create a Group"));
|
||||
}
|
||||
mGroupId = groupId;
|
||||
|
||||
std::list<RsGroupInfo> groupInfoList;
|
||||
rsPeers->getGroupInfoList(groupInfoList);
|
||||
/* Initialize friends list */
|
||||
ui.friendList->setHeaderText(tr("Friends"));
|
||||
ui.friendList->setModus(FriendSelectionWidget::MODUS_CHECK);
|
||||
ui.friendList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GPG);
|
||||
ui.friendList->start();
|
||||
|
||||
std::list<RsGroupInfo>::iterator groupIt;
|
||||
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) {
|
||||
if (m_groupId.empty() || groupIt->id != m_groupId) {
|
||||
usedGroupNames.append(GroupDefs::name(*groupIt));
|
||||
}
|
||||
}
|
||||
if (mGroupId.empty() == false) {
|
||||
/* edit exisiting group */
|
||||
RsGroupInfo groupInfo;
|
||||
if (rsPeers->getGroupInfo(mGroupId, groupInfo)) {
|
||||
mIsStandard = (groupInfo.flag & RS_GROUP_FLAG_STANDARD);
|
||||
|
||||
on_groupname_textChanged(ui.groupname->text());
|
||||
if (mIsStandard) {
|
||||
ui.groupName->setText(GroupDefs::name(groupInfo));
|
||||
} else {
|
||||
ui.groupName->setText(misc::removeNewLine(groupInfo.name));
|
||||
}
|
||||
|
||||
setWindowTitle(tr("Edit Group"));
|
||||
ui.headerFrame->setHeaderText(tr("Edit Group"));
|
||||
|
||||
ui.groupName->setDisabled(mIsStandard);
|
||||
|
||||
ui.friendList->setSelectedGpgIds(groupInfo.peerIds, false);
|
||||
} else {
|
||||
/* Group not found, create new */
|
||||
mGroupId.clear();
|
||||
}
|
||||
} else {
|
||||
ui.headerFrame->setHeaderText(tr("Create a Group"));
|
||||
}
|
||||
|
||||
std::list<RsGroupInfo> groupInfoList;
|
||||
rsPeers->getGroupInfoList(groupInfoList);
|
||||
|
||||
std::list<RsGroupInfo>::iterator groupIt;
|
||||
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) {
|
||||
if (mGroupId.empty() || groupIt->id != mGroupId) {
|
||||
mUsedGroupNames.append(GroupDefs::name(*groupIt));
|
||||
}
|
||||
}
|
||||
|
||||
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(changeGroup()));
|
||||
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect(ui.groupName, SIGNAL(textChanged(QString)), this, SLOT(groupNameChanged(QString)));
|
||||
|
||||
groupNameChanged(ui.groupName->text());
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
CreateGroup::~CreateGroup()
|
||||
{
|
||||
Settings->saveWidgetInformation(this);
|
||||
}
|
||||
|
||||
void CreateGroup::on_groupname_textChanged(QString text)
|
||||
void CreateGroup::groupNameChanged(QString text)
|
||||
{
|
||||
if (text.isEmpty() || usedGroupNames.contains(misc::removeNewLine(text))) {
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
} else {
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
if (text.isEmpty() || mUsedGroupNames.contains(misc::removeNewLine(text))) {
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
} else {
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateGroup::on_buttonBox_accepted()
|
||||
void CreateGroup::changeGroup()
|
||||
{
|
||||
RsGroupInfo groupInfo;
|
||||
RsGroupInfo groupInfo;
|
||||
|
||||
if (m_groupId.empty()) {
|
||||
// add new group
|
||||
groupInfo.name = misc::removeNewLine(ui.groupname->text()).toUtf8().constData();
|
||||
if (rsPeers->addGroup(groupInfo)) {
|
||||
close();
|
||||
}
|
||||
} else {
|
||||
if (rsPeers->getGroupInfo(m_groupId, groupInfo) == true) {
|
||||
groupInfo.name = misc::removeNewLine(ui.groupname->text()).toUtf8().constData();
|
||||
if (rsPeers->editGroup(m_groupId, groupInfo)) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mGroupId.empty()) {
|
||||
// add new group
|
||||
groupInfo.name = misc::removeNewLine(ui.groupName->text()).toUtf8().constData();
|
||||
if (!rsPeers->addGroup(groupInfo)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (rsPeers->getGroupInfo(mGroupId, groupInfo) == true) {
|
||||
if (!mIsStandard) {
|
||||
groupInfo.name = misc::removeNewLine(ui.groupName->text()).toUtf8().constData();
|
||||
if (!rsPeers->editGroup(mGroupId, groupInfo)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::list<std::string> gpgIds;
|
||||
ui.friendList->selectedGpgIds(gpgIds, true);
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
for (it = groupInfo.peerIds.begin(); it != groupInfo.peerIds.end(); ++it) {
|
||||
std::list<std::string>::iterator gpgIt = std::find(gpgIds.begin(), gpgIds.end(), *it);
|
||||
if (gpgIt == gpgIds.end()) {
|
||||
rsPeers->assignPeerToGroup(groupInfo.id, *it, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
gpgIds.erase(gpgIt);
|
||||
}
|
||||
|
||||
for (it = gpgIds.begin(); it != gpgIds.end(); ++it) {
|
||||
rsPeers->assignPeerToGroup(groupInfo.id, *it, true);
|
||||
}
|
||||
|
||||
accept();
|
||||
}
|
||||
|
@ -19,39 +19,32 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifndef _CREATEGROUP_H
|
||||
#define _CREATEGROUP_H
|
||||
|
||||
#include "ui_CreateGroup.h"
|
||||
|
||||
|
||||
class CreateGroup : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default constructor */
|
||||
CreateGroup(const std::string groupId, QWidget *parent = 0);
|
||||
/** Default destructor */
|
||||
~CreateGroup();
|
||||
|
||||
public slots:
|
||||
/** Default constructor */
|
||||
CreateGroup(const std::string &groupId, QWidget *parent = 0);
|
||||
/** Default destructor */
|
||||
~CreateGroup();
|
||||
|
||||
private slots:
|
||||
void changeGroup();
|
||||
void groupNameChanged(QString);
|
||||
|
||||
private:
|
||||
std::string m_groupId;
|
||||
std::string mGroupId;
|
||||
QStringList mUsedGroupNames;
|
||||
bool mIsStandard;
|
||||
|
||||
QStringList usedGroupNames;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::CreateGroup ui;
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_groupname_textChanged(QString );
|
||||
/** Qt Designer generated object */
|
||||
Ui::CreateGroup ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>386</width>
|
||||
<height>158</height>
|
||||
<height>298</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -27,77 +27,55 @@
|
||||
<widget class="HeaderFrame" name="headerFrame"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="groupLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="groupLabel">
|
||||
<property name="text">
|
||||
<string>Group Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="groupname">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="groupName">
|
||||
<property name="toolTip">
|
||||
<string>Enter a name for your group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<item>
|
||||
<widget class="FriendSelectionWidget" name="friendList" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>208</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -110,24 +88,13 @@
|
||||
<header>gui/common/HeaderFrame.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>FriendSelectionWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/common/FriendSelectionWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CreateGroup</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>338</x>
|
||||
<y>116</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>192</x>
|
||||
<y>78</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -209,6 +209,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
|
||||
/* initialize friends list */
|
||||
ui.friendSelectionWidget->setHeaderText(tr("Send To:"));
|
||||
ui.friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_MULTI);
|
||||
ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
|
||||
ui.friendSelectionWidget->start();
|
||||
|
||||
QActionGroup *grp = new QActionGroup(this);
|
||||
|
@ -2787,6 +2787,10 @@ p, li { white-space: pre-wrap; }
|
||||
<source>Edit Group</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Friends</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>CreateLobbyDialog</name>
|
||||
|
Loading…
Reference in New Issue
Block a user