2012-01-26 19:32:17 -05:00
|
|
|
/****************************************************************
|
|
|
|
*
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012, RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
#include <QDialogButtonBox>
|
2012-01-26 19:32:17 -05:00
|
|
|
#include "FriendSelectionWidget.h"
|
|
|
|
#include "ui_FriendSelectionWidget.h"
|
|
|
|
#include "gui/notifyqt.h"
|
|
|
|
#include "gui/common/RSTreeWidgetItem.h"
|
|
|
|
#include "gui/common/StatusDefs.h"
|
|
|
|
#include "gui/common/PeerDefs.h"
|
|
|
|
#include "gui/common/GroupDefs.h"
|
2012-11-19 11:01:21 -05:00
|
|
|
#include "rshare.h"
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
#include <retroshare/rsstatus.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#define COLUMN_NAME 0
|
|
|
|
#define COLUMN_CHECK 0
|
|
|
|
#define COLUMN_DATA 0
|
2013-01-22 19:22:17 -05:00
|
|
|
#define COLUMN_COUNT 1
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
#define ROLE_ID Qt::UserRole
|
|
|
|
#define ROLE_SORT Qt::UserRole + 1
|
|
|
|
|
|
|
|
#define IMAGE_GROUP16 ":/images/user/group16.png"
|
|
|
|
#define IMAGE_FRIENDINFO ":/images/peerdetails_16x16.png"
|
|
|
|
|
|
|
|
static bool isSelected(FriendSelectionWidget::Modus modus, QTreeWidgetItem *item)
|
|
|
|
{
|
|
|
|
switch (modus) {
|
|
|
|
case FriendSelectionWidget::MODUS_SINGLE:
|
|
|
|
case FriendSelectionWidget::MODUS_MULTI:
|
|
|
|
return item->isSelected();
|
|
|
|
case FriendSelectionWidget::MODUS_CHECK:
|
|
|
|
return (item->checkState(COLUMN_CHECK) == Qt::Checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setSelected(FriendSelectionWidget::Modus modus, QTreeWidgetItem *item, bool select)
|
|
|
|
{
|
|
|
|
switch (modus) {
|
|
|
|
case FriendSelectionWidget::MODUS_SINGLE:
|
|
|
|
case FriendSelectionWidget::MODUS_MULTI:
|
|
|
|
item->setSelected(select);
|
|
|
|
break;
|
|
|
|
case FriendSelectionWidget::MODUS_CHECK:
|
|
|
|
item->setCheckState(COLUMN_CHECK, select ? Qt::Checked : Qt::Unchecked);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::FriendSelectionWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mStarted = false;
|
|
|
|
mListModus = MODUS_SINGLE;
|
|
|
|
mShowTypes = SHOW_GROUP | SHOW_SSL;
|
|
|
|
mInGroupItemChanged = false;
|
|
|
|
mInGpgItemChanged = false;
|
|
|
|
mInSslItemChanged = false;
|
|
|
|
mInFillList = false;
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
|
|
|
|
connect(ui->friendList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
|
|
|
|
connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));
|
2012-04-05 17:03:03 -04:00
|
|
|
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillList()));
|
|
|
|
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int)));
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mCompareRole = new RSTreeWidgetItemCompareRole;
|
|
|
|
mCompareRole->setRole(COLUMN_NAME, ROLE_SORT);
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
/* initialize list */
|
|
|
|
ui->friendList->setColumnCount(COLUMN_COUNT);
|
|
|
|
ui->friendList->headerItem()->setText(COLUMN_NAME, tr("Name"));
|
|
|
|
|
|
|
|
/* sort list by name ascending */
|
2012-01-26 19:32:17 -05:00
|
|
|
ui->friendList->sortItems(COLUMN_NAME, Qt::AscendingOrder);
|
2012-10-29 06:59:26 -04:00
|
|
|
|
|
|
|
ui->filterLineEdit->setPlaceholderText(tr("Search Friends"));
|
2012-11-05 19:28:11 -05:00
|
|
|
ui->filterLineEdit->showFilterIcon();
|
2012-11-19 11:01:21 -05:00
|
|
|
|
|
|
|
/* Refresh style to have the correct text color */
|
|
|
|
Rshare::refreshStyleSheet(this, false);
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
FriendSelectionWidget::~FriendSelectionWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2012-11-19 11:01:21 -05:00
|
|
|
void FriendSelectionWidget::changeEvent(QEvent *e)
|
|
|
|
{
|
|
|
|
QWidget::changeEvent(e);
|
|
|
|
switch (e->type()) {
|
|
|
|
case QEvent::StyleChange:
|
|
|
|
fillList();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// remove compiler warnings
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-26 19:32:17 -05:00
|
|
|
void FriendSelectionWidget::setHeaderText(const QString &text)
|
|
|
|
{
|
|
|
|
ui->friendList->headerItem()->setText(COLUMN_NAME, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FriendSelectionWidget::setModus(Modus modus)
|
|
|
|
{
|
2013-01-22 19:22:17 -05:00
|
|
|
mListModus = modus;
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
switch (mListModus) {
|
2012-01-26 19:32:17 -05:00
|
|
|
case MODUS_SINGLE:
|
|
|
|
case MODUS_CHECK:
|
|
|
|
ui->friendList->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
break;
|
|
|
|
case MODUS_MULTI:
|
|
|
|
ui->friendList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fillList();
|
|
|
|
}
|
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
void FriendSelectionWidget::setShowType(ShowTypes types)
|
2012-01-26 19:32:17 -05:00
|
|
|
{
|
2013-01-22 19:22:17 -05:00
|
|
|
mShowTypes = types;
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
fillList();
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
int FriendSelectionWidget::addColumn(const QString &title)
|
|
|
|
{
|
|
|
|
int column = ui->friendList->columnCount();
|
|
|
|
ui->friendList->setColumnCount(column + 1);
|
|
|
|
ui->friendList->headerItem()->setText(column, title);
|
|
|
|
return column;
|
|
|
|
}
|
|
|
|
|
2012-01-26 19:32:17 -05:00
|
|
|
void FriendSelectionWidget::start()
|
|
|
|
{
|
2013-01-22 19:22:17 -05:00
|
|
|
mStarted = true;
|
2012-01-26 19:32:17 -05:00
|
|
|
fillList();
|
2013-01-22 19:22:17 -05:00
|
|
|
|
|
|
|
for (int i = 0; i < ui->friendList->columnCount(); ++i) {
|
|
|
|
ui->friendList->resizeColumnToContents(i);
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-01-26 19:32:17 -05:00
|
|
|
void FriendSelectionWidget::fillList()
|
|
|
|
{
|
2013-01-22 19:22:17 -05:00
|
|
|
if (!mStarted) {
|
2012-01-26 19:32:17 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mInFillList = true;
|
|
|
|
|
2012-01-26 19:32:17 -05:00
|
|
|
// get selected items
|
|
|
|
std::list<std::string> sslIdsSelected;
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mShowTypes & SHOW_SSL) {
|
2012-11-24 09:48:31 -05:00
|
|
|
selectedSslIds(sslIdsSelected, true);
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
std::list<std::string> groupIdsSelected;
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mShowTypes & SHOW_GROUP) {
|
2012-11-24 09:48:31 -05:00
|
|
|
selectedGroupIds(groupIdsSelected);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<std::string> gpgIdsSelected;
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mShowTypes & SHOW_GPG) {
|
2012-11-24 09:48:31 -05:00
|
|
|
selectedGpgIds(gpgIdsSelected, true);
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
// remove old items
|
|
|
|
ui->friendList->clear();
|
|
|
|
|
|
|
|
// get existing groups
|
|
|
|
std::list<RsGroupInfo> groupInfoList;
|
|
|
|
std::list<RsGroupInfo>::iterator groupIt;
|
|
|
|
rsPeers->getGroupInfoList(groupInfoList);
|
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
std::list<std::string> gpgIds;
|
|
|
|
std::list<std::string>::iterator gpgIt;
|
|
|
|
rsPeers->getGPGAcceptedList(gpgIds);
|
|
|
|
|
2012-01-26 19:32:17 -05:00
|
|
|
std::list<std::string> sslIds;
|
|
|
|
std::list<std::string>::iterator sslIt;
|
2013-01-22 19:22:17 -05:00
|
|
|
if ((mShowTypes & (SHOW_SSL | SHOW_GPG)) == SHOW_SSL) {
|
2012-11-24 09:48:31 -05:00
|
|
|
rsPeers->getFriendList(sslIds);
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
std::list<StatusInfo> statusInfo;
|
2012-11-24 09:48:31 -05:00
|
|
|
std::list<StatusInfo>::iterator statusIt;
|
2012-01-26 19:32:17 -05:00
|
|
|
rsStatus->getStatusList(statusInfo);
|
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
std::list<std::string> filledIds; // gpg or ssl id
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
// start with groups
|
|
|
|
groupIt = groupInfoList.begin();
|
|
|
|
while (true) {
|
|
|
|
QTreeWidgetItem *groupItem = NULL;
|
2012-11-24 09:48:31 -05:00
|
|
|
QTreeWidgetItem *gpgItem = NULL;
|
2012-01-26 19:32:17 -05:00
|
|
|
RsGroupInfo *groupInfo = NULL;
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if ((mShowTypes & SHOW_GROUP) && groupIt != groupInfoList.end()) {
|
2012-01-26 19:32:17 -05:00
|
|
|
groupInfo = &(*groupIt);
|
|
|
|
|
|
|
|
if (groupInfo->peerIds.size() == 0) {
|
|
|
|
// don't show empty groups
|
|
|
|
groupIt++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add group item
|
2013-01-22 19:22:17 -05:00
|
|
|
groupItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GROUP);
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
// Add item to the list
|
|
|
|
ui->friendList->addTopLevelItem(groupItem);
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
groupItem->setFlags(Qt::ItemIsUserCheckable | groupItem->flags());
|
2012-01-26 19:32:17 -05:00
|
|
|
groupItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
|
|
|
groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP16));
|
|
|
|
|
|
|
|
groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id));
|
|
|
|
|
|
|
|
groupItem->setExpanded(true);
|
|
|
|
|
|
|
|
QString groupName = GroupDefs::name(*groupInfo);
|
|
|
|
groupItem->setText(COLUMN_NAME, groupName);
|
|
|
|
groupItem->setData(COLUMN_DATA, ROLE_SORT, ((groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? "0 " : "1 ") + groupName);
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mListModus == MODUS_CHECK) {
|
2012-01-26 19:32:17 -05:00
|
|
|
groupItem->setCheckState(0, Qt::Unchecked);
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
emit itemAdded(IDTYPE_GROUP, QString::fromStdString(groupInfo->id), groupItem);
|
|
|
|
|
2012-01-26 19:32:17 -05:00
|
|
|
if (std::find(groupIdsSelected.begin(), groupIdsSelected.end(), groupInfo->id) != groupIdsSelected.end()) {
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, groupItem, true);
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mShowTypes & SHOW_GPG) {
|
2012-11-24 09:48:31 -05:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
// add equal too, its no problem
|
|
|
|
filledIds.push_back(*gpgIt);
|
|
|
|
|
|
|
|
RsPeerDetails detail;
|
|
|
|
if (!rsPeers->getPeerDetails(*gpgIt, detail)) {
|
|
|
|
continue; /* BAD */
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
2012-11-24 09:48:31 -05:00
|
|
|
|
|
|
|
// make a widget per friend
|
2013-01-22 19:22:17 -05:00
|
|
|
gpgItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GPG);
|
2012-11-24 09:48:31 -05:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
if (state != (int) RS_STATUS_OFFLINE) {
|
|
|
|
gpgItem->setTextColor(COLUMN_NAME, textColorOnline());
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags());
|
2012-11-24 09:48:31 -05:00
|
|
|
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);
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mListModus == MODUS_CHECK) {
|
2012-11-24 09:48:31 -05:00
|
|
|
gpgItem->setCheckState(0, Qt::Unchecked);
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
// add to the list
|
|
|
|
if (groupItem) {
|
|
|
|
groupItem->addChild(gpgItem);
|
|
|
|
} else {
|
|
|
|
ui->friendList->addTopLevelItem(gpgItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
gpgItem->setExpanded(true);
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
emit itemAdded(IDTYPE_GPG, QString::fromStdString(detail.gpg_id), gpgItem);
|
|
|
|
|
|
|
|
if (mShowTypes & SHOW_SSL) {
|
2012-11-24 09:48:31 -05:00
|
|
|
// 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
|
2013-01-22 19:22:17 -05:00
|
|
|
QTreeWidgetItem *item = new RSTreeWidgetItem(mCompareRole, IDTYPE_SSL);
|
2012-11-24 09:48:31 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
item->setFlags(Qt::ItemIsUserCheckable | item->flags());
|
2012-11-24 09:48:31 -05:00
|
|
|
initSslItem(item, detail, statusInfo, textColorOnline());
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mListModus == MODUS_CHECK) {
|
2012-11-24 09:48:31 -05:00
|
|
|
item->setCheckState(0, Qt::Unchecked);
|
|
|
|
}
|
|
|
|
|
|
|
|
// add to the list
|
|
|
|
gpgItem->addChild(item);
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
emit itemAdded(IDTYPE_SSL, QString::fromStdString(detail.id), item);
|
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
if (std::find(sslIdsSelected.begin(), sslIdsSelected.end(), detail.id) != sslIdsSelected.end()) {
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, item, true);
|
2012-11-24 09:48:31 -05:00
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
if (std::find(gpgIdsSelected.begin(), gpgIdsSelected.end(), detail.gpg_id) != gpgIdsSelected.end()) {
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, gpgItem, true);
|
2012-11-24 09:48:31 -05:00
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
2012-11-24 09:48:31 -05:00
|
|
|
} else {
|
|
|
|
// iterate through ssl ids
|
|
|
|
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
|
|
|
|
RsPeerDetails detail;
|
|
|
|
if (!rsPeers->getPeerDetails(*sslIt, detail)) {
|
|
|
|
continue; /* BAD */
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
// add equal too, its no problem
|
|
|
|
filledIds.push_back(detail.id);
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
// make a widget per friend
|
2013-01-22 19:22:17 -05:00
|
|
|
QTreeWidgetItem *item = new RSTreeWidgetItem(mCompareRole, IDTYPE_SSL);
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
initSslItem(item, detail, statusInfo, textColorOnline());
|
2013-01-22 19:22:17 -05:00
|
|
|
item->setFlags(Qt::ItemIsUserCheckable | item->flags());
|
2012-11-24 09:48:31 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mListModus == MODUS_CHECK) {
|
2012-11-24 09:48:31 -05:00
|
|
|
item->setCheckState(0, Qt::Unchecked);
|
|
|
|
}
|
|
|
|
|
|
|
|
// add to the list
|
|
|
|
if (groupItem) {
|
|
|
|
groupItem->addChild(item);
|
|
|
|
} else {
|
|
|
|
ui->friendList->addTopLevelItem(item);
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
emit itemAdded(IDTYPE_SSL, QString::fromStdString(detail.id), item);
|
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
if (std::find(sslIdsSelected.begin(), sslIdsSelected.end(), detail.id) != sslIdsSelected.end()) {
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, item, true);
|
2012-11-24 09:48:31 -05:00
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (groupIt != groupInfoList.end()) {
|
|
|
|
groupIt++;
|
|
|
|
} else {
|
|
|
|
// all done
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-05 17:03:03 -04:00
|
|
|
if (ui->filterLineEdit->text().isEmpty() == false) {
|
|
|
|
filterItems(ui->filterLineEdit->text());
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ui->friendList->update(); /* update display */
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mInFillList = false;
|
|
|
|
|
2012-01-26 19:32:17 -05:00
|
|
|
emit contentChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
|
|
|
{
|
2012-11-24 09:48:31 -05:00
|
|
|
QString gpgId;
|
|
|
|
int gpgStatus = RS_STATUS_OFFLINE;
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mShowTypes & SHOW_GPG) {
|
2012-11-24 09:48:31 -05:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
|
|
|
QTreeWidgetItem *item;
|
|
|
|
while ((item = *itemIterator) != NULL) {
|
|
|
|
itemIterator++;
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
switch (idTypeFromItem(item)) {
|
2012-11-24 09:48:31 -05:00
|
|
|
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(gpgStatus)));
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
2012-11-24 09:48:31 -05:00
|
|
|
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);
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
|
2012-11-24 09:48:31 -05:00
|
|
|
item->setTextColor(COLUMN_NAME, color);
|
|
|
|
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
2012-11-24 09:48:31 -05:00
|
|
|
// friend can assigned to groups more than one
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FriendSelectionWidget::contextMenuRequested(const QPoint &pos)
|
|
|
|
{
|
|
|
|
emit customContextMenuRequested(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FriendSelectionWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
|
|
|
|
{
|
|
|
|
if (!item) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
emit doubleClicked(idTypeFromItem(item), item->data(COLUMN_DATA, ROLE_ID).toString());
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FriendSelectionWidget::itemChanged(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mInFillList) {
|
2012-01-26 19:32:17 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (column != COLUMN_CHECK) {
|
2013-01-22 19:22:17 -05:00
|
|
|
emit itemChanged(idTypeFromItem(item), item->data(COLUMN_DATA, ROLE_ID).toString(), item, column);
|
2012-01-26 19:32:17 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mListModus != MODUS_CHECK) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (idTypeFromItem(item)) {
|
2012-01-26 19:32:17 -05:00
|
|
|
case IDTYPE_NONE:
|
|
|
|
break;
|
|
|
|
case IDTYPE_GROUP:
|
|
|
|
{
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mInGroupItemChanged || mInGpgItemChanged || mInSslItemChanged) {
|
2012-11-24 09:48:31 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mInGroupItemChanged = true;
|
2012-11-24 09:48:31 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
bool selected = isSelected(mListModus, item);
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
int childCount = item->childCount();
|
|
|
|
for (int i = 0; i < childCount; ++i) {
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, item->child(i), selected);
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
2012-11-24 09:48:31 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mInGroupItemChanged = false;
|
2012-11-24 09:48:31 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDTYPE_GPG:
|
|
|
|
{
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mInGpgItemChanged) {
|
2012-11-24 09:48:31 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mInGpgItemChanged = true;
|
2012-11-24 09:48:31 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if (!mInSslItemChanged) {
|
|
|
|
bool selected = isSelected(mListModus, item);
|
2012-11-24 09:48:31 -05:00
|
|
|
|
|
|
|
int childCount = item->childCount();
|
|
|
|
for (int i = 0; i < childCount; ++i) {
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, item->child(i), selected);
|
2012-11-24 09:48:31 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
if (!mInGroupItemChanged) {
|
2012-11-24 09:48:31 -05:00
|
|
|
QTreeWidgetItem *itemParent = item->parent();
|
|
|
|
if (itemParent) {
|
|
|
|
int childCount = itemParent->childCount();
|
|
|
|
bool foundUnselected = false;
|
|
|
|
for (int index = 0; index < childCount; ++index) {
|
2013-01-22 19:22:17 -05:00
|
|
|
if (!isSelected(mListModus, itemParent->child(index))) {
|
2012-11-24 09:48:31 -05:00
|
|
|
foundUnselected = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, itemParent, !foundUnselected);
|
2012-11-24 09:48:31 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mInGpgItemChanged = false;
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDTYPE_SSL:
|
|
|
|
{
|
2013-01-22 19:22:17 -05:00
|
|
|
if (mInGroupItemChanged || mInGpgItemChanged || mInSslItemChanged) {
|
2012-01-26 19:32:17 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mInSslItemChanged = true;
|
2012-11-24 09:48:31 -05:00
|
|
|
|
|
|
|
QTreeWidgetItem *itemParent = item->parent();
|
|
|
|
if (itemParent) {
|
|
|
|
int childCount = itemParent->childCount();
|
|
|
|
bool foundUnselected = false;
|
|
|
|
for (int index = 0; index < childCount; ++index) {
|
2013-01-22 19:22:17 -05:00
|
|
|
if (!isSelected(mListModus, itemParent->child(index))) {
|
2012-11-24 09:48:31 -05:00
|
|
|
foundUnselected = true;
|
|
|
|
break;
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, itemParent, !foundUnselected);
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
2012-11-24 09:48:31 -05:00
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
mInSslItemChanged = false;
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-05 17:03:03 -04:00
|
|
|
void FriendSelectionWidget::filterItems(const QString& text)
|
2012-01-26 19:32:17 -05:00
|
|
|
{
|
|
|
|
int count = ui->friendList->topLevelItemCount();
|
|
|
|
for (int index = 0; index < count; index++) {
|
2012-04-05 17:03:03 -04:00
|
|
|
filterItem(ui->friendList->topLevelItem(index), text);
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FriendSelectionWidget::filterItem(QTreeWidgetItem *item, const QString &text)
|
|
|
|
{
|
|
|
|
bool visible = true;
|
|
|
|
|
|
|
|
if (text.isEmpty() == false) {
|
|
|
|
if (item->text(0).contains(text, Qt::CaseInsensitive) == false) {
|
|
|
|
visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int visibleChildCount = 0;
|
|
|
|
int count = item->childCount();
|
|
|
|
for (int index = 0; index < count; index++) {
|
|
|
|
if (filterItem(item->child(index), text)) {
|
|
|
|
visibleChildCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visible || visibleChildCount) {
|
|
|
|
item->setHidden(false);
|
|
|
|
} else {
|
|
|
|
item->setHidden(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (visible || visibleChildCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
int FriendSelectionWidget::selectedItemCount()
|
|
|
|
{
|
|
|
|
return ui->friendList->selectedItems().count();
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
std::string FriendSelectionWidget::selectedId(IdType &idType)
|
2012-01-26 19:32:17 -05:00
|
|
|
{
|
|
|
|
QTreeWidgetItem *item = ui->friendList->currentItem();
|
|
|
|
if (!item) {
|
|
|
|
idType = IDTYPE_NONE;
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
idType = idTypeFromItem(item);
|
|
|
|
return idFromItem(item);
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FriendSelectionWidget::selectedIds(IdType idType, std::list<std::string> &ids, bool onlyDirectSelected)
|
|
|
|
{
|
|
|
|
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
|
|
|
QTreeWidgetItem *item;
|
|
|
|
while ((item = *itemIterator) != NULL) {
|
|
|
|
itemIterator++;
|
|
|
|
|
|
|
|
std::string id;
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
switch (idTypeFromItem(item)) {
|
2012-01-26 19:32:17 -05:00
|
|
|
case IDTYPE_NONE:
|
|
|
|
break;
|
|
|
|
case IDTYPE_GROUP:
|
|
|
|
if (idType == IDTYPE_GROUP) {
|
2013-01-22 19:22:17 -05:00
|
|
|
if (isSelected(mListModus, item)) {
|
|
|
|
id = idFromItem(item);
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2012-11-24 09:48:31 -05:00
|
|
|
case IDTYPE_GPG:
|
|
|
|
if (idType == IDTYPE_GPG) {
|
2013-01-22 19:22:17 -05:00
|
|
|
if (isSelected(mListModus, item)) {
|
|
|
|
id = idFromItem(item);
|
2012-11-24 09:48:31 -05:00
|
|
|
} else {
|
|
|
|
if (!onlyDirectSelected) {
|
|
|
|
QTreeWidgetItem *itemParent = item;
|
|
|
|
while ((itemParent = itemParent->parent()) != NULL) {
|
2013-01-22 19:22:17 -05:00
|
|
|
if (isSelected(mListModus, itemParent)) {
|
|
|
|
id = idFromItem(item);
|
2012-11-24 09:48:31 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2012-01-26 19:32:17 -05:00
|
|
|
case IDTYPE_SSL:
|
|
|
|
if (idType == IDTYPE_SSL) {
|
2013-01-22 19:22:17 -05:00
|
|
|
if (isSelected(mListModus, item)) {
|
|
|
|
id = idFromItem(item);
|
2012-01-26 19:32:17 -05:00
|
|
|
} else {
|
|
|
|
if (!onlyDirectSelected) {
|
2012-11-24 09:48:31 -05:00
|
|
|
QTreeWidgetItem *itemParent = item;
|
|
|
|
while ((itemParent = itemParent->parent()) != NULL) {
|
2013-01-22 19:22:17 -05:00
|
|
|
if (isSelected(mListModus, itemParent)) {
|
|
|
|
id = idFromItem(item);
|
2012-11-24 09:48:31 -05:00
|
|
|
break;
|
|
|
|
}
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!id.empty() && std::find(ids.begin(), ids.end(), id) == ids.end()) {
|
|
|
|
ids.push_back(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FriendSelectionWidget::setSelectedIds(IdType idType, const std::list<std::string> &ids, bool add)
|
|
|
|
{
|
|
|
|
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
|
|
|
QTreeWidgetItem *item;
|
|
|
|
while ((item = *itemIterator) != NULL) {
|
|
|
|
itemIterator++;
|
|
|
|
|
2013-01-22 19:22:17 -05:00
|
|
|
std::string id = idFromItem(item);
|
|
|
|
IdType itemType = idTypeFromItem(item);
|
2012-01-26 19:32:17 -05:00
|
|
|
|
|
|
|
switch (itemType) {
|
|
|
|
case IDTYPE_NONE:
|
|
|
|
break;
|
|
|
|
case IDTYPE_GROUP:
|
2012-11-24 09:48:31 -05:00
|
|
|
case IDTYPE_GPG:
|
2012-01-26 19:32:17 -05:00
|
|
|
case IDTYPE_SSL:
|
|
|
|
if (idType == itemType) {
|
|
|
|
if (std::find(ids.begin(), ids.end(), id) != ids.end()) {
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, item, true);
|
2012-01-26 19:32:17 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!add) {
|
2013-01-22 19:22:17 -05:00
|
|
|
setSelected(mListModus, item, false);
|
2012-01-26 19:32:17 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-22 19:22:17 -05:00
|
|
|
|
|
|
|
void FriendSelectionWidget::itemsFromId(IdType idType, const std::string &id, QList<QTreeWidgetItem*> &items)
|
|
|
|
{
|
|
|
|
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
|
|
|
QTreeWidgetItem *item;
|
|
|
|
while ((item = *itemIterator) != NULL) {
|
|
|
|
itemIterator++;
|
|
|
|
|
|
|
|
if (idType == idTypeFromItem(item) && idFromItem(item) == id) {
|
|
|
|
items.push_back(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FriendSelectionWidget::items(QList<QTreeWidgetItem*> &_items, IdType idType)
|
|
|
|
{
|
|
|
|
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
|
|
|
QTreeWidgetItem *item;
|
|
|
|
while ((item = *itemIterator) != NULL) {
|
|
|
|
itemIterator++;
|
|
|
|
|
|
|
|
if (idType == IDTYPE_NONE || idType == idTypeFromItem(item)) {
|
|
|
|
_items.push_back(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FriendSelectionWidget::IdType FriendSelectionWidget::idTypeFromItem(QTreeWidgetItem *item)
|
|
|
|
{
|
|
|
|
if (!item) {
|
|
|
|
return IDTYPE_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (IdType) item->type();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string FriendSelectionWidget::idFromItem(QTreeWidgetItem *item)
|
|
|
|
{
|
|
|
|
if (!item) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
|
|
|
}
|
2013-02-22 16:42:27 -05:00
|
|
|
|