Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
walletstack.cpp
Go to the documentation of this file.
1 /*
2  * Qt4 bitcoin GUI.
3  *
4  * W.J. van der Laan 2011-2012
5  * The Bitcoin Developers 2011-2013
6  */
7 #include "walletstack.h"
8 #include "walletview.h"
9 #include "bitcoingui.h"
10 
11 #include <QMap>
12 #include <QMessageBox>
13 
14 WalletStack::WalletStack(QWidget *parent) :
15  QStackedWidget(parent),
16  gui(0),
17  clientModel(0),
18  bOutOfSync(true)
19 {
20  setContentsMargins(0,0,0,0);
21 }
22 
24 {
25 }
26 
27 bool WalletStack::addWallet(const QString& name, WalletModel *walletModel)
28 {
29  if (!gui || !clientModel || mapWalletViews.count(name) > 0)
30  return false;
31 
32  WalletView *walletView = new WalletView(this, gui);
33  walletView->setBitcoinGUI(gui);
34  walletView->setClientModel(clientModel);
35  walletView->setWalletModel(walletModel);
36  walletView->showOutOfSyncWarning(bOutOfSync);
37  addWidget(walletView);
38  mapWalletViews[name] = walletView;
39 
40  // Ensure a walletView is able to show the main window
41  connect(walletView, SIGNAL(showNormalIfMinimized()), gui, SLOT(showNormalIfMinimized()));
42 
43  return true;
44 }
45 
46 bool WalletStack::removeWallet(const QString& name)
47 {
48  if (mapWalletViews.count(name) == 0) return false;
49  WalletView *walletView = mapWalletViews.take(name);
50  removeWidget(walletView);
51  return true;
52 }
53 
55 {
56  QMap<QString, WalletView*>::const_iterator i;
57  for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
58  removeWidget(i.value());
59  mapWalletViews.clear();
60 }
61 
62 bool WalletStack::handleURI(const QString &uri)
63 {
64  WalletView *walletView = (WalletView*)currentWidget();
65  if (!walletView) return false;
66 
67  return walletView->handleURI(uri);
68 }
69 
71 {
72  bOutOfSync = fShow;
73  QMap<QString, WalletView*>::const_iterator i;
74  for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
75  i.value()->showOutOfSyncWarning(fShow);
76 }
77 
79 {
80  QMap<QString, WalletView*>::const_iterator i;
81  for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
82  i.value()->gotoOverviewPage();
83 }
84 
86 {
87  QMap<QString, WalletView*>::const_iterator i;
88  for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
89  i.value()->gotoHistoryPage();
90 }
91 
93 {
94  QMap<QString, WalletView*>::const_iterator i;
95  for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
96  i.value()->gotoAddressBookPage();
97 }
98 
100 {
101  QMap<QString, WalletView*>::const_iterator i;
102  for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
103  i.value()->gotoReceiveCoinsPage();
104 }
105 
107 {
108  QMap<QString, WalletView*>::const_iterator i;
109  for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
110  i.value()->gotoSendCoinsPage(addr);
111 }
112 
114 {
115  WalletView *walletView = (WalletView*)currentWidget();
116  if (walletView) walletView->gotoSignMessageTab(addr);
117 }
118 
120 {
121  WalletView *walletView = (WalletView*)currentWidget();
122  if (walletView) walletView->gotoVerifyMessageTab(addr);
123 }
124 
125 void WalletStack::encryptWallet(bool status)
126 {
127  WalletView *walletView = (WalletView*)currentWidget();
128  if (walletView) walletView->encryptWallet(status);
129 }
130 
132 {
133  WalletView *walletView = (WalletView*)currentWidget();
134  if (walletView) walletView->backupWallet();
135 }
136 
138 {
139  WalletView *walletView = (WalletView*)currentWidget();
140  if (walletView) walletView->changePassphrase();
141 }
142 
144 {
145  WalletView *walletView = (WalletView*)currentWidget();
146  if (walletView) walletView->unlockWallet();
147 }
148 
150 {
151  WalletView *walletView = (WalletView*)currentWidget();
152  if (walletView) walletView->setEncryptionStatus();
153 }
154 
156 {
157  if (mapWalletViews.count(name) == 0) return;
158  WalletView *walletView = mapWalletViews.value(name);
159  setCurrentWidget(walletView);
160  walletView->setEncryptionStatus();
161 }
bool handleURI(const QString &uri)
Definition: walletstack.cpp:62
void changePassphrase()
Change encrypted wallet passphrase.
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
Definition: walletview.cpp:198
bool bOutOfSync
Definition: walletstack.h:66
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
void removeAllWallets()
Definition: walletstack.cpp:54
void changePassphrase()
Change encrypted wallet passphrase.
Definition: walletview.cpp:265
void backupWallet()
Backup the wallet.
void gotoOverviewPage()
Switch to overview (home) page.
Definition: walletstack.cpp:78
void unlockWallet()
Ask for passphrase to unlock wallet temporarily.
void gotoReceiveCoinsPage()
Switch to receive coins page.
Definition: walletstack.cpp:99
BitcoinGUI * gui
Definition: walletstack.h:62
bool addWallet(const QString &name, WalletModel *walletModel)
Definition: walletstack.cpp:27
void setBitcoinGUI(BitcoinGUI *gui)
Definition: walletview.cpp:96
void setWalletModel(WalletModel *walletModel)
Set the wallet model.
Definition: walletview.cpp:112
void showOutOfSyncWarning(bool fShow)
Definition: walletstack.cpp:70
void gotoAddressBookPage()
Switch to address book page.
Definition: walletstack.cpp:92
void gotoHistoryPage()
Switch to history (transactions) page.
Definition: walletstack.cpp:85
bool removeWallet(const QString &name)
Definition: walletstack.cpp:46
void unlockWallet()
Ask for passphrase to unlock wallet temporarily.
Definition: walletview.cpp:272
ClientModel * clientModel
Definition: walletstack.h:63
void backupWallet()
Backup the wallet.
Definition: walletview.cpp:246
void encryptWallet(bool status)
Encrypt the wallet.
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
Definition: walletview.cpp:189
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:36
void setCurrentWallet(const QString &name)
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
void setEncryptionStatus()
Set the encryption status as shown in the UI.
void setClientModel(ClientModel *clientModel)
Set the client model.
Definition: walletview.cpp:101
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
void encryptWallet(bool status)
Encrypt the wallet.
Definition: walletview.cpp:235
bool handleURI(const QString &uri)
Definition: walletview.cpp:212
void showOutOfSyncWarning(bool fShow)
Definition: walletview.cpp:225
QMap< QString, WalletView * > mapWalletViews
Definition: walletstack.h:64
const char * name
Definition: testharness.cc:18
WalletStack(QWidget *parent=0)
Definition: walletstack.cpp:14
void setEncryptionStatus()
Definition: walletview.cpp:230