summaryrefslogtreecommitdiffstats
path: root/kmymoney2/dialogs/kgncpricesourcedlg.cpp
blob: 8c807f3d71b47f9ab2c7740ae1d2b446ed988244 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/***************************************************************************
                          kgncpricesourcedlg.cpp
                             -------------------
    copyright            : (C) 2005 by Ace Jones
    author               : Tony Bloomfield
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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
#include <tqlabel.h>
#include <tqlistbox.h>
#include <tqlineedit.h>
#include <tqbuttongroup.h>
#include <tqlayout.h>
#include <tqapplication.h>

// ----------------------------------------------------------------------------
// KDE Includes
#include <kapplication.h>
#include <kurlrequester.h>
#include <ktextbrowser.h>
#include <klocale.h>

// ----------------------------------------------------------------------------
// Project Includes
#include "kgncpricesourcedlg.h"
#include "../converter/webpricequote.h"

KGncPriceSourceDlg::KGncPriceSourceDlg(TQWidget *parent, const char *name)
 : KGncPriceSourceDlgDecl(parent, name)
{
}
KGncPriceSourceDlg::KGncPriceSourceDlg(const TQString &stockName, const TQString &gncSource){
  // signals and slots connections
  connect( buttonGroup5, TQT_SIGNAL( released(int) ), this, TQT_SLOT( buttonPressed(int) ) );
  connect( buttonHelp, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotHelp() ) );
  // initialize data fields
  textStockName->setText (i18n ("Investment: %1").tqarg(stockName));
  textGncSource->setText (i18n ("Quote source: %1").tqarg(gncSource));
  listKnownSource->insertStringList (WebPriceQuote::quoteSources());
  lineUserSource->setText (gncSource);
  checkAlwaysUse->setChecked(true);
  buttonGroup5->setButton (0);
  buttonPressed (0);
  return;
}

KGncPriceSourceDlg::~KGncPriceSourceDlg()
{
}

enum ButtonIds {NOSOURCE = 0, KMMSOURCE, USERSOURCE};

void KGncPriceSourceDlg::buttonPressed (int buttonId) {
  m_currentButton = buttonId;
  switch (m_currentButton) {
    case NOSOURCE:
      listKnownSource->clearSelection();
      listKnownSource->setEnabled (false);
      lineUserSource->deselect();
      lineUserSource->setEnabled (false);
      break;
    case KMMSOURCE:
      lineUserSource->deselect ();
      lineUserSource->setEnabled (false);
      listKnownSource->setEnabled (true);
      listKnownSource->setFocus();
      listKnownSource->setSelected (0, true);
      break;
    case USERSOURCE:
      listKnownSource->clearSelection();
      listKnownSource->setEnabled (false);
      lineUserSource->setEnabled (true);
      lineUserSource->selectAll();
      lineUserSource->setFocus ();
      break;
  }
}

TQString KGncPriceSourceDlg::selectedSource() const {
  TQString s;
  switch (m_currentButton) {
    case NOSOURCE: s = ""; break;
    case KMMSOURCE: s = listKnownSource->currentText(); break;
    case USERSOURCE: s = lineUserSource->text(); break;
  }
  return (s);
}

void KGncPriceSourceDlg::slotHelp(void)
{
  kapp->invokeHelp ("details.impexp.gncquotes");
}

#include "kgncpricesourcedlg.moc"