Mercurial > hg > bitcoin
changeset 1201:e42be0adb78d draft
Implement range... transaction filter
author | Wladimir J. van der Laan <laanwj@gmail.com> |
---|---|
date | Fri, 22 Jul 2011 18:30:25 +0200 |
parents | bed5698d5381 |
children | 5b1a1eeed2bb |
files | src/qt/transactionview.cpp src/qt/transactionview.h |
diffstat | 2 files changed, 58 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -25,6 +25,8 @@ #include <QMenu> #include <QApplication> #include <QClipboard> +#include <QLabel> +#include <QDateTimeEdit> #include <QDebug> @@ -90,6 +92,7 @@ QTableView *view = new QTableView(this); vlayout->addLayout(hlayout); + vlayout->addWidget(createDateRangeWidget()); vlayout->addWidget(view); vlayout->setSpacing(0); int width = view->verticalScrollBar()->sizeHint().width(); @@ -167,6 +170,7 @@ void TransactionView::chooseDate(int idx) { QDate current = QDate::currentDate(); + dateRangeWidget->setVisible(false); switch(dateWidget->itemData(idx).toInt()) { case All: @@ -203,10 +207,10 @@ TransactionFilterProxy::MAX_DATE); break; case Range: - // TODO ask specific range + dateRangeWidget->setVisible(true); + dateRangeChanged(); break; } - } void TransactionView::chooseType(int idx) @@ -337,3 +341,46 @@ 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)); +}
--- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -12,6 +12,8 @@ class QLineEdit; class QModelIndex; class QMenu; +class QFrame; +class QDateTimeEdit; QT_END_NAMESPACE class TransactionView : public QWidget @@ -45,8 +47,15 @@ QMenu *contextMenu; + QFrame *dateRangeWidget; + QDateTimeEdit *dateFrom; + QDateTimeEdit *dateTo; + + QWidget *createDateRangeWidget(); + private slots: void contextualMenu(const QPoint &); + void dateRangeChanged(); signals: void doubleClicked(const QModelIndex&);