mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
implement filtering, action listeners
This commit is contained in:
parent
0522725754
commit
af94377667
3 changed files with 119 additions and 63 deletions
|
|
@ -1,12 +1,14 @@
|
|||
#include "TransactionTableModel.h"
|
||||
|
||||
#include <QLocale>
|
||||
|
||||
/* Credit and Debit columns are right-aligned as they contain numbers */
|
||||
static Qt::AlignmentFlag column_alignments[] = {
|
||||
Qt::AlignLeft,
|
||||
Qt::AlignLeft,
|
||||
Qt::AlignLeft,
|
||||
Qt::AlignRight,
|
||||
Qt::AlignRight
|
||||
static int column_alignments[] = {
|
||||
Qt::AlignLeft|Qt::AlignVCenter,
|
||||
Qt::AlignLeft|Qt::AlignVCenter,
|
||||
Qt::AlignLeft|Qt::AlignVCenter,
|
||||
Qt::AlignRight|Qt::AlignVCenter,
|
||||
Qt::AlignRight|Qt::AlignVCenter
|
||||
};
|
||||
|
||||
TransactionTableModel::TransactionTableModel(QObject *parent):
|
||||
|
|
@ -36,16 +38,24 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
|||
{
|
||||
/* index.row(), index.column() */
|
||||
/* Return QString */
|
||||
return QString("test");
|
||||
return QLocale::system().toString(index.row());
|
||||
} else if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
return column_alignments[index.column()];
|
||||
} else if (role == Qt::UserRole)
|
||||
{
|
||||
/* user role: transaction type for filtering
|
||||
"s" (sent)
|
||||
"r" (received)
|
||||
"g" (generated)
|
||||
*/
|
||||
switch(index.row() % 3)
|
||||
{
|
||||
case 0: return QString("s");
|
||||
case 1: return QString("r");
|
||||
case 2: return QString("o");
|
||||
}
|
||||
}
|
||||
/* user role: transaction type
|
||||
"s" (sent)
|
||||
"r" (received)
|
||||
"g" (generated)
|
||||
*/
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue