/** * Adds a participant to a convo, if that conversation dont exist, the tab and convo is created. * @brief MainWindow::addToConvo * @param fromIp ip of user that added someone to a conversation, empty if originating user is the current user. * @param fromName name of user that added someone to a conversation, empty if originating user is the current user. * @param member new participant to be added: "{name}/{ip}" * @param cid Conversation id. * @return false if member already exists in the conversation, true otherwise. */ bool MainWindow::addToConvo(QString fromIp, QString fromName, QString member, QString cid) { Conversation* lst = 0; QStringList tmp = member.split("/", QString::SkipEmptyParts); int i = 0; for (; i < convos->count(); ++i) { if(convos->at(i)->getCid().compare(cid) == 0) { lst = convos->at(i); break; } } if(lst == 0) { createTab(cid, fromIp, fromName); lst = convos->at(convos->count()-1); } else { for (int i = 0; i < lst->count(); ++i) { if(tmp.at(1).compare(lst->at(i)->getIp()) == 0) return false; } } lst->add(tmp.at(1), tmp.at(0)); if(ui->tabgrpConversations->currentIndex() == (i+1)) ui->lstInConvo->addItem(member); return true; }
/** * Called when tab is switched, empties the participant list, * and populates it with the participants in the newly selected * tab. * @brief MainWindow::on_tabgrpConversations_currentChanged */ void MainWindow::on_tabgrpConversations_currentChanged(int index) { ui->lstInConvo->clear(); indicateChange(index, Qt::black); if(index == 0) return; Conversation* lst = convos->at(index-1); for (int i = 0; i < lst->count() ; ++i) { Peer* p = lst->at(i); ui->lstInConvo->addItem(p->getName() + "/" + p->getIp()); } }