#include "walletmodel.h"
#include "addresstablemodel.h"
#include "transactiontablemodel.h"
-#include "guiutil.h"
+#include "bitcoinunits.h"
#include "csvmodelwriter.h"
#include "transactiondescdialog.h"
#include "editaddressdialog.h"
+#include "optionsmodel.h"
#include <QScrollBar>
#include <QComboBox>
#include <QMenu>
#include <QApplication>
#include <QClipboard>
+#include <QLabel>
+#include <QDateTimeEdit>
#include <QDebug>
QTableView *view = new QTableView(this);
vlayout->addLayout(hlayout);
+ vlayout->addWidget(createDateRangeWidget());
vlayout->addWidget(view);
vlayout->setSpacing(0);
int width = view->verticalScrollBar()->sizeHint().width();
// Connect actions
connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int)));
connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int)));
- connect(addressWidget, SIGNAL(textChanged(const QString&)), this, SLOT(changedPrefix(const QString&)));
- connect(amountWidget, SIGNAL(textChanged(const QString&)), this, SLOT(changedAmount(const QString&)));
+ connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString)));
+ connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString)));
- connect(view, SIGNAL(doubleClicked(const QModelIndex&)), this, SIGNAL(doubleClicked(const QModelIndex&)));
+ connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex)));
connect(view,
- SIGNAL(customContextMenuRequested(const QPoint &)),
+ SIGNAL(customContextMenuRequested(QPoint)),
this,
- SLOT(contextualMenu(const QPoint &)));
+ SLOT(contextualMenu(QPoint)));
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress()));
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel()));
void TransactionView::chooseDate(int idx)
{
QDate current = QDate::currentDate();
+ dateRangeWidget->setVisible(false);
switch(dateWidget->itemData(idx).toInt())
{
case All:
TransactionFilterProxy::MAX_DATE);
break;
case Range:
- // TODO ask specific range
+ dateRangeWidget->setVisible(true);
+ dateRangeChanged();
break;
}
-
}
void TransactionView::chooseType(int idx)
void TransactionView::changedAmount(const QString &amount)
{
qint64 amount_parsed = 0;
- if(GUIUtil::parseMoney(amount, &amount_parsed))
+ if(BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed))
{
transactionProxyModel->setMinAmount(amount_parsed);
}
dlg.exec();
}
}
+
+QWidget *TransactionView::createDateRangeWidget()
+{
+ dateRangeWidget = new QFrame();
+ dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
+ dateRangeWidget->setContentsMargins(1,1,1,1);
+ QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget);
+ layout->setContentsMargins(0,0,0,0);
+ layout->addSpacing(23);
+ layout->addWidget(new QLabel("Range:"));
+
+ dateFrom = new QDateTimeEdit(this);
+ dateFrom->setDisplayFormat("dd/MM/yy");
+ dateFrom->setCalendarPopup(true);
+ dateFrom->setMinimumWidth(100);
+ dateFrom->setDate(QDate::currentDate().addDays(-7));
+ layout->addWidget(dateFrom);
+ layout->addWidget(new QLabel("to"));
+
+ dateTo = new QDateTimeEdit(this);
+ dateTo->setDisplayFormat("dd/MM/yy");
+ dateTo->setCalendarPopup(true);
+ dateTo->setMinimumWidth(100);
+ dateTo->setDate(QDate::currentDate());
+ layout->addWidget(dateTo);
+ layout->addStretch();
+
+ // Hide by default
+ dateRangeWidget->setVisible(false);
+
+ // Notify on change
+ connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged()));
+ connect(dateTo, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged()));
+
+ return dateRangeWidget;
+}
+
+void TransactionView::dateRangeChanged()
+{
+ transactionProxyModel->setDateRange(
+ QDateTime(dateFrom->date()),
+ QDateTime(dateTo->date()).addDays(1));
+}