/*! \brief remove the peer from the layout * * the peer is moved to position (-1, -1) so it * wont be displayed anymore * * \sa dropEvent() */ void XletSwitchBoard::removePeerFromLayout() { const QString userid = sender()->property("userid" ).toString(); // qDebug() << Q_FUNC_INFO << userid << m_peerhash.keys(); if (m_peerhash.contains(userid)) { PeerItem *peeritem = m_peerhash[userid]; BasePeerWidget *peerwidget = peeritem->getWidget(); m_layout->removeWidget(peerwidget); m_layout->setItemPosition(peerwidget, QPoint(-1, -1)); //savePositions(); // this disconnect() step takes time, whether explicitly or implicitly, // so we should be careful to avoid too much connect's (anyway) disconnect(peerwidget, SIGNAL(removeFromPanel()), this, SLOT(removePeerFromLayout())); peerwidget->deleteLater(); peeritem->setWidget(NULL); update(); } else { m_layout->removeWidget(static_cast<QWidget *>(sender())); sender()->deleteLater(); } }
/*! \brief update the list of Persons displayed */ void SearchPanel::updateDisplay() { if (m_live_reload_enabled == false) { return; } // max number of peers displayed on the search panel unsigned maxdisplay = maxDisplay(); // number of columns (0 = auto) unsigned ncolumns = 0; ncolumns = m_scrollarea->width() / (PeerWidget::max_width + 2 * SearchPanel::peer_spacing); // Prevent arithmetic exception if (ncolumns == 0) { ncolumns = 1; } // first hide/delete everyonedisplayed QHashIterator<QString, PeerItem *> i(m_peerhash); while (i.hasNext()) { i.next(); PeerItem *peeritem = i.value(); BasePeerWidget *peerwidget = peeritem->getWidget(); if ((peerwidget != NULL) && (m_peerlayout->indexOf(peerwidget) > -1)) { m_peerlayout->removeWidget(peerwidget); peerwidget->hide(); peeritem->setWidget(NULL); peerwidget->deleteLater(); } } // then display all users whose name match the search pattern unsigned naff = 0; i.toFront(); while (i.hasNext()) { i.next(); PeerItem * peeritem = i.value(); BasePeerWidget * peerwidget = peeritem->getWidget(); const UserInfo * userinfo = peeritem->userinfo(); if (userinfo == NULL) continue; if (peeritem->matchPattern(m_searchpattern) && (naff < maxdisplay)) { if (peerwidget == NULL) { peerwidget = new PeerWidget(userinfo); if (! userinfo->agentid().isEmpty()) { peerwidget->updateAgentConfig(userinfo->xagentid()); peerwidget->updateAgentStatus(userinfo->xagentid()); } foreach (const QString &xphoneid, userinfo->phonelist()) { peerwidget->updatePhoneConfig(xphoneid); peerwidget->updatePhoneStatus(xphoneid); } peeritem->setWidget(peerwidget); peeritem->updateDisplayedStatus(); peeritem->updateDisplayedName(); m_peerlayout->addWidget(peerwidget, naff / ncolumns, naff % ncolumns); naff++; peerwidget->show(); } } }