Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/csvimport/csvimporterplugin.cpp
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #include "csvimporterplugin.h" | 21 | #include "csvimporterplugin.h" | ||
22 | 22 | | |||
23 | // ---------------------------------------------------------------------------- | 23 | // ---------------------------------------------------------------------------- | ||
24 | // QT Includes | 24 | // QT Includes | ||
25 | 25 | | |||
26 | #include <QFile> | 26 | #include <QFile> | ||
27 | #include <QAction> | 27 | #include <QAction> | ||
28 | #include <QTextCodec> | ||||
29 | #include <QTextStream> | ||||
30 | #include <QMessageBox> | ||||
28 | 31 | | |||
29 | // ---------------------------------------------------------------------------- | 32 | // ---------------------------------------------------------------------------- | ||
30 | // KDE Includes | 33 | // KDE Includes | ||
31 | 34 | | |||
32 | #include <KActionCollection> | 35 | #include <KActionCollection> | ||
33 | #include <KLocalizedString> | 36 | #include <KMessageBox> | ||
34 | 37 | | |||
35 | // ---------------------------------------------------------------------------- | 38 | // ---------------------------------------------------------------------------- | ||
36 | // Project Includes | 39 | // Project Includes | ||
37 | 40 | | |||
38 | #include "mymoneystatementreader.h" | 41 | #include "mymoneystatementreader.h" | ||
39 | #include "mymoneystatement.h" | 42 | #include "mymoneystatement.h" | ||
40 | #include "csvwizard.h" | 43 | #include "mymoneyfile.h" | ||
41 | 44 | | |||
42 | CsvImporterPlugin::CsvImporterPlugin() : | 45 | CsvImporterPlugin::CsvImporterPlugin() : | ||
43 | KMyMoneyPlugin::Plugin(nullptr, "csvimport"/*must be the same as X-KDE-PluginInfo-Name*/) | 46 | KMyMoneyPlugin::Plugin(nullptr, "csvimport"/*must be the same as X-KDE-PluginInfo-Name*/) | ||
44 | { | 47 | { | ||
45 | setComponentName("kmm_csvimport", i18n("CSV importer")); | 48 | setComponentName("kmm_csvimport", i18n("CSV importer")); | ||
46 | setXMLFile("kmm_csvimport.rc"); | 49 | setXMLFile("kmm_csvimport.rc"); | ||
47 | createActions(); | 50 | createActions(); | ||
48 | // For information, announce that we have been loaded. | 51 | // For information, announce that we have been loaded. | ||
49 | qDebug("KMyMoney csvimport plugin loaded"); | 52 | qDebug("KMyMoney csvimport plugin loaded"); | ||
50 | } | 53 | } | ||
51 | 54 | | |||
52 | CsvImporterPlugin::~CsvImporterPlugin() | 55 | CsvImporterPlugin::~CsvImporterPlugin() | ||
53 | { | 56 | { | ||
54 | } | 57 | } | ||
55 | 58 | | |||
56 | void CsvImporterPlugin::createActions() | 59 | void CsvImporterPlugin::createActions() | ||
57 | { | 60 | { | ||
58 | m_action = actionCollection()->addAction("file_import_csv"); | 61 | m_action = actionCollection()->addAction("file_import_csv"); | ||
59 | m_action->setText(i18n("CSV...")); | 62 | m_action->setText(i18n("CSV...")); | ||
60 | connect(m_action, SIGNAL(triggered(bool)), this, SLOT(slotImportFile())); | 63 | connect(m_action, SIGNAL(triggered(bool)), this, SLOT(startWizardRun())); | ||
61 | } | 64 | } | ||
62 | 65 | | |||
63 | void CsvImporterPlugin::slotImportFile() | 66 | void CsvImporterPlugin::startWizardRun() | ||
64 | { | 67 | { | ||
65 | m_action->setEnabled(false); | 68 | m_action->setEnabled(false); | ||
66 | CSVWizard *csvImporter = new CSVWizard; | 69 | m_importer = new CSVImporter; | ||
67 | csvImporter->m_plugin = this; | 70 | m_wizard = new CSVWizard(this, m_importer); | ||
68 | csvImporter->init(); | 71 | m_silent = false; | ||
69 | 72 | connect(m_importer, SIGNAL(statementReady(MyMoneyStatement&)), this, SLOT(slotGetStatement(MyMoneyStatement&))); | |||
70 | connect(csvImporter, SIGNAL(statementReady(MyMoneyStatement&)), this, SLOT(slotGetStatement(MyMoneyStatement&))); | | |||
71 | m_action->setEnabled(false);// don't allow further plugins to start while this is open | 73 | m_action->setEnabled(false);// don't allow further plugins to start while this is open | ||
72 | } | 74 | } | ||
73 | 75 | | |||
74 | bool CsvImporterPlugin::slotGetStatement(MyMoneyStatement& s) | 76 | bool CsvImporterPlugin::slotGetStatement(MyMoneyStatement& s) | ||
75 | { | 77 | { | ||
76 | return statementInterface()->import(s); | 78 | bool ret = statementInterface()->import(s, m_silent); | ||
79 | delete m_importer; | ||||
80 | return ret; | ||||
77 | } | 81 | } | ||
78 | 82 | | |||
79 | #include "csvimporterplugin.moc" | 83 | #include "csvimporterplugin.moc" |