Browse Source

Initial draft of AllAccounts plugin.

cl-refactor
Gav Wood 9 years ago
parent
commit
602cc0458d
  1. 19
      alethzero/AllAccounts.cpp
  2. 16
      alethzero/AllAccounts.h
  3. 6
      alethzero/MainFace.cpp
  4. 4
      alethzero/MainFace.h
  5. 24
      alethzero/MainWin.cpp
  6. 7
      alethzero/MainWin.h

19
alethzero/AllAccounts.cpp

@ -36,16 +36,19 @@ AllAccounts::AllAccounts(MainFace* _m):
m_ui(new Ui::AllAccounts)
{
m_ui->setupUi(dock());
installWatches();
refresh();
}
AllAccounts::~AllAccounts()
{
}
// TODO: Introduce interface for MainWin's refreshAccounts() and have it call refresh().
void AllAccounts::installWatches()
{
installWatch(ChainChangedFilter, [=](LocalisedLogEntries const&){ onAllChange(); });
installWatch(PendingChangedFilter, [=](LocalisedLogEntries const&){ onAllChange(); });
}
void AllAccounts::refresh()
{
@ -71,6 +74,11 @@ void AllAccounts::refresh()
m_refreshAccounts->setEnabled(false);
}
void AllAccounts::onAllChange()
{
ui->refreshAccounts->setEnabled(true);
}
void AllAccounts::on_accounts_currentItemChanged()
{
m_ui->accountInfo->clear();
@ -108,8 +116,3 @@ void AllAccounts::on_accounts_doubleClicked()
}
}
void AllAccounts::on_refreshAccounts_clicked()
{
refreshAccounts();
}

16
alethzero/AllAccounts.h

@ -40,14 +40,22 @@ public:
AllAccounts(MainFace* _m): Plugin(_m, "AllAccounts") {}
~AllAccounts();
void refresh();
public slots:
private slots:
void on_accounts_currentItemChanged();
void on_accounts_doubleClicked();
void on_refreshAccounts_clicked();
void on_refreshAccounts_clicked() { refresh(); }
void on_accountsFilter_textChanged() { onAllChange(); }
void on_showBasic_toggled() { onAllChange(); }
void on_showContracts_toggled() { onAllChange(); }
void on_onlyNamed_toggled() { onAllChange(); }
private:
void onAllChange();
void installWatches();
void refresh();
Ui::AllAccounts* m_ui;
QAction* m_refreshAccounts;
};

6
alethzero/MainFace.cpp

@ -58,3 +58,9 @@ void MainFace::killPlugins()
{
m_plugins.clear();
}
void MainFace::allChange()
{
for (auto const& p: m_plugins)
p.second->onAllChange();
}

4
alethzero/MainFace.h

@ -49,6 +49,8 @@ public:
void adoptPlugin(Plugin* _p) { m_plugins.insert(_p->name(), std::shared_ptr<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;
@ -75,6 +77,8 @@ public:
void addToDock(Qt::DockWidgetArea _area, QDockWidget* _dockwidget, Qt::Orientation _orientation);
void addAction(QAction* _a);
virtual void onAllChange() {}
private:
MainFace* m_main;
std::string m_name;

24
alethzero/MainWin.cpp

@ -526,7 +526,6 @@ void Main::onNewBlock()
// update blockchain dependent views.
refreshBlockCount();
refreshBlockChain();
ui->refreshAccounts->setEnabled(true);
// We must update balances since we can't filter updates to basic accounts.
refreshBalances();
@ -538,7 +537,6 @@ void Main::onNewPending()
// update any pending-transaction dependent views.
refreshPending();
ui->refreshAccounts->setEnabled(true);
}
void Main::on_forceMining_triggered()
@ -1241,8 +1239,8 @@ void Main::refreshAll()
refreshBlockChain();
refreshBlockCount();
refreshPending();
ui->refreshAccounts->setEnabled(true);
refreshBalances();
allChange();
}
void Main::refreshPending()
@ -1267,26 +1265,6 @@ void Main::refreshPending()
}
}
void Main::on_accountsFilter_textChanged()
{
ui->refreshAccounts->setEnabled(true);
}
void Main::on_showBasic_toggled()
{
ui->refreshAccounts->setEnabled(true);
}
void Main::on_showContracts_toggled()
{
ui->refreshAccounts->setEnabled(true);
}
void Main::on_onlyNamed_toggled()
{
ui->refreshAccounts->setEnabled(true);
}
void Main::refreshBlockCount()
{
auto d = ethereum()->blockChain().details();

7
alethzero/MainWin.h

@ -145,13 +145,6 @@ private slots:
void on_claimPresale_triggered();
void on_exportKey_triggered();
// Account pane
void on_accountsFilter_textChanged();
void on_showBasic_toggled();
void on_showContracts_toggled();
void on_onlyNamed_toggled();
void on_refreshAccounts_clicked();
// Tools
void on_newTransaction_triggered();
void on_loadJS_triggered();

Loading…
Cancel
Save