Browse Source

All Accounts panel works with address book.

cl-refactor
Gav Wood 10 years ago
parent
commit
0fc3d1b21f
  1. 20
      alethzero/plugins/blockchain/AllAccounts.cpp
  2. 2
      alethzero/plugins/blockchain/AllAccounts.h
  3. 11
      alethzero/plugins/blockchain/AllAccounts.ui

20
alethzero/plugins/blockchain/AllAccounts.cpp

@ -14,12 +14,12 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file AllAccounts.h /** @file AllAccounts.cpp
* @author Gav Wood <i@gavwood.com> * @author Gav Wood <i@gavwood.com>
* @date 2015 * @date 2015
*/ */
#if ETH_FATDB #if ETH_FATDB || !ETH_TRUE
#include "AllAccounts.h" #include "AllAccounts.h"
#include <sstream> #include <sstream>
@ -51,7 +51,7 @@ AllAccounts::AllAccounts(MainFace* _m):
connect(m_ui->accountsFilter, SIGNAL(textChanged(QString)), SLOT(onAllChange())); connect(m_ui->accountsFilter, SIGNAL(textChanged(QString)), SLOT(onAllChange()));
connect(m_ui->showBasic, SIGNAL(toggled(bool)), SLOT(onAllChange())); connect(m_ui->showBasic, SIGNAL(toggled(bool)), SLOT(onAllChange()));
connect(m_ui->showContracts, SIGNAL(toggled(bool)), SLOT(onAllChange())); connect(m_ui->showContracts, SIGNAL(toggled(bool)), SLOT(onAllChange()));
connect(m_ui->onlyNamed, SIGNAL(toggled(bool)), SLOT(onAllChange())); connect(m_ui->onlyKnown, SIGNAL(toggled(bool)), SLOT(onAllChange()));
} }
AllAccounts::~AllAccounts() AllAccounts::~AllAccounts()
@ -72,20 +72,24 @@ void AllAccounts::refresh()
m_ui->accounts->clear(); m_ui->accounts->clear();
bool showContract = m_ui->showContracts->isChecked(); bool showContract = m_ui->showContracts->isChecked();
bool showBasic = m_ui->showBasic->isChecked(); bool showBasic = m_ui->showBasic->isChecked();
bool onlyNamed = m_ui->onlyNamed->isChecked(); bool onlyKnown = m_ui->onlyKnown->isChecked();
auto as = ethereum()->addresses();
sort(as.begin(), as.end()); Addresses as;
if (onlyKnown)
as = main()->allKnownAddresses();
else
as = ethereum()->addresses();
for (auto const& i: as) for (auto const& i: as)
{ {
bool isContract = (ethereum()->codeHashAt(i) != EmptySHA3); bool isContract = (ethereum()->codeHashAt(i) != EmptySHA3);
if (!((showContract && isContract) || (showBasic && !isContract))) if (!((showContract && isContract) || (showBasic && !isContract)))
continue; continue;
string r = static_cast<Context*>(main())->render(i); string r = static_cast<Context*>(main())->render(i);
if (onlyNamed && !(r.find('"') != string::npos || r.substr(0, 2) == "XE"))
continue;
(new QListWidgetItem(QString("%2: %1 [%3]").arg(formatBalance(ethereum()->balanceAt(i)).c_str()).arg(QString::fromStdString(r)).arg((unsigned)ethereum()->countAt(i)), m_ui->accounts)) (new QListWidgetItem(QString("%2: %1 [%3]").arg(formatBalance(ethereum()->balanceAt(i)).c_str()).arg(QString::fromStdString(r)).arg((unsigned)ethereum()->countAt(i)), m_ui->accounts))
->setData(Qt::UserRole, QByteArray((char const*)i.data(), Address::size)); ->setData(Qt::UserRole, QByteArray((char const*)i.data(), Address::size));
} }
m_ui->accounts->sortItems();
#endif #endif
m_ui->refreshAccounts->setEnabled(false); m_ui->refreshAccounts->setEnabled(false);
} }

2
alethzero/plugins/blockchain/AllAccounts.h

@ -21,7 +21,7 @@
#pragma once #pragma once
#if ETH_FATDB #if ETH_FATDB || !ETH_TRUE
#include <QListWidget> #include <QListWidget>
#include <QPlainTextEdit> #include <QPlainTextEdit>

11
alethzero/plugins/blockchain/AllAccounts.ui

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>405</width>
<height>300</height> <height>300</height>
</rect> </rect>
</property> </property>
@ -46,6 +46,9 @@
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -62,15 +65,15 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="onlyNamed"> <widget class="QToolButton" name="onlyKnown">
<property name="text"> <property name="text">
<string>Only Named</string> <string>Only Known</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked"> <property name="checked">
<bool>false</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>

Loading…
Cancel
Save