summaryrefslogtreecommitdiffstats
path: root/kmymoney2/wizards/wizardpages/currency.cpp
blob: 02200e20cd53665f9d958d84f05d04e906bad4e2 (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
67
68
69
70
/***************************************************************************
                             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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

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

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

#include <tdelocale.h>
#include <tdelistview.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 TDEListViewItem(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"