Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/kgncimportoptionsdlg.cpp
Context not available. | |||||
2 | kgncimportoptions.cpp | 2 | kgncimportoptions.cpp | ||
---|---|---|---|---|---|
3 | ------------------- | 3 | ------------------- | ||
4 | copyright : (C) 2005 by Tony Bloomfield <tonybloom@users.sourceforge.net> | 4 | copyright : (C) 2005 by Tony Bloomfield <tonybloom@users.sourceforge.net> | ||
5 | (C) 2017 by Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> | ||||
5 | 6 | | |||
6 | ***************************************************************************/ | 7 | ***************************************************************************/ | ||
7 | 8 | | |||
Context not available. | |||||
29 | 30 | | |||
30 | #include <KHelpClient> | 31 | #include <KHelpClient> | ||
31 | #include <QDialogButtonBox> | 32 | #include <QDialogButtonBox> | ||
32 | #include <QPushButton> | | |||
33 | #include <QVBoxLayout> | | |||
34 | 33 | | |||
35 | // ---------------------------------------------------------------------------- | 34 | // ---------------------------------------------------------------------------- | ||
36 | // Project Includes | 35 | // Project Includes | ||
37 | 36 | | |||
38 | // dialog constructor | 37 | #include "ui_kgncimportoptionsdlg.h" | ||
39 | KGncImportOptionsDlg::KGncImportOptionsDlg(QWidget *) | 38 | | ||
39 | class KGncImportOptionsDlgPrivate | ||||
40 | { | ||||
41 | Q_DISABLE_COPY(KGncImportOptionsDlgPrivate) | ||||
42 | Q_DECLARE_PUBLIC(KGncImportOptionsDlg) | ||||
43 | | ||||
44 | public: | ||||
45 | KGncImportOptionsDlgPrivate(KGncImportOptionsDlg *qq) : | ||||
46 | q_ptr(qq), | ||||
47 | ui(new Ui::KGncImportOptionsDlg), | ||||
48 | m_localeCodec(nullptr) | ||||
49 | { | ||||
50 | } | ||||
51 | | ||||
52 | ~KGncImportOptionsDlgPrivate() | ||||
53 | { | ||||
54 | delete ui; | ||||
55 | } | ||||
56 | | ||||
57 | void init() | ||||
58 | { | ||||
59 | Q_Q(KGncImportOptionsDlg); | ||||
60 | ui->setupUi(q); | ||||
61 | | ||||
62 | ui->buttonInvestGroup->setId(ui->radioInvest1, 0); // one invest acct per stock | ||||
63 | ui->buttonInvestGroup->setId(ui->radioInvest2, 1); // one invest acct for all stocks | ||||
64 | ui->buttonInvestGroup->setId(ui->radioInvest3, 2); // prompt for each stock | ||||
65 | | ||||
66 | ui->buttonGroup5->setExclusive(false); | ||||
67 | ui->checkFinanceQuote->setChecked(true); | ||||
68 | | ||||
69 | ui->buttonGroup2->setExclusive(false); | ||||
70 | ui->checkSchedules->setChecked(false); | ||||
71 | | ||||
72 | buildCodecList(); // build list of codecs and insert into combo box | ||||
73 | | ||||
74 | ui->buttonGroup4->setExclusive(false); | ||||
75 | ui->checkDecode->setChecked(false); | ||||
76 | ui->comboDecode->setEnabled(false); | ||||
77 | | ||||
78 | ui->buttonGroup18->setExclusive(false); | ||||
79 | ui->checkTxNotes->setChecked(false); | ||||
80 | | ||||
81 | ui->buttonGroup3->setExclusive(false); | ||||
82 | ui->checkDebugGeneral->setChecked(false); | ||||
83 | ui->checkDebugXML->setChecked(false); | ||||
84 | ui->checkAnonymize->setChecked(false); | ||||
85 | | ||||
86 | q->connect(ui->checkDecode, &QAbstractButton::toggled, q, &KGncImportOptionsDlg::slotDecodeOptionChanged); | ||||
87 | q->connect(ui->buttonBox, &QDialogButtonBox::helpRequested, q, &KGncImportOptionsDlg::slotHelp); | ||||
88 | } | ||||
89 | | ||||
90 | void buildCodecList() | ||||
91 | { | ||||
92 | m_localeCodec = QTextCodec::codecForLocale(); | ||||
93 | auto codecList = QTextCodec::availableCodecs(); | ||||
94 | QList<QByteArray>::ConstIterator itc; | ||||
95 | for (itc = codecList.constBegin(); itc != codecList.constEnd(); ++itc) { | ||||
96 | if (*itc == m_localeCodec) | ||||
97 | ui->comboDecode->insertItem(0, QString(*itc)); | ||||
98 | else | ||||
99 | ui->comboDecode->insertItem(9999, QString(*itc)); | ||||
100 | } | ||||
101 | } | ||||
102 | | ||||
103 | KGncImportOptionsDlg *q_ptr; | ||||
104 | Ui::KGncImportOptionsDlg *ui; | ||||
105 | QTextCodec *m_localeCodec; | ||||
106 | }; | ||||
107 | | ||||
108 | KGncImportOptionsDlg::KGncImportOptionsDlg(QWidget *parent) : | ||||
109 | QDialog(parent), | ||||
110 | d_ptr(new KGncImportOptionsDlgPrivate(this)) | ||||
40 | { | 111 | { | ||
41 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Help); | 112 | Q_D(KGncImportOptionsDlg); | ||
42 | QWidget *mainWidget = new QWidget(this); | 113 | d->init(); | ||
43 | QVBoxLayout *mainLayout = new QVBoxLayout; | | |||
44 | setLayout(mainLayout); | | |||
45 | mainLayout->addWidget(mainWidget); | | |||
46 | QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); | | |||
47 | okButton->setDefault(true); | | |||
48 | okButton->setShortcut(Qt::CTRL | Qt::Key_Return); | | |||
49 | connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); | | |||
50 | connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); | | |||
51 | m_widget = new KGncImportOptionsDlgDecl(); | | |||
52 | mainLayout->addWidget(m_widget); | | |||
53 | | ||||
54 | m_widget->buttonInvestGroup->setId(m_widget->radioInvest1, 0); // one invest acct per stock | | |||
55 | m_widget->buttonInvestGroup->setId(m_widget->radioInvest2, 1); // one invest acct for all stocks | | |||
56 | m_widget->buttonInvestGroup->setId(m_widget->radioInvest3, 2); // prompt for each stock | | |||
57 | | ||||
58 | m_widget->buttonGroup5->setExclusive(false); | | |||
59 | m_widget->checkFinanceQuote->setChecked(true); | | |||
60 | | ||||
61 | m_widget->buttonGroup2->setExclusive(false); | | |||
62 | m_widget->checkSchedules->setChecked(false); | | |||
63 | | ||||
64 | buildCodecList(); // build list of codecs and insert into combo box | | |||
65 | | ||||
66 | m_widget->buttonGroup4->setExclusive(false); | | |||
67 | m_widget->checkDecode->setChecked(false); | | |||
68 | m_widget->comboDecode->setEnabled(false); | | |||
69 | | ||||
70 | m_widget->buttonGroup18->setExclusive(false); | | |||
71 | m_widget->checkTxNotes->setChecked(false); | | |||
72 | | ||||
73 | m_widget->buttonGroup3->setExclusive(false); | | |||
74 | m_widget->checkDebugGeneral->setChecked(false); | | |||
75 | m_widget->checkDebugXML->setChecked(false); | | |||
76 | m_widget->checkAnonymize->setChecked(false); | | |||
77 | | ||||
78 | connect(m_widget->checkDecode, SIGNAL(toggled(bool)), this, SLOT(slotDecodeOptionChanged(bool))); | | |||
79 | connect(this, SIGNAL(helpClicked()), this, SLOT(slotHelp())); | | |||
80 | | ||||
81 | mainLayout->addWidget(buttonBox); | | |||
82 | } | 114 | } | ||
83 | 115 | | |||
84 | KGncImportOptionsDlg::~KGncImportOptionsDlg() {} | 116 | KGncImportOptionsDlg::~KGncImportOptionsDlg() | ||
117 | { | ||||
118 | Q_D(KGncImportOptionsDlg); | ||||
119 | delete d; | ||||
120 | } | ||||
85 | 121 | | |||
86 | // enable the combo box for selection if required | 122 | // enable the combo box for selection if required | ||
87 | void KGncImportOptionsDlg::slotDecodeOptionChanged(bool isOn) | 123 | void KGncImportOptionsDlg::slotDecodeOptionChanged(bool isOn) | ||
88 | { | 124 | { | ||
125 | Q_D(KGncImportOptionsDlg); | ||||
89 | if (isOn) { | 126 | if (isOn) { | ||
90 | m_widget->comboDecode->setEnabled(true); | 127 | d->ui->comboDecode->setEnabled(true); | ||
91 | m_widget->comboDecode->setCurrentItem(0); | 128 | d->ui->comboDecode->setCurrentItem(0); | ||
92 | } else { | 129 | } else { | ||
93 | m_widget->comboDecode->setEnabled(false); | 130 | d->ui->comboDecode->setEnabled(false); | ||
94 | } | 131 | } | ||
95 | } | 132 | } | ||
96 | void KGncImportOptionsDlg::buildCodecList() | 133 | | ||
134 | int KGncImportOptionsDlg::investmentOption() const | ||||
97 | { | 135 | { | ||
98 | m_localeCodec = QTextCodec::codecForLocale(); | 136 | Q_D(const KGncImportOptionsDlg); | ||
99 | QList<QByteArray> codecList = QTextCodec::availableCodecs(); | 137 | return (d->ui->buttonInvestGroup->checkedId()); | ||
100 | QList<QByteArray>::ConstIterator itc; | 138 | }; | ||
101 | for (itc = codecList.constBegin(); itc != codecList.constEnd(); ++itc) { | 139 | | ||
102 | if (*itc == m_localeCodec) | 140 | bool KGncImportOptionsDlg::quoteOption() const | ||
103 | m_widget->comboDecode->insertItem(0, QString(*itc)); | 141 | { | ||
104 | else | 142 | Q_D(const KGncImportOptionsDlg); | ||
105 | m_widget->comboDecode->insertItem(9999, QString(*itc)); | 143 | return (d->ui->checkFinanceQuote->isChecked()); | ||
106 | } | 144 | }; | ||
107 | } | 145 | | ||
146 | bool KGncImportOptionsDlg::scheduleOption() const | ||||
147 | { | ||||
148 | Q_D(const KGncImportOptionsDlg); | ||||
149 | return (d->ui->checkSchedules->isChecked()); | ||||
150 | }; | ||||
108 | 151 | | |||
109 | // return selected codec or 0 | 152 | // return selected codec or 0 | ||
110 | QTextCodec* KGncImportOptionsDlg::decodeOption() | 153 | QTextCodec* KGncImportOptionsDlg::decodeOption() | ||
111 | { | 154 | { | ||
112 | if (!m_widget->checkDecode->isChecked()) { | 155 | Q_D(const KGncImportOptionsDlg); | ||
113 | return (0); | 156 | if (!d->ui->checkDecode->isChecked()) { | ||
157 | return nullptr; | ||||
114 | } else { | 158 | } else { | ||
115 | return (QTextCodec::codecForName(m_widget->comboDecode->currentText().toUtf8())); | 159 | return (QTextCodec::codecForName(d->ui->comboDecode->currentText().toUtf8())); | ||
116 | } | 160 | } | ||
117 | } | 161 | } | ||
118 | 162 | | |||
163 | bool KGncImportOptionsDlg::txNotesOption() const | ||||
164 | { | ||||
165 | Q_D(const KGncImportOptionsDlg); | ||||
166 | return (d->ui->checkTxNotes->isChecked()); | ||||
167 | } | ||||
168 | | ||||
169 | bool KGncImportOptionsDlg::generalDebugOption() const | ||||
170 | { | ||||
171 | Q_D(const KGncImportOptionsDlg); | ||||
172 | return (d->ui->checkDebugGeneral->isChecked()); | ||||
173 | } | ||||
174 | | ||||
175 | bool KGncImportOptionsDlg::xmlDebugOption() const | ||||
176 | { | ||||
177 | Q_D(const KGncImportOptionsDlg); | ||||
178 | return (d->ui->checkDebugXML->isChecked()); | ||||
179 | } | ||||
180 | | ||||
181 | bool KGncImportOptionsDlg::anonymizeOption() const | ||||
182 | { | ||||
183 | Q_D(const KGncImportOptionsDlg); | ||||
184 | return (d->ui->checkAnonymize->isChecked()); | ||||
185 | } | ||||
186 | | ||||
119 | void KGncImportOptionsDlg::slotHelp() | 187 | void KGncImportOptionsDlg::slotHelp() | ||
120 | { | 188 | { | ||
121 | KHelpClient::invokeHelp("details.impexp.gncoptions"); | 189 | KHelpClient::invokeHelp("details.impexp.gncoptions"); | ||
Context not available. |