{
}
+inline void AddressBookRepaint()
+{
+}
+
inline void InitMessage(const std::string &message)
{
}
this->model = model;
if(!model)
return;
- // Refresh list from core
- model->updateList();
proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(model);
}
}
-void AddressTableModel::updateList()
+void AddressTableModel::update()
{
// Update address book model from Bitcoin core
beginResetModel();
{
return QString();
}
- // Add entry and update list
+ // Add entry
CRITICAL_BLOCK(wallet->cs_wallet)
wallet->SetAddressBookName(strAddress, strLabel);
- updateList();
return QString::fromStdString(strAddress);
}
{
wallet->DelAddressBookName(rec->address.toStdString());
}
- updateList();
return true;
}
-void AddressTableModel::update()
-{
-
-}
-
/* Look up label for address in address book, if not found return empty string.
*/
QString AddressTableModel::labelForAddress(const QString &address) const
*/
QString addRow(const QString &type, const QString &label, const QString &address);
- /* Update address list from core. Invalidates any indices.
- */
- void updateList();
-
/* Look up label for address in address book, if not found return empty string.
*/
QString labelForAddress(const QString &address) const;
void defaultAddressChanged(const QString &address);
public slots:
+ /* Update address list from core. Invalidates any indices.
+ */
void update();
};
#endif
// Need a global reference for the notifications to find the GUI
-BitcoinGUI *guiref;
-QSplashScreen *splashref;
+static BitcoinGUI *guiref;
+static QSplashScreen *splashref;
+static WalletModel *walletmodel;
+static ClientModel *clientmodel;
int MyMessageBox(const std::string& message, const std::string& caption, int style, wxWindow* parent, int x, int y)
{
void MainFrameRepaint()
{
- if(guiref)
- QMetaObject::invokeMethod(guiref, "refreshStatusBar", Qt::QueuedConnection);
+ if(clientmodel)
+ QMetaObject::invokeMethod(clientmodel, "update", Qt::QueuedConnection);
+ if(walletmodel)
+ QMetaObject::invokeMethod(walletmodel, "update", Qt::QueuedConnection);
+}
+
+void AddressBookRepaint()
+{
+ if(walletmodel)
+ QMetaObject::invokeMethod(walletmodel, "updateAddressList", Qt::QueuedConnection);
}
void InitMessage(const std::string &message)
splash.finish(&window);
ClientModel clientModel(&optionsModel);
+ clientmodel = &clientModel;
WalletModel walletModel(pwalletMain, &optionsModel);
+ walletmodel = &walletModel;
guiref = &window;
window.setClientModel(&clientModel);
app.exec();
guiref = 0;
+ clientmodel = 0;
+ walletmodel = 0;
}
Shutdown(NULL);
}
progressBar->setToolTip(tooltip);
}
-void BitcoinGUI::refreshStatusBar()
-{
- /* Might display multiple times in the case of multiple alerts
- static QString prevStatusBar;
- QString newStatusBar = clientModel->getStatusBarWarnings();
- if (prevStatusBar != newStatusBar)
- {
- prevStatusBar = newStatusBar;
- error(tr("Network Alert"), newStatusBar);
- }*/
- setNumBlocks(clientModel->getNumBlocks());
-}
-
void BitcoinGUI::error(const QString &title, const QString &message)
{
// Report errors from network/worker thread
@see WalletModel::EncryptionStatus
*/
void setEncryptionStatus(int status);
- /** Set the status bar text if there are any warnings (removes sync progress bar if applicable) */
- void refreshStatusBar();
/** Notify the user of an error in the network or transaction handling code. */
void error(const QString &title, const QString &message);
#include "headers.h"
-#include <QTimer>
#include <QDateTime>
ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
QObject(parent), optionsModel(optionsModel),
cachedNumConnections(0), cachedNumBlocks(0)
{
- // Until signal notifications is built into the bitcoin core,
- // simply update everything after polling using a timer.
- QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(update()));
- timer->start(MODEL_UPDATE_DELAY);
-
numBlocksAtStartup = -1;
}
{
int newNumConnections = getNumConnections();
int newNumBlocks = getNumBlocks();
+ QString newStatusBar = getStatusBarWarnings();
if(cachedNumConnections != newNumConnections)
emit numConnectionsChanged(newNumConnections);
- if(cachedNumBlocks != newNumBlocks)
+ if(cachedNumBlocks != newNumBlocks || cachedStatusBar != newStatusBar)
+ {
+ // Simply emit a numBlocksChanged for now in case the status message changes,
+ // so that the view updates the status bar.
+ // TODO: It should send a notification.
+ // (However, this might generate looped notifications and needs to be thought through and tested carefully)
+ // error(tr("Network Alert"), newStatusBar);
emit numBlocksChanged(newNumBlocks);
+ }
cachedNumConnections = newNumConnections;
cachedNumBlocks = newNumBlocks;
+ cachedStatusBar = newStatusBar;
}
bool ClientModel::isTestNet() const
int cachedNumConnections;
int cachedNumBlocks;
+ QString cachedStatusBar;
int numBlocksAtStartup;
#include "headers.h"
#include "db.h" // for BackupWallet
-#include <QTimer>
#include <QSet>
WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) :
cachedBalance(0), cachedUnconfirmedBalance(0), cachedNumTransactions(0),
cachedEncryptionStatus(Unencrypted)
{
- // Until signal notifications is built into the bitcoin core,
- // simply update everything after polling using a timer.
- QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(update()));
- timer->start(MODEL_UPDATE_DELAY);
-
addressTableModel = new AddressTableModel(wallet, this);
transactionTableModel = new TransactionTableModel(wallet, this);
}
addressTableModel->update();
}
+void WalletModel::updateAddressList()
+{
+ addressTableModel->update();
+}
+
bool WalletModel::validateAddress(const QString &address)
{
CBitcoinAddress addressParsed(address.toStdString());
}
}
- // Update our model of the address table
- addressTableModel->updateList();
-
return SendCoinsReturn(OK, 0, hex);
}
void error(const QString &title, const QString &message);
public slots:
-
-private slots:
void update();
+ void updateAddressList();
};
extern void CalledSetStatusBar(const std::string& strText, int nField);
extern void UIThreadCall(boost::function0<void> fn);
extern void MainFrameRepaint();
+extern void AddressBookRepaint();
extern void InitMessage(const std::string &message);
extern std::string _(const char* psz);
bool CWallet::SetAddressBookName(const CBitcoinAddress& address, const string& strName)
{
mapAddressBook[address] = strName;
+ AddressBookRepaint();
if (!fFileBacked)
return false;
return CWalletDB(strWalletFile).WriteName(address.ToString(), strName);
bool CWallet::DelAddressBookName(const CBitcoinAddress& address)
{
mapAddressBook.erase(address);
+ AddressBookRepaint();
if (!fFileBacked)
return false;
return CWalletDB(strWalletFile).EraseName(address.ToString());