summaryrefslogtreecommitdiffstats
path: root/kmymoney2/wizards/wizardpages/currency.cpp
blob: cf645aba932e27a0c0ca505a8b4e9a0ca2c6b04b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/***************************************************************************
                             userinfo.cpp
                             -------------------
    begin                : Fri Jun  1 2007
    copyright            : (C) 2007 Thomas Baumgart
    email                : Thomas Baumgart <ipwizard@users.sourceforge.net>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

// ----------------------------------------------------------------------------
// QT Includes

// ----------------------------------------------------------------------------
// KDE Includes

#include <klocale.h>
#include <klistview.h>

// ----------------------------------------------------------------------------
// Project Includes

#include "currency.h"

Currency::Currency(TQWidget* parent, const char* name) :
  CurrencyDecl(parent, name)
{
  m_currencyList->setAllColumnsShowFocus(true);
  m_currencyList->setMultiSelection(false);
}

TQListViewItem* Currency::insertCurrency(const MyMoneySecurity& sec)
{
  return new KListViewItem(m_currencyList, sec.name(), TQString(sec.id()), sec.tradingSymbol());
}

void Currency::selectCurrency(const MyMoneySecurity& sec)
{
  TQListViewItem* it_v;
  TQListViewItemIterator it(m_currencyList);
  while((it_v = it.current()) != 0) {
    if(it_v->text(1) == TQString(sec.id())) {
      m_currencyList->setSelected(it_v, true);
      m_currencyList->ensureItemVisible(it_v);
      break;
    }
  }
}

TQString Currency::selectedCurrency(void) const
{
  TQString id;
  if(m_currencyList->selectedItem()) {
    id = m_currencyList->selectedItem()->text(1);
  }
  return id;
}

#include "currency.moc"