Commit ec858ede authored by Emmanuel Lepage's avatar Emmanuel Lepage

Add drag and drop support, initial context menu and fix 3 bugs in the account dialog

parent 9b4fffcd
...@@ -69,6 +69,7 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection) ...@@ -69,6 +69,7 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection)
newNumbers << new Contact::PhoneNumber(number.number(),number.typeLabel()); newNumbers << new Contact::PhoneNumber(number.number(),number.typeLabel());
m_pContactByPhone[number.number()] = aContact; m_pContactByPhone[number.number()] = aContact;
} }
m_pContactByUid[tmp.uid()] = aContact;
aContact->setNickName (tmp.nickName() ); aContact->setNickName (tmp.nickName() );
aContact->setFormattedName (tmp.formattedName() ); aContact->setFormattedName (tmp.formattedName() );
...@@ -103,6 +104,11 @@ Contact* AkonadiBackend::getContactByPhone(QString phoneNumber) ...@@ -103,6 +104,11 @@ Contact* AkonadiBackend::getContactByPhone(QString phoneNumber)
return m_pContactByPhone[phoneNumber]; return m_pContactByPhone[phoneNumber];
} }
Contact* AkonadiBackend::getContactByUid(QString uid)
{
return m_pContactByUid[uid];
}
void AkonadiBackend::collectionsReceived( const Akonadi::Collection::List& list) void AkonadiBackend::collectionsReceived( const Akonadi::Collection::List& list)
{ {
foreach (Akonadi::Collection coll, list) { foreach (Akonadi::Collection coll, list) {
......
...@@ -16,17 +16,17 @@ class AkonadiBackend : public QObject { ...@@ -16,17 +16,17 @@ class AkonadiBackend : public QObject {
public: public:
static AkonadiBackend* getInstance(); static AkonadiBackend* getInstance();
Contact* getContactByPhone(QString phoneNumber); Contact* getContactByPhone(QString phoneNumber);
Contact* getContactByUid(QString uid);
private: private:
AkonadiBackend(QObject* parent); AkonadiBackend(QObject* parent);
virtual ~AkonadiBackend(); virtual ~AkonadiBackend();
//Attributes //Attributes
static AkonadiBackend* m_pInstance; static AkonadiBackend* m_pInstance;
Akonadi::Session* m_pSession; Akonadi::Session* m_pSession;
Akonadi::Collection m_pCollection; Akonadi::Collection m_pCollection;
QHash<QString,Contact*> m_pContactByPhone; QHash<QString,Contact*> m_pContactByPhone;
QHash<QString,Contact*> m_pContactByUid;
public slots: public slots:
ContactList update(); ContactList update();
ContactList update(Akonadi::Collection collection); ContactList update(Akonadi::Collection collection);
......
#include "CallView.h" #include "CallView.h"
#include "AkonadiBackend.h"
#include "lib/Contact.h"
#include <QtGui/QInputDialog>
///Retrieve current and older calls from the daemon, fill history and the calls TreeView and enable drag n' drop ///Retrieve current and older calls from the daemon, fill history and the calls TreeView and enable drag n' drop
CallView::CallView(ModelType type, QWidget* parent) : QTreeWidget(parent), CallModel<CallTreeItem*,QTreeWidgetItem*>(type) CallView::CallView(ModelType type, QWidget* parent) : QTreeWidget(parent), TreeWidgetCallModel(type)
{ {
if (type == ActiveCall) if (type == ActiveCall)
initCall(); initCall();
...@@ -46,21 +50,14 @@ CallView::CallView(ModelType type, QWidget* parent) : QTreeWidget(parent), CallM ...@@ -46,21 +50,14 @@ CallView::CallView(ModelType type, QWidget* parent) : QTreeWidget(parent), CallM
* * * *
****************************************************************************/ ****************************************************************************/
///Action performed when an item is dropped on the TreeView bool CallView::callToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action)
bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action)
{ {
Q_UNUSED(index) Q_UNUSED(index)
Q_UNUSED(action) Q_UNUSED(action)
QByteArray encodedCallId = data->data( MIME_CALLID ); QByteArray encodedCallId = data->data( MIME_CALLID );
QByteArray encodedPhoneNumber = data->data( MIME_PHONENUMBER );
qDebug() << "In export"<< QString(encodedCallId);
qDebug() << "In export2"<< QString(encodedPhoneNumber);
if (!QString(encodedCallId).isEmpty()) { if (!QString(encodedCallId).isEmpty()) {
clearArtefact(getIndex(encodedCallId)); clearArtefact(getIndex(encodedCallId));
if (!parent) { if (!parent) {
qDebug() << "Call dropped on empty space"; qDebug() << "Call dropped on empty space";
if (getIndex(encodedCallId)->parent()) { if (getIndex(encodedCallId)->parent()) {
...@@ -71,12 +68,12 @@ bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData ...@@ -71,12 +68,12 @@ bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData
qDebug() << "The call is not in a conversation (doing nothing)"; qDebug() << "The call is not in a conversation (doing nothing)";
return true; return true;
} }
if (getCall(parent)->getCallId() == QString(encodedCallId)) { if (getCall(parent)->getCallId() == QString(encodedCallId)) {
qDebug() << "Call dropped on itself (doing nothing)"; qDebug() << "Call dropped on itself (doing nothing)";
return true; return true;
} }
if ((parent->childCount()) && (getIndex(encodedCallId)->childCount())) { if ((parent->childCount()) && (getIndex(encodedCallId)->childCount())) {
qDebug() << "Merging two conferences"; qDebug() << "Merging two conferences";
mergeConferences(getCall(parent),getCall(encodedCallId)); mergeConferences(getCall(parent),getCall(encodedCallId));
...@@ -84,15 +81,15 @@ bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData ...@@ -84,15 +81,15 @@ bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData
} }
else if ((parent->parent()) || (parent->childCount())) { else if ((parent->parent()) || (parent->childCount())) {
qDebug() << "Call dropped on a conference"; qDebug() << "Call dropped on a conference";
if ((getIndex(encodedCallId)->childCount()) && (!parent->childCount())) { if ((getIndex(encodedCallId)->childCount()) && (!parent->childCount())) {
qDebug() << "Conference dropped on a call (doing nothing)"; qDebug() << "Conference dropped on a call (doing nothing)";
return true; return true;
} }
QTreeWidgetItem* call1 = getIndex(encodedCallId); QTreeWidgetItem* call1 = getIndex(encodedCallId);
QTreeWidgetItem* call2 = (parent->parent())?parent->parent():parent; QTreeWidgetItem* call2 = (parent->parent())?parent->parent():parent;
if (call1->parent()) { if (call1->parent()) {
qDebug() << "Call 1 is part of a conference"; qDebug() << "Call 1 is part of a conference";
if (call1->parent() == call2) { if (call1->parent() == call2) {
...@@ -109,6 +106,14 @@ bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData ...@@ -109,6 +106,14 @@ bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData
} }
} }
qDebug() << "Adding participant"; qDebug() << "Adding participant";
int state = getCall(call1)->getState();
if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) {
getCall(call1)->actionPerformed(CALL_ACTION_ACCEPT);
}
state = getCall(call2)->getState();
if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) {
getCall(call2)->actionPerformed(CALL_ACTION_ACCEPT);
}
addParticipant(getCall(call1),getCall(call2)); addParticipant(getCall(call1),getCall(call2));
return true; return true;
} }
...@@ -116,14 +121,135 @@ bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData ...@@ -116,14 +121,135 @@ bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData
qDebug() << "Call dropped on it's own conference (doing nothing)"; qDebug() << "Call dropped on it's own conference (doing nothing)";
return true; return true;
} }
qDebug() << "Call dropped on another call"; qDebug() << "Call dropped on another call";
createConferenceFromCall(getCall(encodedCallId),getCall(parent)); createConferenceFromCall(getCall(encodedCallId),getCall(parent));
return true; return true;
} }
return false;
}
bool CallView::phoneNumberToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action)
{
Q_UNUSED(index)
Q_UNUSED(action)
QByteArray encodedPhoneNumber = data->data( MIME_PHONENUMBER );
if (!QString(encodedPhoneNumber).isEmpty()) {
Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(encodedPhoneNumber);
QString name;
if (contact)
name = contact->getFormattedName();
else
name = "Unknow";
Call* call2 = TreeWidgetCallModel::addDialingCall(name, TreeWidgetCallModel::getCurrentAccountId());
call2->appendText(QString(encodedPhoneNumber));
if (!parent) {
//Dropped on free space
qDebug() << "Adding new dialing call";
}
else if (parent->childCount() || parent->parent()) {
//Dropped on a conversation
QTreeWidgetItem* call = (parent->parent())?parent->parent():parent;
addParticipant(getCall(call),call2);
}
else {
//Dropped on call
call2->actionPerformed(CALL_ACTION_ACCEPT);
int state = getCall(parent)->getState();
if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) {
getCall(parent)->actionPerformed(CALL_ACTION_ACCEPT);
}
createConferenceFromCall(call2,getCall(parent));
}
}
return false;
}
bool CallView::contactToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action)
{
qDebug() << "contactToCall";
Q_UNUSED(index)
Q_UNUSED(action)
QByteArray encodedContact = data->data( MIME_CONTACT );
if (!QString(encodedContact).isEmpty()) {
Contact* contact = AkonadiBackend::getInstance()->getContactByUid(encodedContact);
qDebug() << "Contact:" << contact;
if (contact) {
qDebug() << "In contact";
Call* call2;
if (contact->getPhoneNumbers().count() == 1) {
call2 = TreeWidgetCallModel::addDialingCall(contact->getFormattedName(), TreeWidgetCallModel::getCurrentAccountId());
call2->appendText(contact->getPhoneNumbers()[0]->getNumber());
}
else if (contact->getPhoneNumbers().count() > 1) {
bool ok = false;
QHash<QString,QString> map;
QStringList list;
foreach (Contact::PhoneNumber* number, contact->getPhoneNumbers()) {
map[number->getType()+" ("+number->getNumber()+")"] = number->getNumber();
list << number->getType()+" ("+number->getNumber()+")";
}
QString result = QInputDialog::getItem (this, QString("Select phone number"), QString("This contact have many phone number, please select the one you wish to call"), list, 0, false, &ok);
if (ok) {
call2 = TreeWidgetCallModel::addDialingCall(contact->getFormattedName(), TreeWidgetCallModel::getCurrentAccountId());
call2->appendText(map[result]);
}
else {
qDebug() << "Operation cancelled";
return false;
}
}
else {
qDebug() << "This contact have no valid phone number";
return false;
}
if (!parent) {
//Dropped on free space
qDebug() << "Adding new dialing call";
}
else if (parent->childCount() || parent->parent()) {
//Dropped on a conversation
QTreeWidgetItem* call = (parent->parent())?parent->parent():parent;
addParticipant(getCall(call),call2);
}
else {
//Dropped on call
call2->actionPerformed(CALL_ACTION_ACCEPT);
int state = getCall(parent)->getState();
if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) {
getCall(parent)->actionPerformed(CALL_ACTION_ACCEPT);
}
createConferenceFromCall(call2,getCall(parent));
}
}
}
return false;
}
///Action performed when an item is dropped on the TreeView
bool CallView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action)
{
Q_UNUSED(index)
Q_UNUSED(action)
QByteArray encodedCallId = data->data( MIME_CALLID );
QByteArray encodedPhoneNumber = data->data( MIME_PHONENUMBER );
QByteArray encodedContact = data->data( MIME_CONTACT );
if (!QString(encodedCallId).isEmpty()) {
qDebug() << "CallId dropped"<< QString(encodedCallId);
callToCall(parent, index, data, action);
}
else if (!QString(encodedPhoneNumber).isEmpty()) {
qDebug() << "PhoneNumber dropped"<< QString(encodedPhoneNumber);
phoneNumberToCall(parent, index, data, action);
}
else if (!QString(encodedContact).isEmpty()) {
qDebug() << "Contact dropped"<< QString(encodedContact);
contactToCall(parent, index, data, action);
}
return false; return false;
} }
...@@ -350,7 +476,7 @@ void CallView::itemClicked(QTreeWidgetItem* item, int column) { ...@@ -350,7 +476,7 @@ void CallView::itemClicked(QTreeWidgetItem* item, int column) {
Call* CallView::addConference(const QString & confID) Call* CallView::addConference(const QString & confID)
{ {
qDebug() << "Conference created"; qDebug() << "Conference created";
Call* newConf = CallModel<CallTreeItem*,QTreeWidgetItem*>::addConference(confID); Call* newConf = TreeWidgetCallModel::addConference(confID);
//InternalCallModelStruct<CallTreeItem>* aNewStruct = privateCallList_callId[confID]; //InternalCallModelStruct<CallTreeItem>* aNewStruct = privateCallList_callId[confID];
...@@ -387,7 +513,7 @@ Call* CallView::addConference(const QString & confID) ...@@ -387,7 +513,7 @@ Call* CallView::addConference(const QString & confID)
bool CallView::conferenceChanged(const QString &confId, const QString &state) bool CallView::conferenceChanged(const QString &confId, const QString &state)
{ {
qDebug() << "Conference changed"; qDebug() << "Conference changed";
if (!CallModel<CallTreeItem*,QTreeWidgetItem*>::conferenceChanged(confId, state)) if (!TreeWidgetCallModel::conferenceChanged(confId, state))
return false; return false;
CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
...@@ -421,7 +547,7 @@ void CallView::conferenceRemoved(const QString &confId) ...@@ -421,7 +547,7 @@ void CallView::conferenceRemoved(const QString &confId)
insertItem(extractItem(getIndex(confId)->child(0))); insertItem(extractItem(getIndex(confId)->child(0)));
} }
takeTopLevelItem(indexOfTopLevelItem(getIndex(confId))); takeTopLevelItem(indexOfTopLevelItem(getIndex(confId)));
CallModel<CallTreeItem*,QTreeWidgetItem*>::conferenceRemoved(confId); TreeWidgetCallModel::conferenceRemoved(confId);
qDebug() << "Conference removed"; qDebug() << "Conference removed";
} }
......
...@@ -22,7 +22,9 @@ class CallTreeItemDelegate : public QItemDelegate ...@@ -22,7 +22,9 @@ class CallTreeItemDelegate : public QItemDelegate
} }
}; };
class CallView : private QTreeWidget, public CallModel<CallTreeItem*,QTreeWidgetItem*> { typedef CallModel<CallTreeItem*,QTreeWidgetItem*> TreeWidgetCallModel;
class CallView : private QTreeWidget, public TreeWidgetCallModel {
Q_OBJECT Q_OBJECT
public: public:
CallView(ModelType type, QWidget* parent =0); CallView(ModelType type, QWidget* parent =0);
...@@ -48,6 +50,9 @@ class CallView : private QTreeWidget, public CallModel<CallTreeItem*,QTreeWidget ...@@ -48,6 +50,9 @@ class CallView : private QTreeWidget, public CallModel<CallTreeItem*,QTreeWidget
protected: protected:
void dragEnterEvent(QDragEnterEvent *e) { e->accept(); } void dragEnterEvent(QDragEnterEvent *e) { e->accept(); }
void dragMoveEvent(QDragMoveEvent *e) { e->accept(); } void dragMoveEvent(QDragMoveEvent *e) { e->accept(); }
bool callToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action);
bool phoneNumberToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action);
bool contactToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action);
public slots: public slots:
void destroyCall(Call* toDestroy); void destroyCall(Call* toDestroy);
......
...@@ -76,8 +76,8 @@ enum CallAction { ...@@ -76,8 +76,8 @@ enum CallAction {
NumberOfCallActions}; NumberOfCallActions};
private: private:
// Whether or not the object has been initialized // Whether or not the object has been initialized
bool initialized_; bool initialized_;
KAction * action_accept; KAction * action_accept;
KAction * action_refuse; KAction * action_refuse;
KAction * action_hold; KAction * action_hold;
......
...@@ -253,14 +253,25 @@ void DlgAccounts::saveAccount(QListWidgetItem * item) ...@@ -253,14 +253,25 @@ void DlgAccounts::saveAccount(QListWidgetItem * item)
account->setAccountDetail(LOCAL_INTERFACE,comboBox_ni_local_address->currentText()); account->setAccountDetail(LOCAL_INTERFACE,comboBox_ni_local_address->currentText());
QStringList _codecList; QStringList _codecList;
qDebug() << keditlistbox_codec->items() << codecList;
foreach (QString aCodec, keditlistbox_codec->items()) { foreach (QString aCodec, keditlistbox_codec->items()) {
foreach (StringHash _aCodec, codecList) { foreach (StringHash _aCodec, codecList) {
if (_aCodec["alias"] == aCodec) { if (_aCodec["alias"] == aCodec) {
qDebug() << "Saving:" << _aCodec["id"];
_codecList << _aCodec["id"]; _codecList << _aCodec["id"];
} }
} }
// }
// foreach (QString aCodec, keditlistbox_codec->items()) {
// foreach (StringHash aCodec, codecList) {
// if (aCodec["alias"] == keditlistbox_codec->currentText()) {
// label_bandwidth_value->setText(aCodec["bandwidth"]);
// label_bitrate_value->setText(aCodec["bitrate"]);
// label_frequency_value->setText(aCodec["frequency"]);
// }
// }
} }
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
configurationManager.setActiveAudioCodecList(_codecList, account->getAccountDetail(ACCOUNT_ID)); configurationManager.setActiveAudioCodecList(_codecList, account->getAccountDetail(ACCOUNT_ID));
qDebug() << "Account codec have been saved" << _codecList << account->getAccountDetail(ACCOUNT_ID); qDebug() << "Account codec have been saved" << _codecList << account->getAccountDetail(ACCOUNT_ID);
...@@ -368,10 +379,11 @@ void DlgAccounts::loadAccount(QListWidgetItem * item) ...@@ -368,10 +379,11 @@ void DlgAccounts::loadAccount(QListWidgetItem * item)
keditlistbox_codec->clear(); keditlistbox_codec->clear();
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
QStringList activeCodecList = configurationManager.getActiveAudioCodecList(account->getAccountDetail(ACCOUNT_ID)); QStringList activeCodecList = configurationManager.getActiveAudioCodecList(account->getAccountDetail(ACCOUNT_ID));
qDebug() << "Active codecs" << activeCodecList;
foreach (QString aCodec, activeCodecList) { foreach (QString aCodec, activeCodecList) {
foreach (StringHash _aCodec, codecList) { foreach (StringHash _aCodec, codecList) {
if (_aCodec["id"] == aCodec) ; if (_aCodec["id"] == aCodec)
keditlistbox_codec->insertItem(_aCodec["alias"]); keditlistbox_codec->insertItem(_aCodec["alias"]);
} }
} }
...@@ -623,7 +635,7 @@ void DlgAccounts::loadCodecList() ...@@ -623,7 +635,7 @@ void DlgAccounts::loadCodecList()
_codec["frequency"] = codec[1]; _codec["frequency"] = codec[1];
_codec["bitrate"] = codec[2]; _codec["bitrate"] = codec[2];
_codec["bandwidth"] = ""; //TODO remove _codec["bandwidth"] = ""; //TODO remove
_codec["id"] = aCodec; _codec["id"] = QString::number(aCodec);
tmpNameList << _codec["name"]; tmpNameList << _codec["name"];
......
...@@ -456,7 +456,11 @@ ...@@ -456,7 +456,11 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QSpinBox" name="spinBox_ni_local_port"/> <widget class="QSpinBox" name="spinBox_ni_local_port">
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<spacer name="horizontalSpacer_8"> <spacer name="horizontalSpacer_8">
...@@ -509,7 +513,11 @@ ...@@ -509,7 +513,11 @@
</widget> </widget>
</item> </item>
<item row="4" column="1" colspan="2"> <item row="4" column="1" colspan="2">
<widget class="QSpinBox" name="spinBox_pa_published_port"/> <widget class="QSpinBox" name="spinBox_pa_published_port">
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_pa_published_address"/> <widget class="QLineEdit" name="lineEdit_pa_published_address"/>
...@@ -777,8 +785,8 @@ ...@@ -777,8 +785,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>536</width> <width>539</width>
<height>758</height> <height>660</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QGridLayout" name="gridLayout_5">
...@@ -1156,6 +1164,11 @@ ...@@ -1156,6 +1164,11 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>KEditListBox</class>
<extends>QGroupBox</extends>
<header>keditlistbox.h</header>
</customwidget>
<customwidget> <customwidget>
<class>KIntSpinBox</class> <class>KIntSpinBox</class>
<extends>QSpinBox</extends> <extends>QSpinBox</extends>
...@@ -1166,11 +1179,6 @@ ...@@ -1166,11 +1179,6 @@
<extends>QFrame</extends> <extends>QFrame</extends>
<header>kurlrequester.h</header> <header>kurlrequester.h</header>
</customwidget> </customwidget>
<customwidget>
<class>KEditListBox</class>
<extends>QGroupBox</extends>
<header>keditlistbox.h</header>
</customwidget>
<customwidget> <customwidget>
<class>KLineEdit</class> <class>KLineEdit</class>
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
......
...@@ -37,6 +37,7 @@ class QNumericTreeWidgetItem : public QTreeWidgetItem { ...@@ -37,6 +37,7 @@ class QNumericTreeWidgetItem : public QTreeWidgetItem {
QNumericTreeWidgetItem(QTreeWidget* parent):QTreeWidgetItem(parent),widget(0),weight(-1){} QNumericTreeWidgetItem(QTreeWidget* parent):QTreeWidgetItem(parent),widget(0),weight(-1){}
QNumericTreeWidgetItem(QTreeWidgetItem* parent):QTreeWidgetItem(parent),widget(0),weight(-1){} QNumericTreeWidgetItem(QTreeWidgetItem* parent):QTreeWidgetItem(parent),widget(0),weight(-1){}
ContactItemWidget* widget; ContactItemWidget* widget;
QString number;
int weight; int weight;
private: private:
bool operator<(const QTreeWidgetItem & other) const { bool operator<(const QTreeWidgetItem & other) const {
...@@ -56,7 +57,7 @@ ContactDock::ContactDock(QWidget* parent) : QDockWidget(parent) ...@@ -56,7 +57,7 @@ ContactDock::ContactDock(QWidget* parent) : QDockWidget(parent)
m_pFilterLE = new KLineEdit ( ); m_pFilterLE = new KLineEdit ( );
m_pSplitter = new QSplitter ( Qt::Vertical,this ); m_pSplitter = new QSplitter ( Qt::Vertical,this );
m_pSortByCBB = new QComboBox ( this ); m_pSortByCBB = new QComboBox ( this );
m_pContactView = new QTreeWidget ( this ); m_pContactView = new ContactTree ( this );
m_pCallView = new QListWidget ( this ); m_pCallView = new QListWidget ( this );
m_pShowHistoCK = new QCheckBox ( this ); m_pShowHistoCK = new QCheckBox ( this );
...@@ -121,10 +122,14 @@ void ContactDock::reloadContact() ...@@ -121,10 +122,14 @@ void ContactDock::reloadContact()
if (numbers.count() > 1) { if (numbers.count() > 1) {
foreach (Contact::PhoneNumber* number, numbers) { foreach (Contact::PhoneNumber* number, numbers) {
QNumericTreeWidgetItem* item2 = new QNumericTreeWidgetItem(item); QNumericTreeWidgetItem* item2 = new QNumericTreeWidgetItem(item);
QLabel* numberL = new QLabel("<b>"+number->getType()+":</b>"+number->getNumber()); QLabel* numberL = new QLabel("<b>"+number->getType()+":</b>"+number->getNumber(),this);
item2->number = number->getNumber();