Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/kmymoney.cpp
Show First 20 Lines • Show All 214 Lines • ▼ Show 20 Line(s) | |||||
215 | { | 215 | { | ||
216 | public: | 216 | public: | ||
217 | Private(KMyMoneyApp *app) : | 217 | Private(KMyMoneyApp *app) : | ||
218 | q(app), | 218 | q(app), | ||
219 | m_ft(0), | 219 | m_ft(0), | ||
220 | m_moveToAccountSelector(0), | 220 | m_moveToAccountSelector(0), | ||
221 | m_statementXMLindex(0), | 221 | m_statementXMLindex(0), | ||
222 | m_balanceWarning(0), | 222 | m_balanceWarning(0), | ||
223 | m_collectingStatements(false), | | |||
224 | m_backupResult(0), | 223 | m_backupResult(0), | ||
225 | m_backupMount(0), | 224 | m_backupMount(0), | ||
226 | m_ignoreBackupExitCode(false), | 225 | m_ignoreBackupExitCode(false), | ||
227 | m_fileOpen(false), | 226 | m_fileOpen(false), | ||
228 | m_fmode(QFileDevice::ReadUser | QFileDevice::WriteUser), | 227 | m_fmode(QFileDevice::ReadUser | QFileDevice::WriteUser), | ||
229 | m_myMoneyView(0), | 228 | m_myMoneyView(0), | ||
230 | m_progressBar(0), | 229 | m_progressBar(0), | ||
231 | m_smtReader(0), | | |||
232 | m_searchDlg(0), | 230 | m_searchDlg(0), | ||
233 | m_autoSaveTimer(0), | 231 | m_autoSaveTimer(0), | ||
234 | m_progressTimer(0), | 232 | m_progressTimer(0), | ||
235 | m_inAutoSaving(false), | 233 | m_inAutoSaving(false), | ||
236 | m_transactionEditor(0), | 234 | m_transactionEditor(0), | ||
237 | m_endingBalanceDlg(0), | 235 | m_endingBalanceDlg(0), | ||
238 | m_saveEncrypted(0), | 236 | m_saveEncrypted(0), | ||
239 | m_additionalKeyLabel(0), | 237 | m_additionalKeyLabel(0), | ||
Show All 26 Lines | 262 | /** | |||
266 | */ | 264 | */ | ||
267 | KMyMoneyApp * const q; | 265 | KMyMoneyApp * const q; | ||
268 | 266 | | |||
269 | MyMoneyFileTransaction* m_ft; | 267 | MyMoneyFileTransaction* m_ft; | ||
270 | KMyMoneyAccountSelector* m_moveToAccountSelector; | 268 | KMyMoneyAccountSelector* m_moveToAccountSelector; | ||
271 | int m_statementXMLindex; | 269 | int m_statementXMLindex; | ||
272 | KBalanceWarning* m_balanceWarning; | 270 | KBalanceWarning* m_balanceWarning; | ||
273 | 271 | | |||
274 | bool m_collectingStatements; | | |||
275 | QStringList m_statementResults; | | |||
276 | QString m_lastPayeeEnteredId; | | |||
277 | | ||||
278 | /** the configuration object of the application */ | 272 | /** the configuration object of the application */ | ||
279 | KSharedConfigPtr m_config; | 273 | KSharedConfigPtr m_config; | ||
280 | 274 | | |||
281 | /** | 275 | /** | ||
282 | * @brief Structure of plugins objects by their interfaces | 276 | * @brief Structure of plugins objects by their interfaces | ||
283 | */ | 277 | */ | ||
284 | KMyMoneyPlugin::Container m_plugins; | 278 | KMyMoneyPlugin::Container m_plugins; | ||
285 | 279 | | |||
Show All 39 Lines | |||||
325 | 319 | | |||
326 | bool m_startDialog; | 320 | bool m_startDialog; | ||
327 | QString m_mountpoint; | 321 | QString m_mountpoint; | ||
328 | 322 | | |||
329 | QProgressBar* m_progressBar; | 323 | QProgressBar* m_progressBar; | ||
330 | QTime m_lastUpdate; | 324 | QTime m_lastUpdate; | ||
331 | QLabel* m_statusLabel; | 325 | QLabel* m_statusLabel; | ||
332 | 326 | | |||
333 | MyMoneyStatementReader* m_smtReader; | | |||
334 | // allows multiple imports to be launched trough web connect and to be executed sequentially | 327 | // allows multiple imports to be launched trough web connect and to be executed sequentially | ||
335 | QQueue<QString> m_importUrlsQueue; | 328 | QQueue<QString> m_importUrlsQueue; | ||
336 | KFindTransactionDlg* m_searchDlg; | 329 | KFindTransactionDlg* m_searchDlg; | ||
337 | 330 | | |||
338 | MyMoneyAccount m_selectedAccount; | | |||
339 | MyMoneyAccount m_reconciliationAccount; | | |||
340 | MyMoneySchedule m_selectedSchedule; | | |||
341 | KMyMoneyRegister::SelectedTransactions m_selectedTransactions; | | |||
342 | | ||||
343 | // This is Auto Saving related | 331 | // This is Auto Saving related | ||
344 | bool m_autoSaveEnabled; | 332 | bool m_autoSaveEnabled; | ||
345 | QTimer* m_autoSaveTimer; | 333 | QTimer* m_autoSaveTimer; | ||
346 | QTimer* m_progressTimer; | 334 | QTimer* m_progressTimer; | ||
347 | int m_autoSavePeriod; | 335 | int m_autoSavePeriod; | ||
348 | bool m_inAutoSaving; | 336 | bool m_inAutoSaving; | ||
349 | 337 | | |||
350 | // pointer to the current transaction editor | 338 | // pointer to the current transaction editor | ||
▲ Show 20 Lines • Show All 1685 Lines • ▼ Show 20 Line(s) | 2019 | #endif | |||
2036 | {Action::EditFindTransaction, &KMyMoneyApp::slotFindTransaction}, | 2024 | {Action::EditFindTransaction, &KMyMoneyApp::slotFindTransaction}, | ||
2037 | // ************* | 2025 | // ************* | ||
2038 | // The View menu | 2026 | // The View menu | ||
2039 | // ************* | 2027 | // ************* | ||
2040 | {Action::ViewTransactionDetail, &KMyMoneyApp::slotShowTransactionDetail}, | 2028 | {Action::ViewTransactionDetail, &KMyMoneyApp::slotShowTransactionDetail}, | ||
2041 | {Action::ViewHideReconciled, &KMyMoneyApp::slotHideReconciledTransactions}, | 2029 | {Action::ViewHideReconciled, &KMyMoneyApp::slotHideReconciledTransactions}, | ||
2042 | {Action::ViewHideCategories, &KMyMoneyApp::slotHideUnusedCategories}, | 2030 | {Action::ViewHideCategories, &KMyMoneyApp::slotHideUnusedCategories}, | ||
2043 | {Action::ViewShowAll, &KMyMoneyApp::slotShowAllAccounts}, | 2031 | {Action::ViewShowAll, &KMyMoneyApp::slotShowAllAccounts}, | ||
2044 | // ***************** | | |||
2045 | // The accounts menu | | |||
2046 | // ***************** | | |||
2047 | {Action::MapOnlineAccount, &KMyMoneyApp::slotAccountMapOnline}, | | |||
2048 | {Action::UnmapOnlineAccount, &KMyMoneyApp::slotAccountUnmapOnline}, | | |||
2049 | {Action::UpdateAccount, &KMyMoneyApp::slotAccountUpdateOnline}, | | |||
2050 | {Action::UpdateAllAccounts, &KMyMoneyApp::slotAccountUpdateOnlineAll}, | | |||
2051 | // ************** | 2032 | // ************** | ||
2052 | // The tools menu | 2033 | // The tools menu | ||
2053 | // ************** | 2034 | // ************** | ||
2054 | {Action::ToolCurrencies, &KMyMoneyApp::slotCurrencyDialog}, | 2035 | {Action::ToolCurrencies, &KMyMoneyApp::slotCurrencyDialog}, | ||
2055 | {Action::ToolPrices, &KMyMoneyApp::slotPriceDialog}, | 2036 | {Action::ToolPrices, &KMyMoneyApp::slotPriceDialog}, | ||
2056 | {Action::ToolUpdatePrices, &KMyMoneyApp::slotEquityPriceUpdate}, | 2037 | {Action::ToolUpdatePrices, &KMyMoneyApp::slotEquityPriceUpdate}, | ||
2057 | {Action::ToolConsistency, &KMyMoneyApp::slotFileConsistencyCheck}, | 2038 | {Action::ToolConsistency, &KMyMoneyApp::slotFileConsistencyCheck}, | ||
2058 | {Action::ToolPerformance, &KMyMoneyApp::slotPerformanceTest}, | 2039 | {Action::ToolPerformance, &KMyMoneyApp::slotPerformanceTest}, | ||
▲ Show 20 Lines • Show All 1686 Lines • ▼ Show 20 Line(s) | |||||
3745 | { | 3726 | { | ||
3746 | const auto file = MyMoneyFile::instance(); | 3727 | const auto file = MyMoneyFile::instance(); | ||
3747 | const bool fileOpen = d->m_fileOpen; | 3728 | const bool fileOpen = d->m_fileOpen; | ||
3748 | const bool modified = file->dirty(); | 3729 | const bool modified = file->dirty(); | ||
3749 | // const bool importRunning = (d->m_smtReader != 0); | 3730 | // const bool importRunning = (d->m_smtReader != 0); | ||
3750 | auto aC = actionCollection(); | 3731 | auto aC = actionCollection(); | ||
3751 | 3732 | | |||
3752 | // ************* | 3733 | // ************* | ||
3753 | // Disabling actions to be disabled at this point | | |||
3754 | // ************* | | |||
3755 | { | | |||
3756 | static const QVector<Action> disabledActions { | | |||
3757 | Action::UpdateAllAccounts | | |||
3758 | }; | | |||
3759 | | ||||
3760 | for (const auto& a : disabledActions) | | |||
3761 | pActions[a]->setEnabled(false); | | |||
3762 | } | | |||
3763 | | ||||
3764 | // ************* | | |||
3765 | // Disabling actions based on conditions | 3734 | // Disabling actions based on conditions | ||
3766 | // ************* | 3735 | // ************* | ||
3767 | { | 3736 | { | ||
3768 | QString tooltip = i18n("Create a new transaction"); | 3737 | QString tooltip = i18n("Create a new transaction"); | ||
3769 | const QVector<QPair<Action, bool>> actionStates { | 3738 | const QVector<QPair<Action, bool>> actionStates { | ||
3770 | // {qMakePair(Action::FileOpenDatabase, true)}, | 3739 | // {qMakePair(Action::FileOpenDatabase, true)}, | ||
3771 | // {qMakePair(Action::FileSaveAsDatabase, fileOpen)}, | 3740 | // {qMakePair(Action::FileSaveAsDatabase, fileOpen)}, | ||
3772 | {qMakePair(Action::FilePersonalData, fileOpen)}, | 3741 | {qMakePair(Action::FilePersonalData, fileOpen)}, | ||
Show All 24 Lines | 3760 | // {qMakePair(Action::PriceNew, fileOpen)}, | |||
3797 | 3766 | | |||
3798 | // ************* | 3767 | // ************* | ||
3799 | // Disabling standard actions based on conditions | 3768 | // Disabling standard actions based on conditions | ||
3800 | // ************* | 3769 | // ************* | ||
3801 | aC->action(QString::fromLatin1(KStandardAction::name(KStandardAction::Save)))->setEnabled(modified /*&& !d->m_myMoneyView->isDatabase()*/); | 3770 | aC->action(QString::fromLatin1(KStandardAction::name(KStandardAction::Save)))->setEnabled(modified /*&& !d->m_myMoneyView->isDatabase()*/); | ||
3802 | aC->action(QString::fromLatin1(KStandardAction::name(KStandardAction::SaveAs)))->setEnabled(fileOpen); | 3771 | aC->action(QString::fromLatin1(KStandardAction::name(KStandardAction::SaveAs)))->setEnabled(fileOpen); | ||
3803 | aC->action(QString::fromLatin1(KStandardAction::name(KStandardAction::Close)))->setEnabled(fileOpen); | 3772 | aC->action(QString::fromLatin1(KStandardAction::name(KStandardAction::Close)))->setEnabled(fileOpen); | ||
3804 | aC->action(QString::fromLatin1(KStandardAction::name(KStandardAction::Print)))->setEnabled(fileOpen && d->m_myMoneyView->canPrint()); | 3773 | aC->action(QString::fromLatin1(KStandardAction::name(KStandardAction::Print)))->setEnabled(fileOpen && d->m_myMoneyView->canPrint()); | ||
3805 | | ||||
3806 | // ************* | | |||
3807 | // Enabling actions based on conditions | | |||
3808 | // ************* | | |||
3809 | QList<MyMoneyAccount> accList; | | |||
3810 | file->accountList(accList); | | |||
3811 | QList<MyMoneyAccount>::const_iterator it_a; | | |||
3812 | QMap<QString, KMyMoneyPlugin::OnlinePlugin*>::const_iterator it_p = d->m_plugins.online.constEnd(); | | |||
3813 | for (it_a = accList.constBegin(); (it_p == d->m_plugins.online.constEnd()) && (it_a != accList.constEnd()); ++it_a) { | | |||
3814 | if ((*it_a).hasOnlineMapping()) { | | |||
3815 | // check if provider is available | | |||
3816 | it_p = d->m_plugins.online.constFind((*it_a).onlineBankingSettings().value("provider").toLower()); | | |||
3817 | if (it_p != d->m_plugins.online.constEnd()) { | | |||
3818 | QStringList protocols; | | |||
3819 | (*it_p)->protocols(protocols); | | |||
3820 | if (protocols.count() > 0) { | | |||
3821 | pActions[Action::UpdateAllAccounts]->setEnabled(true); | | |||
3822 | } | | |||
3823 | } | | |||
3824 | } | | |||
3825 | } | | |||
3826 | } | 3774 | } | ||
3827 | 3775 | | |||
3828 | void KMyMoneyApp::slotResetSelections() | 3776 | void KMyMoneyApp::slotResetSelections() | ||
3829 | { | 3777 | { | ||
3830 | slotSelectAccount(MyMoneyAccount()); | | |||
3831 | d->m_myMoneyView->slotObjectSelected(MyMoneyAccount()); | 3778 | d->m_myMoneyView->slotObjectSelected(MyMoneyAccount()); | ||
3832 | d->m_myMoneyView->slotObjectSelected(MyMoneyInstitution()); | 3779 | d->m_myMoneyView->slotObjectSelected(MyMoneyInstitution()); | ||
3833 | d->m_myMoneyView->slotObjectSelected(MyMoneySchedule()); | 3780 | d->m_myMoneyView->slotObjectSelected(MyMoneySchedule()); | ||
3834 | d->m_myMoneyView->slotObjectSelected(MyMoneyTag()); | 3781 | d->m_myMoneyView->slotObjectSelected(MyMoneyTag()); | ||
3835 | d->m_myMoneyView->slotTransactionsSelected(KMyMoneyRegister::SelectedTransactions()); | 3782 | d->m_myMoneyView->slotTransactionsSelected(KMyMoneyRegister::SelectedTransactions()); | ||
3836 | slotUpdateActions(); | 3783 | slotUpdateActions(); | ||
3837 | } | 3784 | } | ||
3838 | 3785 | | |||
3839 | void KMyMoneyApp::slotSelectAccount(const MyMoneyObject& obj) | | |||
3840 | { | | |||
3841 | if (typeid(obj) != typeid(MyMoneyAccount)) | | |||
3842 | return; | | |||
3843 | | ||||
3844 | d->m_selectedAccount = MyMoneyAccount(); | | |||
3845 | const MyMoneyAccount& acc = dynamic_cast<const MyMoneyAccount&>(obj); | | |||
3846 | if (!acc.isInvest()) | | |||
3847 | d->m_selectedAccount = acc; | | |||
3848 | | ||||
3849 | // qDebug("slotSelectAccount('%s')", d->m_selectedAccount.name().data()); | | |||
3850 | slotUpdateActions(); | | |||
3851 | emit accountSelected(d->m_selectedAccount); | | |||
3852 | } | | |||
3853 | | ||||
3854 | void KMyMoneyApp::slotDataChanged() | 3786 | void KMyMoneyApp::slotDataChanged() | ||
3855 | { | 3787 | { | ||
3856 | // As this method is called every time the MyMoneyFile instance | 3788 | // As this method is called every time the MyMoneyFile instance | ||
3857 | // notifies a modification, it's the perfect place to start the timer if needed | 3789 | // notifies a modification, it's the perfect place to start the timer if needed | ||
3858 | if (d->m_autoSaveEnabled && !d->m_autoSaveTimer->isActive()) { | 3790 | if (d->m_autoSaveEnabled && !d->m_autoSaveTimer->isActive()) { | ||
3859 | d->m_autoSaveTimer->setSingleShot(true); | 3791 | d->m_autoSaveTimer->setSingleShot(true); | ||
3860 | d->m_autoSaveTimer->start(d->m_autoSavePeriod * 60 * 1000); //miliseconds | 3792 | d->m_autoSaveTimer->start(d->m_autoSavePeriod * 60 * 1000); //miliseconds | ||
3861 | } | 3793 | } | ||
▲ Show 20 Lines • Show All 393 Lines • ▼ Show 20 Line(s) | 4185 | { | |||
4255 | QDateTime nextDay(QDate(dt.date().addDays(1)), QTime(0, 0, 0)); | 4187 | QDateTime nextDay(QDate(dt.date().addDays(1)), QTime(0, 0, 0)); | ||
4256 | 4188 | | |||
4257 | // +1 is to make sure that we're already in the next day when the | 4189 | // +1 is to make sure that we're already in the next day when the | ||
4258 | // signal is sent (this way we also avoid setting the timer to 0) | 4190 | // signal is sent (this way we also avoid setting the timer to 0) | ||
4259 | QTimer::singleShot((dt.secsTo(nextDay) + 1)*1000, this, SLOT(slotDateChanged())); | 4191 | QTimer::singleShot((dt.secsTo(nextDay) + 1)*1000, this, SLOT(slotDateChanged())); | ||
4260 | d->m_myMoneyView->slotRefreshViews(); | 4192 | d->m_myMoneyView->slotRefreshViews(); | ||
4261 | } | 4193 | } | ||
4262 | 4194 | | |||
4263 | void KMyMoneyApp::slotOnlineAccountRequested(const MyMoneyAccount& acc, eMenu::Action action) | | |||
4264 | { | | |||
4265 | d->m_selectedAccount = acc; | | |||
4266 | switch (action) { | | |||
4267 | case eMenu::Action::UnmapOnlineAccount: | | |||
4268 | slotAccountUnmapOnline(); | | |||
4269 | break; | | |||
4270 | case eMenu::Action::MapOnlineAccount: | | |||
4271 | slotAccountMapOnline(); | | |||
4272 | break; | | |||
4273 | case eMenu::Action::UpdateAccount: | | |||
4274 | slotAccountUpdateOnline(); | | |||
4275 | break; | | |||
4276 | case eMenu::Action::UpdateAllAccounts: | | |||
4277 | slotAccountUpdateOnlineAll(); | | |||
4278 | break; | | |||
4279 | default: | | |||
4280 | break; | | |||
4281 | } | | |||
4282 | } | | |||
4283 | | ||||
4284 | void KMyMoneyApp::slotAccountUnmapOnline() | | |||
4285 | { | | |||
4286 | // no account selected | | |||
4287 | if (d->m_selectedAccount.id().isEmpty()) | | |||
4288 | return; | | |||
4289 | | ||||
4290 | // not a mapped account | | |||
4291 | if (!d->m_selectedAccount.hasOnlineMapping()) | | |||
4292 | return; | | |||
4293 | | ||||
4294 | if (KMessageBox::warningYesNo(this, QString("<qt>%1</qt>").arg(i18n("Do you really want to remove the mapping of account <b>%1</b> to an online account? Depending on the details of the online banking method used, this action cannot be reverted.", d->m_selectedAccount.name())), i18n("Remove mapping to online account")) == KMessageBox::Yes) { | | |||
4295 | MyMoneyFileTransaction ft; | | |||
4296 | try { | | |||
4297 | d->m_selectedAccount.setOnlineBankingSettings(MyMoneyKeyValueContainer()); | | |||
4298 | // delete the kvp that is used in MyMoneyStatementReader too | | |||
4299 | // we should really get rid of it, but since I don't know what it | | |||
4300 | // is good for, I'll keep it around. (ipwizard) | | |||
4301 | d->m_selectedAccount.deletePair("StatementKey"); | | |||
4302 | MyMoneyFile::instance()->modifyAccount(d->m_selectedAccount); | | |||
4303 | ft.commit(); | | |||
4304 | // The mapping could disable the online task system | | |||
4305 | onlineJobAdministration::instance()->updateOnlineTaskProperties(); | | |||
4306 | } catch (const MyMoneyException &e) { | | |||
4307 | KMessageBox::error(this, i18n("Unable to unmap account from online account: %1", e.what())); | | |||
4308 | } | | |||
4309 | } | | |||
4310 | } | | |||
4311 | | ||||
4312 | void KMyMoneyApp::slotAccountMapOnline() | | |||
4313 | { | | |||
4314 | // no account selected | | |||
4315 | if (d->m_selectedAccount.id().isEmpty()) | | |||
4316 | return; | | |||
4317 | | ||||
4318 | // already an account mapped | | |||
4319 | if (d->m_selectedAccount.hasOnlineMapping()) | | |||
4320 | return; | | |||
4321 | | ||||
4322 | // check if user tries to map a brokerageAccount | | |||
4323 | if (d->m_selectedAccount.name().contains(i18n(" (Brokerage)"))) { | | |||
4324 | if (KMessageBox::warningContinueCancel(this, i18n("You try to map a brokerage account to an online account. This is usually not advisable. In general, the investment account should be mapped to the online account. Please cancel if you intended to map the investment account, continue otherwise"), i18n("Mapping brokerage account")) == KMessageBox::Cancel) { | | |||
4325 | return; | | |||
4326 | } | | |||
4327 | } | | |||
4328 | | ||||
4329 | // if we have more than one provider let the user select the current provider | | |||
4330 | QString provider; | | |||
4331 | QMap<QString, KMyMoneyPlugin::OnlinePlugin*>::const_iterator it_p; | | |||
4332 | switch (d->m_plugins.online.count()) { | | |||
4333 | case 0: | | |||
4334 | break; | | |||
4335 | case 1: | | |||
4336 | provider = d->m_plugins.online.begin().key(); | | |||
4337 | break; | | |||
4338 | default: { | | |||
4339 | QMenu popup(this); | | |||
4340 | popup.setTitle(i18n("Select online banking plugin")); | | |||
4341 | | ||||
4342 | // Populate the pick list with all the provider | | |||
4343 | for (it_p = d->m_plugins.online.constBegin(); it_p != d->m_plugins.online.constEnd(); ++it_p) { | | |||
4344 | popup.addAction(it_p.key())->setData(it_p.key()); | | |||
4345 | } | | |||
4346 | | ||||
4347 | QAction *item = popup.actions()[0]; | | |||
4348 | if (item) { | | |||
4349 | popup.setActiveAction(item); | | |||
4350 | } | | |||
4351 | | ||||
4352 | // cancelled | | |||
4353 | if ((item = popup.exec(QCursor::pos(), item)) == 0) { | | |||
4354 | return; | | |||
4355 | } | | |||
4356 | | ||||
4357 | provider = item->data().toString(); | | |||
4358 | } | | |||
4359 | break; | | |||
4360 | } | | |||
4361 | | ||||
4362 | if (provider.isEmpty()) | | |||
4363 | return; | | |||
4364 | | ||||
4365 | // find the provider | | |||
4366 | it_p = d->m_plugins.online.constFind(provider.toLower()); | | |||
4367 | if (it_p != d->m_plugins.online.constEnd()) { | | |||
4368 | // plugin found, call it | | |||
4369 | MyMoneyKeyValueContainer settings; | | |||
4370 | if ((*it_p)->mapAccount(d->m_selectedAccount, settings)) { | | |||
4371 | settings["provider"] = provider.toLower(); | | |||
4372 | MyMoneyAccount acc(d->m_selectedAccount); | | |||
4373 | acc.setOnlineBankingSettings(settings); | | |||
4374 | MyMoneyFileTransaction ft; | | |||
4375 | try { | | |||
4376 | MyMoneyFile::instance()->modifyAccount(acc); | | |||
4377 | ft.commit(); | | |||
4378 | // The mapping could enable the online task system | | |||
4379 | onlineJobAdministration::instance()->updateOnlineTaskProperties(); | | |||
4380 | } catch (const MyMoneyException &e) { | | |||
4381 | KMessageBox::error(this, i18n("Unable to map account to online account: %1", e.what())); | | |||
4382 | } | | |||
4383 | } | | |||
4384 | } | | |||
4385 | } | | |||
4386 | | ||||
4387 | void KMyMoneyApp::slotAccountUpdateOnlineAll() | | |||
4388 | { | | |||
4389 | QList<MyMoneyAccount> accList; | | |||
4390 | MyMoneyFile::instance()->accountList(accList); | | |||
4391 | QList<MyMoneyAccount>::iterator it_a; | | |||
4392 | QMap<QString, KMyMoneyPlugin::OnlinePlugin*>::const_iterator it_p; | | |||
4393 | d->m_statementResults.clear(); | | |||
4394 | d->m_collectingStatements = true; | | |||
4395 | | ||||
4396 | // remove all those from the list, that don't have a 'provider' or the | | |||
4397 | // provider is not currently present | | |||
4398 | for (it_a = accList.begin(); it_a != accList.end();) { | | |||
4399 | if (!(*it_a).hasOnlineMapping() | | |||
4400 | || d->m_plugins.online.find((*it_a).onlineBankingSettings().value("provider").toLower()) == d->m_plugins.online.end()) { | | |||
4401 | it_a = accList.erase(it_a); | | |||
4402 | } else | | |||
4403 | ++it_a; | | |||
4404 | } | | |||
4405 | const QVector<Action> disabledActions {Action::UpdateAccount, Action::UpdateAllAccounts}; | | |||
4406 | for (const auto& a : disabledActions) | | |||
4407 | pActions[a]->setEnabled(false); | | |||
4408 | | ||||
4409 | // now work on the remaining list of accounts | | |||
4410 | int cnt = accList.count() - 1; | | |||
4411 | for (it_a = accList.begin(); it_a != accList.end(); ++it_a) { | | |||
4412 | it_p = d->m_plugins.online.constFind((*it_a).onlineBankingSettings().value("provider").toLower()); | | |||
4413 | (*it_p)->updateAccount(*it_a, cnt != 0); | | |||
4414 | --cnt; | | |||
4415 | } | | |||
4416 | | ||||
4417 | d->m_collectingStatements = false; | | |||
4418 | if (!d->m_statementResults.isEmpty()) | | |||
4419 | KMessageBox::informationList(this, i18n("The statements have been processed with the following results:"), d->m_statementResults, i18n("Statement stats")); | | |||
4420 | | ||||
4421 | // re-enable the disabled actions | | |||
4422 | slotUpdateActions(); | | |||
4423 | } | | |||
4424 | | ||||
4425 | void KMyMoneyApp::slotAccountUpdateOnline() | | |||
4426 | { | | |||
4427 | // no account selected | | |||
4428 | if (d->m_selectedAccount.id().isEmpty()) | | |||
4429 | return; | | |||
4430 | | ||||
4431 | // no online account mapped | | |||
4432 | if (!d->m_selectedAccount.hasOnlineMapping()) | | |||
4433 | return; | | |||
4434 | | ||||
4435 | const QVector<Action> disabledActions {Action::UpdateAccount, Action::UpdateAllAccounts}; | | |||
4436 | for (const auto& a : disabledActions) | | |||
4437 | pActions[a]->setEnabled(false); | | |||
4438 | | ||||
4439 | // find the provider | | |||
4440 | QMap<QString, KMyMoneyPlugin::OnlinePlugin*>::const_iterator it_p; | | |||
4441 | it_p = d->m_plugins.online.constFind(d->m_selectedAccount.onlineBankingSettings().value("provider").toLower()); | | |||
4442 | if (it_p != d->m_plugins.online.constEnd()) { | | |||
4443 | // plugin found, call it | | |||
4444 | d->m_collectingStatements = true; | | |||
4445 | d->m_statementResults.clear(); | | |||
4446 | (*it_p)->updateAccount(d->m_selectedAccount); | | |||
4447 | d->m_collectingStatements = false; | | |||
4448 | if (!d->m_statementResults.isEmpty()) | | |||
4449 | KMessageBox::informationList(this, i18n("The statements have been processed with the following results:"), d->m_statementResults, i18n("Statement stats")); | | |||
4450 | } | | |||
4451 | | ||||
4452 | // re-enable the disabled actions | | |||
4453 | slotUpdateActions(); | | |||
4454 | } | | |||
4455 | | ||||
4456 | void KMyMoneyApp::setHolidayRegion(const QString& holidayRegion) | 4195 | void KMyMoneyApp::setHolidayRegion(const QString& holidayRegion) | ||
4457 | { | 4196 | { | ||
4458 | #ifdef KF5Holidays_FOUND | 4197 | #ifdef KF5Holidays_FOUND | ||
4459 | //since the cost of updating the cache is now not negligible | 4198 | //since the cost of updating the cache is now not negligible | ||
4460 | //check whether the region has been modified | 4199 | //check whether the region has been modified | ||
4461 | if (!d->m_holidayRegion || d->m_holidayRegion->regionCode() != holidayRegion) { | 4200 | if (!d->m_holidayRegion || d->m_holidayRegion->regionCode() != holidayRegion) { | ||
4462 | // Delete the previous holidayRegion before creating a new one. | 4201 | // Delete the previous holidayRegion before creating a new one. | ||
4463 | delete d->m_holidayRegion; | 4202 | delete d->m_holidayRegion; | ||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 4284 | for (uint i = 0; i < d.count(); ++i) { | |||
4546 | qDebug("Remove %s", qPrintable(d[i])); | 4285 | qDebug("Remove %s", qPrintable(d[i])); | ||
4547 | d.remove(KMyMoneySettings::logPath() + QString("/%1").arg(d[i])); | 4286 | d.remove(KMyMoneySettings::logPath() + QString("/%1").arg(d[i])); | ||
4548 | } | 4287 | } | ||
4549 | m_statementXMLindex = 0; | 4288 | m_statementXMLindex = 0; | ||
4550 | } | 4289 | } | ||
4551 | 4290 | | |||
4552 | void KMyMoneyApp::Private::closeFile() | 4291 | void KMyMoneyApp::Private::closeFile() | ||
4553 | { | 4292 | { | ||
4554 | q->slotSelectAccount(MyMoneyAccount()); | | |||
4555 | q->d->m_myMoneyView->slotObjectSelected(MyMoneyAccount()); | 4293 | q->d->m_myMoneyView->slotObjectSelected(MyMoneyAccount()); | ||
4556 | q->d->m_myMoneyView->slotObjectSelected(MyMoneyInstitution()); | 4294 | q->d->m_myMoneyView->slotObjectSelected(MyMoneyInstitution()); | ||
4557 | q->d->m_myMoneyView->slotObjectSelected(MyMoneySchedule()); | 4295 | q->d->m_myMoneyView->slotObjectSelected(MyMoneySchedule()); | ||
4558 | q->d->m_myMoneyView->slotObjectSelected(MyMoneyTag()); | 4296 | q->d->m_myMoneyView->slotObjectSelected(MyMoneyTag()); | ||
4559 | q->d->m_myMoneyView->slotTransactionsSelected(KMyMoneyRegister::SelectedTransactions()); | 4297 | q->d->m_myMoneyView->slotTransactionsSelected(KMyMoneyRegister::SelectedTransactions()); | ||
4560 | // q->slotSelectTransactions(KMyMoneyRegister::SelectedTransactions()); | | |||
4561 | 4298 | | |||
4562 | m_reconciliationAccount = MyMoneyAccount(); | | |||
4563 | m_myMoneyView->finishReconciliation(MyMoneyAccount()); | 4299 | m_myMoneyView->finishReconciliation(MyMoneyAccount()); | ||
4564 | 4300 | | |||
4565 | m_myMoneyView->slotFileClosed(); | 4301 | m_myMoneyView->slotFileClosed(); | ||
4566 | 4302 | | |||
4567 | disconnectStorageFromModels(); | 4303 | disconnectStorageFromModels(); | ||
4568 | 4304 | | |||
4569 | // notify the models that the file is going to be closed (we should have something like dataChanged that reaches the models first) | 4305 | // notify the models that the file is going to be closed (we should have something like dataChanged that reaches the models first) | ||
4570 | Models::instance()->fileClosed(); | 4306 | Models::instance()->fileClosed(); | ||
Show All 18 Lines |