Browse Source

Implement range... transaction filter

miguelfreitas
Wladimir J. van der Laan 14 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 @@
#include <QMenu> #include <QMenu>
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
#include <QLabel>
#include <QDateTimeEdit>
#include <QDebug> #include <QDebug>
@ -90,6 +92,7 @@ TransactionView::TransactionView(QWidget *parent) :
QTableView *view = new QTableView(this); QTableView *view = new QTableView(this);
vlayout->addLayout(hlayout); vlayout->addLayout(hlayout);
vlayout->addWidget(createDateRangeWidget());
vlayout->addWidget(view); vlayout->addWidget(view);
vlayout->setSpacing(0); vlayout->setSpacing(0);
int width = view->verticalScrollBar()->sizeHint().width(); int width = view->verticalScrollBar()->sizeHint().width();
@ -167,6 +170,7 @@ void TransactionView::setModel(WalletModel *model)
void TransactionView::chooseDate(int idx) void TransactionView::chooseDate(int idx)
{ {
QDate current = QDate::currentDate(); QDate current = QDate::currentDate();
dateRangeWidget->setVisible(false);
switch(dateWidget->itemData(idx).toInt()) switch(dateWidget->itemData(idx).toInt())
{ {
case All: case All:
@ -203,10 +207,10 @@ void TransactionView::chooseDate(int idx)
TransactionFilterProxy::MAX_DATE); TransactionFilterProxy::MAX_DATE);
break; break;
case Range: case Range:
// TODO ask specific range dateRangeWidget->setVisible(true);
dateRangeChanged();
break; break;
} }
} }
void TransactionView::chooseType(int idx) void TransactionView::chooseType(int idx)
@ -337,3 +341,46 @@ void TransactionView::showDetails()
dlg.exec(); 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;
class QLineEdit; class QLineEdit;
class QModelIndex; class QModelIndex;
class QMenu; class QMenu;
class QFrame;
class QDateTimeEdit;
QT_END_NAMESPACE QT_END_NAMESPACE
class TransactionView : public QWidget class TransactionView : public QWidget
@ -45,8 +47,15 @@ private:
QMenu *contextMenu; QMenu *contextMenu;
QFrame *dateRangeWidget;
QDateTimeEdit *dateFrom;
QDateTimeEdit *dateTo;
QWidget *createDateRangeWidget();
private slots: private slots:
void contextualMenu(const QPoint &); void contextualMenu(const QPoint &);
void dateRangeChanged();
signals: signals:
void doubleClicked(const QModelIndex&); void doubleClicked(const QModelIndex&);

Loading…
Cancel
Save