diff --git a/kde/src/klib/HelperFunctions.cpp b/kde/src/klib/HelperFunctions.cpp index 4b4ccb1f38fae8762efec34a3518ca17b067f587..e242eb25d757f7d78765ce29418d7f7623ef2faf 100644 --- a/kde/src/klib/HelperFunctions.cpp +++ b/kde/src/klib/HelperFunctions.cpp @@ -61,4 +61,16 @@ QString HelperFunctions::normStrippped(QString str) normStripppedC += char2; } return normStripppedC; +} + +///Escape lesser and greater +QString HelperFunctions::escapeHtmlEntities(QString str) +{ + while (str.indexOf('<') != -1) { + str = str.replace("<","<"); + } + while (str.indexOf('>') != -1) { + str = str.replace(">",">"); + } + return str; } \ No newline at end of file diff --git a/kde/src/klib/HelperFunctions.h b/kde/src/klib/HelperFunctions.h index 167beee844067e4c8ac3565a8b2f0835332fe608..9eeef93c7ce20008e939785ac92e00908fdcde6e 100644 --- a/kde/src/klib/HelperFunctions.h +++ b/kde/src/klib/HelperFunctions.h @@ -39,5 +39,6 @@ class LIB_EXPORT HelperFunctions { public: static ContactHash toHash(QList<Contact*> contacts); static QString normStrippped(QString str); + static QString escapeHtmlEntities(QString str); }; #endif \ No newline at end of file diff --git a/kde/src/widgets/CallTreeItem.cpp b/kde/src/widgets/CallTreeItem.cpp index 4663111d915e646799f3441d2f5bfd42eaed2f75..5e9d6fa3c2084820d493876331f964942d47effc 100644 --- a/kde/src/widgets/CallTreeItem.cpp +++ b/kde/src/widgets/CallTreeItem.cpp @@ -25,6 +25,8 @@ #include <QtCore/QStringList> #include <QtCore/QMimeData> #include <QtCore/QTimer> +#include <QtGui/QClipboard> +#include <QtGui/QApplication> #include <QtGui/QWidget> #include <QtGui/QLabel> #include <QtGui/QSpacerItem> @@ -381,6 +383,20 @@ void CallTreeItem::conversationEvent(QMimeData* data) emit conversationDropEvent(m_pItemCall,data); } +///Copy +void CallTreeItem::copy() +{ + kDebug() << "Copying contact"; + QMimeData* mimeData = new QMimeData(); + mimeData->setData(MIME_CALLID, m_pItemCall->getCallId().toUtf8()); + QString numbers(m_pItemCall->getPeerName()+": "+m_pItemCall->getPeerPhoneNumber()); + QString numbersHtml("<b>"+m_pItemCall->getPeerName()+"</b><br />"+m_pItemCall->getPeerPhoneNumber()); + mimeData->setData("text/plain", numbers.toUtf8()); + mimeData->setData("text/html", numbersHtml.toUtf8()); + QClipboard* clipboard = QApplication::clipboard(); + clipboard->setMimeData(mimeData); +} + ///Called when the overlay need to be hidden void CallTreeItem::hide() { diff --git a/kde/src/widgets/CallTreeItem.h b/kde/src/widgets/CallTreeItem.h index b49a6c3e224db4b5b8d5e913e5fe77c551fe0830..5304aa8f57bd8449a667296a9d546d84ceb128a8 100644 --- a/kde/src/widgets/CallTreeItem.h +++ b/kde/src/widgets/CallTreeItem.h @@ -91,6 +91,7 @@ private slots: void conversationEvent(QMimeData* data); void hide(); void incrementTimer(); + void copy(); public slots: void updated(); diff --git a/kde/src/widgets/ContactItemWidget.cpp b/kde/src/widgets/ContactItemWidget.cpp index 0b1bd0f0f4637b5dbfe4ea3a30ab14d6c88112b8..1cade1ef2cdac72368dbdcc76588b586dd24f469 100644 --- a/kde/src/widgets/ContactItemWidget.cpp +++ b/kde/src/widgets/ContactItemWidget.cpp @@ -62,7 +62,7 @@ ContactItemWidget::ContactItemWidget(QWidget *parent) m_pCallAgain = new KAction(this); m_pCallAgain->setShortcut ( Qt::CTRL + Qt::Key_Enter ); m_pCallAgain->setText ( i18n("Call Again") ); - m_pCallAgain->setIcon ( KIcon(ICON_DIALING) ); + m_pCallAgain->setIcon ( KIcon("call-start") ); m_pEditContact = new KAction(this); m_pEditContact->setShortcut ( Qt::CTRL + Qt::Key_E ); @@ -349,6 +349,14 @@ void ContactItemWidget::copy() kDebug() << "Copying contact"; QMimeData* mimeData = new QMimeData(); mimeData->setData(MIME_CONTACT, m_pContactKA->getUid().toUtf8()); + QString numbers(m_pContactKA->getFormattedName()+": "); + QString numbersHtml("<b>"+m_pContactKA->getFormattedName()+"</b><br />"); + foreach (Contact::PhoneNumber* number, m_pContactKA->getPhoneNumbers()) { + numbers += number->getNumber()+" ("+number->getType()+") "; + numbersHtml += number->getNumber()+" ("+number->getType()+") <br />"; + } + mimeData->setData("text/plain", numbers.toUtf8()); + mimeData->setData("text/html", numbersHtml.toUtf8()); QClipboard* clipboard = QApplication::clipboard(); clipboard->setMimeData(mimeData); } diff --git a/kde/src/widgets/HistoryDock.cpp b/kde/src/widgets/HistoryDock.cpp index cfef3c775dd5d13e6ea4d061436c82eaee426206..dcd3c166ee4527cfa92edfb4cbe74d878d236445 100644 --- a/kde/src/widgets/HistoryDock.cpp +++ b/kde/src/widgets/HistoryDock.cpp @@ -310,8 +310,10 @@ void HistoryDock::enableDateRange(bool disable) ///Filter the history void HistoryDock::filter(QString text) { + QString lower = text.toLower(); foreach(HistoryTreeItem* item, m_History) { - bool visible = (HelperFunctions::normStrippped(item->getName()).indexOf(text) != -1) || (HelperFunctions::normStrippped(item->getPhoneNumber()).indexOf(text) != -1); + bool visible = ( HelperFunctions::normStrippped( item->getName() ).indexOf( lower ) != -1) + || ( HelperFunctions::normStrippped( item->getPhoneNumber() ).indexOf( lower ) != -1); item->getItem()-> setHidden(!visible); } m_pItemView->expandAll(); diff --git a/kde/src/widgets/HistoryTreeItem.cpp b/kde/src/widgets/HistoryTreeItem.cpp index 3861599b168d5feca2ccff8c4391aa36bfb8b83f..13a7e00f0845e965e2f446680e2d5d6612e654c3 100644 --- a/kde/src/widgets/HistoryTreeItem.cpp +++ b/kde/src/widgets/HistoryTreeItem.cpp @@ -32,6 +32,8 @@ #include <QtGui/QPainter> #include <QtGui/QSlider> #include <QtGui/QColor> +#include <QtGui/QClipboard> +#include <QtGui/QApplication> #include <QtGui/QFontMetrics> #include <QtCore/QStringList> #include <QtCore/QFile> @@ -51,6 +53,7 @@ //SFLPhone #include "klib/AkonadiBackend.h" +#include "klib/HelperFunctions.h" #include "SFLPhone.h" #include "widgets/BookmarkDock.h" #include "widgets/TranslucentButtons.h" @@ -86,9 +89,9 @@ HistoryTreeItem::HistoryTreeItem(QWidget *parent ,QString phone) m_pAddToContact = new KAction(this); m_pBookmark = new KAction(this); - m_pCallAgain->setShortcut ( Qt::Key_Enter ); + m_pCallAgain->setShortcut ( Qt::Key_Enter ); m_pCallAgain->setText ( i18n("Call Again") ); - m_pCallAgain->setIcon ( KIcon(ICON_DIALING) ); + m_pCallAgain->setIcon ( KIcon("call-start") ); m_pAddToContact->setShortcut ( Qt::CTRL + Qt::Key_E ); m_pAddToContact->setText ( i18n("Add Number to Contact") ); @@ -102,7 +105,6 @@ HistoryTreeItem::HistoryTreeItem(QWidget *parent ,QString phone) m_pCopy->setShortcut ( Qt::CTRL + Qt::Key_C ); m_pCopy->setText ( i18n("Copy") ); m_pCopy->setIcon ( KIcon("edit-copy") ); - m_pCopy->setDisabled ( true ); m_pEmail->setShortcut ( Qt::CTRL + Qt::Key_M ); m_pEmail->setText ( i18n("Send Email") ); @@ -191,12 +193,12 @@ HistoryTreeItem::~HistoryTreeItem() delete m_pBookmark ; delete m_pMenu ; - if (m_pPlay) delete m_pPlay ; - if (m_pRemove) delete m_pRemove ; - if (m_pAudioSlider) delete m_pAudioSlider ; - if (m_pTimeLeftL) delete m_pTimeLeftL ; - if (m_pTimePlayedL) delete m_pTimePlayedL ; - if (m_pPlayer) delete m_pPlayer ; + if ( m_pPlay ) delete m_pPlay ; + if ( m_pRemove ) delete m_pRemove ; + if ( m_pAudioSlider ) delete m_pAudioSlider ; + if ( m_pTimeLeftL ) delete m_pTimeLeftL ; + if ( m_pTimePlayedL ) delete m_pTimePlayedL ; + if ( m_pPlayer ) delete m_pPlayer ; } @@ -215,27 +217,7 @@ Call* HistoryTreeItem::call() const ///The item have to be updated void HistoryTreeItem::updated() { - if (!getContactInfo(m_pItemCall->getPeerPhoneNumber()),true) { - if(! m_pItemCall->getPeerName().trimmed().isEmpty()) { - m_pPeerNameL->setText("<b>"+m_pItemCall->getPeerName()+"</b>"); - } - } - call_state state = m_pItemCall->getState(); - bool recording = m_pItemCall->getRecording(); - if(state != CALL_STATE_OVER) { - if(state == CALL_STATE_CURRENT && recording) { - m_pIconL->setPixmap(QPixmap(ICON_CURRENT_REC)); - } - else { - QString str = QString(callStateIcons[state]); - m_pIconL->setPixmap(QPixmap(str)); - } - m_pCallNumberL->setText(m_pItemCall->getPeerPhoneNumber()); - - if(state == CALL_STATE_DIALING) { - m_pCallNumberL->setText(m_pItemCall->getCallNumber()); - } - } + getContactInfo(m_pItemCall->getPeerPhoneNumber()); } //updated ///Show the context menu @@ -266,7 +248,7 @@ void HistoryTreeItem::callAgain() if (m_pItemCall) { kDebug() << "Calling "<< m_pItemCall->getPeerPhoneNumber(); } - Call* call = SFLPhone::model()->addDialingCall(m_Name, SFLPhone::app()->model()->getCurrentAccountId()); + Call* call = SFLPhone::model()->addDialingCall(getName(), SFLPhone::app()->model()->getCurrentAccountId()); call->setCallNumber(m_PhoneNumber); call->setPeerName(m_pPeerNameL->text()); call->actionPerformed(CALL_ACTION_ACCEPT); @@ -275,10 +257,26 @@ void HistoryTreeItem::callAgain() ///Copy the call void HistoryTreeItem::copy() { - //TODO kDebug() << "Copying contact"; + QMimeData* mimeData = new QMimeData(); + mimeData->setData(MIME_CALLID, m_pItemCall->getCallId().toUtf8()); + QString numbers; + QString numbersHtml; + if (m_pContact) { + numbers = m_pContact->getFormattedName()+": "+m_PhoneNumber; + numbersHtml = "<b>"+m_pContact->getFormattedName()+"</b><br />"+HelperFunctions::escapeHtmlEntities(m_PhoneNumber); + } + else { + numbers = m_pItemCall->getPeerName()+": "+m_PhoneNumber; + numbersHtml = "<b>"+m_pItemCall->getPeerName()+"</b><br />"+HelperFunctions::escapeHtmlEntities(m_PhoneNumber); + } + mimeData->setData("text/plain", numbers.toUtf8()); + mimeData->setData("text/html", numbersHtml.toUtf8()); + QClipboard* clipboard = QApplication::clipboard(); + clipboard->setMimeData(mimeData); } + ///Create a contact from those informations void HistoryTreeItem::addContact() { @@ -470,11 +468,6 @@ void HistoryTreeItem::setCall(Call *call) connect(m_pPlay , SIGNAL(clicked() ) , m_pItemCall , SLOT(playRecording() )); connect(m_pItemCall , SIGNAL(playbackStarted() ) , this , SLOT(showRecordPlayer() )); - if (m_pItemCall->isConference()) { - m_pIconL->setVisible(true); - return; - } - m_pCallNumberL->setText(m_pItemCall->getPeerPhoneNumber()); m_pTimeL->setText(QDateTime::fromTime_t(m_pItemCall->getStartTimeStamp().toUInt()).toString()); @@ -489,7 +482,7 @@ void HistoryTreeItem::setCall(Call *call) updated(); m_TimeStamp = m_pItemCall->getStartTimeStamp().toUInt(); - m_Length = dur; + m_Length = dur; m_Name = m_pItemCall->getPeerName(); m_PhoneNumber = m_pItemCall->getPeerPhoneNumber(); @@ -522,13 +515,13 @@ bool HistoryTreeItem::getContactInfo(QString phoneNumber) { Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(phoneNumber,true); if (contact) { + m_pPeerNameL->setText("<b>"+contact->getFormattedName()+"</b>"); if (contact->getPhoto() != NULL) m_pIconL->setPixmap(*contact->getPhoto()); else if (m_pItemCall && !m_pItemCall->getRecordingPath().isEmpty()) m_pIconL->setPixmap(QPixmap(KStandardDirs::locate("data","sflphone-client-kde/voicemail.png"))); else m_pIconL->setPixmap(QPixmap(KIcon("user-identity").pixmap(QSize(48,48)))); - m_pPeerNameL->setText("<b>"+contact->getFormattedName()+"</b>"); m_pContact = contact; } else {