void QtHistory::replayItem(int id) { if (id != 0){ HistoryMementoCollection * collection = _cHistory.getHistory().getHistoryMementoCollection(); HistoryMemento* memento = collection->getMemento(id); QString data = QString::fromStdString(memento->getData()); QtWengoPhone * qtWengoPhone = (QtWengoPhone *) _cHistory.getCWengoPhone().getPresentation(); //VOXOX - CJC - 2009.06.10 QtVoxMessageBox box(_historyWidget->getWidget()); box.setWindowTitle("VoxOx - Call History"); box.setText(tr("Do you want to call %1?").arg(formatName(memento->getPeer(), _isWengoAccountConnected))); box.setStandardButtons(QMessageBox::Yes | QMessageBox::No ); /*QMessageBox mb(tr("@product@ - Call History"), tr("Do you want to call %1?").arg(formatName(memento->getPeer(), _isWengoAccountConnected)), QMessageBox::Question, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton, _historyWidget->getWidget());*/ switch (memento->getState()) { case HistoryMemento::OutgoingSmsOk: case HistoryMemento::OutgoingSmsNok: { //Retrieve info & configure the Sms widget std::string data = _cHistory.getMementoData(id); QString text = QString::fromUtf8(data.c_str(), data.size()); QString phoneNumber = QString::fromStdString(_cHistory.getMementoPeer(id)); //Test existance of Sms (available only if a WengoAccount has been created) QtSms * sms = qtWengoPhone->getQtSms(); if (sms) { sms->setText(text); sms->setPhoneNumber(phoneNumber); sms->getWidget()->show(); } break; } case HistoryMemento::OutgoingCall: case HistoryMemento::IncomingCall: case HistoryMemento::MissedCall: case HistoryMemento::RejectedCall: if (box.exec() == QMessageBox::Yes) { _cHistory.replay(id); } break; case HistoryMemento::ChatSession: _chatLogViewer = new QtChatLogViewer(NULL, *qtWengoPhone, data ); _chatLogViewer->restartChat(); break; default: break; } } }
void QtHistory::showChatLog(int id) { if (id != 0){ HistoryMementoCollection * collection = _cHistory.getHistory().getHistoryMementoCollection(); HistoryMemento* memento = collection->getMemento(id); QtWengoPhone * qtWengoPhone = (QtWengoPhone *) _cHistory.getCWengoPhone().getPresentation(); if(memento->getState() == HistoryMemento::ChatSession){ _chatLogViewer = new QtChatLogViewer(NULL, *qtWengoPhone, QString::fromStdString(memento->getData())); _chatLogViewer->show(); } } }
QVariant QtHistory::data(const QModelIndex& index, int role) const { if (index.row() < 0 || index.row() >= _mementoIdList.size()) { return QVariant(); } int id = _mementoIdList[index.row()]; HistoryMementoCollection * collection = _cHistory.getHistory().getHistoryMementoCollection(); HistoryMemento* memento = collection->getMemento(id); if (!memento) { LOG_ERROR("Couldn't get memento for id " + String::fromNumber(id)); return QVariant(); } if (role == Qt::DisplayRole) { switch (index.column()) { case 0: return textForMementoState(memento->getState()); case 1: return QVariant(formatName(memento->getPeer(), _isWengoAccountConnected)); case 2: return QVariant(formatDate(qDateTimeForMemento(memento))); case 3: //VOXOX - CJC - 2009.05.31 Only show duration for calls if(memento->getState() == HistoryMemento::OutgoingCall || memento->getState()== HistoryMemento::IncomingCall ||memento->getState() == HistoryMemento::MissedCall || memento->getState() == HistoryMemento::RejectedCall){ return QVariant(formatDuration(qTimeForDuration(memento->getDuration()))); }else{ return QVariant(""); } default: return QVariant(); } } else if (role == Qt::DecorationRole) { if (index.column() == 0) { return QVariant(iconForMementoState(memento->getState())); } else { return QVariant(); } } else if (role == Qt::UserRole) { return QVariant(id); } return QVariant(); }