fixed auto-expanding of nodes in friend list

This commit is contained in:
csoler 2017-03-01 21:18:16 +01:00
parent 91f2cf720f
commit 006e5423db
2 changed files with 31 additions and 31 deletions

View File

@ -122,6 +122,8 @@ FriendList::FriendList(QWidget *parent) :
connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu()));
connect(ui->peerTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(chatfriend(QTreeWidgetItem *)));
connect(ui->peerTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(expandItem(QTreeWidgetItem *)));
connect(ui->peerTreeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this, SLOT(collapseItem(QTreeWidgetItem *)));
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged()));
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(insertPeers()));
@ -1267,40 +1269,36 @@ bool FriendList::getExpandedPeers(std::set<RsPgpId> &peers) const
return true;
}
///** Open a QFileDialog to browse for export a file. */
//void FriendList::exportfriend()
//{
// QTreeWidgetItem *c = getCurrentPeer();
//#ifdef FRIENDS_DEBUG
// std::cerr << "FriendList::exportfriend()" << std::endl;
//#endif
// if (!c)
// {
//#ifdef FRIENDS_DEBUG
// std::cerr << "FriendList::exportfriend() None Selected -- sorry" << std::endl;
//#endif
// return;
// }
// std::string id = getPeerRsCertId(c);
// if (misc::getSaveFileName(this, RshareSettings::LASTDIR_CERT, tr("Save Certificate"), tr("Certificates (*.pqi)"), fileName))
// {
//#ifdef FRIENDS_DEBUG
// std::cerr << "FriendList::exportfriend() Saving to: " << fileName.toStdString() << std::endl;
//#endif
// if (rsPeers)
// {
// rsPeers->saveCertificateToFile(id, fileName.toUtf8().constData());
// }
// }
//}
void FriendList::collapseItem(QTreeWidgetItem *item)
{
switch (item->type())
{
case TYPE_GROUP:
openGroups.erase(RsNodeGroupId(getRsId(item))) ;
break;
case TYPE_GPG:
openPeers.erase(RsPgpId(getRsId(item))) ;
default:
break;
}
}
void FriendList::expandItem(QTreeWidgetItem *item)
{
switch (item->type())
{
case TYPE_GROUP:
openGroups.insert(RsNodeGroupId(getRsId(item))) ;
break;
case TYPE_GPG:
openPeers.insert(RsPgpId(getRsId(item))) ;
default:
break;
}
}
void FriendList::chatfriendproxy()
{
chatfriend(getCurrentPeer());
chatfriend(getCurrentPeer());
}
/**

View File

@ -101,6 +101,8 @@ public slots:
private slots:
void peerTreeColumnVisibleChanged(int column, bool visible);
void peerTreeItemCollapsedExpanded(QTreeWidgetItem *item);
void collapseItem(QTreeWidgetItem *item);
void expandItem(QTreeWidgetItem *item);
protected:
void changeEvent(QEvent *e);