Browse Source

Merge branch 'master' of github.com:laanwj/bitcoin-qt

0.8
Wladimir J. van der Laan 14 years ago
parent
commit
4181184acf
  1. 1
      gui/include/bitcoingui.h
  2. 2
      gui/include/transactiontablemodel.h
  3. 7
      gui/src/addressbookdialog.cpp
  4. 27
      gui/src/bitcoingui.cpp

1
gui/include/bitcoingui.h

@ -82,6 +82,7 @@ private slots:
void copyClipboardClicked(); void copyClipboardClicked();
void trayIconActivated(QSystemTrayIcon::ActivationReason reason); void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
void transactionDetails(const QModelIndex& idx); void transactionDetails(const QModelIndex& idx);
void incomingTransaction(const QModelIndex & parent, int start, int end);
}; };
#endif #endif

2
gui/include/transactiontablemodel.h

@ -37,7 +37,7 @@ public:
QVariant data(const QModelIndex &index, int role) const; QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const;
QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
private: private:
QStringList columns; QStringList columns;
TransactionTablePriv *priv; TransactionTablePriv *priv;

7
gui/src/addressbookdialog.cpp

@ -82,7 +82,7 @@ void AddressBookDialog::on_copyToClipboard_clicked()
foreach (QModelIndex index, indexes) foreach (QModelIndex index, indexes)
{ {
QVariant address = table->model()->data(index); QVariant address = index.data();
QApplication::clipboard()->setText(address.toString()); QApplication::clipboard()->setText(address.toString());
} }
} }
@ -94,6 +94,9 @@ void AddressBookDialog::on_editButton_clicked()
{ {
return; return;
} }
/* Map selected index to source address book model */
QAbstractProxyModel *proxy_model = static_cast<QAbstractProxyModel*>(getCurrentTable()->model());
QModelIndex selected = proxy_model->mapToSource(indexes.at(0));
/* Double click also triggers edit button */ /* Double click also triggers edit button */
EditAddressDialog dlg( EditAddressDialog dlg(
@ -101,7 +104,7 @@ void AddressBookDialog::on_editButton_clicked()
EditAddressDialog::EditSendingAddress : EditAddressDialog::EditSendingAddress :
EditAddressDialog::EditReceivingAddress); EditAddressDialog::EditReceivingAddress);
dlg.setModel(model); dlg.setModel(model);
dlg.loadRow(indexes.at(0).row()); dlg.loadRow(selected.row());
if(dlg.exec()) if(dlg.exec())
{ {
dlg.saveCurrentRow(); dlg.saveCurrentRow();

27
gui/src/bitcoingui.cpp

@ -214,7 +214,7 @@ QWidget *BitcoinGUI::createTabs()
QTableView *view = new QTableView(this); QTableView *view = new QTableView(this);
tabs->addTab(view, tab_labels.at(i)); tabs->addTab(view, tab_labels.at(i));
connect(view, SIGNAL(activated(const QModelIndex&)), this, SLOT(transactionDetails(const QModelIndex&))); connect(view, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(transactionDetails(const QModelIndex&)));
transactionViews.append(view); transactionViews.append(view);
} }
@ -257,6 +257,9 @@ void BitcoinGUI::setTabsModel(QAbstractItemModel *transaction_model)
transaction_table->horizontalHeader()->resizeSection( transaction_table->horizontalHeader()->resizeSection(
TransactionTableModel::Credit, 79); TransactionTableModel::Credit, 79);
} }
connect(transaction_model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
this, SLOT(incomingTransaction(const QModelIndex &, int, int)));
} }
void BitcoinGUI::sendcoinsClicked() void BitcoinGUI::sendcoinsClicked()
@ -407,3 +410,25 @@ void BitcoinGUI::transactionDetails(const QModelIndex& idx)
dlg.exec(); dlg.exec();
} }
void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end)
{
TransactionTableModel *ttm = model->getTransactionTableModel();
qint64 credit = ttm->index(start, TransactionTableModel::Credit, parent)
.data(Qt::EditRole).toULongLong();
qint64 debit = ttm->index(start, TransactionTableModel::Debit, parent)
.data(Qt::EditRole).toULongLong();
if((credit+debit)>0)
{
/* On incoming transaction, make an info balloon */
QString date = ttm->index(start, TransactionTableModel::Date, parent)
.data().toString();
QString description = ttm->index(start, TransactionTableModel::Description, parent)
.data().toString();
trayIcon->showMessage(tr("Incoming transaction"),
"Date: " + date + "\n" +
"Amount: " + QString::fromStdString(FormatMoney(credit+debit, true)) + "\n" +
description,
QSystemTrayIcon::Information);
}
}

Loading…
Cancel
Save