| 134 | } |
| 135 | |
| 136 | void AddressBookPage::setModel(AddressTableModel *_model) |
| 137 | { |
| 138 | this->model = _model; |
| 139 | if(!_model) |
| 140 | return; |
| 141 | |
| 142 | auto type = tab == ReceivingTab ? AddressTableModel::Receive : AddressTableModel::Send; |
| 143 | proxyModel = new AddressBookSortFilterProxyModel(type, this); |
| 144 | proxyModel->setSourceModel(_model); |
| 145 | |
| 146 | connect(ui->searchLineEdit, &QLineEdit::textChanged, proxyModel, &QSortFilterProxyModel::setFilterWildcard); |
| 147 | |
| 148 | ui->tableView->setModel(proxyModel); |
| 149 | ui->tableView->sortByColumn(0, Qt::AscendingOrder); |
| 150 | |
| 151 | // Set column widths |
| 152 | ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch); |
| 153 | ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents); |
| 154 | |
| 155 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, |
| 156 | this, &AddressBookPage::selectionChanged); |
| 157 | |
| 158 | // Select row for newly created address |
| 159 | connect(_model, &AddressTableModel::rowsInserted, this, &AddressBookPage::selectNewAddress); |
| 160 | |
| 161 | selectionChanged(); |
| 162 | } |
| 163 | |
| 164 | void AddressBookPage::on_copyAddress_clicked() |
| 165 | { |
no outgoing calls
no test coverage detected