Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/kchooseimportexportdlg.cpp
Context not available. | |||||
7 | Javier Campos Morales <javi_c@users.sourceforge.net> | 7 | Javier Campos Morales <javi_c@users.sourceforge.net> | ||
---|---|---|---|---|---|
8 | Felix Rodriguez <frodriguez@users.sourceforge.net> | 8 | Felix Rodriguez <frodriguez@users.sourceforge.net> | ||
9 | John C <thetacoturtle@users.sourceforge.net> | 9 | John C <thetacoturtle@users.sourceforge.net> | ||
10 | (C) 2017 by Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> | ||||
10 | ***************************************************************************/ | 11 | ***************************************************************************/ | ||
11 | 12 | | |||
12 | /*************************************************************************** | 13 | /*************************************************************************** | ||
Context not available. | |||||
36 | // ---------------------------------------------------------------------------- | 37 | // ---------------------------------------------------------------------------- | ||
37 | // Project Includes | 38 | // Project Includes | ||
38 | 39 | | |||
39 | #include "ui_kchooseimportexportdlgdecl.h" | 40 | #include "ui_kchooseimportexportdlg.h" | ||
40 | 41 | | |||
41 | struct KChooseImportExportDlg::Private { | 42 | class KChooseImportExportDlgPrivate | ||
42 | Ui::KChooseImportExportDlgDecl ui; | 43 | { | ||
44 | Q_DISABLE_COPY(KChooseImportExportDlgPrivate) | ||||
45 | | ||||
46 | public: | ||||
47 | KChooseImportExportDlgPrivate() : | ||||
48 | ui(new Ui::KChooseImportExportDlg) | ||||
49 | { | ||||
50 | } | ||||
51 | | ||||
52 | ~KChooseImportExportDlgPrivate() | ||||
53 | { | ||||
54 | delete ui; | ||||
55 | } | ||||
56 | | ||||
57 | void readConfig() | ||||
58 | { | ||||
59 | auto config = KSharedConfig::openConfig(); | ||||
60 | auto grp = config->group("Last Use Settings"); | ||||
61 | m_lastType = grp.readEntry("KChooseImportExportDlg_LastType"); | ||||
62 | } | ||||
63 | | ||||
64 | void writeConfig() const | ||||
65 | { | ||||
66 | auto config = KSharedConfig::openConfig(); | ||||
67 | auto grp = config->group("Last Use Settings"); | ||||
68 | grp.writeEntry("KChooseImportExportDlg_LastType", ui->typeCombo->currentText()); | ||||
69 | config->sync(); | ||||
70 | } | ||||
71 | | ||||
72 | Ui::KChooseImportExportDlg *ui; | ||||
73 | QString m_lastType; | ||||
43 | }; | 74 | }; | ||
44 | 75 | | |||
45 | KChooseImportExportDlg::KChooseImportExportDlg(int type, QWidget *parent) | | |||
46 | : QDialog(parent), d(new Private) | | |||
47 | { | | |||
48 | d->ui.setupUi(this); | | |||
49 | 76 | | |||
50 | QString filename; | 77 | KChooseImportExportDlg::KChooseImportExportDlg(int type, QWidget *parent) : | ||
78 | QDialog(parent), | ||||
79 | d_ptr(new KChooseImportExportDlgPrivate) | ||||
80 | { | ||||
81 | Q_D(KChooseImportExportDlg); | ||||
82 | d->ui->setupUi(this); | ||||
51 | setModal(true); | 83 | setModal(true); | ||
52 | 84 | | |||
53 | if (type == 0) { // import | 85 | if (type == 0) { // import | ||
54 | d->ui.topLabel->setText(i18n("Please choose the type of import you wish to perform. A simple explanation\n" | 86 | d->ui->topLabel->setText(i18n("Please choose the type of import you wish to perform. A simple explanation\n" | ||
55 | "of the import type is available at the bottom of the screen and is updated when\n" | 87 | "of the import type is available at the bottom of the screen and is updated when\n" | ||
56 | "you select an item from the choice box." | 88 | "you select an item from the choice box." | ||
57 | "\n\nOnce you have chosen an import type please press the OK button.")); | 89 | "\n\nOnce you have chosen an import type please press the OK button.")); | ||
58 | d->ui.promptLabel->setText(i18n("Choose import type:")); | 90 | d->ui->promptLabel->setText(i18n("Choose import type:")); | ||
59 | setWindowTitle(i18n("Choose Import Type Dialog")); | 91 | setWindowTitle(i18n("Choose Import Type Dialog")); | ||
60 | } else { // export | 92 | } else { // export | ||
61 | d->ui.topLabel->setText(i18n("Please choose the type of export you wish to perform. A simple explanation\n" | 93 | d->ui->topLabel->setText(i18n("Please choose the type of export you wish to perform. A simple explanation\n" | ||
62 | "of the export type is available at the bottom of the screen and is updated when\n" | 94 | "of the export type is available at the bottom of the screen and is updated when\n" | ||
63 | "you select an item from the choice box." | 95 | "you select an item from the choice box." | ||
64 | "\n\nOnce you have chosen an export type please press the OK button.")); | 96 | "\n\nOnce you have chosen an export type please press the OK button.")); | ||
65 | d->ui.promptLabel->setText(i18n("Choose export type:")); | 97 | d->ui->promptLabel->setText(i18n("Choose export type:")); | ||
66 | setWindowTitle(i18n("Choose Export Type Dialog")); | 98 | setWindowTitle(i18n("Choose Export Type Dialog")); | ||
67 | } | 99 | } | ||
68 | 100 | | |||
69 | readConfig(); | 101 | d->readConfig(); | ||
70 | slotTypeActivated(m_lastType); | 102 | slotTypeActivated(d->m_lastType); | ||
71 | d->ui.typeCombo->setCurrentItem(((m_lastType == "QIF") ? i18n("QIF") : i18n("CSV")), false); | 103 | d->ui->typeCombo->setCurrentItem(((d->m_lastType == "QIF") ? i18n("QIF") : i18n("CSV")), false); | ||
72 | 104 | | |||
73 | connect(d->ui.typeCombo, SIGNAL(activated(QString)), this, SLOT(slotTypeActivated(QString))); | 105 | connect(d->ui->typeCombo, static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::activated), this, &KChooseImportExportDlg::slotTypeActivated); | ||
74 | connect(d->ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept())); | | |||
75 | connect(d->ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject())); | | |||
76 | } | 106 | } | ||
77 | 107 | | |||
78 | KChooseImportExportDlg::~KChooseImportExportDlg() | 108 | KChooseImportExportDlg::~KChooseImportExportDlg() | ||
79 | { | 109 | { | ||
80 | writeConfig(); | 110 | Q_D(KChooseImportExportDlg); | ||
111 | d->writeConfig(); | ||||
81 | delete d; | 112 | delete d; | ||
82 | } | 113 | } | ||
83 | 114 | | |||
84 | void KChooseImportExportDlg::slotTypeActivated(const QString& text) | 115 | void KChooseImportExportDlg::slotTypeActivated(const QString& text) | ||
85 | { | 116 | { | ||
117 | Q_D(KChooseImportExportDlg); | ||||
86 | if (text == "QIF") { | 118 | if (text == "QIF") { | ||
87 | d->ui.descriptionLabel->setText(i18n("QIF files are created by the popular accounting program Quicken.\n" | 119 | d->ui->descriptionLabel->setText(i18n("QIF files are created by the popular accounting program Quicken.\n" | ||
88 | "Another dialog will appear, if you choose this type, asking for further\n" | 120 | "Another dialog will appear, if you choose this type, asking for further\n" | ||
89 | "information relevant to the Quicken format.")); | 121 | "information relevant to the Quicken format.")); | ||
90 | } else { | 122 | } else { | ||
91 | d->ui.descriptionLabel->setText(i18n("The CSV type uses a comma delimited text file that can be used by\n" | 123 | d->ui->descriptionLabel->setText(i18n("The CSV type uses a comma delimited text file that can be used by\n" | ||
92 | "most popular spreadsheet programs available for Linux and other operating\n" | 124 | "most popular spreadsheet programs available for Linux and other operating\n" | ||
93 | "systems.")); | 125 | "systems.")); | ||
94 | } | 126 | } | ||
95 | } | 127 | } | ||
96 | 128 | | |||
97 | QString KChooseImportExportDlg::importExportType() | 129 | QString KChooseImportExportDlg::importExportType() const | ||
98 | { | | |||
99 | return d->ui.typeCombo->currentText(); | | |||
100 | } | | |||
101 | | ||||
102 | void KChooseImportExportDlg::readConfig() | | |||
103 | { | | |||
104 | KSharedConfigPtr config = KSharedConfig::openConfig(); | | |||
105 | KConfigGroup grp = config->group("Last Use Settings"); | | |||
106 | m_lastType = grp.readEntry("KChooseImportExportDlg_LastType"); | | |||
107 | } | | |||
108 | | ||||
109 | void KChooseImportExportDlg::writeConfig() | | |||
110 | { | 130 | { | ||
111 | KSharedConfigPtr config = KSharedConfig::openConfig(); | 131 | Q_D(const KChooseImportExportDlg); | ||
112 | KConfigGroup grp = config->group("Last Use Settings"); | 132 | return d->ui->typeCombo->currentText(); | ||
113 | grp.writeEntry("KChooseImportExportDlg_LastType", d->ui.typeCombo->currentText()); | | |||
114 | config->sync(); | | |||
115 | } | 133 | } | ||
Context not available. |