#include <QClipboard>
#include <QFileDialog>
#include <QMessageBox>
-#include <QDebug>
AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
QDialog(parent),
tab(tab)
{
ui->setupUi(this);
+
+#ifdef Q_WS_MAC // Icons on push buttons are very uncommon on Mac
+ ui->newAddressButton->setIcon(QIcon());
+ ui->copyToClipboard->setIcon(QIcon());
+ ui->deleteButton->setIcon(QIcon());
+#endif
+
switch(mode)
{
case ForSending:
void AddressBookPage::setModel(AddressTableModel *model)
{
this->model = model;
+ if(!model)
+ return;
// Refresh list from core
model->updateList();
selectionChanged();
}
-QTableView *AddressBookPage::getCurrentTable()
-{
- return ui->tableView;
-}
-
void AddressBookPage::on_copyToClipboard_clicked()
{
// Copy currently selected address to clipboard
// (or nothing, if nothing selected)
- QTableView *table = getCurrentTable();
+ QTableView *table = ui->tableView;
+ if(!table->selectionModel())
+ return;
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
foreach (QModelIndex index, indexes)
void AddressBookPage::on_newAddressButton_clicked()
{
+ if(!model)
+ return;
EditAddressDialog dlg(
tab == SendingTab ?
EditAddressDialog::NewSendingAddress :
void AddressBookPage::on_deleteButton_clicked()
{
- QTableView *table = getCurrentTable();
+ QTableView *table = ui->tableView;
+ if(!table->selectionModel())
+ return;
QModelIndexList indexes = table->selectionModel()->selectedRows();
if(!indexes.isEmpty())
{
void AddressBookPage::selectionChanged()
{
// Set button states based on selected tab and selection
- QTableView *table = getCurrentTable();
+ QTableView *table = ui->tableView;
+ if(!table->selectionModel())
+ return;
if(table->selectionModel()->hasSelection())
{
void AddressBookPage::done(int retval)
{
+ QTableView *table = ui->tableView;
+ if(!table->selectionModel() || !table->model())
+ return;
// When this is a tab/widget and not a model dialog, ignore "done"
if(mode == ForEditing)
return;
// Figure out which address was selected, and return it
- QTableView *table = getCurrentTable();
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
foreach (QModelIndex index, indexes)