Skip to content
Snippets Groups Projects
Commit 89bba742 authored by Jérémy Quentin's avatar Jérémy Quentin
Browse files

[#1307] Implement "edit before call" in history and address book.

parent 50e3c983
Branches
Tags
No related merge requests found
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <QtGui/QMenu> #include <QtGui/QMenu>
#include <QtGui/QBrush> #include <QtGui/QBrush>
#include <QtGui/QPalette> #include <QtGui/QPalette>
#include <QtGui/QInputDialog>
#include <kstandardaction.h> #include <kstandardaction.h>
#include <kactioncollection.h> #include <kactioncollection.h>
...@@ -332,12 +333,27 @@ void sflphone_kdeView::enter() ...@@ -332,12 +333,27 @@ void sflphone_kdeView::enter()
if(stackedWidget_screen->currentWidget() == page_callHistory) if(stackedWidget_screen->currentWidget() == page_callHistory)
{ {
qDebug() << "In call history."; qDebug() << "In call history.";
lineEdit_searchHistory->clear(); action_history->setChecked(false);
stackedWidget_screen->setCurrentWidget(page_callList);
Call * pastCall = callList->findCallByHistoryItem(listWidget_callHistory->currentItem());
Call * call = callList->addDialingCall(pastCall->getPeerName());
call->appendItemText(pastCall->getPeerPhoneNumber());
addCallToCallList(call);
listWidget_callList->setCurrentRow(listWidget_callList->count() - 1);
actionb(call, CALL_ACTION_ACCEPT);
} }
if(stackedWidget_screen->currentWidget() == page_addressBook) if(stackedWidget_screen->currentWidget() == page_addressBook)
{ {
qDebug() << "In address book."; qDebug() << "In address book.";
lineEdit_addressBook->clear(); action_addressBook->setChecked(false);
stackedWidget_screen->setCurrentWidget(page_callList);
ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(listWidget_addressBook->currentItem()));
Call * call = callList->addDialingCall(w->getContactName());
call->appendItemText(w->getContactNumber());
addCallToCallList(call);
listWidget_callList->setCurrentRow(listWidget_callList->count() - 1);
actionb(call, CALL_ACTION_ACCEPT);
} }
} }
...@@ -958,12 +974,20 @@ void sflphone_kdeView::on_stackedWidget_screen_currentChanged(int index) ...@@ -958,12 +974,20 @@ void sflphone_kdeView::on_stackedWidget_screen_currentChanged(int index)
void sflphone_kdeView::contextMenuEvent(QContextMenuEvent *event) void sflphone_kdeView::contextMenuEvent(QContextMenuEvent *event)
{ {
QMenu menu(this); QMenu menu(this);
if(stackedWidget_screen->currentWidget() == page_callHistory || stackedWidget_screen->currentWidget() == page_addressBook)
{
QAction * action_edit = new QAction(&menu);
action_edit->setText(tr2i18n("Edit before call", 0));
connect(action_edit, SIGNAL(triggered()),
this , SLOT(editBeforeCall()));
menu.addAction(action_edit);
}
menu.addAction(action_accept); menu.addAction(action_accept);
menu.addAction(action_refuse); menu.addAction(action_refuse);
menu.addAction(action_hold); menu.addAction(action_hold);
menu.addAction(action_transfer); menu.addAction(action_transfer);
menu.addAction(action_record); menu.addAction(action_record);
//TODO accounts to choose
menu.addSeparator(); menu.addSeparator();
QVector<Account *> accounts = registeredAccounts(); QVector<Account *> accounts = registeredAccounts();
for (int i = 0 ; i < accounts.size() ; i++) for (int i = 0 ; i < accounts.size() ; i++)
...@@ -984,6 +1008,43 @@ void sflphone_kdeView::contextMenuEvent(QContextMenuEvent *event) ...@@ -984,6 +1008,43 @@ void sflphone_kdeView::contextMenuEvent(QContextMenuEvent *event)
} }
void sflphone_kdeView::editBeforeCall()
{
qDebug() << "editBeforeCall";
QString name;
QString number;
if(stackedWidget_screen->currentWidget() == page_callHistory)
{
QListWidgetItem * item = listWidget_callHistory->currentItem();
if(item)
{
Call * call = callList->findCallByHistoryItem(item);
name = call->getPeerName();
number = call->getPeerPhoneNumber();
}
}
if(stackedWidget_screen->currentWidget() == page_addressBook)
{
QListWidgetItem * item = listWidget_addressBook->currentItem();
if(item)
{
ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(listWidget_addressBook->currentItem()));
name = w->getContactName();
number = w->getContactNumber();
}
}
QString newNumber = QInputDialog::getText(this, tr2i18n("Edit before call", 0), QString(), QLineEdit::Normal, number);
action_history->setChecked(false);
action_addressBook->setChecked(false);
stackedWidget_screen->setCurrentWidget(page_callList);
Call * call = callList->addDialingCall(name);
call->appendItemText(newNumber);
addCallToCallList(call);
listWidget_callList->setCurrentRow(listWidget_callList->count() - 1);
actionb(call, CALL_ACTION_ACCEPT);
}
void sflphone_kdeView::setAccountFirst(Account * account) void sflphone_kdeView::setAccountFirst(Account * account)
{ {
qDebug() << "setAccountFirst : " << account->getAlias(); qDebug() << "setAccountFirst : " << account->getAlias();
...@@ -1073,8 +1134,6 @@ void sflphone_kdeView::on_action_accept_triggered() ...@@ -1073,8 +1134,6 @@ void sflphone_kdeView::on_action_accept_triggered()
Call * pastCall = callList->findCallByHistoryItem(listWidget_callHistory->currentItem()); Call * pastCall = callList->findCallByHistoryItem(listWidget_callHistory->currentItem());
Call * call = callList->addDialingCall(pastCall->getPeerName()); Call * call = callList->addDialingCall(pastCall->getPeerName());
call->appendItemText(pastCall->getPeerPhoneNumber()); call->appendItemText(pastCall->getPeerPhoneNumber());
// if(!pastCall->getPeerName().isEmpty())
// call->setPeerName(pastCall->getPeerName());
addCallToCallList(call); addCallToCallList(call);
listWidget_callList->setCurrentRow(listWidget_callList->count() - 1); listWidget_callList->setCurrentRow(listWidget_callList->count() - 1);
actionb(call, CALL_ACTION_ACCEPT); actionb(call, CALL_ACTION_ACCEPT);
...@@ -1085,7 +1144,6 @@ void sflphone_kdeView::on_action_accept_triggered() ...@@ -1085,7 +1144,6 @@ void sflphone_kdeView::on_action_accept_triggered()
stackedWidget_screen->setCurrentWidget(page_callList); stackedWidget_screen->setCurrentWidget(page_callList);
ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(listWidget_addressBook->currentItem())); ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(listWidget_addressBook->currentItem()));
Call * call = callList->addDialingCall(w->getContactName()); Call * call = callList->addDialingCall(w->getContactName());
// call->setPeerName(w->getContactName());
call->appendItemText(w->getContactNumber()); call->appendItemText(w->getContactNumber());
addCallToCallList(call); addCallToCallList(call);
listWidget_callList->setCurrentRow(listWidget_callList->count() - 1); listWidget_callList->setCurrentRow(listWidget_callList->count() - 1);
......
...@@ -57,7 +57,6 @@ class sflphone_kdeView : public QWidget, public Ui::SFLPhone ...@@ -57,7 +57,6 @@ class sflphone_kdeView : public QWidget, public Ui::SFLPhone
Q_OBJECT Q_OBJECT
private: private:
//Ui::SFLPhone ui_sflphone_kdeview_base;
static ConfigurationDialog * configDialog; static ConfigurationDialog * configDialog;
AccountWizard * wizard; AccountWizard * wizard;
...@@ -81,11 +80,17 @@ public: ...@@ -81,11 +80,17 @@ public:
QErrorMessage * getErrorWindow(); QErrorMessage * getErrorWindow();
private slots: private slots:
void actionb(Call * call, call_action action);
void action(QListWidgetItem * item, call_action action);
void setAccountFirst(Account * account);
//void typeChar(QChar c); //void typeChar(QChar c);
void typeString(QString str); void typeString(QString str);
void backspace(); void backspace();
void actionb(Call * call, call_action action); void escape();
void action(QListWidgetItem * item, call_action action); void enter();
void editBeforeCall();
void alternateColors(QListWidget * listWidget); void alternateColors(QListWidget * listWidget);
...@@ -106,8 +111,6 @@ private slots: ...@@ -106,8 +111,6 @@ private slots:
void updateVolumeControls(); void updateVolumeControls();
void updateDialpad(); void updateDialpad();
void escape();
void enter();
virtual void keyPressEvent(QKeyEvent *event) virtual void keyPressEvent(QKeyEvent *event)
{ {
...@@ -115,7 +118,7 @@ private slots: ...@@ -115,7 +118,7 @@ private slots:
if(key == Qt::Key_Escape) if(key == Qt::Key_Escape)
escape(); escape();
else if(key == Qt::Key_Return || key == Qt::Key_Enter) else if(key == Qt::Key_Return || key == Qt::Key_Enter)
on_action_accept_triggered(); enter();
else if(key == Qt::Key_Backspace) else if(key == Qt::Key_Backspace)
backspace(); backspace();
else else
...@@ -128,7 +131,6 @@ private slots: ...@@ -128,7 +131,6 @@ private slots:
} }
} }
void on_action_displayVolumeControls_toggled(); void on_action_displayVolumeControls_toggled();
void on_action_displayDialpad_toggled(); void on_action_displayDialpad_toggled();
void on_action_configureAccounts_triggered(); void on_action_configureAccounts_triggered();
...@@ -143,7 +145,6 @@ private slots: ...@@ -143,7 +145,6 @@ private slots:
void on_action_history_triggered(bool checked); void on_action_history_triggered(bool checked);
void on_action_addressBook_triggered(bool checked); void on_action_addressBook_triggered(bool checked);
void on_action_mailBox_triggered(); void on_action_mailBox_triggered();
//void on_actionAbout();
void on_pushButton_1_clicked(); void on_pushButton_1_clicked();
void on_pushButton_2_clicked(); void on_pushButton_2_clicked();
...@@ -184,7 +185,6 @@ private slots: ...@@ -184,7 +185,6 @@ private slots:
void on1_voiceMailNotify(const QString &accountID, int count); void on1_voiceMailNotify(const QString &accountID, int count);
void on1_volumeChanged(const QString &device, double value); void on1_volumeChanged(const QString &device, double value);
void setAccountFirst(Account * account);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment