Browse Source

Build fixes for plugin stuff.

cl-refactor
Gav Wood 10 years ago
parent
commit
380b3a8204
  1. 17
      alethzero/AllAccounts.cpp
  2. 2
      alethzero/AllAccounts.h
  3. 10
      alethzero/MainFace.cpp
  4. 17
      alethzero/MainFace.h
  5. 2
      alethzero/MainWin.cpp
  6. 6
      alethzero/MainWin.h

17
alethzero/AllAccounts.cpp

@ -21,6 +21,7 @@
#include "AllAccounts.h"
#include <sstream>
#include <QClipboard>
#include <libdevcore/Log.h>
#include <libdevcore/SHA3.h>
#include <libevmcore/Instruction.h>
@ -46,8 +47,8 @@ AllAccounts::~AllAccounts()
void AllAccounts::installWatches()
{
installWatch(ChainChangedFilter, [=](LocalisedLogEntries const&){ onAllChange(); });
installWatch(PendingChangedFilter, [=](LocalisedLogEntries const&){ onAllChange(); });
main()->installWatch(ChainChangedFilter, [=](LocalisedLogEntries const&){ onAllChange(); });
main()->installWatch(PendingChangedFilter, [=](LocalisedLogEntries const&){ onAllChange(); });
}
void AllAccounts::refresh()
@ -64,10 +65,10 @@ void AllAccounts::refresh()
bool isContract = (ethereum()->codeHashAt(i) != EmptySHA3);
if (!((showContract && isContract) || (showBasic && !isContract)))
continue;
string r = 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)), 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));
}
#endif
@ -76,7 +77,7 @@ void AllAccounts::refresh()
void AllAccounts::onAllChange()
{
ui->refreshAccounts->setEnabled(true);
m_ui->refreshAccounts->setEnabled(true);
}
void AllAccounts::on_accounts_currentItemChanged()
@ -102,15 +103,15 @@ void AllAccounts::on_accounts_currentItemChanged()
{
m_ui->accountInfo->appendHtml("Corrupted trie.");
}
ui->accountInfo->moveCursor(QTextCursor::Start);
m_ui->accountInfo->moveCursor(QTextCursor::Start);
}
}
void AllAccounts::on_accounts_doubleClicked()
{
if (ui->accounts->count())
if (m_ui->accounts->count())
{
auto hba = ui->accounts->currentItem()->data(Qt::UserRole).toByteArray();
auto hba = m_ui->accounts->currentItem()->data(Qt::UserRole).toByteArray();
auto h = Address((byte const*)hba.data(), Address::ConstructFromPointer);
qApp->clipboard()->setText(QString::fromStdString(toHex(h.asArray())));
}

2
alethzero/AllAccounts.h

@ -37,7 +37,7 @@ namespace az
class AllAccounts: public Plugin
{
public:
AllAccounts(MainFace* _m): Plugin(_m, "AllAccounts") {}
AllAccounts(MainFace* _m);
~AllAccounts();
private slots:

10
alethzero/MainFace.cpp

@ -20,7 +20,7 @@
*/
#include "MainFace.h"
using namespace std;
using namespace dev;
using namespace az;
@ -31,7 +31,6 @@ Plugin::Plugin(MainFace* _f, std::string const& _name):
_f->adoptPlugin(this);
}
QDockWidget* Plugin::dock(Qt::DockWidgetArea _area, QString _title)
{
if (_title.isEmpty())
@ -46,7 +45,7 @@ QDockWidget* Plugin::dock(Qt::DockWidgetArea _area, QString _title)
void Plugin::addToDock(Qt::DockWidgetArea _area, QDockWidget* _dockwidget, Qt::Orientation _orientation)
{
m_main->addDockWidget(_area, m_dock, _orientation);
m_main->addDockWidget(_area, _dockwidget, _orientation);
}
void Plugin::addAction(QAction* _a)
@ -54,6 +53,11 @@ void Plugin::addAction(QAction* _a)
m_main->addAction(_a);
}
void MainFace::adoptPlugin(Plugin* _p)
{
m_plugins[_p->name()] = shared_ptr<Plugin>(_p);
}
void MainFace::killPlugins()
{
m_plugins.clear();

17
alethzero/MainFace.h

@ -24,16 +24,18 @@
#include <memory>
#include <map>
#include <string>
#include <functional>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QAction>
#include <QtWidgets/QDockWidget>
#include <libevm/ExtVMFace.h>
#include "Context.h"
namespace dev
{
namespace web3 { class WebThreeDirect; }
namespace eth { class Client; }
class WebThreeDirect;
namespace eth { class Client; class LogFilter; }
namespace shh { class WhisperHost; }
namespace az
@ -41,22 +43,27 @@ namespace az
class Plugin;
using WatchHandler = std::function<void(dev::eth::LocalisedLogEntries const&)>;
class MainFace: public QMainWindow, public Context
{
public:
explicit MainFace(QWidget* _parent = nullptr): QMainWindow(_parent) {}
void adoptPlugin(Plugin* _p) { m_plugins.insert(_p->name(), std::shared_ptr<Plugin>(_p)); }
void adoptPlugin(Plugin* _p);
void killPlugins();
void allChange();
// TODO: tidy - all should be references that throw if module unavailable.
// TODO: provide a set of available web3 modules.
virtual dev::web3::WebThreeDirect* web3() const = 0;
virtual dev::WebThreeDirect* web3() const = 0;
virtual dev::eth::Client* ethereum() const = 0;
virtual std::shared_ptr<dev::shh::WhisperHost> whisper() const = 0;
virtual unsigned installWatch(dev::eth::LogFilter const& _tf, WatchHandler const& _f) = 0;
virtual unsigned installWatch(dev::h256 const& _tf, WatchHandler const& _f) = 0;
private:
std::unordered_map<std::string, std::shared_ptr<Plugin>> m_plugins;
};
@ -69,7 +76,7 @@ public:
std::string const& name() const { return m_name; }
dev::web3::WebThreeDirect* web3() const { return m_main->web3(); }
dev::WebThreeDirect* web3() const { return m_main->web3(); }
dev::eth::Client* ethereum() const { return m_main->ethereum(); }
std::shared_ptr<dev::shh::WhisperHost> whisper() const { return m_main->whisper(); }
MainFace* main() { return m_main; }

2
alethzero/MainWin.cpp

@ -418,7 +418,7 @@ unsigned Main::installWatch(LogFilter const& _tf, WatchHandler const& _f)
return ret;
}
unsigned Main::installWatch(dev::h256 _tf, WatchHandler const& _f)
unsigned Main::installWatch(h256 const& _tf, WatchHandler const& _f)
{
auto ret = ethereum()->installWatch(_tf, Reaping::Manual);
m_handlers[ret] = _f;

6
alethzero/MainWin.h

@ -26,7 +26,6 @@
#endif
#include <map>
#include <QtNetwork/QNetworkAccessManager>
#include <QtCore/QAbstractListModel>
#include <QtCore/QMutex>
@ -132,7 +131,6 @@ private slots:
// View
void on_refresh_triggered();
void on_showAll_triggered() { refreshBlockChain(); }
void on_showAllAccounts_triggered() { refreshAccounts(); }
void on_preview_triggered();
// Account management
@ -221,8 +219,8 @@ private:
void setPrivateChain(QString const& _private, bool _forceConfigure = false);
unsigned installWatch(dev::eth::LogFilter const& _tf, WatchHandler const& _f);
unsigned installWatch(dev::h256 _tf, WatchHandler const& _f);
unsigned installWatch(dev::eth::LogFilter const& _tf, WatchHandler const& _f) override;
unsigned installWatch(dev::h256 const& _tf, WatchHandler const& _f) override;
void uninstallWatch(unsigned _w);
void keysChanged();

Loading…
Cancel
Save