Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/csv/export/csvexporterplugin.cpp
Show All 23 Lines | |||||
24 | 24 | | |||
25 | #include <QUrl> | 25 | #include <QUrl> | ||
26 | 26 | | |||
27 | // ---------------------------------------------------------------------------- | 27 | // ---------------------------------------------------------------------------- | ||
28 | // KDE Includes | 28 | // KDE Includes | ||
29 | 29 | | |||
30 | #include <KActionCollection> | 30 | #include <KActionCollection> | ||
31 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
32 | #include <KMessageBox> | ||||
33 | #include <KIO/StatJob> | ||||
32 | 34 | | |||
33 | // ---------------------------------------------------------------------------- | 35 | // ---------------------------------------------------------------------------- | ||
34 | // Project Includes | 36 | // Project Includes | ||
35 | 37 | | |||
36 | CsvExporterPlugin::CsvExporterPlugin() : | 38 | CsvExporterPlugin::CsvExporterPlugin() : | ||
37 | KMyMoneyPlugin::Plugin(nullptr, "csvexport"/*must be the same as X-KDE-PluginInfo-Name*/) | 39 | KMyMoneyPlugin::Plugin(nullptr, "csvexport"/*must be the same as X-KDE-PluginInfo-Name*/) | ||
38 | { | 40 | { | ||
39 | setComponentName("kmm_csvexport", i18n("CSV exporter")); | 41 | setComponentName("kmm_csvexport", i18n("CSV exporter")); | ||
Show All 29 Lines | 69 | writer->write(m_dlg->filename(), m_dlg->accountId(), | |||
69 | m_dlg->startDate(), m_dlg->endDate(), | 71 | m_dlg->startDate(), m_dlg->endDate(), | ||
70 | m_dlg->separator()); | 72 | m_dlg->separator()); | ||
71 | } | 73 | } | ||
72 | } | 74 | } | ||
73 | } | 75 | } | ||
74 | 76 | | |||
75 | bool CsvExporterPlugin::okToWriteFile(const QUrl &url) | 77 | bool CsvExporterPlugin::okToWriteFile(const QUrl &url) | ||
76 | { | 78 | { | ||
77 | Q_UNUSED(url) | | |||
78 | | ||||
79 | // check if the file exists and warn the user | 79 | // check if the file exists and warn the user | ||
80 | bool reallySaveFile = true; | 80 | bool reallySaveFile = true; | ||
81 | 81 | | |||
82 | // TODO: port this to KF5 (NetAccess) | 82 | bool fileExists = false; | ||
83 | #if 0 | 83 | | ||
84 | if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) { | 84 | if (url.isValid()) { | ||
85 | short int detailLevel = 0; // Lowest level: file/dir/symlink/none | ||||
86 | KIO::StatJob* statjob = KIO::stat(url, KIO::StatJob::SourceSide, detailLevel); | ||||
87 | bool noerror = statjob->exec(); | ||||
88 | if (noerror) { | ||||
89 | // We want a file | ||||
90 | fileExists = !statjob->statResult().isDir(); | ||||
91 | } | ||||
92 | } | ||||
93 | | ||||
94 | if (fileExists) { | ||||
85 | if (KMessageBox::warningYesNo(0, QString("<qt>") + i18n("The file <b>%1</b> already exists. Do you really want to overwrite it?", url.toDisplayString(QUrl::PreferLocalFile)) + QString("</qt>"), i18n("File already exists")) != KMessageBox::Yes) | 95 | if (KMessageBox::warningYesNo(0, QString("<qt>") + i18n("The file <b>%1</b> already exists. Do you really want to overwrite it?", url.toDisplayString(QUrl::PreferLocalFile)) + QString("</qt>"), i18n("File already exists")) != KMessageBox::Yes) | ||
86 | reallySaveFile = false; | 96 | reallySaveFile = false; | ||
87 | } | 97 | } | ||
88 | #endif | | |||
89 | return reallySaveFile; | 98 | return reallySaveFile; | ||
90 | } | 99 | } |