Address book: select action (edit/select) based on context

This commit is contained in:
Wladimir J. van der Laan 2011-06-13 12:07:32 +02:00
parent 249300aebe
commit e83474f2eb
5 changed files with 30 additions and 44 deletions

View File

@ -8,12 +8,24 @@
#include <QClipboard> #include <QClipboard>
#include <QDebug> #include <QDebug>
AddressBookDialog::AddressBookDialog(QWidget *parent) : AddressBookDialog::AddressBookDialog(Mode mode, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::AddressBookDialog), ui(new Ui::AddressBookDialog),
model(0) model(0)
{ {
ui->setupUi(this); 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() AddressBookDialog::~AddressBookDialog()
@ -126,6 +138,7 @@ void AddressBookDialog::on_newAddressButton_clicked()
void AddressBookDialog::on_tabWidget_currentChanged(int index) void AddressBookDialog::on_tabWidget_currentChanged(int index)
{ {
// Enable/disable buttons based on selected tab
switch(index) switch(index)
{ {
case SendingTab: case SendingTab:
@ -166,3 +179,4 @@ void AddressBookDialog::on_buttonBox_accepted()
reject(); reject();
} }
} }

View File

@ -17,13 +17,18 @@ class AddressBookDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit AddressBookDialog(QWidget *parent = 0); enum Tabs {
~AddressBookDialog();
enum {
SendingTab = 0, SendingTab = 0,
ReceivingTab = 1 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 setModel(AddressTableModel *model);
void setTab(int tab); void setTab(int tab);

View File

@ -285,7 +285,7 @@ void BitcoinGUI::sendcoinsClicked()
void BitcoinGUI::addressbookClicked() void BitcoinGUI::addressbookClicked()
{ {
AddressBookDialog dlg; AddressBookDialog dlg(AddressBookDialog::ForEditing);
dlg.setModel(model->getAddressTableModel()); dlg.setModel(model->getAddressTableModel());
dlg.setTab(AddressBookDialog::SendingTab); dlg.setTab(AddressBookDialog::SendingTab);
dlg.exec(); dlg.exec();
@ -293,7 +293,7 @@ void BitcoinGUI::addressbookClicked()
void BitcoinGUI::receivingAddressesClicked() void BitcoinGUI::receivingAddressesClicked()
{ {
AddressBookDialog dlg; AddressBookDialog dlg(AddressBookDialog::ForEditing);
dlg.setModel(model->getAddressTableModel()); dlg.setModel(model->getAddressTableModel());
dlg.setTab(AddressBookDialog::ReceivingTab); dlg.setTab(AddressBookDialog::ReceivingTab);
dlg.exec(); dlg.exec();

View File

@ -17,7 +17,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="sendTab"> <widget class="QWidget" name="sendTab">
<property name="toolTip"> <property name="toolTip">
@ -159,38 +159,5 @@
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
<connections> <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>
</ui> </ui>

View File

@ -100,7 +100,7 @@ void SendCoinsDialog::on_pasteButton_clicked()
void SendCoinsDialog::on_addressBookButton_clicked() void SendCoinsDialog::on_addressBookButton_clicked()
{ {
AddressBookDialog dlg; AddressBookDialog dlg(AddressBookDialog::ForSending);
dlg.setModel(model->getAddressTableModel()); dlg.setModel(model->getAddressTableModel());
dlg.setTab(AddressBookDialog::SendingTab); dlg.setTab(AddressBookDialog::SendingTab);
dlg.exec(); dlg.exec();