diff options
author | Peter Colberg <peter@colberg.org> | 2015-12-30 23:16:47 -0500 |
---|---|---|
committer | Peter Colberg <peter@colberg.org> | 2015-12-30 23:16:47 -0500 |
commit | f3926963ea687c6dbac3d6e3fdb832f81bddf903 (patch) | |
tree | e931f1b66a6c90372f64060a83399c1e834c15c0 /src/gui/historyform.cpp | |
parent | 1943a35fbcab844d469e8129f78bf7ebe504aa42 (diff) | |
download | twinkle-f3926963ea687c6dbac3d6e3fdb832f81bddf903.tar twinkle-f3926963ea687c6dbac3d6e3fdb832f81bddf903.tar.gz twinkle-f3926963ea687c6dbac3d6e3fdb832f81bddf903.tar.lz twinkle-f3926963ea687c6dbac3d6e3fdb832f81bddf903.tar.xz twinkle-f3926963ea687c6dbac3d6e3fdb832f81bddf903.zip |
historyform: Show call details of current item
The signal QAbstractItemView::activated() is emitted only when
double-clicking or pressing the Enter key on a current item.
Listen to signal QItemSelectionModel::currentChanged(), which is emitted
when the current item is changed with a single click or the arrow keys.
Diffstat (limited to 'src/gui/historyform.cpp')
-rw-r--r-- | src/gui/historyform.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/gui/historyform.cpp b/src/gui/historyform.cpp index 15b882a..319d6f1 100644 --- a/src/gui/historyform.cpp +++ b/src/gui/historyform.cpp @@ -84,6 +84,8 @@ void HistoryForm::init() #else historyListView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); #endif + + connect(historyListView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(showCallDetails(QModelIndex))); inCheckBox->setChecked(true); outCheckBox->setChecked(true); @@ -236,9 +238,7 @@ void HistoryForm::loadHistory() // Sort entries using currently selected sort column and order. historyListView->sortByColumn(historyListView->horizontalHeader()->sortIndicatorSection(), historyListView->horizontalHeader()->sortIndicatorOrder()); // Make the first entry the selected entry. - historyListView->selectRow(0); - - // showCallDetails(first); + if (numberOfCalls) historyListView->selectRow(0); } // Update history when triggered by a call back function on the user @@ -279,13 +279,14 @@ void HistoryForm::closeEvent( QCloseEvent *e ) QDialog::closeEvent(e); } -void HistoryForm::showCallDetails(QModelIndex index) +void HistoryForm::showCallDetails(const QModelIndex &index) { - QString s; + cdrTextEdit->clear(); + + if (!index.isValid()) return; int x = m_model->data(index, Qt::UserRole).toInt(); const t_call_record& cr = m_history[x]; - cdrTextEdit->clear(); t_user *user_config = phone->ref_user_profile(cr.user_profile); // If the user profile is not active, then use the @@ -294,7 +295,7 @@ void HistoryForm::showCallDetails(QModelIndex index) user_config = phone->ref_users().front(); } - s = "<table>"; + QString s = "<table>"; // Left column: header names s += "<tr><td><b>"; |