#include <QClipboard>
#include <QDebug>
-AddressBookDialog::AddressBookDialog(QWidget *parent) :
+AddressBookDialog::AddressBookDialog(Mode mode, QWidget *parent) :
QDialog(parent),
ui(new Ui::AddressBookDialog),
model(0)
{
ui->setupUi(this);
+
+ switch(mode)
+ {
+ case ForSending:
+ connect(ui->receiveTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_buttonBox_accepted()));
+ connect(ui->sendTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_buttonBox_accepted()));
+ break;
+ case ForEditing:
+ connect(ui->receiveTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_editButton_clicked()));
+ connect(ui->sendTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_editButton_clicked()));
+ break;
+ }
}
AddressBookDialog::~AddressBookDialog()
void AddressBookDialog::on_tabWidget_currentChanged(int index)
{
+ // Enable/disable buttons based on selected tab
switch(index)
{
case SendingTab:
reject();
}
}
+
Q_OBJECT
public:
- explicit AddressBookDialog(QWidget *parent = 0);
- ~AddressBookDialog();
-
- enum {
+ enum Tabs {
SendingTab = 0,
ReceivingTab = 1
- } Tabs;
+ };
+
+ enum Mode {
+ ForSending, // Pick address for sending
+ ForEditing // Open address book for editing
+ };
+
+ explicit AddressBookDialog(Mode mode, QWidget *parent = 0);
+ ~AddressBookDialog();
void setModel(AddressTableModel *model);
void setTab(int tab);
void BitcoinGUI::addressbookClicked()
{
- AddressBookDialog dlg;
+ AddressBookDialog dlg(AddressBookDialog::ForEditing);
dlg.setModel(model->getAddressTableModel());
dlg.setTab(AddressBookDialog::SendingTab);
dlg.exec();
void BitcoinGUI::receivingAddressesClicked()
{
- AddressBookDialog dlg;
+ AddressBookDialog dlg(AddressBookDialog::ForEditing);
dlg.setModel(model->getAddressTableModel());
dlg.setTab(AddressBookDialog::ReceivingTab);
dlg.exec();
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="sendTab">
<property name="toolTip">
</layout>
</widget>
<resources/>
- <connections>
- <connection>
- <sender>receiveTableView</sender>
- <signal>doubleClicked(QModelIndex)</signal>
- <receiver>editButton</receiver>
- <slot>click()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>334</x>
- <y>249</y>
- </hint>
- <hint type="destinationlabel">
- <x>333</x>
- <y>326</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>sendTableView</sender>
- <signal>doubleClicked(QModelIndex)</signal>
- <receiver>editButton</receiver>
- <slot>click()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>329</x>
- <y>261</y>
- </hint>
- <hint type="destinationlabel">
- <x>332</x>
- <y>326</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>
void SendCoinsDialog::on_addressBookButton_clicked()
{
- AddressBookDialog dlg;
+ AddressBookDialog dlg(AddressBookDialog::ForSending);
dlg.setModel(model->getAddressTableModel());
dlg.setTab(AddressBookDialog::SendingTab);
dlg.exec();