Browse Source

Implement range... transaction filter

pull/1/head
Wladimir J. van der Laan 12 years ago
parent
commit
8b936b617f
  1. 51
      src/qt/transactionview.cpp
  2. 9
      src/qt/transactionview.h

51
src/qt/transactionview.cpp

@ -25,6 +25,8 @@ @@ -25,6 +25,8 @@
#include <QMenu>
#include <QApplication>
#include <QClipboard>
#include <QLabel>
#include <QDateTimeEdit>
#include <QDebug>
@ -90,6 +92,7 @@ TransactionView::TransactionView(QWidget *parent) : @@ -90,6 +92,7 @@ TransactionView::TransactionView(QWidget *parent) :
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::setModel(WalletModel *model) @@ -167,6 +170,7 @@ void TransactionView::setModel(WalletModel *model)
void TransactionView::chooseDate(int idx)
{
QDate current = QDate::currentDate();
dateRangeWidget->setVisible(false);
switch(dateWidget->itemData(idx).toInt())
{
case All:
@ -203,10 +207,10 @@ void TransactionView::chooseDate(int idx) @@ -203,10 +207,10 @@ void TransactionView::chooseDate(int idx)
TransactionFilterProxy::MAX_DATE);
break;
case Range:
// TODO ask specific range
dateRangeWidget->setVisible(true);
dateRangeChanged();
break;
}
}
void TransactionView::chooseType(int idx)
@ -337,3 +341,46 @@ void TransactionView::showDetails() @@ -337,3 +341,46 @@ void TransactionView::showDetails()
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));
}

9
src/qt/transactionview.h

@ -12,6 +12,8 @@ class QComboBox; @@ -12,6 +12,8 @@ class QComboBox;
class QLineEdit;
class QModelIndex;
class QMenu;
class QFrame;
class QDateTimeEdit;
QT_END_NAMESPACE
class TransactionView : public QWidget
@ -45,8 +47,15 @@ private: @@ -45,8 +47,15 @@ private:
QMenu *contextMenu;
QFrame *dateRangeWidget;
QDateTimeEdit *dateFrom;
QDateTimeEdit *dateTo;
QWidget *createDateRangeWidget();
private slots:
void contextualMenu(const QPoint &);
void dateRangeChanged();
signals:
void doubleClicked(const QModelIndex&);

Loading…
Cancel
Save