|
|
@ -3,6 +3,7 @@ |
|
|
|
#include "txtablemodel.h" |
|
|
|
#include "settings.h" |
|
|
|
#include "rpc.h" |
|
|
|
#include "guiconstants.h" |
|
|
|
|
|
|
|
TxTableModel::TxTableModel(QObject *parent) |
|
|
|
: QAbstractTableModel(parent) { |
|
|
@ -56,7 +57,7 @@ bool TxTableModel::exportToCsv(QString fileName) const { |
|
|
|
out << "\"" << headers[i] << "\","; |
|
|
|
} |
|
|
|
out << "\"Memo\""; |
|
|
|
out << endl; |
|
|
|
out << Qt::endl; |
|
|
|
|
|
|
|
// Write out each row
|
|
|
|
for (int row = 0; row < modeldata->length(); row++) { |
|
|
@ -65,7 +66,7 @@ bool TxTableModel::exportToCsv(QString fileName) const { |
|
|
|
} |
|
|
|
// Memo
|
|
|
|
out << "\"" << modeldata->at(row).memo << "\""; |
|
|
|
out << endl; |
|
|
|
out << Qt::endl; |
|
|
|
} |
|
|
|
|
|
|
|
file.close(); |
|
|
@ -92,6 +93,22 @@ void TxTableModel::updateAllData() { |
|
|
|
layoutChanged(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QImage TxTableModel::colorizeIcon(QIcon icon, QColor color) const{ |
|
|
|
QImage img(icon.pixmap(16, 16).toImage()); |
|
|
|
img = img.convertToFormat(QImage::Format_ARGB32); |
|
|
|
for (int x = img.width(); x--; ) |
|
|
|
{ |
|
|
|
for (int y = img.height(); y--; ) |
|
|
|
{ |
|
|
|
const QRgb rgb = img.pixel(x, y); |
|
|
|
img.setPixel(x, y, qRgba(color.red(), color.green(), color.blue(), qAlpha(rgb))); |
|
|
|
} |
|
|
|
} |
|
|
|
return img; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int TxTableModel::rowCount(const QModelIndex&) const |
|
|
|
{ |
|
|
|
if (modeldata == nullptr) return 0; |
|
|
@ -106,19 +123,31 @@ void TxTableModel::updateAllData() { |
|
|
|
|
|
|
|
QVariant TxTableModel::data(const QModelIndex &index, int role) const |
|
|
|
{ |
|
|
|
// Get current theme name
|
|
|
|
QString theme_name = Settings::getInstance()->get_theme_name(); |
|
|
|
QBrush b; |
|
|
|
QColor color; |
|
|
|
if (theme_name == "dark" || theme_name == "midnight") { |
|
|
|
color = COLOR_WHITE; |
|
|
|
}else{ |
|
|
|
color = COLOR_BLACK; |
|
|
|
} |
|
|
|
|
|
|
|
// Align column 4 (amount) right
|
|
|
|
if (role == Qt::TextAlignmentRole && index.column() == 3) return QVariant(Qt::AlignRight | Qt::AlignVCenter); |
|
|
|
|
|
|
|
if (role == Qt::ForegroundRole) { |
|
|
|
if (modeldata->at(index.row()).confirmations == 0) { |
|
|
|
QBrush b; |
|
|
|
b.setColor(Qt::red); |
|
|
|
b.setColor(COLOR_UNCONFIRMED_TX); |
|
|
|
return b; |
|
|
|
} |
|
|
|
if (theme_name == "dark" || theme_name == "midnight") { |
|
|
|
b.setColor(color); |
|
|
|
return b; |
|
|
|
}else{ |
|
|
|
b.setColor(color); |
|
|
|
return b; |
|
|
|
} |
|
|
|
|
|
|
|
// Else, just return the default brush
|
|
|
|
QBrush b; |
|
|
|
b.setColor(Qt::black); |
|
|
|
return b; |
|
|
|
} |
|
|
|
|
|
|
@ -180,19 +209,26 @@ void TxTableModel::updateAllData() { |
|
|
|
|
|
|
|
// Send
|
|
|
|
if(this->getType(index.row()) == "send"){ |
|
|
|
QIcon icon(":/icons/res/tx_output.png"); |
|
|
|
QImage image = colorizeIcon(QIcon(":/icons/res/tx_output.png"), color); |
|
|
|
QIcon icon; |
|
|
|
icon.addPixmap(QPixmap::fromImage(image)); |
|
|
|
return QVariant(icon.pixmap(16, 16)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Send T->Z - Untested
|
|
|
|
if(this->getType(index.row()) == "send" && !this->getFromAddr(index.row()).startsWith("zs1")){ |
|
|
|
QIcon icon(":/icons/res/lock_closed.png"); |
|
|
|
QImage image = colorizeIcon(QIcon(":/icons/res/lock_closed.png"), color); |
|
|
|
QIcon icon; |
|
|
|
icon.addPixmap(QPixmap::fromImage(image)); |
|
|
|
return QVariant(icon.pixmap(16, 16)); |
|
|
|
} |
|
|
|
|
|
|
|
// Receive
|
|
|
|
if(this->getType(index.row()) == "receive"){ |
|
|
|
QIcon icon(":/icons/res/tx_input.png"); |
|
|
|
QImage image = colorizeIcon(QIcon(":/icons/res/tx_input.png"), color); |
|
|
|
QIcon icon; |
|
|
|
icon.addPixmap(QPixmap::fromImage(image)); |
|
|
|
return QVariant(icon.pixmap(16, 16)); |
|
|
|
} |
|
|
|
|
|
|
|