1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */
4 * Copyright (C) 2008 Sergey Yanovich <ynvich@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "xpcom-config.h"
25 #include "nsServiceManagerUtils.h"
26 #include "nsStringAPI.h"
27 #include "nsTextFormatter.h"
31 #include "nsArrayUtils.h"
32 #include "nsITreeColumns.h"
34 #include "nsIAtomService.h"
36 /* Project includes */
37 #include "aaIResource.h"
40 #include "aaITransaction.h"
41 #include "aaILoadQuery.h"
42 #include "aaViewUtils.h"
43 #include "aaTreeViewLedger.h"
45 aaTreeViewLedger::aaTreeViewLedger()
49 aaTreeViewLedger::~aaTreeViewLedger()
53 NS_IMPL_ISUPPORTS_INHERITED0(aaTreeViewLedger
, aaTreeView
)
55 /* Virtual overrides */
57 aaTreeViewLedger::GetRowCount(PRInt32
*aRowCount
)
59 NS_ENSURE_ARG_POINTER(aRowCount
);
65 rv
= mDataSet
->GetLength((PRUint32
*) aRowCount
);
66 NS_ENSURE_SUCCESS(rv
, rv
);
74 aaTreeViewLedger::getColumn0(aaITransaction
*txn
, PRUint32 flags
,
80 assignDate(_retval
, txn
->PickFact()->PickTime());
85 aaTreeViewLedger::getColumn1(aaITransaction
*txn
, PRUint32 flags
,
91 nsCOMPtr
<aaIResource
> resource
;
92 aaIFlow
*flow
= txn
->PickFact()->PickTakeFrom();
93 if (flow
&& flow
->PickId()) {
94 txn
->PickFact()->PickTakeFrom()->GetTakeResource(
95 getter_AddRefs(resource
));
97 txn
->PickFact()->PickGiveTo()->GetGiveResource(
98 getter_AddRefs(resource
));
102 return resource
->GetTag(_retval
);
108 aaTreeViewLedger::getColumn2(aaITransaction
*txn
, PRUint32 flags
,
114 assignDouble(_retval
, txn
->PickFact()->PickAmount());
119 aaTreeViewLedger::getColumn3(aaITransaction
*txn
, PRUint32 flags
,
126 aaTreeViewLedger::getColumn4(aaITransaction
*txn
, PRUint32 flags
,
133 aaTreeViewLedger::getColumn5(aaITransaction
*txn
, PRUint32 flags
,
140 aaTreeViewLedger::getColumn6(aaITransaction
*txn
, PRUint32 flags
,
147 aaTreeViewLedger::getColumn7(aaITransaction
*trxn
, PRUint32 flags
,
154 aaTreeViewLedger::colFuncs
[])(aaITransaction
*, PRUint32 flags
,
156 &aaTreeViewLedger::getColumn0
,
157 &aaTreeViewLedger::getColumn1
,
158 &aaTreeViewLedger::getColumn2
,
159 &aaTreeViewLedger::getColumn3
,
160 &aaTreeViewLedger::getColumn4
,
161 &aaTreeViewLedger::getColumn5
,
162 &aaTreeViewLedger::getColumn6
,
163 &aaTreeViewLedger::getColumn7
166 /* Private functions */
168 aaTreeViewLedger::doGetCellText(PRInt32 row
, nsITreeColumn
*col
,
174 PRInt32 ci
= getColumnIndex(col
, sizeof(colFuncs
));
175 NS_ENSURE_TRUE(ci
>= 0, NS_OK
);
177 nsCOMPtr
<aaITransaction
> transaction(do_QueryElementAt(mDataSet
,
178 getIndexFromRow(row
), &rv
));
179 NS_ENSURE_SUCCESS(rv
, rv
);
180 NS_ENSURE_TRUE(transaction
, NS_OK
);
182 return colFuncs
[ci
](transaction
, getOffsetFromRow(row
), _retval
);