#include "editaddressdialog.h"
#include <QSortFilterProxyModel>
+#include <QDebug>
AddressBookDialog::AddressBookDialog(QWidget *parent) :
QDialog(parent),
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()
{
- /* Copy currently selected address to clipboard */
+ /* Copy currently selected address to clipboard */
+
}
void AddressBookDialog::on_editButton_clicked()
EditAddressDialog dlg;
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();
+}
}
class AddressTableModel;
+QT_BEGIN_NAMESPACE
+class QTableView;
+QT_END_NAMESPACE
+
class AddressBookDialog : public QDialog
{
Q_OBJECT
void setModel(AddressTableModel *model);
void setTab(int tab);
+ const QString &getReturnValue() const { return returnValue; }
private:
Ui::AddressBookDialog *ui;
AddressTableModel *model;
+ QString returnValue;
+
+ QTableView *getCurrentTable();
private slots:
+ void on_buttonBox_accepted();
+ void on_deleteButton_clicked();
+ void on_tabWidget_currentChanged(int index);
void on_newAddressButton_clicked();
void on_editButton_clicked();
void on_copyToClipboard_clicked();
- void on_OKButton_clicked();
};
#endif // ADDRESSBOOKDIALOG_H
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTableView" name="sendTableView">
+ <property name="selectionMode">
+ <enum>QAbstractItemView::SingleSelection</enum>
+ </property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</item>
<item>
<widget class="QTableView" name="receiveTableView">
+ <property name="selectionMode">
+ <enum>QAbstractItemView::SingleSelection</enum>
+ </property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</spacer>
</item>
<item>
+ <widget class="QPushButton" name="newAddressButton">
+ <property name="text">
+ <string>&New Address...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="copyToClipboard">
<property name="text">
- <string>Copy to Clipboard</string>
+ <string>&Copy to Clipboard</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editButton">
<property name="text">
- <string>Edit...</string>
+ <string>&Edit...</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="newAddressButton">
+ <widget class="QPushButton" name="deleteButton">
<property name="text">
- <string>New Address...</string>
+ <string>&Delete</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="OKButton">
- <property name="text">
- <string>OK</string>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
/* index.row(), index.column() */
/* Return QString */
if(index.column() == Address)
- return "1PC9aZC4hNX2rmmrt7uHTfYAS3hRbph4UN";
+ return "1PC9aZC4hNX2rmmrt7uHTfYAS3hRbph4UN" + QString::number(index.row());
else
return "Description";
} else if (role == Qt::UserRole)
sendcoinsdialog.h \
addressbookdialog.h \
aboutdialog.h \
- editaddressdialog.h
+ editaddressdialog.h \
+ bitcoinaddressvalidator.h
SOURCES += bitcoin.cpp bitcoingui.cpp \
transactiontablemodel.cpp \
addresstablemodel.cpp \
sendcoinsdialog.cpp \
addressbookdialog.cpp \
aboutdialog.cpp \
- editaddressdialog.cpp
+ editaddressdialog.cpp \
+ bitcoinaddressvalidator.cpp
RESOURCES += \
bitcoin.qrc
--- /dev/null
+#include "bitcoinaddressvalidator.h"
+
+const QString BitcoinAddressValidator::valid_chars = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
+
+BitcoinAddressValidator::BitcoinAddressValidator(QObject *parent) :
+ QRegExpValidator(QRegExp("^["+valid_chars+"]+"), parent)
+{
+}
--- /dev/null
+#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
/* Forward declarations */
class TransactionTableModel;
+
+QT_BEGIN_NAMESPACE
class QLabel;
class QLineEdit;
+QT_END_NAMESPACE
class BitcoinGUI : public QMainWindow
{
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
+#include <QListWidget>
+#include <QStackedWidget>
OptionsDialog::OptionsDialog(QWidget *parent) :
QDialog(parent), contents_widget(0), pages_widget(0)
#define OPTIONSDIALOG_H
#include <QDialog>
-#include <QStackedWidget>
-#include <QListWidget>
+
+QT_BEGIN_NAMESPACE
+class QStackedWidget;
+class QListWidget;
+class QListWidgetItem;
+QT_END_NAMESPACE
class OptionsDialog : public QDialog
{
#include "ui_sendcoinsdialog.h"
#include "addressbookdialog.h"
+#include "bitcoinaddressvalidator.h"
#include <QApplication>
#include <QClipboard>
ui(new Ui::SendCoinsDialog)
{
ui->setupUi(this);
+ ui->payTo->setValidator(new BitcoinAddressValidator(this));
+ ui->payAmount->setValidator(new QDoubleValidator(this));
}
SendCoinsDialog::~SendCoinsDialog()
accept();
}
-void SendCoinsDialog::on_cancelButton_clicked()
-{
- reject();
-}
-
void SendCoinsDialog::on_pasteButton_clicked()
{
/* Paste text from clipboard into recipient field */
{
AddressBookDialog dlg;
dlg.exec();
+ ui->payTo->setText(dlg.getReturnValue());
+}
+
+void SendCoinsDialog::on_buttonBox_rejected()
+{
+ reject();
}
Ui::SendCoinsDialog *ui;
private slots:
+ void on_buttonBox_rejected();
void on_addressBookButton_clicked();
void on_pasteButton_clicked();
- void on_cancelButton_clicked();
void on_sendButton_clicked();
};
</widget>
</item>
<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 row="4" column="1">
<widget class="QLineEdit" name="payAmount">
<property name="text">
<string>&Send</string>
</property>
+ <property name="icon">
+ <iconset resource="bitcoin.qrc">
+ <normaloff>:/icons/send</normaloff>:/icons/send</iconset>
+ </property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="cancelButton">
- <property name="text">
- <string>Cancel</string>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel</set>
</property>
</widget>
</item>
</item>
</layout>
</widget>
- <resources/>
- <connections/>
+ <resources>
+ <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>