Skip to content

Commit

Permalink
Merge remote-tracking branch 'codeshark/multiwallet-qt-no-core' (pull…
Browse files Browse the repository at this point in the history
… #2220)

Conflicts:
	src/qt/bitcoingui.cpp
  • Loading branch information
laanwj committed Mar 29, 2013
2 parents 1be4bba + 67155d9 commit a6d32c9
Show file tree
Hide file tree
Showing 11 changed files with 1,099 additions and 228 deletions.
6 changes: 6 additions & 0 deletions bitcoin-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ HEADERS += src/qt/bitcoingui.h \
src/qt/transactionfilterproxy.h \
src/qt/transactionview.h \
src/qt/walletmodel.h \
src/qt/walletview.h \
src/qt/walletstack.h \
src/qt/walletframe.h \
src/bitcoinrpc.h \
src/qt/overviewpage.h \
src/qt/csvmodelwriter.h \
Expand Down Expand Up @@ -250,6 +253,9 @@ SOURCES += src/qt/bitcoin.cpp \
src/qt/transactionfilterproxy.cpp \
src/qt/transactionview.cpp \
src/qt/walletmodel.cpp \
src/qt/walletview.cpp \
src/qt/walletstack.cpp \
src/qt/walletframe.cpp \
src/bitcoinrpc.cpp \
src/rpcdump.cpp \
src/rpcnet.cpp \
Expand Down
53 changes: 53 additions & 0 deletions multiwallet-qt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Multiwallet Qt Development and Integration Strategy
===================================================

In order to support loading of multiple wallets in bitcoin-qt, a few changes in the UI architecture will be needed.
Fortunately, only four of the files in the existing project are affected by this change.

Three new classes have been implemented in three new .h/.cpp file pairs, with much of the functionality that was previously
implemented in the BitcoinGUI class moved over to these new classes.

The two existing files most affected, by far, are bitcoingui.h and bitcoingui.cpp, as the BitcoinGUI class will require
some major retrofitting.

Only requiring some minor changes is bitcoin.cpp.

Finally, three new headers and source files will have to be added to bitcoin-qt.pro.

Changes to class BitcoinGUI
---------------------------
The principal change to the BitcoinGUI class concerns the QStackedWidget instance called centralWidget.
This widget owns five page views: overviewPage, transactionsPage, addressBookPage, receiveCoinsPage, and sendCoinsPage.

A new class called *WalletView* inheriting from QStackedWidget has been written to handle all renderings and updates of
these page views. In addition to owning these five page views, a WalletView also has a pointer to a WalletModel instance.
This allows the construction of multiple WalletView objects, each rendering a distinct wallet.

A second class called *WalletStack*, also inheriting from QStackedWidget, has been written to handle switching focus between
different loaded wallets. In its current implementation, as a QStackedWidget, only one wallet can be viewed at a time -
but this can be changed later.

A third class called *WalletFrame* inheriting from QFrame has been written as a container for embedding all wallet-related
controls into BitcoinGUI. At present it just contains a WalletStack instance and does little more than passing on messages
from BitcoinGUI to the WalletStack, which in turn passes them to the individual WalletViews. It is a WalletFrame instance
that takes the place of what used to be centralWidget in BitcoinGUI. The purpose of this class is to allow future
refinements of the wallet controls with minimal need for further modifications to BitcoinGUI, thus greatly simplifying
merges while reducing the risk of breaking top-level stuff.

Changes to bitcoin.cpp
----------------------
bitcoin.cpp is the entry point into bitcoin-qt, and as such, will require some minor modifications to provide hooks for
multiple wallet support. Most importantly will be the way it instantiates WalletModels and passes them to the
singleton BitcoinGUI instance called window. Formerly, BitcoinGUI kept a pointer to a single instance of a WalletModel.
The initial change required is very simple: rather than calling window.setWalletModel(&walletModel); we perform the
following two steps:

window.addWallet("~Default", &walletModel);
window.setCurrentWallet("~Default");

The string parameter is just an arbitrary name given to the default wallet. It's been prepended with a tilde to avoid name
collisions in the future with additional wallets.

The shutdown call window.setWalletModel(0) has also been removed. In its place is now:

window.removeAllWallets();
5 changes: 3 additions & 2 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ int main(int argc, char *argv[])
WalletModel walletModel(pwalletMain, &optionsModel);

window.setClientModel(&clientModel);
window.setWalletModel(&walletModel);
window.addWallet("~Default", &walletModel);
window.setCurrentWallet("~Default");

// If -min option passed, start window minimized.
if(GetBoolArg("-min"))
Expand All @@ -253,7 +254,7 @@ int main(int argc, char *argv[])

window.hide();
window.setClientModel(0);
window.setWalletModel(0);
window.removeAllWallets();
guiref = 0;
}
// Shutdown the core and its threads, but don't exit Bitcoin-Qt here
Expand Down
Loading

0 comments on commit a6d32c9

Please sign in to comment.