22 #include <QDateTimeEdit>
23 #include <QDesktopServices>
24 #include <QDoubleValidator>
25 #include <QHBoxLayout>
26 #include <QHeaderView>
33 #include <QSignalMapper>
36 #include <QVBoxLayout>
43 setContentsMargins(0, 0, 0, 0);
45 QHBoxLayout* hlayout =
new QHBoxLayout();
46 hlayout->setContentsMargins(0, 0, 0, 0);
48 hlayout->setSpacing(5);
49 hlayout->addSpacing(26);
51 hlayout->setSpacing(0);
52 hlayout->addSpacing(23);
75 dateWidget->setCurrentIndex(settings.value(
"transactionDate").toInt());
94 typeWidget->setCurrentIndex(settings.value(
"transactionType").toInt());
99 addressWidget->setPlaceholderText(tr(
"Enter address or label to search"));
109 amountWidget->setValidator(
new QDoubleValidator(0, 1e20, 8,
this));
112 QVBoxLayout* vlayout =
new QVBoxLayout(
this);
113 vlayout->setContentsMargins(0, 0, 0, 0);
114 vlayout->setSpacing(0);
116 QTableView* view =
new QTableView(
this);
117 vlayout->addLayout(hlayout);
119 vlayout->addWidget(view);
120 vlayout->setSpacing(0);
121 int width = view->verticalScrollBar()->sizeHint().width();
124 hlayout->addSpacing(width + 2);
126 hlayout->addSpacing(width);
129 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
130 view->setTabKeyNavigation(
false);
131 view->setContextMenuPolicy(Qt::CustomContextMenu);
133 view->installEventFilter(
this);
138 QAction* copyAddressAction =
new QAction(tr(
"Copy address"),
this);
139 QAction* copyLabelAction =
new QAction(tr(
"Copy label"),
this);
140 QAction* copyAmountAction =
new QAction(tr(
"Copy amount"),
this);
141 QAction* copyTxIDAction =
new QAction(tr(
"Copy transaction ID"),
this);
142 QAction* editLabelAction =
new QAction(tr(
"Edit label"),
this);
143 QAction* showDetailsAction =
new QAction(tr(
"Show transaction details"),
this);
170 connect(view, SIGNAL(clicked(QModelIndex)),
this, SLOT(
computeSum()));
171 connect(view, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(
contextualMenu(QPoint)));
173 connect(copyAddressAction, SIGNAL(triggered()),
this, SLOT(
copyAddress()));
174 connect(copyLabelAction, SIGNAL(triggered()),
this, SLOT(
copyLabel()));
175 connect(copyAmountAction, SIGNAL(triggered()),
this, SLOT(
copyAmount()));
176 connect(copyTxIDAction, SIGNAL(triggered()),
this, SLOT(
copyTxID()));
177 connect(editLabelAction, SIGNAL(triggered()),
this, SLOT(
editLabel()));
178 connect(showDetailsAction, SIGNAL(triggered()),
this, SLOT(
showDetails()));
204 transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
216 connect(
transactionView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(
computeSum()));
223 for (
int i = 0; i < listUrls.size(); ++i) {
224 QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host();
225 if (!host.isEmpty()) {
226 QAction* thirdPartyTxUrlAction =
new QAction(host,
this);
245 chooseType(settings.value(
"transactionType").toInt());
246 chooseDate(settings.value(
"transactionDate").toInt());
249 hideOrphans(settings.value(
"fHideOrphans",
false).toBool());
257 QDate current = QDate::currentDate();
272 QDate startOfWeek = current.addDays(-(current.dayOfWeek() - 1));
274 QDateTime(startOfWeek),
280 QDateTime(QDate(current.year(), current.month(), 1)),
285 QDateTime(QDate(current.year(), current.month() - 1, 1)),
286 QDateTime(QDate(current.year(), current.month(), 1)));
290 QDateTime(QDate(current.year(), 1, 1)),
301 settings.setValue(
"transactionDate", idx);
313 settings.setValue(
"transactionType", idx);
326 if (settings.value(
"fHideOrphans",
false).toBool() != fHide) {
327 settings.setValue(
"fHideOrphans", fHide);
361 QString newAmount = amount;
362 newAmount.replace(QString(
","), QString(
"."));
376 tr(
"Export Transaction History"), QString(),
377 tr(
"Comma separated file (*.csv)"), NULL);
379 if (filename.isNull())
383 bool fExport =
false;
398 fExport = writer.
write();
402 Q_EMIT
message(tr(
"Exporting Successful"), tr(
"The transaction history was successfully saved to %1.").arg(filename),
406 Q_EMIT
message(tr(
"Exporting Failed"), tr(
"There was an error trying to save the transaction history to %1.").arg(filename),
414 if (index.isValid()) {
443 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
444 if (!selection.isEmpty()) {
449 if (address.isEmpty()) {
458 QModelIndex modelIdx = addressBook->
index(idx, 0, QModelIndex());
482 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
483 if (!selection.isEmpty()) {
496 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
498 Q_FOREACH (QModelIndex index, selection) {
502 if (amount < 0) strAmount =
"<span style='color:red;'>" + strAmount +
"</span>";
510 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
511 if (!selection.isEmpty())
521 layout->setContentsMargins(0, 0, 0, 0);
522 layout->addSpacing(23);
523 layout->addWidget(
new QLabel(tr(
"Range:")));
526 dateFrom->setDisplayFormat(
"dd/MM/yy");
529 dateFrom->setDate(QDate::currentDate().addDays(-7));
531 layout->addWidget(
new QLabel(tr(
"to")));
533 dateTo =
new QDateTimeEdit(
this);
534 dateTo->setDisplayFormat(
"dd/MM/yy");
535 dateTo->setCalendarPopup(
true);
536 dateTo->setMinimumWidth(100);
537 dateTo->setDate(QDate::currentDate());
538 layout->addWidget(
dateTo);
539 layout->addStretch();
557 QDateTime(
dateTo->date()).addDays(1));
576 QWidget::resizeEvent(event);
583 if (event->type() == QEvent::KeyPress) {
584 QKeyEvent* ke =
static_cast<QKeyEvent*
>(event);
585 if (ke->key() == Qt::Key_C && ke->modifiers().testFlag(Qt::ControlModifier)) {
593 return QWidget::eventFilter(obj, event);