diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -120,6 +120,8 @@
set(KMM_ADDRESSBOOK_FOUND true)
endif()
+option(ENABLE_FORECASTVIEW "Enable forecast view" ON)
+
CMAKE_DEPENDENT_OPTION(ENABLE_SQLSTORAGE "Enable SQL storage support." ON
"Qt5Sql_FOUND" OFF)
diff --git a/kmymoney/CMakeLists.txt b/kmymoney/CMakeLists.txt
--- a/kmymoney/CMakeLists.txt
+++ b/kmymoney/CMakeLists.txt
@@ -56,6 +56,7 @@
########### settings code (kmm_config) STATIC ###############
set( kmm_config_SRCS kmymoneyglobalsettings.cpp )
kconfig_add_kcfg_files( kmm_config_SRCS kmymoneysettings.kcfgc )
+kconfig_add_kcfg_files( kmm_config_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/plugins/forecast/forecastviewsettings.kcfgc )
add_library(kmm_config STATIC ${kmm_config_SRCS})
target_link_libraries(kmm_config KF5::WidgetsAddons KF5::ConfigWidgets Qt5::Sql Alkimia::alkimia)
diff --git a/kmymoney/dialogs/settings/CMakeLists.txt b/kmymoney/dialogs/settings/CMakeLists.txt
--- a/kmymoney/dialogs/settings/CMakeLists.txt
+++ b/kmymoney/dialogs/settings/CMakeLists.txt
@@ -3,7 +3,6 @@
ksettingscolors.cpp
ksettingsfonts.cpp
ksettingsicons.cpp
- ksettingsforecast.cpp
ksettingsgeneral.cpp
ksettingsgpg.cpp
ksettingshome.cpp
@@ -19,7 +18,6 @@
ksettingscolors.ui
ksettingsfonts.ui
ksettingsicons.ui
- ksettingsforecast.ui
ksettingsgeneral.ui
ksettingsgpg.ui
ksettingshome.ui
diff --git a/kmymoney/dialogs/settings/ksettingskmymoney.cpp b/kmymoney/dialogs/settings/ksettingskmymoney.cpp
--- a/kmymoney/dialogs/settings/ksettingskmymoney.cpp
+++ b/kmymoney/dialogs/settings/ksettingskmymoney.cpp
@@ -32,7 +32,6 @@
#include "ksettingsschedules.h"
#include "ksettingsonlinequotes.h"
#include "ksettingshome.h"
-#include "ksettingsforecast.h"
#include "ksettingsreports.h"
#include "ksettingsplugins.h"
@@ -53,7 +52,6 @@
const auto fontsPage = new KSettingsFonts();
const auto iconsPage = new KSettingsIcons();
const auto onlineQuotesPage = new KSettingsOnlineQuotes();
- const auto forecastPage = new KSettingsForecast();
const auto reportsPage = new KSettingsReports();
const auto pluginsPage = new KSettingsPlugins();
@@ -63,7 +61,6 @@
addPage(schedulesPage, i18n("Scheduled transactions"), Icons::get(Icon::ViewSchedules).name());
addPage(onlineQuotesPage, i18n("Online Quotes"), Icons::get(Icon::PreferencesNetwork).name());
addPage(reportsPage, i18nc("Report settings", "Reports"), Icons::get(Icon::ViewReports).name());
- addPage(forecastPage, i18nc("Forecast settings", "Forecast"), Icons::get(Icon::ViewForecast).name());
addPage(encryptionPage, i18n("Encryption"), Icons::get(Icon::Kgpg).name());
addPage(colorsPage, i18n("Colors"), Icons::get(Icon::PreferencesColor).name());
addPage(fontsPage, i18n("Fonts"), Icons::get(Icon::PreferencesFont).name());
diff --git a/kmymoney/kmymoney.kcfg b/kmymoney/kmymoney.kcfg
--- a/kmymoney/kmymoney.kcfg
+++ b/kmymoney/kmymoney.kcfg
@@ -330,52 +330,6 @@
false
-
-
-
- 0
-
-
-
- 90
- 1
- 999
-
-
-
- 30
- 1
- 999
-
-
-
- 3
- 1
- 999
-
-
-
- 0
- 0
- 31
-
-
-
- 1
-
-
-
- true
-
-
-
- true
-
-
-
- true
-
-
diff --git a/kmymoney/kmymoneyglobalsettings.h b/kmymoney/kmymoneyglobalsettings.h
--- a/kmymoney/kmymoneyglobalsettings.h
+++ b/kmymoney/kmymoneyglobalsettings.h
@@ -78,5 +78,7 @@
* Construct a MyMoneyForecast object setup with all KMyMoneySettings
*/
static MyMoneyForecast forecast();
+ static int forecastDays();
+ static int forecastAccountCycle();
};
#endif
diff --git a/kmymoney/kmymoneyglobalsettings.cpp b/kmymoney/kmymoneyglobalsettings.cpp
--- a/kmymoney/kmymoneyglobalsettings.cpp
+++ b/kmymoney/kmymoneyglobalsettings.cpp
@@ -34,6 +34,7 @@
// include kmymoneysettings.cpp here to gain access to s_globalKMyMoneySettings
#include "kmymoneysettings.cpp"
+#include "forecastviewsettings.h"
void KMyMoneyGlobalSettings::injectExternalSettings(KMyMoneySettings* p)
{
@@ -159,16 +160,26 @@
MyMoneyForecast forecast;
// override object defaults with those of the application
- forecast.setForecastCycles(KMyMoneyGlobalSettings::forecastCycles());
- forecast.setAccountsCycle(KMyMoneyGlobalSettings::forecastAccountCycle());
+ forecast.setForecastCycles(ForecastViewSettings::forecastCycles());
+ forecast.setAccountsCycle(ForecastViewSettings::forecastAccountCycle());
forecast.setHistoryStartDate(QDate::currentDate().addDays(-forecast.forecastCycles()*forecast.accountsCycle()));
forecast.setHistoryEndDate(QDate::currentDate().addDays(-1));
- forecast.setForecastDays(KMyMoneyGlobalSettings::forecastDays());
- forecast.setBeginForecastDay(KMyMoneyGlobalSettings::beginForecastDay());
- forecast.setForecastMethod(KMyMoneyGlobalSettings::forecastMethod());
- forecast.setHistoryMethod(KMyMoneyGlobalSettings::historyMethod());
- forecast.setIncludeFutureTransactions(KMyMoneyGlobalSettings::includeFutureTransactions());
- forecast.setIncludeScheduledTransactions(KMyMoneyGlobalSettings::includeScheduledTransactions());
+ forecast.setForecastDays(ForecastViewSettings::forecastDays());
+ forecast.setBeginForecastDay(ForecastViewSettings::beginForecastDay());
+ forecast.setForecastMethod(ForecastViewSettings::forecastMethod());
+ forecast.setHistoryMethod(ForecastViewSettings::historyMethod());
+ forecast.setIncludeFutureTransactions(ForecastViewSettings::includeFutureTransactions());
+ forecast.setIncludeScheduledTransactions(ForecastViewSettings::includeScheduledTransactions());
return forecast;
}
+
+int KMyMoneyGlobalSettings::forecastDays()
+{
+ return ForecastViewSettings::forecastDays();
+}
+
+int KMyMoneyGlobalSettings::forecastAccountCycle()
+{
+ return ForecastViewSettings::forecastAccountCycle();
+}
diff --git a/kmymoney/plugins/CMakeLists.txt b/kmymoney/plugins/CMakeLists.txt
--- a/kmymoney/plugins/CMakeLists.txt
+++ b/kmymoney/plugins/CMakeLists.txt
@@ -9,6 +9,10 @@
add_subdirectory( reconciliationreport )
add_subdirectory( checkprinting )
+if(ENABLE_FORECASTVIEW)
+ add_subdirectory(forecast)
+endif()
+
if(ENABLE_SQLSTORAGE)
add_subdirectory(sql)
endif()
diff --git a/kmymoney/plugins/forecast/CMakeLists.txt b/kmymoney/plugins/forecast/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/kmymoney/plugins/forecast/CMakeLists.txt
@@ -0,0 +1,51 @@
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/forecastview.json.in ${CMAKE_CURRENT_BINARY_DIR}/forecastview.json @ONLY)
+
+set(forecastview_SOURCES
+ forecastview.cpp
+ kforecastview.cpp
+ fixedcolumntreeview.cpp
+ )
+
+ki18n_wrap_ui(forecastview_SOURCES kforecastview.ui)
+kconfig_add_kcfg_files(forecastview_SOURCES forecastviewsettings.kcfgc)
+
+add_library(forecastview MODULE ${forecastview_SOURCES} )
+
+target_link_libraries(forecastview
+ PUBLIC
+ kmm_plugin
+ KF5::TextWidgets
+ reports
+ viewbase
+)
+
+install(TARGETS forecastview
+ DESTINATION "${KDE_INSTALL_PLUGINDIR}/kmymoney")
+
+# the KCM module
+
+set(kcm_forecastview_PART_SRCS
+ kcm_forecastview.cpp
+ )
+
+kconfig_add_kcfg_files(kcm_forecastview_PART_SRCS forecastviewsettings.kcfgc)
+
+ki18n_wrap_ui(kcm_forecastview_PART_SRCS forecastviewsettings.ui)
+
+add_library(kcm_forecastview MODULE ${kcm_forecastview_PART_SRCS})
+
+kcoreaddons_desktop_to_json(kcm_forecastview kcm_forecastview.desktop)
+
+target_link_libraries(kcm_forecastview
+ KF5::I18n
+ KF5::ConfigWidgets
+ KF5::Completion
+ KF5::KIOWidgets
+ KF5::CoreAddons
+ )
+
+install(TARGETS kcm_forecastview
+ DESTINATION "${KDE_INSTALL_PLUGINDIR}/kmymoney")
+
+install(FILES kcm_forecastview.desktop
+ DESTINATION "${SERVICES_INSTALL_DIR}")
diff --git a/kmymoney/widgets/fixedcolumntreeview.h b/kmymoney/plugins/forecast/fixedcolumntreeview.h
rename from kmymoney/widgets/fixedcolumntreeview.h
rename to kmymoney/plugins/forecast/fixedcolumntreeview.h
diff --git a/kmymoney/widgets/fixedcolumntreeview.cpp b/kmymoney/plugins/forecast/fixedcolumntreeview.cpp
rename from kmymoney/widgets/fixedcolumntreeview.cpp
rename to kmymoney/plugins/forecast/fixedcolumntreeview.cpp
diff --git a/kmymoney/dialogs/settings/ksettingsforecast.h b/kmymoney/plugins/forecast/forecastview.h
rename from kmymoney/dialogs/settings/ksettingsforecast.h
rename to kmymoney/plugins/forecast/forecastview.h
--- a/kmymoney/dialogs/settings/ksettingsforecast.h
+++ b/kmymoney/plugins/forecast/forecastview.h
@@ -1,9 +1,8 @@
/***************************************************************************
- ksettingsforecast.h
+ forecastview.h
-------------------
- copyright : (C) 2007 by Alvaro Soliverez
- email : asoliverez@gmail.com
- (C) 2017 by Łukasz Wojniłowicz
+ copyright : (C) 2018 by Łukasz Wojniłowicz
+ email : lukasz.wojnilowicz@gmail.com
***************************************************************************/
/***************************************************************************
@@ -15,33 +14,36 @@
* *
***************************************************************************/
-#ifndef KSETTINGSFORECAST_H
-#define KSETTINGSFORECAST_H
-
-// ----------------------------------------------------------------------------
-// QT Includes
-
-#include
+#ifndef FORECASTVIEW_H
+#define FORECASTVIEW_H
// ----------------------------------------------------------------------------
// KDE Includes
// ----------------------------------------------------------------------------
+// QT Includes
+
// Project Includes
-namespace Ui { class KSettingsForecast; }
+#include "kmymoneyplugin.h"
-class KSettingsForecast : public QWidget
+class KForecastView;
+
+class ForecastView : public KMyMoneyPlugin::Plugin
{
Q_OBJECT
- Q_DISABLE_COPY(KSettingsForecast)
public:
- explicit KSettingsForecast(QWidget* parent = nullptr);
- ~KSettingsForecast();
+ explicit ForecastView(QObject *parent, const QVariantList &args);
+ ~ForecastView() override;
+
+ void plug() override;
+ void unplug() override;
+
+ void injectExternalSettings(KMyMoneySettings* p) override;
private:
- Ui::KSettingsForecast *ui;
+ KForecastView* m_view;
};
-#endif
+#endif
diff --git a/kmymoney/plugins/forecast/forecastview.cpp b/kmymoney/plugins/forecast/forecastview.cpp
new file mode 100644
--- /dev/null
+++ b/kmymoney/plugins/forecast/forecastview.cpp
@@ -0,0 +1,68 @@
+/***************************************************************************
+ forecastview.cpp
+ -------------------
+
+ copyright : (C) 2018 by Łukasz Wojniłowicz
+ email : lukasz.wojnilowicz@gmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "forecastview.h"
+
+// ----------------------------------------------------------------------------
+// QT Includes
+
+// ----------------------------------------------------------------------------
+// KDE Includes
+
+#include
+#include
+
+// ----------------------------------------------------------------------------
+// Project Includes
+
+#include "viewinterface.h"
+#include "kforecastview.h"
+#include "kmymoneyglobalsettings.h"
+
+ForecastView::ForecastView(QObject *parent, const QVariantList &args) :
+ KMyMoneyPlugin::Plugin(parent, "forecastview"/*must be the same as X-KDE-PluginInfo-Name*/)
+{
+ Q_UNUSED(args)
+ setComponentName("forecastview", i18n("Forecast view"));
+ // For information, announce that we have been loaded.
+ qDebug("Plugins: forecastview loaded");
+}
+
+ForecastView::~ForecastView()
+{
+ qDebug("Plugins: forecastview unloaded");
+}
+
+void ForecastView::injectExternalSettings(KMyMoneySettings* p)
+{
+ KMyMoneyGlobalSettings::injectExternalSettings(p);
+}
+
+void ForecastView::plug()
+{
+ m_view = new KForecastView;
+ viewInterface()->addView(m_view, i18n("Forecast"), View::Forecast);
+}
+
+void ForecastView::unplug()
+{
+ viewInterface()->removeView(View::Forecast);
+}
+
+K_PLUGIN_FACTORY_WITH_JSON(ForecastViewFactory, "forecastview.json", registerPlugin();)
+
+#include "forecastview.moc"
diff --git a/kmymoney/plugins/forecast/forecastview.json.in b/kmymoney/plugins/forecast/forecastview.json.in
new file mode 100644
--- /dev/null
+++ b/kmymoney/plugins/forecast/forecastview.json.in
@@ -0,0 +1,21 @@
+{
+ "KPlugin": {
+ "Authors": [
+ {
+ "Email": "asoliverez@gmail.com,lukasz.wojnilowicz@gmail.com",
+ "Name": "Alvaro Soliverez,Łukasz Wojniłowicz"
+ }
+ ],
+ "Description": "Adds forecast view to KMyMoney",
+ "EnabledByDefault": true,
+ "Icon": "forecast",
+ "Id": "forecastview",
+ "License": "GPL",
+ "Name": "Forecast view",
+ "ServiceTypes": [
+ "KMyMoney/Plugin"
+ ],
+ "Version": "@PROJECT_VERSION@@PROJECT_VERSION_SUFFIX@",
+ "Website": "https://kmymoney.org/plugins.html"
+ }
+}
diff --git a/kmymoney/plugins/forecast/forecastviewsettings.kcfg b/kmymoney/plugins/forecast/forecastviewsettings.kcfg
new file mode 100644
--- /dev/null
+++ b/kmymoney/plugins/forecast/forecastviewsettings.kcfg
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+ 0
+
+
+
+ 90
+ 1
+ 999
+
+
+
+ 30
+ 1
+ 999
+
+
+
+ 3
+ 1
+ 999
+
+
+
+ 0
+ 0
+ 31
+
+
+
+ 1
+
+
+
+ true
+
+
+
+ true
+
+
+
+ true
+
+
+
diff --git a/kmymoney/plugins/forecast/forecastviewsettings.kcfgc b/kmymoney/plugins/forecast/forecastviewsettings.kcfgc
new file mode 100644
--- /dev/null
+++ b/kmymoney/plugins/forecast/forecastviewsettings.kcfgc
@@ -0,0 +1,6 @@
+# Code generation options for kconfig_compiler
+File=forecastviewsettings.kcfg
+ClassName=ForecastViewSettings
+Singleton=true
+Mutators=true
+# will create the necessary code for setting those variables
diff --git a/kmymoney/dialogs/settings/ksettingsforecast.ui b/kmymoney/plugins/forecast/forecastviewsettings.ui
rename from kmymoney/dialogs/settings/ksettingsforecast.ui
rename to kmymoney/plugins/forecast/forecastviewsettings.ui
--- a/kmymoney/dialogs/settings/ksettingsforecast.ui
+++ b/kmymoney/plugins/forecast/forecastviewsettings.ui
@@ -3,8 +3,8 @@
- KSettingsForecast
-
+ ForecastViewSettings
+
0
diff --git a/kmymoney/plugins/forecast/kcm_forecastview.h b/kmymoney/plugins/forecast/kcm_forecastview.h
new file mode 100644
--- /dev/null
+++ b/kmymoney/plugins/forecast/kcm_forecastview.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * Copyright 2018 Łukasz Wojniłowicz lukasz.wojnilowicz@gmail.com *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 2 of *
+ * the License or (at your option) version 3 or any later version *
+ * accepted by the membership of KDE e.V. (or its successor approved *
+ * by the membership of KDE e.V.), which shall act as a proxy *
+ * defined in Section 14 of version 3 of the license. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see *
+ ***************************************************************************/
+#ifndef KCM_FORECASTVIEW_H
+#define KCM_FORECASTVIEW_H
+
+#include
+#include
+#include "ui_forecastviewsettings.h"
+
+class ForecastViewSettingsWidget : public QWidget, public Ui::ForecastViewSettings
+{
+ Q_OBJECT
+public:
+ explicit ForecastViewSettingsWidget(QWidget* parent = nullptr);
+};
+
+class KCMForecastView : public KCModule
+{
+public:
+ explicit KCMForecastView(QWidget* parent, const QVariantList& args);
+ ~KCMForecastView();
+};
+
+#endif
+
diff --git a/kmymoney/plugins/forecast/kcm_forecastview.cpp b/kmymoney/plugins/forecast/kcm_forecastview.cpp
new file mode 100644
--- /dev/null
+++ b/kmymoney/plugins/forecast/kcm_forecastview.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright 2018 Łukasz Wojniłowicz lukasz.wojnilowicz@gmail.com *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 2 of *
+ * the License or (at your option) version 3 or any later version *
+ * accepted by the membership of KDE e.V. (or its successor approved *
+ * by the membership of KDE e.V.), which shall act as a proxy *
+ * defined in Section 14 of version 3 of the license. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see *
+ ***************************************************************************/
+
+#include "kcm_forecastview.h"
+#include
+
+// KDE includes
+#include
+#include
+#include "forecastviewsettings.h"
+
+ForecastViewSettingsWidget::ForecastViewSettingsWidget(QWidget* parent) :
+ QWidget(parent)
+{
+ setupUi(this);
+}
+
+KCMForecastView::KCMForecastView(QWidget *parent, const QVariantList& args)
+ : KCModule(parent, args)
+{
+ ForecastViewSettingsWidget* w = new ForecastViewSettingsWidget(this);
+ addConfig(ForecastViewSettings::self(), w);
+ QVBoxLayout *layout = new QVBoxLayout;
+ setLayout(layout);
+ layout->addWidget(w);
+ setButtons(NoAdditionalButton);
+ load();
+}
+
+KCMForecastView::~KCMForecastView()
+{
+}
+
+K_PLUGIN_FACTORY_WITH_JSON(KCMForecastViewFactory, "kcm_forecastview.json", registerPlugin();)
+
+#include "kcm_forecastview.moc"
diff --git a/kmymoney/plugins/forecast/kcm_forecastview.desktop b/kmymoney/plugins/forecast/kcm_forecastview.desktop
new file mode 100644
--- /dev/null
+++ b/kmymoney/plugins/forecast/kcm_forecastview.desktop
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Name=Forecast view configuration
+Name[x-test]=xxForecast view configurationxx
+Icon=forecast
+Type=Service
+ServiceTypes=KCModule
+Exec=kcmshell5 forecastview
+Categories=Qt;KDE;kmymoney;
+Keywords=forecastview;kmymoney;
+Keywords[x-test]=xxforecastviewxx;xxkmymoneyxx;
+X-KDE-Library=kmymoney/kcm_forecastview
+X-KDE-ParentApp=forecastview
+X-KDE-ParentComponents=forecastview
+Comment=Configuration for forecast view plugin
+Comment[x-test]=xxConfiguration for forecast view pluginxx
diff --git a/kmymoney/views/kforecastview.h b/kmymoney/plugins/forecast/kforecastview.h
rename from kmymoney/views/kforecastview.h
rename to kmymoney/plugins/forecast/kforecastview.h
--- a/kmymoney/views/kforecastview.h
+++ b/kmymoney/plugins/forecast/kforecastview.h
@@ -49,7 +49,7 @@
Q_OBJECT
public:
- explicit KForecastView(QWidget *parent = 0);
+ explicit KForecastView(QWidget *parent = nullptr);
~KForecastView() override;
void setDefaultFocus() override;
diff --git a/kmymoney/views/kforecastview.cpp b/kmymoney/plugins/forecast/kforecastview.cpp
rename from kmymoney/views/kforecastview.cpp
rename to kmymoney/plugins/forecast/kforecastview.cpp
diff --git a/kmymoney/views/kforecastview.ui b/kmymoney/plugins/forecast/kforecastview.ui
rename from kmymoney/views/kforecastview.ui
rename to kmymoney/plugins/forecast/kforecastview.ui
diff --git a/kmymoney/views/kforecastview_p.h b/kmymoney/plugins/forecast/kforecastview_p.h
rename from kmymoney/views/kforecastview_p.h
rename to kmymoney/plugins/forecast/kforecastview_p.h
--- a/kmymoney/views/kforecastview_p.h
+++ b/kmymoney/plugins/forecast/kforecastview_p.h
@@ -42,6 +42,7 @@
// Project Includes
#include "ui_kforecastview.h"
+#include "forecastviewsettings.h"
#include "kmymoneyviewbase_p.h"
#include "mymoneymoney.h"
#include "mymoneyforecast.h"
@@ -692,15 +693,15 @@
void loadForecastSettings()
{
//fill the settings controls
- ui->m_forecastDays->setValue(KMyMoneyGlobalSettings::forecastDays());
- ui->m_accountsCycle->setValue(KMyMoneyGlobalSettings::forecastAccountCycle());
- ui->m_beginDay->setValue(KMyMoneyGlobalSettings::beginForecastDay());
- ui->m_forecastCycles->setValue(KMyMoneyGlobalSettings::forecastCycles());
+ ui->m_forecastDays->setValue(ForecastViewSettings::forecastDays());
+ ui->m_accountsCycle->setValue(ForecastViewSettings::forecastAccountCycle());
+ ui->m_beginDay->setValue(ForecastViewSettings::beginForecastDay());
+ ui->m_forecastCycles->setValue(ForecastViewSettings::forecastCycles());
ui->m_historyMethod->setId(ui->radioButton11, 0); // simple moving avg
ui->m_historyMethod->setId(ui->radioButton12, 1); // weighted moving avg
ui->m_historyMethod->setId(ui->radioButton13, 2); // linear regression
- ui->m_historyMethod->button(KMyMoneyGlobalSettings::historyMethod())->setChecked(true);
- switch (KMyMoneyGlobalSettings::forecastMethod()) {
+ ui->m_historyMethod->button(ForecastViewSettings::historyMethod())->setChecked(true);
+ switch (ForecastViewSettings::forecastMethod()) {
case 0:
ui->m_forecastMethod->setText(i18nc("Scheduled method", "Scheduled"));
ui->m_forecastCycles->setDisabled(true);
diff --git a/kmymoney/dialogs/settings/ksettingsforecast.h b/kmymoney/plugins/forecast/ksettingsforecast.h
rename from kmymoney/dialogs/settings/ksettingsforecast.h
rename to kmymoney/plugins/forecast/ksettingsforecast.h
diff --git a/kmymoney/dialogs/settings/ksettingsforecast.cpp b/kmymoney/plugins/forecast/ksettingsforecast.cpp
rename from kmymoney/dialogs/settings/ksettingsforecast.cpp
rename to kmymoney/plugins/forecast/ksettingsforecast.cpp
diff --git a/kmymoney/plugins/interfaces/kmmviewinterface.h b/kmymoney/plugins/interfaces/kmmviewinterface.h
--- a/kmymoney/plugins/interfaces/kmmviewinterface.h
+++ b/kmymoney/plugins/interfaces/kmmviewinterface.h
@@ -98,6 +98,8 @@
**/
void slotRefreshViews() override;
+ void addView(KMyMoneyViewBase* view, const QString& name, View idView) override;
+ void removeView(View idView) override;
private:
KMyMoneyView* m_view;
};
diff --git a/kmymoney/plugins/interfaces/kmmviewinterface.cpp b/kmymoney/plugins/interfaces/kmmviewinterface.cpp
--- a/kmymoney/plugins/interfaces/kmmviewinterface.cpp
+++ b/kmymoney/plugins/interfaces/kmmviewinterface.cpp
@@ -57,6 +57,16 @@
m_view->slotRefreshViews();
}
+void KMyMoneyPlugin::KMMViewInterface::addView(KMyMoneyViewBase* view, const QString& name, View idView)
+{
+ m_view->addView(view, name, idView);
+}
+
+void KMyMoneyPlugin::KMMViewInterface::removeView(View idView)
+{
+ m_view->removeView(idView);
+}
+
bool KMyMoneyPlugin::KMMViewInterface::fileOpen()
{
return m_view->fileOpen();
diff --git a/kmymoney/plugins/viewinterface.h b/kmymoney/plugins/viewinterface.h
--- a/kmymoney/plugins/viewinterface.h
+++ b/kmymoney/plugins/viewinterface.h
@@ -42,11 +42,14 @@
class SelectedTransactions;
}
+enum class View;
+
class MyMoneyInstitution;
class MyMoneyAccount;
class MyMoneySplit;
class MyMoneyTransaction;
class IMyMoneyOperationsFormat;
+class KMyMoneyViewBase;
namespace KMyMoneyPlugin
{
@@ -109,6 +112,9 @@
*/
// virtual void addWidget(KMyMoneyViewBase* view, QWidget* w) = 0;
+ virtual void addView(KMyMoneyViewBase* view, const QString& name, View idView) = 0;
+ virtual void removeView(View idView) = 0;
+
Q_SIGNALS:
/**
* This signal is emitted when a new account has been selected by
diff --git a/kmymoney/views/CMakeLists.txt b/kmymoney/views/CMakeLists.txt
--- a/kmymoney/views/CMakeLists.txt
+++ b/kmymoney/views/CMakeLists.txt
@@ -1,18 +1,24 @@
+set(viewbase_SOURCES
+ kmymoneyviewbase.cpp
+ )
+
+add_library(viewbase STATIC ${viewbase_SOURCES})
+
+target_link_libraries(viewbase PUBLIC KF5::TextWidgets)
+
############# next target (views) STATIC ###################
set(libviews_a_SOURCES
kaccountsview.cpp
kbudgetview.cpp
kcategoriesview.cpp
- kforecastview.cpp
kgloballedgerview.cpp
kwelcomepage.cpp
khomeview.cpp
kinstitutionsview.cpp
kinvestmentview.cpp
kmymoneyfile.cpp
- kmymoneyview.cpp
- kmymoneyviewbase.cpp
kmymoneyaccountsviewbase.cpp
+ kmymoneyview.cpp
kpayeesview.cpp
kreportsview.cpp
kscheduledview.cpp
@@ -46,7 +52,6 @@
kaccountsview.ui
kbudgetview.ui
kcategoriesview.ui
- kforecastview.ui
kinstitutionsview.ui
kinvestmentview.ui
kpayeesview.ui
@@ -92,6 +97,7 @@
payeeidentifier_iban_bic
payeeidentifier_nationalAccount
kmm_mymoney # needed to load payeeIdentifier
+ viewbase
)
# we rely on some of the dialogs to be generated
diff --git a/kmymoney/views/kmymoneyview.h b/kmymoney/views/kmymoneyview.h
--- a/kmymoney/views/kmymoneyview.h
+++ b/kmymoney/views/kmymoneyview.h
@@ -46,6 +46,7 @@
namespace KMyMoneyPlugin { class OnlinePlugin; }
namespace KMyMoneyPlugin { class StoragePlugin; }
namespace eDialogs { enum class ScheduleResultCode; }
+namespace Icons { enum class Icon; }
class KMyMoneyApp;
class KHomeView;
@@ -65,13 +66,13 @@
class MyMoneySecurity;
class MyMoneyReport;
class TransactionEditor;
-class KForecastView;
class KOnlineJobOutbox;
class KMyMoneyTitleLabel;
class MyMoneyAccount;
class MyMoneyMoney;
class MyMoneyObject;
class QLabel;
+class KMyMoneyViewBase;
/**
* This class represents the view of the MyMoneyFile which contains
@@ -124,10 +125,10 @@
KGlobalLedgerView *m_ledgerView;
KInvestmentView *m_investmentView;
KReportsView* m_reportsView;
- KForecastView* m_forecastView;
KOnlineJobOutbox* m_onlineJobOutboxView;
- QHash viewFrames;
+ QHash viewFrames;
+ QHash viewBases;
KMyMoneyTitleLabel* m_header;
bool m_inConstructor;
@@ -334,6 +335,9 @@
*/
eDialogs::ScheduleResultCode enterSchedule(MyMoneySchedule& schedule, bool autoEnter, bool extendedKeys);
+ void addView(KMyMoneyViewBase* view, const QString& name, View idView);
+ void removeView(View idView);
+
protected:
/**
* Overwritten because KMyMoney has it's custom header.
diff --git a/kmymoney/views/kmymoneyview.cpp b/kmymoney/views/kmymoneyview.cpp
--- a/kmymoney/views/kmymoneyview.cpp
+++ b/kmymoney/views/kmymoneyview.cpp
@@ -81,7 +81,6 @@
#include "kinvestmentview.h"
#include "kreportsview.h"
#include "kbudgetview.h"
-#include "kforecastview.h"
#include "konlinejoboutbox.h"
#include "kmymoney.h"
#include "models.h"
@@ -230,11 +229,7 @@
connect(m_budgetView, &KMyMoneyViewBase::aboutToShow, this, &KMyMoneyView::resetViewSelection);
// Page 11
- m_forecastView = new KForecastView;
- viewFrames[View::Forecast] = m_model->addPage(m_forecastView, i18n("Forecast"));
- viewFrames[View::Forecast]->setIcon(Icons::get(Icon::ViewForecast));
- connect(m_forecastView, &KMyMoneyViewBase::aboutToShow, this, &KMyMoneyView::connectView);
- connect(m_forecastView, &KMyMoneyViewBase::aboutToShow, this, &KMyMoneyView::resetViewSelection);
+ // KForecastView
// Page 12
m_onlineJobOutboxView = new KOnlineJobOutbox;
@@ -387,8 +382,10 @@
void KMyMoneyView::slotShowForecastPage()
{
- showPage(viewFrames[View::Forecast]);
- m_forecastView->setDefaultFocus();
+ if (viewFrames.contains(View::Forecast)) {
+ showPage(viewFrames[View::Forecast]);
+ viewBases[View::Forecast]->setDefaultFocus();
+ }
}
void KMyMoneyView::slotShowOutboxPage()
@@ -488,6 +485,39 @@
return m_scheduledView->enterSchedule(schedule, autoEnter, extendedKeys);
}
+void KMyMoneyView::addView(KMyMoneyViewBase* view, const QString& name, View idView)
+{
+ auto isViewInserted = false;
+ for (auto i = (int)idView; i < (int)View::None; ++i) {
+ if (viewFrames.contains((View)i)) {
+ viewFrames[idView] = m_model->insertPage(viewFrames[(View)i],view, name);
+ viewBases[idView] = view;
+ isViewInserted = true;
+ break;
+ }
+ }
+
+ if (!isViewInserted)
+ viewFrames[idView] = m_model->addPage(view, name);
+
+ auto icon = Icon::ViewForecast;
+ switch (idView) {
+ case View::Forecast:
+ icon = Icon::ViewForecast;
+ break;
+ default:
+ break;
+ }
+ viewFrames[idView]->setIcon(Icons::get(icon));
+}
+
+void KMyMoneyView::removeView(View idView)
+{
+ m_model->removePage(viewFrames[idView]);
+ viewFrames.remove(idView);
+ viewBases.remove(idView);
+}
+
bool KMyMoneyView::showPageHeader() const
{
return false;
@@ -555,30 +585,10 @@
void KMyMoneyView::enableViewsIfFileOpen()
{
// call set enabled only if the state differs to avoid widgets 'bouncing on the screen' while doing this
- if (viewFrames[View::Accounts]->isEnabled() != m_fileOpen)
- viewFrames[View::Accounts]->setEnabled(m_fileOpen);
- if (viewFrames[View::Institutions]->isEnabled() != m_fileOpen)
- viewFrames[View::Institutions]->setEnabled(m_fileOpen);
- if (viewFrames[View::Schedules]->isEnabled() != m_fileOpen)
- viewFrames[View::Schedules]->setEnabled(m_fileOpen);
- if (viewFrames[View::Categories]->isEnabled() != m_fileOpen)
- viewFrames[View::Categories]->setEnabled(m_fileOpen);
- if (viewFrames[View::Payees]->isEnabled() != m_fileOpen)
- viewFrames[View::Payees]->setEnabled(m_fileOpen);
- if (viewFrames[View::Tags]->isEnabled() != m_fileOpen)
- viewFrames[View::Tags]->setEnabled(m_fileOpen);
- if (viewFrames[View::Budget]->isEnabled() != m_fileOpen)
- viewFrames[View::Budget]->setEnabled(m_fileOpen);
- if (viewFrames[View::Ledgers]->isEnabled() != m_fileOpen)
- viewFrames[View::Ledgers]->setEnabled(m_fileOpen);
- if (viewFrames[View::Investments]->isEnabled() != m_fileOpen)
- viewFrames[View::Investments]->setEnabled(m_fileOpen);
- if (viewFrames[View::Reports]->isEnabled() != m_fileOpen)
- viewFrames[View::Reports]->setEnabled(m_fileOpen);
- if (viewFrames[View::Forecast]->isEnabled() != m_fileOpen)
- viewFrames[View::Forecast]->setEnabled(m_fileOpen);
- if (viewFrames[View::OnlineJobOutbox]->isEnabled() != m_fileOpen)
- viewFrames[View::OnlineJobOutbox]->setEnabled(m_fileOpen);
+ for (auto i = (int)View::Home; i < (int)View::None; ++i)
+ if (viewFrames.contains(View(i)))
+ if (viewFrames[View(i)]->isEnabled() != m_fileOpen)
+ viewFrames[View(i)]->setEnabled(m_fileOpen);
emit viewStateChanged(m_fileOpen);
}
@@ -1503,8 +1513,10 @@
m_homeView->refresh();
m_investmentView->refresh();
m_reportsView->refresh();
- m_forecastView->refresh();
m_scheduledView->refresh();
+ for (auto i = (int)View::Home; i < (int)View::None; ++i)
+ if (viewBases.contains(View(i)))
+ viewBases[View(i)]->refresh();
m_payeesView->slotClosePayeeIdentifierSource();
}
@@ -2138,10 +2150,6 @@
connect(m_reportsView, &KReportsView::transactionSelected, m_ledgerView, &KGlobalLedgerView::slotLedgerSelected);
break;
- case View::Forecast:
- disconnect(m_forecastView, &KForecastView::aboutToShow, this, &KMyMoneyView::connectView);
- break;
-
case View::OnlineJobOutbox:
disconnect(m_onlineJobOutboxView, &KOnlineJobOutbox::aboutToShow, this, &KMyMoneyView::connectView);
break;
diff --git a/kmymoney/widgets/CMakeLists.txt b/kmymoney/widgets/CMakeLists.txt
--- a/kmymoney/widgets/CMakeLists.txt
+++ b/kmymoney/widgets/CMakeLists.txt
@@ -89,7 +89,6 @@
# Common sources for libkmymoney.so and libwidgets.a that do not
# contain the KMM_DESIGNER flag
set(_uncritial_common_sources
- fixedcolumntreeview.cpp
kbudgetvalues.cpp
kmymoneyaccountcombo.cpp
kmymoneyaccountselector.cpp