Browse Source

more improvements

miguelfreitas
Wladimir J. van der Laan 14 years ago
parent
commit
4d1bb15e31
  1. 52
      addressbookdialog.cpp
  2. 12
      addressbookdialog.h
  3. 33
      addressbookdialog.ui
  4. 2
      addresstablemodel.cpp
  5. 6
      bitcoin.pro
  6. 8
      bitcoinaddressvalidator.cpp
  7. 19
      bitcoinaddressvalidator.h
  8. 3
      bitcoingui.h
  9. 2
      optionsdialog.cpp
  10. 8
      optionsdialog.h
  11. 14
      sendcoinsdialog.cpp
  12. 2
      sendcoinsdialog.h
  13. 45
      sendcoinsdialog.ui

52
addressbookdialog.cpp

@ -5,6 +5,7 @@
#include "editaddressdialog.h" #include "editaddressdialog.h"
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QDebug>
AddressBookDialog::AddressBookDialog(QWidget *parent) : AddressBookDialog::AddressBookDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -62,14 +63,23 @@ void AddressBookDialog::setTab(int tab)
ui->tabWidget->setCurrentIndex(tab); ui->tabWidget->setCurrentIndex(tab);
} }
void AddressBookDialog::on_OKButton_clicked() QTableView *AddressBookDialog::getCurrentTable()
{ {
accept(); switch(ui->tabWidget->currentIndex())
{
case SendingTab:
return ui->sendTableView;
case ReceivingTab:
return ui->receiveTableView;
default:
return 0;
}
} }
void AddressBookDialog::on_copyToClipboard_clicked() void AddressBookDialog::on_copyToClipboard_clicked()
{ {
/* Copy currently selected address to clipboard */ /* Copy currently selected address to clipboard */
} }
void AddressBookDialog::on_editButton_clicked() void AddressBookDialog::on_editButton_clicked()
@ -84,3 +94,39 @@ void AddressBookDialog::on_newAddressButton_clicked()
EditAddressDialog dlg; EditAddressDialog dlg;
dlg.exec(); dlg.exec();
} }
void AddressBookDialog::on_tabWidget_currentChanged(int index)
{
switch(index)
{
case SendingTab:
ui->deleteButton->show();
break;
case ReceivingTab:
ui->deleteButton->hide();
break;
}
}
void AddressBookDialog::on_deleteButton_clicked()
{
QTableView *table = getCurrentTable();
QModelIndexList indexes = table->selectionModel()->selectedRows();
foreach (QModelIndex index, indexes) {
table->model()->removeRow(index.row());
}
}
void AddressBookDialog::on_buttonBox_accepted()
{
QTableView *table = getCurrentTable();
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
foreach (QModelIndex index, indexes) {
QVariant address = table->model()->data(index);
returnValue = address.toString();
}
accept();
}

12
addressbookdialog.h

@ -8,6 +8,10 @@ namespace Ui {
} }
class AddressTableModel; class AddressTableModel;
QT_BEGIN_NAMESPACE
class QTableView;
QT_END_NAMESPACE
class AddressBookDialog : public QDialog class AddressBookDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -23,15 +27,21 @@ public:
void setModel(AddressTableModel *model); void setModel(AddressTableModel *model);
void setTab(int tab); void setTab(int tab);
const QString &getReturnValue() const { return returnValue; }
private: private:
Ui::AddressBookDialog *ui; Ui::AddressBookDialog *ui;
AddressTableModel *model; AddressTableModel *model;
QString returnValue;
QTableView *getCurrentTable();
private slots: private slots:
void on_buttonBox_accepted();
void on_deleteButton_clicked();
void on_tabWidget_currentChanged(int index);
void on_newAddressButton_clicked(); void on_newAddressButton_clicked();
void on_editButton_clicked(); void on_editButton_clicked();
void on_copyToClipboard_clicked(); void on_copyToClipboard_clicked();
void on_OKButton_clicked();
}; };
#endif // ADDRESSBOOKDIALOG_H #endif // ADDRESSBOOKDIALOG_H

33
addressbookdialog.ui

@ -26,6 +26,9 @@
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QTableView" name="sendTableView"> <widget class="QTableView" name="sendTableView">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior"> <property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum> <enum>QAbstractItemView::SelectRows</enum>
</property> </property>
@ -56,6 +59,9 @@
</item> </item>
<item> <item>
<widget class="QTableView" name="receiveTableView"> <widget class="QTableView" name="receiveTableView">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior"> <property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum> <enum>QAbstractItemView::SelectRows</enum>
</property> </property>
@ -83,31 +89,44 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="newAddressButton">
<property name="text">
<string>&amp;New Address...</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="copyToClipboard"> <widget class="QPushButton" name="copyToClipboard">
<property name="text"> <property name="text">
<string>Copy to Clipboard</string> <string>&amp;Copy to Clipboard</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="editButton"> <widget class="QPushButton" name="editButton">
<property name="text"> <property name="text">
<string>Edit...</string> <string>&amp;Edit...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="newAddressButton"> <widget class="QPushButton" name="deleteButton">
<property name="text"> <property name="text">
<string>New Address...</string> <string>&amp;Delete</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="OKButton"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="text"> <property name="sizePolicy">
<string>OK</string> <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>

2
addresstablemodel.cpp

@ -29,7 +29,7 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
/* index.row(), index.column() */ /* index.row(), index.column() */
/* Return QString */ /* Return QString */
if(index.column() == Address) if(index.column() == Address)
return "1PC9aZC4hNX2rmmrt7uHTfYAS3hRbph4UN"; return "1PC9aZC4hNX2rmmrt7uHTfYAS3hRbph4UN" + QString::number(index.row());
else else
return "Description"; return "Description";
} else if (role == Qt::UserRole) } else if (role == Qt::UserRole)

6
bitcoin.pro

@ -16,7 +16,8 @@ HEADERS += bitcoingui.h \
sendcoinsdialog.h \ sendcoinsdialog.h \
addressbookdialog.h \ addressbookdialog.h \
aboutdialog.h \ aboutdialog.h \
editaddressdialog.h editaddressdialog.h \
bitcoinaddressvalidator.h
SOURCES += bitcoin.cpp bitcoingui.cpp \ SOURCES += bitcoin.cpp bitcoingui.cpp \
transactiontablemodel.cpp \ transactiontablemodel.cpp \
addresstablemodel.cpp \ addresstablemodel.cpp \
@ -25,7 +26,8 @@ SOURCES += bitcoin.cpp bitcoingui.cpp \
sendcoinsdialog.cpp \ sendcoinsdialog.cpp \
addressbookdialog.cpp \ addressbookdialog.cpp \
aboutdialog.cpp \ aboutdialog.cpp \
editaddressdialog.cpp editaddressdialog.cpp \
bitcoinaddressvalidator.cpp
RESOURCES += \ RESOURCES += \
bitcoin.qrc bitcoin.qrc

8
bitcoinaddressvalidator.cpp

@ -0,0 +1,8 @@
#include "bitcoinaddressvalidator.h"
const QString BitcoinAddressValidator::valid_chars = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
BitcoinAddressValidator::BitcoinAddressValidator(QObject *parent) :
QRegExpValidator(QRegExp("^["+valid_chars+"]+"), parent)
{
}

19
bitcoinaddressvalidator.h

@ -0,0 +1,19 @@
#ifndef BITCOINADDRESSVALIDATOR_H
#define BITCOINADDRESSVALIDATOR_H
#include <QRegExpValidator>
class BitcoinAddressValidator : public QRegExpValidator
{
Q_OBJECT
public:
explicit BitcoinAddressValidator(QObject *parent = 0);
static const QString valid_chars;
signals:
public slots:
};
#endif // BITCOINADDRESSVALIDATOR_H

3
bitcoingui.h

@ -6,8 +6,11 @@
/* Forward declarations */ /* Forward declarations */
class TransactionTableModel; class TransactionTableModel;
QT_BEGIN_NAMESPACE
class QLabel; class QLabel;
class QLineEdit; class QLineEdit;
QT_END_NAMESPACE
class BitcoinGUI : public QMainWindow class BitcoinGUI : public QMainWindow
{ {

2
optionsdialog.cpp

@ -4,6 +4,8 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QPushButton> #include <QPushButton>
#include <QListWidget>
#include <QStackedWidget>
OptionsDialog::OptionsDialog(QWidget *parent) : OptionsDialog::OptionsDialog(QWidget *parent) :
QDialog(parent), contents_widget(0), pages_widget(0) QDialog(parent), contents_widget(0), pages_widget(0)

8
optionsdialog.h

@ -2,8 +2,12 @@
#define OPTIONSDIALOG_H #define OPTIONSDIALOG_H
#include <QDialog> #include <QDialog>
#include <QStackedWidget>
#include <QListWidget> QT_BEGIN_NAMESPACE
class QStackedWidget;
class QListWidget;
class QListWidgetItem;
QT_END_NAMESPACE
class OptionsDialog : public QDialog class OptionsDialog : public QDialog
{ {

14
sendcoinsdialog.cpp

@ -2,6 +2,7 @@
#include "ui_sendcoinsdialog.h" #include "ui_sendcoinsdialog.h"
#include "addressbookdialog.h" #include "addressbookdialog.h"
#include "bitcoinaddressvalidator.h"
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
@ -11,6 +12,8 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
ui(new Ui::SendCoinsDialog) ui(new Ui::SendCoinsDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->payTo->setValidator(new BitcoinAddressValidator(this));
ui->payAmount->setValidator(new QDoubleValidator(this));
} }
SendCoinsDialog::~SendCoinsDialog() SendCoinsDialog::~SendCoinsDialog()
@ -23,11 +26,6 @@ void SendCoinsDialog::on_sendButton_clicked()
accept(); accept();
} }
void SendCoinsDialog::on_cancelButton_clicked()
{
reject();
}
void SendCoinsDialog::on_pasteButton_clicked() void SendCoinsDialog::on_pasteButton_clicked()
{ {
/* Paste text from clipboard into recipient field */ /* Paste text from clipboard into recipient field */
@ -38,4 +36,10 @@ void SendCoinsDialog::on_addressBookButton_clicked()
{ {
AddressBookDialog dlg; AddressBookDialog dlg;
dlg.exec(); dlg.exec();
ui->payTo->setText(dlg.getReturnValue());
}
void SendCoinsDialog::on_buttonBox_rejected()
{
reject();
} }

2
sendcoinsdialog.h

@ -19,9 +19,9 @@ private:
Ui::SendCoinsDialog *ui; Ui::SendCoinsDialog *ui;
private slots: private slots:
void on_buttonBox_rejected();
void on_addressBookButton_clicked(); void on_addressBookButton_clicked();
void on_pasteButton_clicked(); void on_pasteButton_clicked();
void on_cancelButton_clicked();
void on_sendButton_clicked(); void on_sendButton_clicked();
}; };

45
sendcoinsdialog.ui

@ -43,7 +43,11 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="payTo"/> <widget class="QLineEdit" name="payTo">
<property name="maxLength">
<number>34</number>
</property>
</widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QLineEdit" name="payAmount"> <widget class="QLineEdit" name="payAmount">
@ -116,12 +120,22 @@
<property name="text"> <property name="text">
<string>&amp;Send</string> <string>&amp;Send</string>
</property> </property>
<property name="icon">
<iconset resource="bitcoin.qrc">
<normaloff>:/icons/send</normaloff>:/icons/send</iconset>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="cancelButton"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="text"> <property name="sizePolicy">
<string>Cancel</string> <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -129,6 +143,25 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources>
<connections/> <include location="bitcoin.qrc"/>
</resources>
<connections>
<connection>
<sender>payAmount</sender>
<signal>returnPressed()</signal>
<receiver>sendButton</receiver>
<slot>click()</slot>
<hints>
<hint type="sourcelabel">
<x>191</x>
<y>65</y>
</hint>
<hint type="destinationlabel">
<x>570</x>
<y>121</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>

Loading…
Cancel
Save