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 "nsComponentManagerUtils.h"
26 #include "nsServiceManagerUtils.h"
27 #include "nsStringAPI.h"
28 #include "nsTextFormatter.h"
32 #include "nsArrayUtils.h"
33 #include "nsITreeColumns.h"
35 #include "nsIAtomService.h"
37 /* Project includes */
38 #include "aaIResource.h"
40 #include "aaISqlRequest.h"
41 #include "aaAccountLoaders.h"
42 #include "aaViewUtils.h"
43 #include "aaTreeViewQuote.h"
45 aaTreeViewQuote::aaTreeViewQuote()
47 mDataLoader
= do_CreateInstance(AA_LOADQUOTE_CONTRACT
);
50 aaTreeViewQuote::~aaTreeViewQuote()
54 NS_IMPL_ISUPPORTS_INHERITED0(aaTreeViewQuote
, aaTreeView
)
58 aaTreeViewQuote::getColumn0(aaIQuote
*quote
, PRUint32 flags
,
63 nsCOMPtr
<aaIResource
> resource
;
64 rv
= quote
->GetResource(getter_AddRefs(resource
));
65 NS_ENSURE_TRUE(resource
, NS_OK
);
67 return resource
->GetTag(_retval
);
71 aaTreeViewQuote::getColumn1(aaIQuote
*quote
, PRUint32 flags
,
74 NS_ENSURE_TRUE(quote
, NS_OK
);
76 assignDate(_retval
, quote
->PickTime());
81 aaTreeViewQuote::getColumn2(aaIQuote
*quote
, PRUint32 flags
,
84 NS_ENSURE_TRUE(quote
, NS_OK
);
86 assignSignificantDouble(_retval
, quote
->PickRate());
91 aaTreeViewQuote::colFuncs
[])(aaIQuote
*, PRUint32 flags
,
93 &aaTreeViewQuote::getColumn0
,
94 &aaTreeViewQuote::getColumn1
,
95 &aaTreeViewQuote::getColumn2
98 /* Private functions */
100 aaTreeViewQuote::doGetCellText(PRInt32 row
, nsITreeColumn
*col
,
106 PRInt32 ci
= getColumnIndex(col
, sizeof(colFuncs
));
107 NS_ENSURE_TRUE(ci
>= 0, NS_OK
);
109 nsCOMPtr
<aaIQuote
> quote(do_QueryElementAt(mDataSet
, row
, &rv
));
110 NS_ENSURE_SUCCESS(rv
, rv
);
111 NS_ENSURE_TRUE(quote
, NS_OK
);
113 return colFuncs
[ci
](quote
, mFlags
, _retval
);