forked from hush/SilentDragon
Browse Source
Includes chinese translation, validation of addresses and various bugfixes Conflicts: silentdragon.pro src/mainwindow.cppimportviewkey
Jonathan "Duke" Leto
5 years ago
21 changed files with 528 additions and 57 deletions
Binary file not shown.
@ -0,0 +1,37 @@ |
|||
#include "validateaddress.h" |
|||
|
|||
|
|||
ValidateAddressesModel::ValidateAddressesModel(QTableView *parent, QList<QPair<QString, QString>> props) |
|||
: QAbstractTableModel(parent) { |
|||
headers << tr("Property") << tr("Value"); |
|||
this->props = props; |
|||
} |
|||
|
|||
|
|||
int ValidateAddressesModel::rowCount(const QModelIndex&) const { |
|||
return props.size(); |
|||
} |
|||
|
|||
int ValidateAddressesModel::columnCount(const QModelIndex&) const { |
|||
return headers.size(); |
|||
} |
|||
|
|||
QVariant ValidateAddressesModel::data(const QModelIndex &index, int role) const { |
|||
QPair<QString, QString> p = props.at(index.row()); |
|||
if (role == Qt::DisplayRole) { |
|||
switch(index.column()) { |
|||
case 0: return p.first; |
|||
case 1: return p.second; |
|||
} |
|||
} |
|||
return QVariant(); |
|||
} |
|||
|
|||
|
|||
QVariant ValidateAddressesModel::headerData(int section, Qt::Orientation orientation, int role) const { |
|||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { |
|||
return headers.at(section); |
|||
} |
|||
|
|||
return QVariant(); |
|||
} |
@ -0,0 +1,23 @@ |
|||
#ifndef VALIDATEADDRESS_H |
|||
#define VALIDATEADDRESS_H |
|||
|
|||
#include "precompiled.h" |
|||
|
|||
class ValidateAddressesModel : public QAbstractTableModel { |
|||
|
|||
public: |
|||
ValidateAddressesModel(QTableView* parent, QList<QPair<QString, QString>> props); |
|||
~ValidateAddressesModel() = default; |
|||
|
|||
int rowCount(const QModelIndex &parent) const; |
|||
int columnCount(const QModelIndex &parent) const; |
|||
QVariant data(const QModelIndex &index, int role) const; |
|||
QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
|||
|
|||
private: |
|||
QList<QPair<QString, QString>> props; |
|||
QStringList headers; |
|||
}; |
|||
|
|||
|
|||
#endif // VALIDATEADDRESS_H
|
@ -0,0 +1,85 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ui version="4.0"> |
|||
<class>ValidateAddress</class> |
|||
<widget class="QDialog" name="ValidateAddress"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>400</width> |
|||
<height>300</height> |
|||
</rect> |
|||
</property> |
|||
<property name="windowTitle"> |
|||
<string>Validate Address</string> |
|||
</property> |
|||
<layout class="QGridLayout" name="gridLayout"> |
|||
<item row="0" column="1"> |
|||
<widget class="QLabel" name="lblAddress"> |
|||
<property name="text"> |
|||
<string>TextLabel</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="0" column="0"> |
|||
<widget class="QLabel" name="label"> |
|||
<property name="text"> |
|||
<string>Address:</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="1" column="0" colspan="2"> |
|||
<widget class="QTableView" name="tblProps"> |
|||
<attribute name="horizontalHeaderStretchLastSection"> |
|||
<bool>true</bool> |
|||
</attribute> |
|||
</widget> |
|||
</item> |
|||
<item row="2" column="0" colspan="2"> |
|||
<widget class="QDialogButtonBox" name="buttonBox"> |
|||
<property name="orientation"> |
|||
<enum>Qt::Horizontal</enum> |
|||
</property> |
|||
<property name="standardButtons"> |
|||
<set>QDialogButtonBox::Close</set> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
<resources/> |
|||
<connections> |
|||
<connection> |
|||
<sender>buttonBox</sender> |
|||
<signal>accepted()</signal> |
|||
<receiver>ValidateAddress</receiver> |
|||
<slot>accept()</slot> |
|||
<hints> |
|||
<hint type="sourcelabel"> |
|||
<x>248</x> |
|||
<y>254</y> |
|||
</hint> |
|||
<hint type="destinationlabel"> |
|||
<x>157</x> |
|||
<y>274</y> |
|||
</hint> |
|||
</hints> |
|||
</connection> |
|||
<connection> |
|||
<sender>buttonBox</sender> |
|||
<signal>rejected()</signal> |
|||
<receiver>ValidateAddress</receiver> |
|||
<slot>reject()</slot> |
|||
<hints> |
|||
<hint type="sourcelabel"> |
|||
<x>316</x> |
|||
<y>260</y> |
|||
</hint> |
|||
<hint type="destinationlabel"> |
|||
<x>286</x> |
|||
<y>274</y> |
|||
</hint> |
|||
</hints> |
|||
</connection> |
|||
</connections> |
|||
</ui> |
@ -0,0 +1,38 @@ |
|||
#include "viewalladdresses.h" |
|||
#include "settings.h" |
|||
|
|||
ViewAllAddressesModel::ViewAllAddressesModel(QTableView *parent, QList<QString> taddrs, RPC* rpc) |
|||
: QAbstractTableModel(parent) { |
|||
headers << tr("Address") << tr("Balance (%1)").arg(Settings::getTokenName()); |
|||
addresses = taddrs; |
|||
this->rpc = rpc; |
|||
} |
|||
|
|||
|
|||
int ViewAllAddressesModel::rowCount(const QModelIndex&) const { |
|||
return addresses.size(); |
|||
} |
|||
|
|||
int ViewAllAddressesModel::columnCount(const QModelIndex&) const { |
|||
return headers.size(); |
|||
} |
|||
|
|||
QVariant ViewAllAddressesModel::data(const QModelIndex &index, int role) const { |
|||
QString address = addresses.at(index.row()); |
|||
if (role == Qt::DisplayRole) { |
|||
switch(index.column()) { |
|||
case 0: return address; |
|||
case 1: return rpc->getAllBalances()->value(address, 0.0); |
|||
} |
|||
} |
|||
return QVariant(); |
|||
} |
|||
|
|||
|
|||
QVariant ViewAllAddressesModel::headerData(int section, Qt::Orientation orientation, int role) const { |
|||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { |
|||
return headers.at(section); |
|||
} |
|||
|
|||
return QVariant(); |
|||
} |
@ -0,0 +1,24 @@ |
|||
#ifndef VIEWALLADDRESSES_H |
|||
#define VIEWALLADDRESSES_H |
|||
|
|||
#include "precompiled.h" |
|||
#include "rpc.h" |
|||
|
|||
class ViewAllAddressesModel : public QAbstractTableModel { |
|||
|
|||
public: |
|||
ViewAllAddressesModel(QTableView* parent, QList<QString> taddrs, RPC* rpc); |
|||
~ViewAllAddressesModel() = default; |
|||
|
|||
int rowCount(const QModelIndex &parent) const; |
|||
int columnCount(const QModelIndex &parent) const; |
|||
QVariant data(const QModelIndex &index, int role) const; |
|||
QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
|||
|
|||
private: |
|||
QList<QString> addresses; |
|||
QStringList headers; |
|||
RPC* rpc; |
|||
}; |
|||
|
|||
#endif |
@ -0,0 +1,81 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ui version="4.0"> |
|||
<class>ViewAddressesDialog</class> |
|||
<widget class="QDialog" name="ViewAddressesDialog"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>400</width> |
|||
<height>300</height> |
|||
</rect> |
|||
</property> |
|||
<property name="windowTitle"> |
|||
<string>All Addresses</string> |
|||
</property> |
|||
<layout class="QGridLayout" name="gridLayout"> |
|||
<item row="1" column="1"> |
|||
<widget class="QDialogButtonBox" name="buttonBox"> |
|||
<property name="orientation"> |
|||
<enum>Qt::Horizontal</enum> |
|||
</property> |
|||
<property name="standardButtons"> |
|||
<set>QDialogButtonBox::Ok</set> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="1" column="0"> |
|||
<widget class="QPushButton" name="btnExportAll"> |
|||
<property name="text"> |
|||
<string>Export All Keys</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="0" column="0" colspan="2"> |
|||
<widget class="QTableView" name="tblAddresses"> |
|||
<property name="selectionMode"> |
|||
<enum>QAbstractItemView::SingleSelection</enum> |
|||
</property> |
|||
<attribute name="horizontalHeaderStretchLastSection"> |
|||
<bool>true</bool> |
|||
</attribute> |
|||
</widget> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
<resources/> |
|||
<connections> |
|||
<connection> |
|||
<sender>buttonBox</sender> |
|||
<signal>accepted()</signal> |
|||
<receiver>ViewAddressesDialog</receiver> |
|||
<slot>accept()</slot> |
|||
<hints> |
|||
<hint type="sourcelabel"> |
|||
<x>248</x> |
|||
<y>254</y> |
|||
</hint> |
|||
<hint type="destinationlabel"> |
|||
<x>157</x> |
|||
<y>274</y> |
|||
</hint> |
|||
</hints> |
|||
</connection> |
|||
<connection> |
|||
<sender>buttonBox</sender> |
|||
<signal>rejected()</signal> |
|||
<receiver>ViewAddressesDialog</receiver> |
|||
<slot>reject()</slot> |
|||
<hints> |
|||
<hint type="sourcelabel"> |
|||
<x>316</x> |
|||
<y>260</y> |
|||
</hint> |
|||
<hint type="destinationlabel"> |
|||
<x>286</x> |
|||
<y>274</y> |
|||
</hint> |
|||
</hints> |
|||
</connection> |
|||
</connections> |
|||
</ui> |
Loading…
Reference in new issue