aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-06-01 20:08:21 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-06-01 20:08:21 +0200
commitef1b844e7b444b07e708dcd9a1e0dc93510dade5 (patch)
tree95d535087158317bf8518d8f0917e1eb2520dc53
parentdf6dfb4ab82da88103738ace69dca2d42fcb87b0 (diff)
monospace font for bitcoin addresses
-rw-r--r--gui/include/addresstablemodel.h4
-rw-r--r--gui/include/guiutil.h3
-rw-r--r--gui/src/addressbookdialog.cpp13
-rw-r--r--gui/src/addresstablemodel.cpp21
-rw-r--r--gui/src/bitcoingui.cpp2
-rw-r--r--gui/src/guiutil.cpp7
6 files changed, 40 insertions, 10 deletions
diff --git a/gui/include/addresstablemodel.h b/gui/include/addresstablemodel.h
index 81fad6db25..6617bb3e89 100644
--- a/gui/include/addresstablemodel.h
+++ b/gui/include/addresstablemodel.h
@@ -29,7 +29,9 @@ public:
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;
diff --git a/gui/include/guiutil.h b/gui/include/guiutil.h
index a73eadc02a..eaa8199900 100644
--- a/gui/include/guiutil.h
+++ b/gui/include/guiutil.h
@@ -2,7 +2,10 @@
#define GUIUTIL_H
#include <QString>
+#include <QFont>
QString DateTimeStr(qint64 nTime);
+/* Render bitcoin addresses in monospace font */
+QFont bitcoinAddressFont();
#endif // GUIUTIL_H
diff --git a/gui/src/addressbookdialog.cpp b/gui/src/addressbookdialog.cpp
index 4ca863bd20..ba6fdb51a0 100644
--- a/gui/src/addressbookdialog.cpp
+++ b/gui/src/addressbookdialog.cpp
@@ -5,6 +5,7 @@
#include "editaddressdialog.h"
#include <QSortFilterProxyModel>
+#include <QClipboard>
#include <QDebug>
AddressBookDialog::AddressBookDialog(QWidget *parent) :
@@ -72,13 +73,21 @@ QTableView *AddressBookDialog::getCurrentTable()
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();
}
diff --git a/gui/src/addresstablemodel.cpp b/gui/src/addresstablemodel.cpp
index d1f1a9c848..21a9044271 100644
--- a/gui/src/addresstablemodel.cpp
+++ b/gui/src/addresstablemodel.cpp
@@ -1,4 +1,5 @@
#include "addresstablemodel.h"
+#include "guiutil.h"
#include "main.h"
const QString AddressTableModel::Send = "S";
@@ -28,10 +29,6 @@ struct AddressTablePriv
{
cachedAddressTable.clear();
- }
-
- void updateAddressTable()
- {
CRITICAL_BLOCK(cs_mapKeys)
CRITICAL_BLOCK(cs_mapAddressBook)
{
@@ -48,7 +45,6 @@ struct AddressTablePriv
}
}
-
int size()
{
return cachedAddressTable.size();
@@ -108,6 +104,12 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
case Address:
return rec->address;
}
+ } else if (role == Qt::FontRole)
+ {
+ if(index.column() == Address)
+ {
+ return bitcoinAddressFont();
+ }
} else if (role == TypeRole)
{
switch(rec->type)
@@ -134,7 +136,7 @@ QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation,
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);
@@ -146,3 +148,10 @@ QModelIndex AddressTableModel::index ( int row, int column, const QModelIndex &
}
}
+void AddressTableModel::updateList()
+{
+ /* Update internal model from Bitcoin core */
+ beginResetModel();
+ priv->refreshAddressTable();
+ endResetModel();
+}
diff --git a/gui/src/bitcoingui.cpp b/gui/src/bitcoingui.cpp
index 66891222a8..0dc895dcc9 100644
--- a/gui/src/bitcoingui.cpp
+++ b/gui/src/bitcoingui.cpp
@@ -83,7 +83,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
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);
diff --git a/gui/src/guiutil.cpp b/gui/src/guiutil.cpp
index d27a8e101c..59b4de305d 100644
--- a/gui/src/guiutil.cpp
+++ b/gui/src/guiutil.cpp
@@ -7,3 +7,10 @@ QString DateTimeStr(qint64 nTime)
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;
+}