Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/kmymoneyutils.cpp
Show All 32 Lines | |||||
33 | #include <QWizard> | 33 | #include <QWizard> | ||
34 | #include <QAbstractButton> | 34 | #include <QAbstractButton> | ||
35 | #include <QPixmapCache> | 35 | #include <QPixmapCache> | ||
36 | #include <QIcon> | 36 | #include <QIcon> | ||
37 | #include <QPainter> | 37 | #include <QPainter> | ||
38 | #include <QBitArray> | 38 | #include <QBitArray> | ||
39 | #include <QRegularExpression> | 39 | #include <QRegularExpression> | ||
40 | #include <QRegularExpressionMatch> | 40 | #include <QRegularExpressionMatch> | ||
41 | #include <QTemporaryFile> | ||||
41 | 42 | | |||
42 | // ---------------------------------------------------------------------------- | 43 | // ---------------------------------------------------------------------------- | ||
43 | // KDE Headers | 44 | // KDE Headers | ||
44 | 45 | | |||
45 | #include <KColorScheme> | 46 | #include <KColorScheme> | ||
46 | #include <KLocalizedString> | 47 | #include <KLocalizedString> | ||
47 | #include <KGuiItem> | 48 | #include <KGuiItem> | ||
48 | #include <KXmlGuiWindow> | 49 | #include <KXmlGuiWindow> | ||
49 | #include <KMessageBox> | 50 | #include <KMessageBox> | ||
50 | #include <KStandardGuiItem> | 51 | #include <KStandardGuiItem> | ||
51 | #include <KIO/StatJob> | 52 | #include <KIO/StatJob> | ||
53 | #include <KIO/StoredTransferJob> | ||||
52 | 54 | | |||
53 | // ---------------------------------------------------------------------------- | 55 | // ---------------------------------------------------------------------------- | ||
54 | // Project Includes | 56 | // Project Includes | ||
55 | 57 | | |||
56 | #include "mymoneymoney.h" | 58 | #include "mymoneymoney.h" | ||
57 | #include "mymoneyexception.h" | 59 | #include "mymoneyexception.h" | ||
58 | #include "mymoneyfile.h" | 60 | #include "mymoneyfile.h" | ||
59 | #include "mymoneyaccount.h" | 61 | #include "mymoneyaccount.h" | ||
▲ Show 20 Lines • Show All 589 Lines • ▼ Show 20 Line(s) | 650 | if (noerror) { | |||
649 | // We want a file | 651 | // We want a file | ||
650 | fileExists = !statjob->statResult().isDir(); | 652 | fileExists = !statjob->statResult().isDir(); | ||
651 | } | 653 | } | ||
652 | statjob->kill(); | 654 | statjob->kill(); | ||
653 | } | 655 | } | ||
654 | return fileExists; | 656 | return fileExists; | ||
655 | } | 657 | } | ||
656 | 658 | | |||
659 | QString KMyMoneyUtils::downloadFile(const QUrl &url) | ||||
660 | { | ||||
661 | QString filename; | ||||
662 | KIO::StoredTransferJob *transferjob = KIO::storedGet (url); | ||||
663 | // KJobWidgets::setWindow(transferjob, this); | ||||
664 | if (! transferjob->exec()) { | ||||
665 | KMessageBox::detailedError(nullptr, | ||||
666 | i18n("Error while loading file '%1'.", url.url()), | ||||
667 | transferjob->errorString(), | ||||
668 | i18n("File access error")); | ||||
669 | return filename; | ||||
670 | } | ||||
671 | | ||||
672 | QTemporaryFile file; | ||||
673 | file.setAutoRemove(false); | ||||
674 | file.open(); | ||||
675 | file.write(transferjob->data()); | ||||
676 | filename = file.fileName(); | ||||
677 | file.close(); | ||||
678 | return filename; | ||||
679 | } | ||||
680 | | ||||
657 | bool KMyMoneyUtils::newPayee(const QString& newnameBase, QString& id) | 681 | bool KMyMoneyUtils::newPayee(const QString& newnameBase, QString& id) | ||
658 | { | 682 | { | ||
659 | bool doit = true; | 683 | bool doit = true; | ||
660 | 684 | | |||
661 | if (newnameBase != i18n("New Payee")) { | 685 | if (newnameBase != i18n("New Payee")) { | ||
662 | // Ask the user if that is what he intended to do? | 686 | // Ask the user if that is what he intended to do? | ||
663 | const auto msg = i18n("<qt>Do you want to add <b>%1</b> as payer/receiver?</qt>", newnameBase); | 687 | const auto msg = i18n("<qt>Do you want to add <b>%1</b> as payer/receiver?</qt>", newnameBase); | ||
664 | 688 | | |||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |