Show memo icon in Tx table
This commit is contained in:
@@ -60,7 +60,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
rpc = new RPC(new QNetworkAccessManager(this), this);
|
rpc = new RPC(new QNetworkAccessManager(this), this);
|
||||||
rpc->refreshZECPrice();
|
rpc->refreshZECPrice();
|
||||||
|
|
||||||
rpc->refresh();
|
rpc->refresh(true); // Force refresh first time
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupStatusBar() {
|
void MainWindow::setupStatusBar() {
|
||||||
@@ -99,7 +99,7 @@ void MainWindow::setupStatusBar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
menu.addAction("Refresh", [=]() {
|
menu.addAction("Refresh", [=]() {
|
||||||
rpc->refresh();
|
rpc->refresh(true);
|
||||||
});
|
});
|
||||||
QPoint gpos(mapToGlobal(pos).x(), mapToGlobal(pos).y() + this->height() - ui->statusBar->height());
|
QPoint gpos(mapToGlobal(pos).x(), mapToGlobal(pos).y() + this->height() - ui->statusBar->height());
|
||||||
menu.exec(gpos);
|
menu.exec(gpos);
|
||||||
@@ -112,8 +112,7 @@ void MainWindow::setupStatusBar() {
|
|||||||
ui->statusBar->addPermanentWidget(statusIcon);
|
ui->statusBar->addPermanentWidget(statusIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupSettingsModal() {
|
void MainWindow::setupSettingsModal() {
|
||||||
|
|
||||||
// Set up File -> Settings action
|
// Set up File -> Settings action
|
||||||
QObject::connect(ui->actionSettings, &QAction::triggered, [=]() {
|
QObject::connect(ui->actionSettings, &QAction::triggered, [=]() {
|
||||||
QDialog settingsDialog(this);
|
QDialog settingsDialog(this);
|
||||||
@@ -132,7 +131,7 @@ void MainWindow::setupSettingsModal() {
|
|||||||
QMessageBox::Yes, QMessageBox::Cancel)) {
|
QMessageBox::Yes, QMessageBox::Cancel)) {
|
||||||
SentTxStore::deleteHistory();
|
SentTxStore::deleteHistory();
|
||||||
// Reload after the clear button so existing txs disappear
|
// Reload after the clear button so existing txs disappear
|
||||||
rpc->refresh();
|
rpc->refresh(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -182,7 +181,7 @@ void MainWindow::setupSettingsModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then refresh everything.
|
// Then refresh everything.
|
||||||
this->rpc->refresh();
|
this->rpc->refresh(true);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
29
src/rpc.cpp
29
src/rpc.cpp
@@ -366,6 +366,7 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
|
|||||||
QSet<QString> txids;
|
QSet<QString> txids;
|
||||||
QMap<QString, QString> memos;
|
QMap<QString, QString> memos;
|
||||||
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
|
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
|
||||||
|
auto zaddr = it.key();
|
||||||
for (auto& i : it.value().get<json::array_t>()) {
|
for (auto& i : it.value().get<json::array_t>()) {
|
||||||
// Filter out change txs
|
// Filter out change txs
|
||||||
if (! i["change"].get<json::boolean_t>()) {
|
if (! i["change"].get<json::boolean_t>()) {
|
||||||
@@ -378,7 +379,7 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
|
|||||||
QString memo(QByteArray::fromHex(
|
QString memo(QByteArray::fromHex(
|
||||||
QByteArray::fromStdString(i["memo"].get<json::string_t>())));
|
QByteArray::fromStdString(i["memo"].get<json::string_t>())));
|
||||||
if (!memo.trimmed().isEmpty())
|
if (!memo.trimmed().isEmpty())
|
||||||
memos[txid] = memo;
|
memos[zaddr + txid] = memo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,7 +424,7 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
|
|||||||
auto confirmations = txidInfo["confirmations"].get<json::number_unsigned_t>();
|
auto confirmations = txidInfo["confirmations"].get<json::number_unsigned_t>();
|
||||||
|
|
||||||
TransactionItem tx{ QString("receive"), timestamp, zaddr, txid, amount,
|
TransactionItem tx{ QString("receive"), timestamp, zaddr, txid, amount,
|
||||||
confirmations, "", memos.value(txid, "") };
|
confirmations, "", memos.value(zaddr + txid, "") };
|
||||||
txdata.push_front(tx);
|
txdata.push_front(tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -441,13 +442,12 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
|
|||||||
|
|
||||||
|
|
||||||
/// This will refresh all the balance data from zcashd
|
/// This will refresh all the balance data from zcashd
|
||||||
void RPC::refresh() {
|
void RPC::refresh(bool force) {
|
||||||
// First, test the connection to see if we can actually get info.
|
getInfoThenRefresh(force);
|
||||||
getInfoThenRefresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RPC::getInfoThenRefresh() {
|
void RPC::getInfoThenRefresh(bool force) {
|
||||||
json payload = {
|
json payload = {
|
||||||
{"jsonrpc", "1.0"},
|
{"jsonrpc", "1.0"},
|
||||||
{"id", "someid"},
|
{"id", "someid"},
|
||||||
@@ -464,10 +464,17 @@ void RPC::getInfoThenRefresh() {
|
|||||||
QIcon i(":/icons/res/connected.png");
|
QIcon i(":/icons/res/connected.png");
|
||||||
main->statusIcon->setPixmap(i.pixmap(16, 16));
|
main->statusIcon->setPixmap(i.pixmap(16, 16));
|
||||||
|
|
||||||
// Refresh everything.
|
static int lastBlock = 0;
|
||||||
refreshBalances();
|
int curBlock = reply["blocks"].get<json::number_integer_t>();
|
||||||
refreshAddresses(); // This calls refreshZSentTransactions() and refreshReceivedZTrans()
|
|
||||||
refreshTransactions();
|
if ( force || (curBlock != lastBlock) ) {
|
||||||
|
// Something changed, so refresh everything.
|
||||||
|
lastBlock = curBlock;
|
||||||
|
|
||||||
|
refreshBalances();
|
||||||
|
refreshAddresses(); // This calls refreshZSentTransactions() and refreshReceivedZTrans()
|
||||||
|
refreshTransactions();
|
||||||
|
}
|
||||||
|
|
||||||
// Call to see if the blockchain is syncing.
|
// Call to see if the blockchain is syncing.
|
||||||
json payload = {
|
json payload = {
|
||||||
@@ -697,7 +704,7 @@ void RPC::watchTxStatus() {
|
|||||||
watchingOps.remove(id);
|
watchingOps.remove(id);
|
||||||
|
|
||||||
// Refresh balances to show unconfirmed balances
|
// Refresh balances to show unconfirmed balances
|
||||||
refresh();
|
refresh(true);
|
||||||
} else if (status == "failed") {
|
} else if (status == "failed") {
|
||||||
// If it failed, then we'll actually show a warning.
|
// If it failed, then we'll actually show a warning.
|
||||||
auto errorMsg = QString::fromStdString(it["error"]["message"]);
|
auto errorMsg = QString::fromStdString(it["error"]["message"]);
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ public:
|
|||||||
RPC(QNetworkAccessManager* restclient, MainWindow* main);
|
RPC(QNetworkAccessManager* restclient, MainWindow* main);
|
||||||
~RPC();
|
~RPC();
|
||||||
|
|
||||||
void refresh(); // Refresh all transactions
|
void refresh(bool force = false);
|
||||||
void refreshAddresses(); // Refresh wallet Z-addrs
|
|
||||||
|
void refreshAddresses();
|
||||||
void refreshZECPrice();
|
void refreshZECPrice();
|
||||||
|
|
||||||
void sendZTransaction (json params, const std::function<void(json)>& cb);
|
void sendZTransaction (json params, const std::function<void(json)>& cb);
|
||||||
@@ -60,7 +61,7 @@ private:
|
|||||||
bool processUnspent (const json& reply);
|
bool processUnspent (const json& reply);
|
||||||
void updateUI (bool anyUnconfirmed);
|
void updateUI (bool anyUnconfirmed);
|
||||||
|
|
||||||
void getInfoThenRefresh();
|
void getInfoThenRefresh(bool force);
|
||||||
|
|
||||||
void getBalance(const std::function<void(json)>& cb);
|
void getBalance(const std::function<void(json)>& cb);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
TxTableModel::TxTableModel(QObject *parent)
|
TxTableModel::TxTableModel(QObject *parent)
|
||||||
: QAbstractTableModel(parent) {
|
: QAbstractTableModel(parent) {
|
||||||
headers << "Category" << "Address" << "Date/Time" << "Amount";
|
headers << "Type" << "Address" << "Date/Time" << "Amount";
|
||||||
}
|
}
|
||||||
|
|
||||||
TxTableModel::~TxTableModel() {
|
TxTableModel::~TxTableModel() {
|
||||||
@@ -86,10 +86,16 @@ void TxTableModel::updateAllData() {
|
|||||||
b.setColor(Qt::black);
|
b.setColor(Qt::black);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
|
auto dat = modeldata->at(index.row());
|
||||||
|
if (role == Qt::DisplayRole) {
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0: return modeldata->at(index.row()).type;
|
case 0: {
|
||||||
|
QString labels = (dat.type == "send" ? "S" : "R");
|
||||||
|
if (!dat.memo.isEmpty())
|
||||||
|
labels = labels + " M";
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
auto addr = modeldata->at(index.row()).address;
|
auto addr = modeldata->at(index.row()).address;
|
||||||
if (addr.trimmed().isEmpty())
|
if (addr.trimmed().isEmpty())
|
||||||
@@ -98,14 +104,24 @@ void TxTableModel::updateAllData() {
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
case 2: return QDateTime::fromSecsSinceEpoch(modeldata->at(index.row()).datetime).toLocalTime().toString();
|
case 2: return QDateTime::fromSecsSinceEpoch(modeldata->at(index.row()).datetime).toLocalTime().toString();
|
||||||
case 3: {
|
case 3: return Settings::getInstance()->getZECDisplayFormat(modeldata->at(index.row()).amount);
|
||||||
if (role == Qt::DisplayRole)
|
|
||||||
return Settings::getInstance()->getZECDisplayFormat(modeldata->at(index.row()).amount);
|
|
||||||
else {
|
|
||||||
return Settings::getInstance()->getUSDFormat(modeldata->at(index.row()).amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (role == Qt::ToolTipRole) {
|
||||||
|
switch (index.column()) {
|
||||||
|
case 0: return modeldata->at(index.row()).type +
|
||||||
|
(dat.memo.isEmpty() ? "" : " tx memo: \"" + dat.memo + "\"");
|
||||||
|
case 1: {
|
||||||
|
auto addr = modeldata->at(index.row()).address;
|
||||||
|
if (addr.trimmed().isEmpty())
|
||||||
|
return "(Shielded)";
|
||||||
|
else
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
case 2: return QDateTime::fromSecsSinceEpoch(modeldata->at(index.row()).datetime).toLocalTime().toString();
|
||||||
|
case 3: return Settings::getInstance()->getUSDFormat(modeldata->at(index.row()).amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|||||||
Reference in New Issue
Block a user