From 19143d91077f554af040bc1944a56141b83e33a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mesquita?= Date: Sat, 23 Jan 2010 18:36:25 +0000 Subject: [PATCH] Do you have the time? git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16481 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- fscomm/fshost.h | 1 + fscomm/mainwindow.cpp | 25 ++++++++++++++++++++++++- fscomm/mainwindow.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/fscomm/fshost.h b/fscomm/fshost.h index dc543947cf..f86cedab97 100644 --- a/fscomm/fshost.h +++ b/fscomm/fshost.h @@ -65,6 +65,7 @@ signals: void delAccount(QSharedPointer); private slots: + /* We need to wait for the gateway deletion before reloading it */ void accountReloadSlot(QSharedPointer); private: diff --git a/fscomm/mainwindow.cpp b/fscomm/mainwindow.cpp index 84ab54e83a..e9a0d7baf0 100644 --- a/fscomm/mainwindow.cpp +++ b/fscomm/mainwindow.cpp @@ -110,6 +110,11 @@ MainWindow::MainWindow(QWidget *parent) : /* Set other properties */ ui->tableAccounts->horizontalHeader()->setStretchLastSection(true); + /* Set the call timer */ + callTimer = new QTimer(this); + callTimer->setInterval(1000); + connect(callTimer, SIGNAL(timeout()), this, SLOT(updateCallTimers())); + callTimer->start(); } MainWindow::~MainWindow() @@ -120,6 +125,17 @@ MainWindow::~MainWindow() g_FSHost.wait(); } +void MainWindow::updateCallTimers() +{ + for(int row=0; rowtableCalls->rowCount(); row++) + { + QTableWidgetItem* item = ui->tableCalls->item(row, 2); + QTime time = QTime::fromString(item->text(),"hh:mm:ss"); + time = time.addSecs(1); + item->setText(time.toString("hh:mm:ss")); + } +} + void MainWindow::setDefaultAccount() { QString accName = ui->tableAccounts->item(ui->tableAccounts->selectedRanges()[0].topRow(), 0)->text(); @@ -199,7 +215,6 @@ void MainWindow::sendDTMF(QString dtmf) g_FSHost.getCurrentActiveCall().data()->sendDTMF(dtmf); } -/* TODO: Update the timers and the item text! */ void MainWindow::callTableDoubleClick(QTableWidgetItem *item) { QSharedPointer lastCall = g_FSHost.getCurrentActiveCall(); @@ -314,6 +329,10 @@ void MainWindow::newOutgoingCall(QSharedPointer call) item1->setData(Qt::UserRole, call.data()->getUUID()); ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,1,item1); + QTableWidgetItem *item2 = new QTableWidgetItem("00:00:00"); + item2->setData(Qt::UserRole, call.data()->getUUID()); + ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,2,item2); + ui->tableCalls->resizeColumnsToContents(); ui->tableCalls->resizeRowsToContents(); ui->tableCalls->horizontalHeader()->setStretchLastSection(true); @@ -347,6 +366,10 @@ void MainWindow::ringing(QSharedPointer call) item1->setData(Qt::UserRole, call.data()->getUUID()); ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,1,item1); + QTableWidgetItem *item2 = new QTableWidgetItem("00:00:00"); + item2->setData(Qt::UserRole, call.data()->getUUID()); + ui->tableCalls->setItem(ui->tableCalls->rowCount()-1,2,item2); + ui->tableCalls->resizeColumnsToContents(); ui->tableCalls->resizeRowsToContents(); ui->tableCalls->horizontalHeader()->setStretchLastSection(true); diff --git a/fscomm/mainwindow.h b/fscomm/mainwindow.h index 61e081cffc..7d8c38b0f2 100644 --- a/fscomm/mainwindow.h +++ b/fscomm/mainwindow.h @@ -79,12 +79,14 @@ private slots: void accountDel(QSharedPointer); void accountStateChanged(QSharedPointer); void sysTrayActivated(QSystemTrayIcon::ActivationReason reason); + void updateCallTimers(); private: Ui::MainWindow *ui; QSignalMapper *dialpadMapper; PrefDialog *preferences; QSystemTrayIcon *sysTray; + QTimer *callTimer; }; #endif // MAINWINDOW_H