Remove QObject inheritance from Account and add event for account removal.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16412 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
João Mesquita
2010-01-20 05:11:40 +00:00
parent 236db6ae69
commit b05dfcb946
8 changed files with 73 additions and 9 deletions

View File

@@ -83,6 +83,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(&g_FSHost, SIGNAL(callFailed(QSharedPointer<Call>)), this, SLOT(callFailed(QSharedPointer<Call>)));
connect(&g_FSHost, SIGNAL(accountStateChange(QSharedPointer<Account>)), this, SLOT(accountStateChanged(QSharedPointer<Account>)));
connect(&g_FSHost, SIGNAL(newAccount(QSharedPointer<Account>)), this, SLOT(accountAdd(QSharedPointer<Account>)));
connect(&g_FSHost, SIGNAL(delAccount(QSharedPointer<Account>)), this, SLOT(accountDel(QSharedPointer<Account>)));
/*connect(&g_FSHost, SIGNAL(coreLoadingError(QString)), this, SLOT(coreLoadingError(QString)));*/
connect(ui->newCallBtn, SIGNAL(clicked()), this, SLOT(makeCall()));
@@ -153,6 +154,22 @@ void MainWindow::accountAdd(QSharedPointer<Account> acc)
ui->tableAccounts->horizontalHeader()->setStretchLastSection(true);
}
void MainWindow::accountDel(QSharedPointer<Account> acc)
{
foreach (QTableWidgetItem *i, ui->tableAccounts->findItems(acc.data()->getName(), Qt::MatchExactly))
{
if (i->text() == acc.data()->getName())
{
ui->tableAccounts->removeRow(i->row());
ui->tableAccounts->setRowCount(ui->tableAccounts->rowCount()-1);
ui->tableAccounts->resizeColumnsToContents();
ui->tableAccounts->resizeRowsToContents();
ui->tableAccounts->horizontalHeader()->setStretchLastSection(true);
return;
}
}
}
void MainWindow::accountStateChanged(QSharedPointer<Account> acc)
{
ui->statusBar->showMessage(tr("Account %1 is %2").arg(acc.data()->getName(), acc.data()->getStateName()));