fixed compilation

This commit is contained in:
csoler 2019-06-28 16:20:26 +02:00
parent 1c123d6df9
commit 5e118e0e27
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
4 changed files with 481 additions and 495 deletions

View File

@ -53,6 +53,12 @@ RsFriendListModel::RsFriendListModel(QObject *parent)
mFilterStrings.clear(); mFilterStrings.clear();
} }
void RsFriendListModel::setDisplayGroups(bool b)
{
mDisplayGroups = b;
// should update here
}
void RsFriendListModel::preMods() void RsFriendListModel::preMods()
{ {
emit layoutAboutToBeChanged(); emit layoutAboutToBeChanged();
@ -603,3 +609,52 @@ void RsFriendListModel::debug_dump() const
for(auto it(mGroups.begin());it!=mGroups.end();++it) for(auto it(mGroups.begin());it!=mGroups.end();++it)
std::cerr << "Group: " << *it << std::endl; std::cerr << "Group: " << *it << std::endl;
} }
bool RsFriendListModel::getGroupData (const QModelIndex& i,RsGroupInfo & data) const
{
if(!i.isValid())
return false;
EntryIndex e;
if(!convertInternalIdToIndex(i.internalId(),e) || e.type != ENTRY_TYPE_GROUP || e.ind >= mGroups.size())
return false;
data = mGroups[e.ind];
return true;
}
bool RsFriendListModel::getProfileData(const QModelIndex& i,RsProfileDetails& data) const
{
if(!i.isValid())
return false;
EntryIndex e;
if(!convertInternalIdToIndex(i.internalId(),e) || e.type != ENTRY_TYPE_PROFILE || e.ind >= mProfiles.size())
return false;
data = mProfiles[e.ind];
return true;
}
bool RsFriendListModel::getNodeData (const QModelIndex& i,RsNodeDetails & data) const
{
if(!i.isValid())
return false;
EntryIndex e;
if(!convertInternalIdToIndex(i.internalId(),e) || e.type != ENTRY_TYPE_NODE || e.ind >= mLocations.size())
return false;
data = mLocations[e.ind];
return true;
}
RsFriendListModel::EntryType RsFriendListModel::getType(const QModelIndex& i) const
{
if(!i.isValid())
return ENTRY_TYPE_UNKNOWN;
EntryIndex e;
if(!convertInternalIdToIndex(i.internalId(),e))
return ENTRY_TYPE_UNKNOWN;
return e.type;
}

View File

@ -85,17 +85,23 @@ public:
}; };
QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;} QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;}
QModelIndex getIndexOfGroup(const RsNodeGroupId& mid) const; QModelIndex getIndexOfGroup(const RsNodeGroupId& mid) const;
static const QString FilterString ; static const QString FilterString ;
// This method will asynchroneously update the data // This method will asynchroneously update the data
EntryType currentItemData(RsGroupInfo&,RsProfileDetails&,RsNodeDetails&) const; void setDisplayGroups(bool b);
EntryType getType(const QModelIndex&) const;
bool getGroupData (const QModelIndex&,RsGroupInfo &) const;
bool getProfileData(const QModelIndex&,RsProfileDetails&) const;
bool getNodeData (const QModelIndex&,RsNodeDetails &) const;
void setFilter(FilterType filter_type, const QStringList& strings) ; void setFilter(FilterType filter_type, const QStringList& strings) ;
// Overloaded methods from QAbstractItemModel
int rowCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;
bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
@ -109,6 +115,7 @@ public:
void clear() ; void clear() ;
private:
QVariant sizeHintRole (int col) const; QVariant sizeHintRole (int col) const;
QVariant displayRole (const EntryIndex &e, int col) const; QVariant displayRole (const EntryIndex &e, int col) const;

View File

@ -110,7 +110,7 @@ Q_DECLARE_METATYPE(ElidedLabel*)
NewFriendList::NewFriendList(QWidget *parent) : NewFriendList::NewFriendList(QWidget *parent) :
QWidget(parent), QWidget(parent),
mCompareRole(new RSTreeWidgetItemCompareRole), // mCompareRole(new RSTreeWidgetItemCompareRole),
mShowGroups(true), mShowGroups(true),
mShowState(false), mShowState(false),
mHideUnconnected(false), mHideUnconnected(false),
@ -137,16 +137,19 @@ NewFriendList::NewFriendList(QWidget *parent) :
ui->filterLineEdit->setPlaceholderText(tr("Search")) ; ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
ui->filterLineEdit->showFilterIcon(); ui->filterLineEdit->showFilterIcon();
/* Add filter actions */ mModel = new RsFriendListModel();
QTreeWidgetItem *headerItem = ui->peerTreeWidget->headerItem(); ui->peerTreeWidget->setModel(mModel);
QString headerText = headerItem->text(COLUMN_NAME);
ui->filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME, QString("%1 %2").arg(tr("Search"), headerText));
ui->filterLineEdit->addFilter(QIcon(), tr("ID"), COLUMN_ID, tr("Search ID"));
mActionSortByState = new QAction(tr("Sort by state"), this); /* Add filter actions */
mActionSortByState->setCheckable(true); // QTreeWidgetItem *headerItem = ui->peerTreeWidget->headerItem();
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(sortByState(bool))); // QString headerText = headerItem->text(COLUMN_NAME);
ui->peerTreeWidget->addContextMenuAction(mActionSortByState); // ui->filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME, QString("%1 %2").arg(tr("Search"), headerText));
// ui->filterLineEdit->addFilter(QIcon(), tr("ID"), COLUMN_ID, tr("Search ID"));
// mActionSortByState = new QAction(tr("Sort by state"), this);
// mActionSortByState->setCheckable(true);
// connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(sortByState(bool)));
// ui->peerTreeWidget->addContextMenuAction(mActionSortByState);
/* Set sort */ /* Set sort */
sortByColumn(COLUMN_NAME, Qt::AscendingOrder); sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
@ -158,8 +161,8 @@ NewFriendList::NewFriendList(QWidget *parent) :
connect(Shortcut, SIGNAL(activated()), this, SLOT(removefriend())); connect(Shortcut, SIGNAL(activated()), this, SLOT(removefriend()));
/* Initialize tree */ /* Initialize tree */
ui->peerTreeWidget->enableColumnCustomize(true); // ui->peerTreeWidget->enableColumnCustomize(true);
ui->peerTreeWidget->setColumnCustomizable(COLUMN_NAME, false); // ui->peerTreeWidget->setColumnCustomizable(COLUMN_NAME, false);
connect(ui->peerTreeWidget, SIGNAL(columnVisibleChanged(int,bool)), this, SLOT(peerTreeColumnVisibleChanged(int,bool))); connect(ui->peerTreeWidget, SIGNAL(columnVisibleChanged(int,bool)), this, SLOT(peerTreeColumnVisibleChanged(int,bool)));
connect(ui->peerTreeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(peerTreeItemCollapsedExpanded(QTreeWidgetItem*))); connect(ui->peerTreeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(peerTreeItemCollapsedExpanded(QTreeWidgetItem*)));
connect(ui->peerTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(peerTreeItemCollapsedExpanded(QTreeWidgetItem*))); connect(ui->peerTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(peerTreeItemCollapsedExpanded(QTreeWidgetItem*)));
@ -183,7 +186,7 @@ NewFriendList::NewFriendList(QWidget *parent) :
NewFriendList::~NewFriendList() NewFriendList::~NewFriendList()
{ {
delete ui; delete ui;
delete(mCompareRole); // delete(mCompareRole);
} }
void NewFriendList::addToolButton(QToolButton *toolButton) void NewFriendList::addToolButton(QToolButton *toolButton)
@ -287,11 +290,12 @@ inline std::string getRsId(QTreeWidgetItem *item)
*/ */
void NewFriendList::peerTreeWidgetCustomPopupMenu() void NewFriendList::peerTreeWidgetCustomPopupMenu()
{ {
QTreeWidgetItem *c = getCurrentPeer(); QModelIndex index = getCurrentIndex();
RsFriendListModel::EntryType type = mModel->getType(index);
QMenu *contextMenu = new QMenu(this); QMenu contextMenu(this);
QWidget *widget = new QWidget(contextMenu); QWidget *widget = new QWidget(&contextMenu);
widget->setStyleSheet( ".QWidget{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC;}"); widget->setStyleSheet( ".QWidget{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC;}");
// create menu header // create menu header
@ -315,167 +319,173 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu()
QWidgetAction *widgetAction = new QWidgetAction(this); QWidgetAction *widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(widget); widgetAction->setDefaultWidget(widget);
contextMenu->addAction(widgetAction); contextMenu.addAction(widgetAction);
// create menu entries // create menu entries
if (c) if(index.isValid())
{ // if a peer is selected {
int type = c->type(); // define header
switch (type) {
case RsFriendListModel::ENTRY_TYPE_GROUP:
//this is a GPG key
textLabel->setText("<strong>" + tr("Group") + "</strong>");
break;
case RsFriendListModel::ENTRY_TYPE_PROFILE:
//this is a GPG key
textLabel->setText("<strong>" + tr("Friend") + "</strong>");
break;
case RsFriendListModel::ENTRY_TYPE_NODE:
//this is a SSL key
textLabel->setText("<strong>" + tr("Node") + "</strong>");
break;
}
// define header // QMenu *lobbyMenu = NULL;
switch (type) {
case TYPE_GROUP:
//this is a GPG key
textLabel->setText("<strong>" + tr("Group") + "</strong>");
break;
case TYPE_GPG:
//this is a GPG key
textLabel->setText("<strong>" + tr("Friend") + "</strong>");
break;
case TYPE_SSL:
//this is a SSL key
textLabel->setText("<strong>" + tr("Node") + "</strong>");
break;
}
// QMenu *lobbyMenu = NULL; switch (type)
{
case RsFriendListModel::ENTRY_TYPE_GROUP:
{
RsGroupInfo group_info ;
mModel->getGroupData(index,group_info);
switch (type) bool standard = group_info.flag & RS_GROUP_FLAG_STANDARD;
{
case TYPE_GROUP:
{
bool standard = c->data(COLUMN_DATA, ROLE_STANDARD).toBool();
#ifdef RS_DIRECT_CHAT #ifdef RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgfriend())); contextMenu.addAction(QIcon(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgGroup()));
contextMenu->addSeparator(); contextMenu.addSeparator();
#endif // RS_DIRECT_CHAT #endif // RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); contextMenu.addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
QAction *action = contextMenu->addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); QAction *action = contextMenu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
action->setDisabled(standard); action->setDisabled(standard);
} }
break; break;
case TYPE_GPG:
{ case RsFriendListModel::ENTRY_TYPE_PROFILE:
{
#ifdef RS_DIRECT_CHAT #ifdef RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); contextMenu.addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy()));
contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message"), this, SLOT(msgfriend())); contextMenu.addAction(QIcon(IMAGE_MSG), tr("Send message"), this, SLOT(msgProfile()));
contextMenu->addSeparator(); contextMenu.addSeparator();
#endif // RS_DIRECT_CHAT #endif // RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configurefriend())); contextMenu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile()));
contextMenu->addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend())); contextMenu.addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend()));
if(mShowGroups) RsFriendListModel::RsProfileDetails details;
{ mModel->getProfileData(index,details);
QMenu* addToGroupMenu = NULL;
QMenu* moveToGroupMenu = NULL;
std::list<RsGroupInfo> groupInfoList; if(mShowGroups)
rsPeers->getGroupInfoList(groupInfoList); {
QMenu* addToGroupMenu = NULL;
QMenu* moveToGroupMenu = NULL;
GroupDefs::sortByName(groupInfoList); std::list<RsGroupInfo> groupInfoList;
rsPeers->getGroupInfoList(groupInfoList);
RsPgpId gpgId ( getRsId(c)); GroupDefs::sortByName(groupInfoList);
QTreeWidgetItem *parent = c->parent(); RsPgpId gpgId ( details.gpg_id );
bool foundGroup = false; // QTreeWidgetItem *parent = c->parent();
// add action for all groups, except the own group
for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpgId) == groupIt->peerIds.end()) {
if (parent) {
if (addToGroupMenu == NULL) {
addToGroupMenu = new QMenu(tr("Add to group"), contextMenu);
}
QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu);
addToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup()));
addToGroupMenu->addAction(addToGroupAction);
}
if (moveToGroupMenu == NULL) { bool foundGroup = false;
moveToGroupMenu = new QMenu(tr("Move to group"), contextMenu); // add action for all groups, except the own group
} for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu); if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpgId) == groupIt->peerIds.end()) {
moveToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString())); // if (parent) {
connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup())); // if (addToGroupMenu == NULL) {
moveToGroupMenu->addAction(moveToGroupAction); // addToGroupMenu = new QMenu(tr("Add to group"), &contextMenu);
} else { // }
foundGroup = true; // QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu);
} // addToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
} // connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup()));
// addToGroupMenu->addAction(addToGroupAction);
// }
QMenu *groupsMenu = contextMenu->addMenu(QIcon(IMAGE_GROUP16), tr("Groups")); if (moveToGroupMenu == NULL) {
groupsMenu->addAction(QIcon(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup())); moveToGroupMenu = new QMenu(tr("Move to group"), &contextMenu);
}
QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu);
moveToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup()));
moveToGroupMenu->addAction(moveToGroupAction);
} else {
foundGroup = true;
}
}
if (addToGroupMenu || moveToGroupMenu || foundGroup) { QMenu *groupsMenu = contextMenu.addMenu(QIcon(IMAGE_GROUP16), tr("Groups"));
if (addToGroupMenu) { groupsMenu->addAction(QIcon(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup()));
groupsMenu->addMenu(addToGroupMenu);
}
if (moveToGroupMenu) { if (addToGroupMenu || moveToGroupMenu || foundGroup) {
groupsMenu->addMenu(moveToGroupMenu); if (addToGroupMenu) {
} groupsMenu->addMenu(addToGroupMenu);
}
if (foundGroup) { if (moveToGroupMenu) {
// add remove from group groupsMenu->addMenu(moveToGroupMenu);
if (parent && parent->type() == TYPE_GROUP) { }
QAction *removeFromGroup = groupsMenu->addAction(tr("Remove from group"));
removeFromGroup->setData(parent->data(COLUMN_DATA, ROLE_ID));
connect(removeFromGroup, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
QAction *removeFromAllGroups = groupsMenu->addAction(tr("Remove from all groups")); if (foundGroup) {
removeFromAllGroups->setData(""); // add remove from group
connect(removeFromAllGroups, SIGNAL(triggered()), this, SLOT(removeFromGroup())); // if (parent && parent->type() == TYPE_GROUP) {
} // QAction *removeFromGroup = groupsMenu->addAction(tr("Remove from group"));
} // removeFromGroup->setData(parent->data(COLUMN_DATA, ROLE_ID));
} // connect(removeFromGroup, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
// }
} QAction *removeFromAllGroups = groupsMenu->addAction(tr("Remove from all groups"));
break ; removeFromAllGroups->setData("");
connect(removeFromAllGroups, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
}
}
case TYPE_SSL: }
{ break ;
case RsFriendListModel::ENTRY_TYPE_NODE:
{
#ifdef RS_DIRECT_CHAT #ifdef RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); contextMenu.addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy()));
contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgfriend())); contextMenu.addAction(QIcon(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgNode()));
contextMenu->addSeparator(); contextMenu.addSeparator();
#endif // RS_DIRECT_CHAT #endif // RS_DIRECT_CHAT
contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configurefriend())); contextMenu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configureNode()));
if (type == TYPE_GPG || type == TYPE_SSL) { if (type == TYPE_GPG || type == TYPE_SSL) {
contextMenu->addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendfriend())); contextMenu.addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendNode()));
} }
RsFriendListModel::RsNodeDetails details;
mModel->getNodeData(index,details);
if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( RsPeerId(getRsId(c)) )) if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( details.id ))
contextMenu->addAction(QIcon(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectfriend())); contextMenu.addAction(QIcon(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectfriend()));
contextMenu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); contextMenu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate()));
//this is a SSL key //this is a SSL key
contextMenu->addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removefriend())); contextMenu.addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removefriend()));
} }
} }
} }
contextMenu->addSeparator(); contextMenu.addSeparator();
QAction *action = contextMenu->addAction(QIcon(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson())); QAction *action = contextMenu.addAction(QIcon(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson()));
if (RSLinkClipboard::empty(RetroShareLink::TYPE_CERTIFICATE)) if (RSLinkClipboard::empty(RetroShareLink::TYPE_CERTIFICATE))
action->setDisabled(true); action->setDisabled(true);
contextMenu->addAction(QIcon(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll())); contextMenu.addAction(QIcon(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll()));
contextMenu->addAction(QIcon(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll())); contextMenu.addAction(QIcon(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll()));
contextMenu = ui->peerTreeWidget->createStandardContextMenu(contextMenu); // contextMenu = ui->peerTreeWidget->createStandardContextMenu(contextMenu);
contextMenu->exec(QCursor::pos()); contextMenu.exec(QCursor::pos());
delete contextMenu;
} }
void NewFriendList::createNewGroup() void NewFriendList::createNewGroup()
@ -546,13 +556,13 @@ static void getNameWidget(QTreeWidget *treeWidget, QTreeWidgetItem *item, Elided
*/ */
bool NewFriendList::getExpandedGroups(std::set<RsNodeGroupId> &groups) const bool NewFriendList::getExpandedGroups(std::set<RsNodeGroupId> &groups) const
{ {
int itemCount = ui->peerTreeWidget->topLevelItemCount(); // int itemCount = ui->peerTreeWidget->topLevelItemCount();
for (int index = 0; index < itemCount; ++index) { // for (int index = 0; index < itemCount; ++index) {
QTreeWidgetItem *item = ui->peerTreeWidget->topLevelItem(index); // QTreeWidgetItem *item = ui->peerTreeWidget->topLevelItem(index);
if (item->type() == TYPE_GROUP && item->isExpanded()) { // if (item->type() == TYPE_GROUP && item->isExpanded()) {
groups.insert(RsNodeGroupId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString())); // groups.insert(RsNodeGroupId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()));
} // }
} // }
return true; return true;
} }
@ -561,15 +571,15 @@ bool NewFriendList::getExpandedGroups(std::set<RsNodeGroupId> &groups) const
*/ */
bool NewFriendList::getExpandedPeers(std::set<RsPgpId> &peers) const bool NewFriendList::getExpandedPeers(std::set<RsPgpId> &peers) const
{ {
peers.clear(); // peers.clear();
QTreeWidgetItemIterator it(ui->peerTreeWidget); // QTreeWidgetItemIterator it(ui->peerTreeWidget);
while (*it) { // while (*it) {
QTreeWidgetItem *item = *it; // QTreeWidgetItem *item = *it;
if (item->type() == TYPE_GPG && item->isExpanded()) { // if (item->type() == TYPE_GPG && item->isExpanded()) {
peers.insert(peers.end(), RsPgpId(getRsId(item))); // peers.insert(peers.end(), RsPgpId(getRsId(item)));
} // }
++it; // ++it;
} // }
return true; return true;
} }
@ -612,52 +622,42 @@ void NewFriendList::addFriend()
connwiz.exec (); connwiz.exec ();
} }
void NewFriendList::msgProfile()
void NewFriendList::msgfriend()
{ {
QTreeWidgetItem *item = getCurrentPeer(); RsFriendListModel::RsNodeDetails det;
if (!item) if(!getCurrentNode(det))
return; return;
switch (item->type()) { MessageComposer::msgFriend(det.id);
case TYPE_GROUP: }
break; void NewFriendList::msgGroup()
case TYPE_GPG: {
MessageComposer::msgFriend(RsPgpId(getRsId(item))); RsFriendListModel::RsNodeDetails det;
break;
case TYPE_SSL: if(!getCurrentNode(det))
MessageComposer::msgFriend(RsPeerId(getRsId(item))); return;
break;
} MessageComposer::msgFriend(det.id);
}
void NewFriendList::msgNode()
{
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
MessageComposer::msgFriend(det.id);
} }
void NewFriendList::recommendfriend() void NewFriendList::recommendNode()
{ {
QTreeWidgetItem *peer = getCurrentPeer(); RsFriendListModel::RsNodeDetails det;
if (!peer) if(!getCurrentNode(det))
return; return;
std::string peerId = getRsId(peer); MessageComposer::recommendFriend(std::set<RsPeerId>({ det.id }));
std::list<RsPeerId> ids;
switch (peer->type())
{
case TYPE_SSL:
ids.push_back(RsPeerId(peerId));
break;
case TYPE_GPG:
rsPeers->getAssociatedSSLIds(RsPgpId(peerId), ids);
break;
default:
return;
}
std::set<RsPeerId> sids ;
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
sids.insert(*it) ;
MessageComposer::recommendFriend(sids);
} }
void NewFriendList::pastePerson() void NewFriendList::pastePerson()
@ -668,9 +668,13 @@ void NewFriendList::pastePerson()
void NewFriendList::copyFullCertificate() void NewFriendList::copyFullCertificate()
{ {
QTreeWidgetItem *c = getCurrentPeer(); RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
RetroShareLink link = RetroShareLink::createCertificate(RsPeerId(getRsId(c))); RetroShareLink link = RetroShareLink::createCertificate(det.id);
urls.push_back(link); urls.push_back(link);
std::cerr << "link: " << std::endl; std::cerr << "link: " << std::endl;
@ -686,36 +690,55 @@ void NewFriendList::copyFullCertificate()
*/ */
std::string NewFriendList::getSelectedGroupId() const std::string NewFriendList::getSelectedGroupId() const
{ {
QTreeWidgetItem *c = getCurrentPeer(); RsGroupInfo ginfo;
if (c && c->type() == TYPE_GROUP) {
return getRsId(c);
}
return std::string(); if(!getCurrentGroup(ginfo))
return std::string();
return ginfo.id.toStdString();
} }
QTreeWidgetItem *NewFriendList::getCurrentPeer() const QModelIndex NewFriendList::getCurrentIndex() const
{
QModelIndexList selectedIndexes = ui->peerTreeWidget->selectionModel()->selectedIndexes();
if(selectedIndexes.size() != RsFriendListModel::COLUMN_THREAD_NB_COLUMNS) // check that a single row is selected
return QModelIndex();
return *selectedIndexes.begin();
}
bool NewFriendList::getCurrentGroup(RsGroupInfo& info) const
{ {
/* get the current, and extract the Id */ /* get the current, and extract the Id */
QTreeWidgetItem *item = ui->peerTreeWidget->currentItem();
#ifdef FRIENDS_DEBUG
if (!item)
{
std::cerr << "Invalid Current Item" << std::endl;
return NULL;
}
/* Display the columns of this item. */ QModelIndex index = getCurrentIndex();
QString out = "CurrentPeerItem: \n";
for(int i = 1; i < COLUMN_COUNT; ++i) if(!index.isValid())
{ return false;
QString txt = item -> text(i);
out += QString("\t%1:%2\n").arg(i).arg(txt); return mModel->getGroupData(index,info);
} }
std::cerr << out.toStdString(); bool NewFriendList::getCurrentNode(RsFriendListModel::RsNodeDetails& prof) const
#endif {
return item; /* get the current, and extract the Id */
QModelIndex index = getCurrentIndex();
if(!index.isValid())
return false;
return mModel->getNodeData(index,prof);
}
bool NewFriendList::getCurrentProfile(RsFriendListModel::RsProfileDetails& prof) const
{
/* get the current, and extract the Id */
QModelIndex index = getCurrentIndex();
if(!index.isValid())
return false;
return mModel->getProfileData(index,prof);
} }
#ifdef UNFINISHED_FD #ifdef UNFINISHED_FD
@ -751,141 +774,68 @@ void FriendsDialog::viewprofile()
* *
* All of these rely on the finding of the current Id. * All of these rely on the finding of the current Id.
*/ */
void NewFriendList::removeNode()
void NewFriendList::removefriend()
{ {
QTreeWidgetItem *c = getCurrentPeer(); RsFriendListModel::RsNodeDetails det;
#ifdef FRIENDS_DEBUG if(!getCurrentNode(det) || !rsPeers)
std::cerr << "FriendList::removefriend()" << std::endl;
#endif
if (!c)
{
#ifdef FRIENDS_DEBUG
std::cerr << "FriendList::removefriend() None Selected -- sorry" << std::endl;
#endif
return; return;
}
if (rsPeers) if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this node?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
{ rsPeers->removeFriendLocation(det.id);
switch (c->type()) {
case TYPE_GPG:
if(!RsPgpId(getRsId(c)).isNull()) {
if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this Friend?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
{
rsPeers->removeFriend(RsPgpId(getRsId(c)));
}
}
break;
case TYPE_SSL:
if (!RsPeerId(getRsId(c)).isNull()) {
if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this node?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
{
rsPeers->removeFriendLocation(RsPeerId(getRsId(c)));
}
}
break;
}
}
} }
void NewFriendList::connectfriend() void NewFriendList::removeProfile()
{ {
QTreeWidgetItem *c = getCurrentPeer(); RsFriendListModel::RsProfileDetails det;
#ifdef FRIENDS_DEBUG if(!getCurrentProfile(det) || !rsPeers)
std::cerr << "FriendList::connectfriend()" << std::endl;
#endif
if (!c)
{
#ifdef FRIENDS_DEBUG
std::cerr << "FriendList::connectfriend() None Selected -- sorry" << std::endl;
#endif
return; return;
}
if (rsPeers) if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this Friend?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
{ rsPeers->removeFriend(det.gpg_id);
if (c->type() == TYPE_GPG) {
int childCount = c->childCount();
for (int childIndex = 0; childIndex < childCount; ++childIndex) {
QTreeWidgetItem *item = c->child(childIndex);
if (item->type() == TYPE_SSL) {
rsPeers->connectAttempt(RsPeerId(getRsId(item)));
// Launch ProgressDialog, only if single SSL child. }
if (childCount == 1)
{ void NewFriendList::connectNode()
ConnectProgressDialog::showProgress(RsPeerId(getRsId(item))); {
} RsFriendListModel::RsNodeDetails det;
} if(!getCurrentNode(det) || !rsPeers)
} return;
} else {
//this is a SSL key rsPeers->connectAttempt(det.id);
rsPeers->connectAttempt(RsPeerId(getRsId(c))); ConnectProgressDialog::showProgress(det.id);
// Launch ProgressDialog.
ConnectProgressDialog::showProgress(RsPeerId(getRsId(c)));
}
}
} }
/* GUI stuff -> don't do anything directly with Control */ /* GUI stuff -> don't do anything directly with Control */
void NewFriendList::configurefriend() void NewFriendList::configureNode()
{ {
if(!RsPeerId(getRsId(getCurrentPeer())).isNull()) RsFriendListModel::RsNodeDetails det;
ConfCertDialog::showIt(RsPeerId(getRsId(getCurrentPeer())), ConfCertDialog::PageDetails);
else if(!RsPgpId(getRsId(getCurrentPeer())).isNull())
PGPKeyDialog::showIt(RsPgpId(getRsId(getCurrentPeer())), PGPKeyDialog::PageDetails);
else
std::cerr << "FriendList::configurefriend: id is not an SSL nor a PGP id." << std::endl;
}
void NewFriendList::getSslIdsFromIndex(const QModelIndex& item, std::list<RsPeerId> &sslIds) if(!getCurrentNode(det))
{
if (item == NULL) {
return; return;
}
std::string peerId = getRsId(item); ConfCertDialog::showIt(det.id, ConfCertDialog::PageDetails);
}
void NewFriendList::configureProfile()
{
RsFriendListModel::RsProfileDetails det;
switch (item->type()) { if(!getCurrentProfile(det))
case TYPE_SSL: return;
sslIds.push_back(RsPeerId(peerId));
break; PGPKeyDialog::showIt(det.gpg_id, PGPKeyDialog::PageDetails);
case TYPE_GPG:
rsPeers->getAssociatedSSLIds(RsPgpId(peerId), sslIds);
break;
case TYPE_GROUP:
{
RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(RsNodeGroupId(peerId), groupInfo)) {
std::set<RsPgpId>::iterator gpgIt;
for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); ++gpgIt) {
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
}
}
}
break;
}
} }
void NewFriendList::addToGroup() void NewFriendList::addToGroup()
{ {
QTreeWidgetItem *c = getCurrentPeer(); RsFriendListModel::RsProfileDetails det;
if (c == NULL) { if(!getCurrentProfile(det) || !rsPeers)
return; return;
}
if (c->type() != TYPE_GPG) {
// wrong type
return;
}
RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString()); RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString());
RsPgpId gpgId ( getRsId(c)); RsPgpId gpgId (det.gpg_id);
if (gpgId.isNull() || groupId.isNull()) { if (gpgId.isNull() || groupId.isNull())
return; return;
}
// automatically expand the group, the peer is added to // automatically expand the group, the peer is added to
addGroupToExpand(groupId); addGroupToExpand(groupId);
@ -896,22 +846,16 @@ void NewFriendList::addToGroup()
void NewFriendList::moveToGroup() void NewFriendList::moveToGroup()
{ {
QTreeWidgetItem *c = getCurrentPeer(); RsFriendListModel::RsProfileDetails pinfo;
if (c == NULL) {
return;
}
if (c->type() != TYPE_GPG) { if(!getCurrentProfile(pinfo))
// wrong type
return; return;
}
RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString()); RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString());
RsPgpId gpgId ( getRsId(c)); RsPgpId gpgId ( pinfo.gpg_id );
if (gpgId.isNull() || groupId.isNull()) { if (gpgId.isNull() || groupId.isNull())
return; return;
}
// remove from all groups // remove from all groups
rsPeers->assignPeerToGroup(RsNodeGroupId(), gpgId, false); rsPeers->assignPeerToGroup(RsNodeGroupId(), gpgId, false);
@ -925,22 +869,16 @@ void NewFriendList::moveToGroup()
void NewFriendList::removeFromGroup() void NewFriendList::removeFromGroup()
{ {
QTreeWidgetItem *c = getCurrentPeer(); RsFriendListModel::RsProfileDetails pinfo;
if (c == NULL) {
return;
}
if (c->type() != TYPE_GPG) { if(!getCurrentProfile(pinfo))
// wrong type
return; return;
}
RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString()); RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString());
RsPgpId gpgId ( getRsId(c)); RsPgpId gpgId ( pinfo.gpg_id );
if (gpgId.isNull()) { if (gpgId.isNull())
return; return;
}
// remove from (all) group(s) // remove from (all) group(s)
rsPeers->assignPeerToGroup(groupId, gpgId, false); rsPeers->assignPeerToGroup(groupId, gpgId, false);
@ -948,17 +886,12 @@ void NewFriendList::removeFromGroup()
void NewFriendList::editGroup() void NewFriendList::editGroup()
{ {
QTreeWidgetItem *c = getCurrentPeer(); RsGroupInfo pinfo;
if (c == NULL) {
return;
}
if (c->type() != TYPE_GROUP) { if(!getCurrentGroup(pinfo))
// wrong type
return; return;
}
RsNodeGroupId groupId ( getRsId(c)); RsNodeGroupId groupId ( pinfo.id );
if (!groupId.isNull()) if (!groupId.isNull())
{ {
@ -969,20 +902,12 @@ void NewFriendList::editGroup()
void NewFriendList::removeGroup() void NewFriendList::removeGroup()
{ {
QTreeWidgetItem *c = getCurrentPeer(); RsGroupInfo pinfo;
if (c == NULL) {
if(!getCurrentGroup(pinfo))
return; return;
}
if (c->type() != TYPE_GROUP) { rsPeers->removeGroup(pinfo.id);
// wrong type
return;
}
RsNodeGroupId groupId ( getRsId(c));
if (!groupId.isNull())
rsPeers->removeGroup(groupId);
} }
void NewFriendList::exportFriendlistClicked() void NewFriendList::exportFriendlistClicked()
@ -1339,7 +1264,7 @@ bool NewFriendList::getGroupIdByName(const std::string &name, RsNodeGroupId &id)
* @param id groupd id * @param id groupd id
* @return success or failure * @return success or failure
*/ */
bool NewFriendList::getOrCreateGroup(const std::string &name, const uint &flag, RsNodeGroupId &id) bool NewFriendList::getOrCreateGroup(const std::string& name, uint flag, RsNodeGroupId &id)
{ {
if(getGroupIdByName(name, id)) if(getGroupIdByName(name, id))
return true; return true;
@ -1405,23 +1330,23 @@ void NewFriendList::setShowState(bool show)
void NewFriendList::sortByState(bool sort) void NewFriendList::sortByState(bool sort)
{ {
int columnCount = ui->peerTreeWidget->columnCount(); // int columnCount = ui->peerTreeWidget->columnCount();
for (int i = 0; i < columnCount; ++i) { // for (int i = 0; i < columnCount; ++i) {
mCompareRole->setRole(i, ROLE_SORT_GROUP); // mCompareRole->setRole(i, ROLE_SORT_GROUP);
mCompareRole->addRole(i, ROLE_SORT_STANDARD_GROUP); // mCompareRole->addRole(i, ROLE_SORT_STANDARD_GROUP);
//
if (sort) { // if (sort) {
mCompareRole->addRole(i, ROLE_SORT_STATE); // mCompareRole->addRole(i, ROLE_SORT_STATE);
mCompareRole->addRole(i, ROLE_SORT_NAME); // mCompareRole->addRole(i, ROLE_SORT_NAME);
} else { // } else {
mCompareRole->addRole(i, ROLE_SORT_NAME); // mCompareRole->addRole(i, ROLE_SORT_NAME);
mCompareRole->addRole(i, ROLE_SORT_STATE); // mCompareRole->addRole(i, ROLE_SORT_STATE);
} // }
} // }
//
mActionSortByState->setChecked(sort); // mActionSortByState->setChecked(sort);
//
ui->peerTreeWidget->resort(); // ui->peerTreeWidget->resort();
} }
bool NewFriendList::isSortByState() bool NewFriendList::isSortByState()
@ -1431,24 +1356,7 @@ bool NewFriendList::isSortByState()
void NewFriendList::setShowGroups(bool show) void NewFriendList::setShowGroups(bool show)
{ {
if (mShowGroups != show) { mModel->setDisplayGroups(show);
mShowGroups = show;
if (mShowGroups) {
// remove all not assigned gpg ids
int childCount = ui->peerTreeWidget->topLevelItemCount();
int childIndex = 0;
while (childIndex < childCount) {
QTreeWidgetItem *item = ui->peerTreeWidget->topLevelItem(childIndex);
if (item->type() == TYPE_GPG) {
delete(ui->peerTreeWidget->takeTopLevelItem(childIndex));
childCount = ui->peerTreeWidget->topLevelItemCount();
continue;
}
++childIndex;
}
}
insertPeers();
}
} }
/** /**
@ -1458,7 +1366,13 @@ void NewFriendList::filterItems(const QString &text)
{ {
int filterColumn = ui->filterLineEdit->currentFilter(); int filterColumn = ui->filterLineEdit->currentFilter();
mFilterText = text; mFilterText = text;
ui->peerTreeWidget->filterItems(filterColumn, mFilterText, ROLE_FILTER);
QStringList lst = text.split(' ',QString::SkipEmptyParts);
if(filterColumn == 0)
mModel->setFilter(RsFriendListModel::FILTER_TYPE_NAME,lst);
else if(filterColumn==1)
mModel->setFilter(RsFriendListModel::FILTER_TYPE_ID,lst);
} }
/** /**
@ -1488,9 +1402,9 @@ void NewFriendList::createDisplayMenu()
displayMenu->addAction(ui->actionShowState); displayMenu->addAction(ui->actionShowState);
displayMenu->addAction(ui->actionShowGroups); displayMenu->addAction(ui->actionShowGroups);
ui->peerTreeWidget->addContextMenuMenu(displayMenu); // ui->peerTreeWidget->addContextMenuMenu(displayMenu);
ui->peerTreeWidget->addContextMenuAction(ui->actionExportFriendlist); // ui->peerTreeWidget->addContextMenuAction(ui->actionExportFriendlist);
ui->peerTreeWidget->addContextMenuAction(ui->actionImportFriendlist); // ui->peerTreeWidget->addContextMenuAction(ui->actionImportFriendlist);
} }
void NewFriendList::updateMenu() void NewFriendList::updateMenu()

View File

@ -25,6 +25,7 @@
#include <QWidget> #include <QWidget>
#include <QTreeView> #include <QTreeView>
#include "FriendListModel.h"
#include "retroshare/rsstatus.h" #include "retroshare/rsstatus.h"
namespace Ui { namespace Ui {
@ -37,126 +38,135 @@ class QToolButton;
class NewFriendList: public QWidget class NewFriendList: public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QColor textColorGroup READ textColorGroup WRITE setTextColorGroup) Q_PROPERTY(QColor textColorGroup READ textColorGroup WRITE setTextColorGroup)
Q_PROPERTY(QColor textColorStatusOffline READ textColorStatusOffline WRITE setTextColorStatusOffline) Q_PROPERTY(QColor textColorStatusOffline READ textColorStatusOffline WRITE setTextColorStatusOffline)
Q_PROPERTY(QColor textColorStatusAway READ textColorStatusAway WRITE setTextColorStatusAway) Q_PROPERTY(QColor textColorStatusAway READ textColorStatusAway WRITE setTextColorStatusAway)
Q_PROPERTY(QColor textColorStatusBusy READ textColorStatusBusy WRITE setTextColorStatusBusy) Q_PROPERTY(QColor textColorStatusBusy READ textColorStatusBusy WRITE setTextColorStatusBusy)
Q_PROPERTY(QColor textColorStatusOnline READ textColorStatusOnline WRITE setTextColorStatusOnline) Q_PROPERTY(QColor textColorStatusOnline READ textColorStatusOnline WRITE setTextColorStatusOnline)
Q_PROPERTY(QColor textColorStatusInactive READ textColorStatusInactive WRITE setTextColorStatusInactive) Q_PROPERTY(QColor textColorStatusInactive READ textColorStatusInactive WRITE setTextColorStatusInactive)
public: public:
enum Column enum Column
{ {
COLUMN_NAME = 0, COLUMN_NAME = 0,
COLUMN_LAST_CONTACT = 1, COLUMN_LAST_CONTACT = 1,
COLUMN_IP = 2, COLUMN_IP = 2,
COLUMN_ID = 3 COLUMN_ID = 3
}; };
public: public:
explicit NewFriendList(QWidget *parent = 0); explicit NewFriendList(QWidget *parent = 0);
~NewFriendList(); ~NewFriendList();
// Add a tool button to the tool area // Add a tool button to the tool area
void addToolButton(QToolButton *toolButton); void addToolButton(QToolButton *toolButton);
void processSettings(bool load); void processSettings(bool load);
void addGroupToExpand(const RsNodeGroupId &groupId); void addGroupToExpand(const RsNodeGroupId &groupId);
bool getExpandedGroups(std::set<RsNodeGroupId> &groups) const; bool getExpandedGroups(std::set<RsNodeGroupId> &groups) const;
void addPeerToExpand(const RsPgpId &gpgId); void addPeerToExpand(const RsPgpId &gpgId);
bool getExpandedPeers(std::set<RsPgpId> &peers) const; bool getExpandedPeers(std::set<RsPgpId> &peers) const;
std::string getSelectedGroupId() const; std::string getSelectedGroupId() const;
void setColumnVisible(Column column, bool visible); void setColumnVisible(Column column, bool visible);
void sortByColumn(Column column, Qt::SortOrder sortOrder); void sortByColumn(Column column, Qt::SortOrder sortOrder);
bool isSortByState(); bool isSortByState();
QColor textColorGroup() const { return mTextColorGroup; } QColor textColorGroup() const { return mTextColorGroup; }
QColor textColorStatusOffline() const { return mTextColorStatus[RS_STATUS_OFFLINE]; } QColor textColorStatusOffline() const { return mTextColorStatus[RS_STATUS_OFFLINE]; }
QColor textColorStatusAway() const { return mTextColorStatus[RS_STATUS_AWAY]; } QColor textColorStatusAway() const { return mTextColorStatus[RS_STATUS_AWAY]; }
QColor textColorStatusBusy() const { return mTextColorStatus[RS_STATUS_BUSY]; } QColor textColorStatusBusy() const { return mTextColorStatus[RS_STATUS_BUSY]; }
QColor textColorStatusOnline() const { return mTextColorStatus[RS_STATUS_ONLINE]; } QColor textColorStatusOnline() const { return mTextColorStatus[RS_STATUS_ONLINE]; }
QColor textColorStatusInactive() const { return mTextColorStatus[RS_STATUS_INACTIVE]; } QColor textColorStatusInactive() const { return mTextColorStatus[RS_STATUS_INACTIVE]; }
void setTextColorGroup(QColor color) { mTextColorGroup = color; } void setTextColorGroup(QColor color) { mTextColorGroup = color; }
void setTextColorStatusOffline(QColor color) { mTextColorStatus[RS_STATUS_OFFLINE] = color; } void setTextColorStatusOffline(QColor color) { mTextColorStatus[RS_STATUS_OFFLINE] = color; }
void setTextColorStatusAway(QColor color) { mTextColorStatus[RS_STATUS_AWAY] = color; } void setTextColorStatusAway(QColor color) { mTextColorStatus[RS_STATUS_AWAY] = color; }
void setTextColorStatusBusy(QColor color) { mTextColorStatus[RS_STATUS_BUSY] = color; } void setTextColorStatusBusy(QColor color) { mTextColorStatus[RS_STATUS_BUSY] = color; }
void setTextColorStatusOnline(QColor color) { mTextColorStatus[RS_STATUS_ONLINE] = color; } void setTextColorStatusOnline(QColor color) { mTextColorStatus[RS_STATUS_ONLINE] = color; }
void setTextColorStatusInactive(QColor color) { mTextColorStatus[RS_STATUS_INACTIVE] = color; } void setTextColorStatusInactive(QColor color) { mTextColorStatus[RS_STATUS_INACTIVE] = color; }
public slots: public slots:
void filterItems(const QString &text); void filterItems(const QString &text);
void sortByState(bool sort); void sortByState(bool sort);
void setShowGroups(bool show); void setShowGroups(bool show);
void setHideUnconnected(bool hidden); void setHideUnconnected(bool hidden);
void setShowState(bool show); void setShowState(bool show);
private slots: private slots:
void peerTreeColumnVisibleChanged(int column, bool visible); void peerTreeColumnVisibleChanged(int column, bool visible);
void peerTreeItemCollapsedExpanded(QTreeWidgetItem *item); void peerTreeItemCollapsedExpanded(QTreeWidgetItem *item);
void collapseItem(QTreeWidgetItem *item); void collapseItem(QTreeWidgetItem *item);
void expandItem(QTreeWidgetItem *item); void expandItem(QTreeWidgetItem *item);
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
void createDisplayMenu(); void createDisplayMenu();
private: private:
Ui::NewFriendList *ui; Ui::NewFriendList *ui;
QAction *mActionSortByState; RsFriendListModel *mModel;
QAction *mActionSortByState;
// Settings for peer list display QModelIndex getCurrentIndex() const;
bool mShowGroups;
bool mShowState;
bool mHideUnconnected;
QString mFilterText; bool getCurrentNode(RsFriendListModel::RsNodeDetails& prof) const;
bool getCurrentGroup(RsGroupInfo& prof) const;
bool getCurrentProfile(RsFriendListModel::RsProfileDetails& prof) const;
bool groupsHasChanged; // Settings for peer list display
std::set<RsNodeGroupId> openGroups; bool mShowGroups;
std::set<RsPgpId> openPeers; bool mShowState;
bool mHideUnconnected;
/* Color definitions (for standard see qss.default) */ QString mFilterText;
QColor mTextColorGroup;
QColor mTextColorStatus[RS_STATUS_COUNT];
QTreeWidgetItem *getCurrentPeer() const; bool groupsHasChanged;
std::set<RsNodeGroupId> openGroups;
std::set<RsPgpId> openPeers;
bool getOrCreateGroup(const std::string& name, uint flag, RsNodeGroupId& id); /* Color definitions (for standard see qss.default) */
bool getGroupIdByName(const std::string& name, RsNodeGroupId& id); QColor mTextColorGroup;
QColor mTextColorStatus[RS_STATUS_COUNT];
bool importExportFriendlistFileDialog(QString &fileName, bool import); bool getOrCreateGroup(const std::string& name, uint flag, RsNodeGroupId& id);
bool exportFriendlist(QString &fileName); bool getGroupIdByName(const std::string& name, RsNodeGroupId& id);
bool importFriendlist(QString &fileName, bool &errorPeers, bool &errorGroups);
bool importExportFriendlistFileDialog(QString &fileName, bool import);
bool exportFriendlist(QString &fileName);
bool importFriendlist(QString &fileName, bool &errorPeers, bool &errorGroups);
private slots: private slots:
void groupsChanged(); void groupsChanged();
void insertPeers(); void insertPeers();
void peerTreeWidgetCustomPopupMenu(); void peerTreeWidgetCustomPopupMenu();
void updateMenu(); void updateMenu();
void pastePerson(); void pastePerson();
void connectfriend(); void connectNode();
void configurefriend(); void configureNode();
void chatfriend(QTreeWidgetItem *item); void configureProfile();
void chatfriendproxy(); void chatfriend(QTreeWidgetItem *item);
void copyFullCertificate(); void chatfriendproxy();
void addFriend(); void copyFullCertificate();
void msgfriend(); void addFriend();
void recommendfriend(); void msgNode();
void removefriend(); void msgGroup();
void createNewGroup() ; void msgProfile();
void recommendNode();
void removeNode();
void removeProfile();
void createNewGroup() ;
void addToGroup(); void addToGroup();
void moveToGroup(); void moveToGroup();
void removeFromGroup(); void removeFromGroup();
void editGroup(); void editGroup();
void removeGroup(); void removeGroup();
void exportFriendlistClicked(); void exportFriendlistClicked();
void importFriendlistClicked(); void importFriendlistClicked();
}; };