diff --git a/sflphone-client-kde/src/CallTreeItem.cpp b/sflphone-client-kde/src/CallTreeItem.cpp index 0fe333b13ee65b6fe06795b1308388944e292f31..cafb6bb6e6c9f47f55b5537e66b5bb8ae13c6e12 100644 --- a/sflphone-client-kde/src/CallTreeItem.cpp +++ b/sflphone-client-kde/src/CallTreeItem.cpp @@ -185,6 +185,7 @@ void CallTreeItem::setCall(Call *call) QHBoxLayout * mainLayout = new QHBoxLayout(); mainLayout->setContentsMargins ( 3, 1, 2, 1); + mainLayout->setSpacing(4); QVBoxLayout * descr = new QVBoxLayout(); descr->setMargin(1); @@ -206,7 +207,8 @@ void CallTreeItem::setCall(Call *call) mainLayout->addItem(horizontalSpacer); itemWidget->setLayout(mainLayout); - + itemWidget->setMinimumSize(QSize(50, 30)); + connect(itemCall, SIGNAL(changed()), this, SLOT(updated())); diff --git a/sflphone-client-kde/src/CallTreeItem.h b/sflphone-client-kde/src/CallTreeItem.h index f20aea6fe688227e7b8b16335cd627f676990108..bc8fb65e9cc784673cbb9176b3445442cfc0e655 100644 --- a/sflphone-client-kde/src/CallTreeItem.h +++ b/sflphone-client-kde/src/CallTreeItem.h @@ -66,7 +66,6 @@ class CallTreeItem : public QObject QVector<QVariant> itemData; CallTreeItem *parentItem; Call *itemCall; - QWidget *itemWidget; QLabel * labelIcon; diff --git a/sflphone-client-kde/src/CallTreeModel.cpp b/sflphone-client-kde/src/CallTreeModel.cpp index f0494ce61b0b8b93fe657563e961d4fe4e487999..28d539ea3feff1286665887fd4f3ea1c0a31006f 100644 --- a/sflphone-client-kde/src/CallTreeModel.cpp +++ b/sflphone-client-kde/src/CallTreeModel.cpp @@ -91,8 +91,9 @@ Qt::ItemFlags CallTreeModel::flags(const QModelIndex &index) const { return 0; } + Qt::ItemFlags val = Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; - return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; + return val; } CallTreeItem *CallTreeModel::getItem(const QModelIndex &index) const diff --git a/sflphone-client-kde/src/CallTreeView.cpp b/sflphone-client-kde/src/CallTreeView.cpp index ebfd3a2e21196fd9bfe3c48bee80c331fd2cdf7a..e6e3041710a08fc73e4891f9fae9cfc5f0747017 100644 --- a/sflphone-client-kde/src/CallTreeView.cpp +++ b/sflphone-client-kde/src/CallTreeView.cpp @@ -19,6 +19,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include <QtCore/QMimeData> + #include "CallTreeView.h" #include "CallTreeModel.h" #include "CallTreeItem.h" @@ -40,7 +42,7 @@ CallTreeView::CallTreeView(QWidget * parent) CallTreeView::~CallTreeView() { - // delete treeModel; + delete treeModel; } CallTreeItem* CallTreeView::insert(Call *call) @@ -82,30 +84,32 @@ CallTreeItem* CallTreeView::insert(CallTreeItem *parent, Call *call) } CallTreeItem *item = treeModel->getItem(index); - item->setCall(call); for (int column = 0; column < treeModel->columnCount(index); ++column) { QModelIndex child = treeModel->index(0, column, index); treeModel->setData(child, QVariant(""), Qt::EditRole); } - + + item->setCall(call); selectionModel()->setCurrentIndex(model()->index(0, 0, index), QItemSelectionModel::ClearAndSelect); + + QModelIndex newIndex = selectionModel()->currentIndex(); + + return treeModel->getItem(newIndex); } -void CallTreeView::remove(CallTreeItem *item) +void CallTreeView::remove(QModelIndex & index) const { - QModelIndex index = selectionModel()->currentIndex(); treeModel->removeRow(index.row(), index.parent()); } -CallTreeItem* CallTreeView::getItem(Call *call) +void CallTreeView::removeCurrent() const { - // to implement - return 0; + QModelIndex index = selectionModel()->currentIndex(); + treeModel->removeRow(index.row(), index.parent()); } - CallTreeItem* CallTreeView::currentItem() { QModelIndex index = selectionModel()->currentIndex(); @@ -127,7 +131,7 @@ void CallTreeView::setCurrentRow(int row) CallTreeModel * treeModel = static_cast<CallTreeModel*>(model()); QModelIndex currentIndex = selectionModel()->currentIndex(); - QModelIndex index = treeModel->index(0, 0, currentIndex); + QModelIndex index = treeModel->index(row, 0, currentIndex); selectionModel()->setCurrentIndex(index, QItemSelectionModel::Current); } @@ -136,3 +140,38 @@ int CallTreeView::count() { return model()->rowCount(); } + +bool CallTreeView::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) +{/* + = data->data("items/index"); + + foreach(QModelIndex index, callList) // iterate over list + { + CallTreeItem *item = static_cast<CallTreeItem*>(index.internalPointer()); + + if (parent == NULL) + { + // make new QTreeWidgetItem and set its text + // if parent is null - add top level item (this parent) + insert(item->call()); + } + else + { + // else add QTreeWidgetItem with parent and expand parent + insert(parent, item->call()); + parent->setExpanded( true ); + } + } */ + return true; +} + +QStringList CallTreeView::mimeTypes() const +{ + +} + + +Qt::DropActions CallTreeView::supportedDropActions () const +{ + +} diff --git a/sflphone-client-kde/src/CallTreeView.h b/sflphone-client-kde/src/CallTreeView.h index a94a8b4367344c8c231910bddd120d94d37a401b..dd0a50430419d4d88c7ddaaa5249ceb6182487e9 100644 --- a/sflphone-client-kde/src/CallTreeView.h +++ b/sflphone-client-kde/src/CallTreeView.h @@ -31,6 +31,9 @@ class CallTreeModel; class CallTreeItem; class Call; +class QModelIndex; +class QTreeWidgetItem; +class QMimeData; class CallTreeView : public QTreeView { @@ -41,11 +44,15 @@ public: CallTreeItem* insert(CallTreeItem *item, Call* call); CallTreeItem* insert(Call* call); - CallTreeItem* getItem(Call *call); - void remove(CallTreeItem* item); + void remove(QModelIndex & index) const; + void removeCurrent() const; CallTreeItem* currentItem(); void setCurrentRow(int row); int count(); + + bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); + QStringList mimeTypes() const; + Qt::DropActions supportedDropActions () const; private: CallTreeModel *treeModel; }; diff --git a/sflphone-client-kde/src/SFLPhoneView.cpp b/sflphone-client-kde/src/SFLPhoneView.cpp index d6f935325b18b742dd2fec81415a33c5dca65dbf..a6f1bcdf533eae95524a984b5c96f92d8e7e15ff 100644 --- a/sflphone-client-kde/src/SFLPhoneView.cpp +++ b/sflphone-client-kde/src/SFLPhoneView.cpp @@ -1,3 +1,4 @@ + /*************************************************************************** * Copyright (C) 2009 by Savoir-Faire Linux * * Author : Jérémy Quentin * @@ -68,10 +69,12 @@ SFLPhoneView::SFLPhoneView(QWidget *parent) errorWindow = new QErrorMessage(this); callList = new CallList(this); + callTree = new CallTreeView(page_callList); historyTree = new CallTreeView(page_callHistory); page_callList->layout()->addWidget(callTree); + page_callHistory->layout()->addWidget(historyTree); historyLoaded = false; @@ -202,20 +205,12 @@ QErrorMessage * SFLPhoneView::getErrorWindow() CallTreeItem* SFLPhoneView::addCallToCallList(Call * call) { return callTree->insert(call); - -// QWidget * widget = call->getItemWidget(); -// } } CallTreeItem* SFLPhoneView::addCallToCallHistory(Call * call) { return historyTree->insert(call); -// if(item) -// { -// QWidget * widget = call->getHistoryItemWidget(); -// historyTree->setItemWidget(item, widget); -// } } void SFLPhoneView::addContactToContactList(Contact * contact) @@ -317,7 +312,15 @@ void SFLPhoneView::backspace() else { call->backspaceItemText(); - updateCallItem(call); + if(call->getState() == CALL_STATE_OVER) + { + callTree->removeCurrent(); + + if(call->getHistoryState() != NONE) + { + historyTree->insert(call); + } + } } } } @@ -344,8 +347,7 @@ void SFLPhoneView::escape() } else { - int state = call->getState(); - if(state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) + if(call->getState() == CALL_STATE_TRANSFER ||call->getState() == CALL_STATE_TRANSF_HOLD) { action(call, CALL_ACTION_TRANSFER); } @@ -461,7 +463,8 @@ void SFLPhoneView::action(Call * call, call_action action) { errorWindow->showMessage(QString(msg)); } - updateCallItem(call); + + //updateCallItem(call); updateWindowCallState(); } } @@ -471,23 +474,6 @@ void SFLPhoneView::action(Call * call, call_action action) ******** Update Display Functions ********** *******************************************/ -void SFLPhoneView::updateCallItem(Call * call) -{ - if(!call) return; - call_state state = call->getState(); - if(state == CALL_STATE_OVER) - { - CallTreeItem * item = callTree->getItem(call); - qDebug() << "Updating call with CALL_STATE_OVER. Deleting item " << call->getCallId(); - callTree->remove(item); - if(call->getHistoryState() != NONE) - { - historyTree->insert(call); - } - } -} - - void SFLPhoneView::updateWindowCallState() { qDebug() << "updateWindowCallState"; @@ -1377,7 +1363,7 @@ void SFLPhoneView::on1_callStateChanged(const QString &callID, const QString &st { call->stateChanged(state); } - updateCallItem(call); + // updateCallItem(call); updateWindowCallState(); } diff --git a/sflphone-client-kde/src/SFLPhoneView.h b/sflphone-client-kde/src/SFLPhoneView.h index 0ba19f793e0d08174eeb9e726d4c91062cd99b08..47b931edf1ad608c09895eedf0449925ddc02c7a 100644 --- a/sflphone-client-kde/src/SFLPhoneView.h +++ b/sflphone-client-kde/src/SFLPhoneView.h @@ -218,13 +218,6 @@ private slots: */ void addContactToContactList(Contact * contact); - /** - * Updates call's item according to its state. - * (Actually it only deletes the item from the main window's - * list widget once the call is OVER.) - * @param call the call to which update the item - */ - void updateCallItem(Call * call); /** * Updates the toolbar's actions' display according to the selected * item's state.