int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- QModelIndex index ( int row, int column, const QModelIndex & parent ) const;
+ QModelIndex index(int row, int column, const QModelIndex & parent) const;
+
+ void updateList();
private:
AddressTablePriv *priv;
QStringList columns;
#define GUIUTIL_H
#include <QString>
+#include <QFont>
QString DateTimeStr(qint64 nTime);
+/* Render bitcoin addresses in monospace font */
+QFont bitcoinAddressFont();
#endif // GUIUTIL_H
#include "editaddressdialog.h"
#include <QSortFilterProxyModel>
+#include <QClipboard>
#include <QDebug>
AddressBookDialog::AddressBookDialog(QWidget *parent) :
void AddressBookDialog::on_copyToClipboard_clicked()
{
- /* Copy currently selected address to clipboard */
+ /* Copy currently selected address to clipboard
+ (or nothing, if nothing selected)
+ */
+ QTableView *table = getCurrentTable();
+ QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
+ foreach (QModelIndex index, indexes) {
+ QVariant address = table->model()->data(index);
+ QApplication::clipboard()->setText(address.toString());
+ }
}
void AddressBookDialog::on_editButton_clicked()
{
- /* Double click should trigger edit button */
+ /* Double click triggers edit button */
EditAddressDialog dlg;
dlg.exec();
}
#include "addresstablemodel.h"
+#include "guiutil.h"
#include "main.h"
const QString AddressTableModel::Send = "S";
{
cachedAddressTable.clear();
- }
-
- void updateAddressTable()
- {
CRITICAL_BLOCK(cs_mapKeys)
CRITICAL_BLOCK(cs_mapAddressBook)
{
}
}
-
int size()
{
return cachedAddressTable.size();
case Address:
return rec->address;
}
+ } else if (role == Qt::FontRole)
+ {
+ if(index.column() == Address)
+ {
+ return bitcoinAddressFont();
+ }
} else if (role == TypeRole)
{
switch(rec->type)
return QVariant();
}
-QModelIndex AddressTableModel::index ( int row, int column, const QModelIndex & parent ) const
+QModelIndex AddressTableModel::index(int row, int column, const QModelIndex & parent) const
{
Q_UNUSED(parent);
AddressTableEntry *data = priv->index(row);
}
}
+void AddressTableModel::updateList()
+{
+ /* Update internal model from Bitcoin core */
+ beginResetModel();
+ priv->refreshAddressTable();
+ endResetModel();
+}
hbox_balance->addSpacing(5);/* Add some spacing between the label and the text */
labelBalance = new QLabel();
- labelBalance->setFont(QFont("Teletype"));
+ labelBalance->setFont(QFont("Monospace"));
hbox_balance->addWidget(labelBalance);
hbox_balance->addStretch(1);
QDateTime date = QDateTime::fromMSecsSinceEpoch(nTime*1000);
return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm");
}
+
+QFont bitcoinAddressFont()
+{
+ QFont font("Monospace");
+ font.setStyleHint(QFont::TypeWriter);
+ return font;
+}