From b599af511d81481aa265056474a7ec69fbf4f4db Mon Sep 17 00:00:00 2001 From: RufusBarma Date: Fri, 5 Jul 2019 16:10:18 +0500 Subject: [PATCH] Add address book ui for quick call. One click - select. Two - call. --- src/gui/getaddressform.cpp | 4 +- src/gui/getaddressform.h | 1 + src/gui/getaddressform.ui | 2 +- src/gui/gui.cpp | 2 +- src/gui/mphoneform.cpp | 69 +++++++++++++++-- src/gui/mphoneform.h | 17 ++++- src/gui/mphoneform.ui | 150 +++++++++++++++++++++++++++---------- 7 files changed, 195 insertions(+), 50 deletions(-) diff --git a/src/gui/getaddressform.cpp b/src/gui/getaddressform.cpp index 06521d26..51fc76d4 100644 --- a/src/gui/getaddressform.cpp +++ b/src/gui/getaddressform.cpp @@ -185,7 +185,7 @@ void GetAddressForm::selectLocalAddress() t_display_url du(t_url(card.sip_address), card.get_display_name()); emit address(du.encode().c_str()); } - + emit leavehere(); accept(); } @@ -227,7 +227,7 @@ void GetAddressForm::deleteLocalAddress() { QModelIndexList sel = localListView->selectionModel()->selectedRows(); if (sel.isEmpty()) - return; + return;https://github.com/LubosD/twinkle.git t_address_card card = m_model->getAddress(sel[0].row()); diff --git a/src/gui/getaddressform.h b/src/gui/getaddressform.h index 1c8443e3..178afd1c 100644 --- a/src/gui/getaddressform.h +++ b/src/gui/getaddressform.h @@ -29,6 +29,7 @@ public slots: signals: void address(const QString &, const QString &); void address(const QString &); + void leavehere(); private: void *addrBook; AddressTableModel* m_model; diff --git a/src/gui/getaddressform.ui b/src/gui/getaddressform.ui index 0682f2ab..7cbee7fd 100644 --- a/src/gui/getaddressform.ui +++ b/src/gui/getaddressform.ui @@ -20,7 +20,7 @@ QTabWidget::Rounded - 0 + 1 diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ac14edd3..368034d7 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -867,7 +867,7 @@ void t_gui::run(void) { // Populate buddy list mainWindow->populateBuddyList(); - + mainWindow->populateAddressList(); // Set width of window to width of tool bar // int widthToolBar = mainWindow->callToolbar->width(); // QSize sizeMainWin = mainWindow->size(); diff --git a/src/gui/mphoneform.cpp b/src/gui/mphoneform.cpp index 6c447a8d..73e69019 100644 --- a/src/gui/mphoneform.cpp +++ b/src/gui/mphoneform.cpp @@ -236,7 +236,7 @@ void MphoneForm::init() // View menu menu->addAction(viewCall_HistoryAction); - + menu->addSeparator(); #ifdef WITH_DIAMONDCARD @@ -256,14 +256,14 @@ void MphoneForm::init() restoreState(g_gui_state->value("mainwindow/state").toByteArray()); restoreGeometry(g_gui_state->value("mainwindow/geometry").toByteArray()); - splitter2->restoreState(g_gui_state->value("mainwindow/mainsplitter").toByteArray()); + splitter2->restoreState(g_gui_state->value("mainwindow/mainsplitter").toByteArray()); } void MphoneForm::destroy() { g_gui_state->setValue("mainwindow/state", saveState()); g_gui_state->setValue("mainwindow/geometry", saveGeometry()); - g_gui_state->setValue("mainwindow/mainsplitter", splitter2->saveState()); + g_gui_state->setValue("mainwindow/mainsplitter", splitter2->saveState()); if (dtmfForm) { MEMMAN_DELETE(dtmfForm); @@ -2353,7 +2353,9 @@ void MphoneForm::selectProfile() connect(selectProfileForm, SIGNAL(profileRenamed()), this, SLOT(updateUserComboBox())); connect(selectProfileForm, SIGNAL(profileRenamed()), - this, SLOT(populateBuddyList())); + this, SLOT(populateBuddyList())); + connect(selectProfileForm, SIGNAL(profileRenamed()), + this, SLOT(populateAddressList())); } selectProfileForm->showForm(this); @@ -2493,6 +2495,7 @@ void MphoneForm::newUsers(const list &profiles) progress.setValue(add_profile_list.size()); populateBuddyList(); + populateAddressList(); updateUserComboBox(); updateRegStatus(); updateMwi(); @@ -2675,7 +2678,10 @@ void MphoneForm::showAddressBook() connect(getAddressForm, SIGNAL(address(const QString &)), this, SLOT(selectedAddress(const QString &))); - + connect(getAddressForm, + SIGNAL(leavehere()), + this, SLOT(populateAddressList())); + getAddressForm->show(); } @@ -2963,6 +2969,18 @@ void MphoneForm::showBuddyList(bool on) viewBuddyListAction->setChecked(on); } +void MphoneForm::showAddressList(bool on) +{ + if (on) { + addressListView->show(); + } else { + addressListView->hide(); + } + + viewAddressList = on; + viewAddressListAction->setChecked(on); +} + void MphoneForm::showCompactLineStatus(bool on) { if (on) { @@ -3021,6 +3039,11 @@ bool MphoneForm::getViewBuddyList() return viewBuddyList; } +bool MphoneForm::getViewAddressList() +{ + return viewAddressList; +} + bool MphoneForm::getViewCompactLineStatus() { return viewCompactLineStatus; @@ -3049,6 +3072,16 @@ void MphoneForm::populateBuddyList() buddyListView->expandAll(); } +void MphoneForm::populateAddressList() +{ + m_model = new AddressTableModel(this, ab_local->get_address_list()); + addressListView->setModel(m_model); + + addressListView->sortByColumn(COL_ADDR_NAME, Qt::AscendingOrder); + + addressListView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); +} + void MphoneForm::showBuddyListPopupMenu(const QPoint &pos) { QTreeWidgetItem* item = buddyListView->currentItem(); @@ -3332,3 +3365,29 @@ void MphoneForm::osdMuteClicked() ((t_gui *)ui)->action_mute(!phone->is_line_muted(phone->get_active_line())); updateState(); } + +void MphoneForm::on_viewAddressListAction_triggered(bool on) +{ + if (on) { + addressListView->show(); + } else { + addressListView->hide(); + } + + viewAddressList = on; + viewAddressListAction->setChecked(on); +} + +void MphoneForm::selectLocalAddress() +{ + qDebug()<<"Enter!"; + QModelIndexList sel = addressListView->selectionModel()->selectedRows(); + if (!sel.isEmpty()) + { + t_address_card card = m_model->getAddress(sel[0].row()); + QString address = '"' +QString::fromStdString(card.get_display_name()) + '"' + " <" + QString::fromStdString(card.sip_address) + '>'; + addToCallComboBox(address); + selectedAddress(address); + qDebug()< true - - + + Qt::Horizontal - - - - 150 - 0 - - - - - 0 - 0 - - - - Qt::CustomContextMenu - - - You can create a separate buddy list for each user profile. You can only see availability of your buddies and publish your own availability if your provider offers a presence server. - - - true - - - - Buddy list - - + + + + + + + 150 + 0 + + + + + 0 + 0 + + + + Qt::CustomContextMenu + + + You can create a separate buddy list for each user profile. You can only see availability of your buddies and publish your own availability if your provider offers a presence server. + + + true + + + + Buddy list + + + + + + + + + 150 + 0 + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + + @@ -1058,7 +1086,7 @@ 0 0 733 - 17 + 19 @@ -1135,6 +1163,7 @@ + @@ -1792,6 +1821,17 @@ diamondcardSign_upAction + + + true + + + true + + + &Address book + + @@ -2286,8 +2326,8 @@ line2rbChangedState(bool) - 309 - 597 + 356 + 595 20 @@ -2302,8 +2342,8 @@ line1rbChangedState(bool) - 309 - 491 + 356 + 489 20 @@ -2478,8 +2518,8 @@ doMessageBuddy(QTreeWidgetItem*) - 130 - 206 + 279 + 268 3 @@ -2494,8 +2534,8 @@ showBuddyListPopupMenu(QPoint) - 98 - 285 + 264 + 268 3 @@ -2503,9 +2543,43 @@ + + addressListView + clicked(QModelIndex) + MphoneForm + selectLocalAddress() + + + 113 + 354 + + + 4 + 376 + + + + + addressListView + doubleClicked(QModelIndex) + MphoneForm + quickCall() + + + 88 + 352 + + + 5 + 349 + + + doMessageBuddy(QTreeWidgetItem*) showBuddyListPopupMenu(QPoint) + selectLocalAddress() + quickCall()