Skip to content
Snippets Groups Projects
Select Git revision
  • a310667adfc37f53f5ae9a53ae1058edb2e74e4c
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • release/201811
  • release/201808
  • wip/patches_poly_2017/cedryk_doucet/abderahmane_bouziane
  • releases/beta1
  • android/release_463
  • android/release_462
  • android/release_461
  • android/release_460
  • android/release_459
  • android/release_458
  • android/release_457
  • android/release_456
  • android/release_455
  • android/release_454
  • android/release_453
  • android/release_452
  • android/release_451
  • android/release_450
  • android/release_449
  • android/release_448
  • android/release_447
  • android/release_446
  • android/release_445
  • android/release_444
38 results

NotificationServiceImpl.java

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    HistoryTreeItem.cpp 5.26 KiB
    /***************************************************************************
     *   Author : Mathieu Leduc-Hamel mathieu.leduc-hamel@savoirfairelinux.com *
     *            Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>*
     *                                                                         *
     *   This program is free software; you can redistribute it and/or modify  *
     *   it under the terms of the GNU General Public License as published by  *
     *   the Free Software Foundation; either version 3 of the License, or     *
     *   (at your option) any later version.                                   *
     *                                                                         *
     *   This program is distributed in the hope that it will be useful,       *
     *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
     *   GNU General Public License for more details.                          *
     *                                                                         *
     *   You should have received a copy of the GNU General Public License     *
     *   along with this program; if not, write to the                         *
     *   Free Software Foundation, Inc.,                                       *
     *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
     ***************************************************************************/
    
    #include <QtCore/QStringList>
    #include <QtGui/QGridLayout>
    
    #include <klocale.h>
    #include <kdebug.h>
    #include <unistd.h>
    
    #include "lib/sflphone_const.h"
    #include "HistoryTreeItem.h"
    #include "AkonadiBackend.h"
    #include "lib/Contact.h"
    
    const char * HistoryTreeItem::callStateIcons[12] = {ICON_INCOMING, ICON_RINGING, ICON_CURRENT, ICON_DIALING, ICON_HOLD, ICON_FAILURE, ICON_BUSY, ICON_TRANSFER, ICON_TRANSF_HOLD, "", "", ICON_CONFERENCE};
    
    HistoryTreeItem::HistoryTreeItem(QWidget *parent)
       : QWidget(parent), itemCall(0), init(false)
    {
       
    }
    
    HistoryTreeItem::~HistoryTreeItem()
    {
       
    }
    
    Call* HistoryTreeItem::call() const
    {
       return itemCall;
    }
    
    void HistoryTreeItem::setCall(Call *call)
    {
       itemCall = call;
       
       if (itemCall->isConference()) {
          labelIcon->setVisible(true);
          return;
       }
       
       labelIcon     = new QLabel(this);
       labelPeerName = new QLabel();
       labelIcon     = new QLabel();
       
       labelIcon->setMinimumSize(70,48);
       labelIcon->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
       
       labelCallNumber2 = new QLabel(itemCall->getPeerPhoneNumber());
       QSpacerItem* verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
    
       m_pTimeL = new QLabel();
       m_pTimeL->setText(QDateTime::fromTime_t(itemCall->getStartTimeStamp().toUInt()).toString());
    
       m_pDurationL = new QLabel();
       int dur = itemCall->getStopTimeStamp().toInt() - itemCall->getStartTimeStamp().toInt();
       m_pDurationL->setText(QString("%1").arg(dur/3600,2)+":"+QString("%1").arg((dur%3600)/60,2)+":"+QString("%1").arg((dur%3600)%60,2)+" ");
    
       QGridLayout* mainLayout = new QGridLayout(this);
       mainLayout->addWidget( labelIcon,0,0,4,1    );
       mainLayout->addWidget( labelPeerName,0,1    );
       mainLayout->addWidget( labelCallNumber2,1,1 );
       mainLayout->addWidget( m_pTimeL,2,1         );
       mainLayout->addItem  ( verticalSpacer,3,1   );
       mainLayout->addWidget( m_pDurationL,0,2,4,1 );
       
       setLayout(mainLayout);
       setMinimumSize(QSize(50, 30));
    
       connect(itemCall, SIGNAL(changed()), this,     SLOT(updated()));
       updated();
    
       m_pTimeStamp = itemCall->getStartTimeStamp().toUInt();
       m_pDuration = dur;
       m_pName = itemCall->getPeerName();
       m_pPhoneNumber = itemCall->getPeerPhoneNumber();
    }
    
    void HistoryTreeItem::updated()
    {
       Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(itemCall->getPeerPhoneNumber());
       if (contact) {
          labelIcon->setPixmap(*contact->getPhoto());
          labelPeerName->setText("<b>"+contact->getFormattedName()+"</b>");
       }
       else {
          labelIcon->setPixmap(QPixmap(KIcon("user-identity").pixmap(QSize(48,48))));
    
          if(! itemCall->getPeerName().trimmed().isEmpty()) {
             labelPeerName->setText("<b>"+itemCall->getPeerName()+"</b>");
          }
          else {
             labelPeerName->setText("<b>Unknow</b>");
          }
       }
       
       call_state state = itemCall->getState();
       bool recording = itemCall->getRecording();
       if(state != CALL_STATE_OVER) {
          if(state == CALL_STATE_CURRENT && recording) {
             labelIcon->setPixmap(QPixmap(ICON_CURRENT_REC));
          }
          else {
             QString str = QString(callStateIcons[state]);
             labelIcon->setPixmap(QPixmap(str));
          }
          labelCallNumber2->setText(itemCall->getPeerPhoneNumber());
                    
          if(state == CALL_STATE_DIALING) {
             labelCallNumber2->setText(itemCall->getCallNumber());
          }
       }
       else {
          qDebug() << "Updating item of call of state OVER. Doing nothing.";
       }
       
    }
    
    uint HistoryTreeItem::getTimeStamp()
    {
       return m_pTimeStamp;
    }
    
    uint HistoryTreeItem::getDuration()
    {
       return m_pDuration;
    }
    
    QString HistoryTreeItem::getName()
    {
       return m_pName;
    }
    
    QString HistoryTreeItem::getPhoneNumber()
    {
       return m_pPhoneNumber;
    }
    
    
    QTreeWidgetItem* HistoryTreeItem::getItem()
    {
       return m_pItem;
    }
    
    void HistoryTreeItem::setItem(QTreeWidgetItem* item)
    {
       m_pItem = item;
    }