aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCozz Lovan <cozzlovan@yahoo.com>2014-03-03 04:16:42 +0100
committerCozz Lovan <cozzlovan@yahoo.com>2014-03-03 23:26:00 +0100
commitdc01ba7b0c203afa78c3312293e0432d680f5d63 (patch)
tree640a5691c5c5d50f18cf8a0bb3457f89369eaf56
parentaefbf6e30cadaf77ebee44284c74cc5449dc173f (diff)
Fix coin control sorts date as text
-rw-r--r--src/qt/coincontroldialog.cpp14
-rw-r--r--src/qt/coincontroldialog.h28
-rw-r--r--src/qt/forms/coincontroldialog.ui7
3 files changed, 39 insertions, 10 deletions
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
index 2d8fcd7a52..1e5a2efc94 100644
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -125,6 +125,7 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) :
ui->treeWidget->setColumnHidden(COLUMN_VOUT_INDEX, true); // store vout index in this column, but dont show it
ui->treeWidget->setColumnHidden(COLUMN_AMOUNT_INT64, true); // store amount int64 in this column, but dont show it
ui->treeWidget->setColumnHidden(COLUMN_PRIORITY_INT64, true); // store priority int64 in this column, but dont show it
+ ui->treeWidget->setColumnHidden(COLUMN_DATE_INT64, true); // store date int64 in this column, but dont show it
// default view is sorted by amount desc
sortView(COLUMN_AMOUNT_INT64, Qt::DescendingOrder);
@@ -327,7 +328,7 @@ void CoinControlDialog::sortView(int column, Qt::SortOrder order)
sortColumn = column;
sortOrder = order;
ui->treeWidget->sortItems(column, order);
- ui->treeWidget->header()->setSortIndicator((sortColumn == COLUMN_AMOUNT_INT64 ? COLUMN_AMOUNT : (sortColumn == COLUMN_PRIORITY_INT64 ? COLUMN_PRIORITY : sortColumn)), sortOrder);
+ ui->treeWidget->header()->setSortIndicator(getMappedColumn(sortColumn), sortOrder);
}
// treeview: clicked on header
@@ -335,22 +336,18 @@ void CoinControlDialog::headerSectionClicked(int logicalIndex)
{
if (logicalIndex == COLUMN_CHECKBOX) // click on most left column -> do nothing
{
- ui->treeWidget->header()->setSortIndicator((sortColumn == COLUMN_AMOUNT_INT64 ? COLUMN_AMOUNT : (sortColumn == COLUMN_PRIORITY_INT64 ? COLUMN_PRIORITY : sortColumn)), sortOrder);
+ ui->treeWidget->header()->setSortIndicator(getMappedColumn(sortColumn), sortOrder);
}
else
{
- if (logicalIndex == COLUMN_AMOUNT) // sort by amount
- logicalIndex = COLUMN_AMOUNT_INT64;
-
- if (logicalIndex == COLUMN_PRIORITY) // sort by priority
- logicalIndex = COLUMN_PRIORITY_INT64;
+ logicalIndex = getMappedColumn(logicalIndex, false);
if (sortColumn == logicalIndex)
sortOrder = ((sortOrder == Qt::AscendingOrder) ? Qt::DescendingOrder : Qt::AscendingOrder);
else
{
sortColumn = logicalIndex;
- sortOrder = ((sortColumn == COLUMN_AMOUNT_INT64 || sortColumn == COLUMN_PRIORITY_INT64 || sortColumn == COLUMN_DATE || sortColumn == COLUMN_CONFIRMATIONS) ? Qt::DescendingOrder : Qt::AscendingOrder); // if amount,date,conf,priority then default => desc, else default => asc
+ sortOrder = ((sortColumn == COLUMN_LABEL || sortColumn == COLUMN_ADDRESS) ? Qt::AscendingOrder : Qt::DescendingOrder); // if label or address then default => asc, else default => desc
}
sortView(sortColumn, sortOrder);
@@ -731,6 +728,7 @@ void CoinControlDialog::updateView()
// date
itemOutput->setText(COLUMN_DATE, GUIUtil::dateTimeStr(out.tx->GetTxTime()));
+ itemOutput->setText(COLUMN_DATE_INT64, strPad(QString::number(out.tx->GetTxTime()), 20, " "));
// confirmations
itemOutput->setText(COLUMN_CONFIRMATIONS, strPad(QString::number(out.nDepth), 8, " "));
diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h
index b9318ca7b0..465e2a009d 100644
--- a/src/qt/coincontroldialog.h
+++ b/src/qt/coincontroldialog.h
@@ -65,9 +65,35 @@ private:
COLUMN_TXHASH,
COLUMN_VOUT_INDEX,
COLUMN_AMOUNT_INT64,
- COLUMN_PRIORITY_INT64
+ COLUMN_PRIORITY_INT64,
+ COLUMN_DATE_INT64
};
+ // some columns have a hidden column containing the value used for sorting
+ int getMappedColumn(int column, bool fVisibleColumn = true)
+ {
+ if (fVisibleColumn)
+ {
+ if (column == COLUMN_AMOUNT_INT64)
+ return COLUMN_AMOUNT;
+ else if (column == COLUMN_PRIORITY_INT64)
+ return COLUMN_PRIORITY;
+ else if (column == COLUMN_DATE_INT64)
+ return COLUMN_DATE;
+ }
+ else
+ {
+ if (column == COLUMN_AMOUNT)
+ return COLUMN_AMOUNT_INT64;
+ else if (column == COLUMN_PRIORITY)
+ return COLUMN_PRIORITY_INT64;
+ else if (column == COLUMN_DATE)
+ return COLUMN_DATE_INT64;
+ }
+
+ return column;
+ }
+
private slots:
void showMenu(const QPoint &);
void copyAmount();
diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui
index a31c491e95..cd1c0ffa18 100644
--- a/src/qt/forms/coincontroldialog.ui
+++ b/src/qt/forms/coincontroldialog.ui
@@ -428,7 +428,7 @@
<bool>false</bool>
</property>
<property name="columnCount">
- <number>11</number>
+ <number>12</number>
</property>
<attribute name="headerShowSortIndicator" stdset="0">
<bool>true</bool>
@@ -494,6 +494,11 @@
<string/>
</property>
</column>
+ <column>
+ <property name="text">
+ <string/>
+ </property>
+ </column>
</widget>
</item>
<item>