File indexing completed on 2024-05-19 05:08:18
0001 /* 0002 SPDX-FileCopyrightText: 2000-2001 Michael Edwardes <mte@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2004 Thomas Baumgart <ipwizard@users.sourceforge.net> 0004 SPDX-FileCopyrightText: 2017, 2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KMYMONEYVIEW_H 0009 #define KMYMONEYVIEW_H 0010 0011 #include <config-kmymoney.h> 0012 0013 // ---------------------------------------------------------------------------- 0014 // QT Includes 0015 0016 #include <QFileDevice> 0017 0018 // ---------------------------------------------------------------------------- 0019 // KDE Includes 0020 0021 #include <KPageWidget> 0022 0023 // ---------------------------------------------------------------------------- 0024 // Project Includes 0025 0026 #ifdef ENABLE_ACTIVITIES 0027 namespace KActivities 0028 { 0029 class ResourceInstance; 0030 } 0031 #endif 0032 0033 namespace eAccountsModel { 0034 enum class Column; 0035 } 0036 namespace eMenu { 0037 enum class Action; 0038 enum class Menu; 0039 } 0040 namespace KMyMoneyPlugin { 0041 class OnlinePlugin; 0042 } 0043 namespace eDialogs { 0044 enum class ScheduleResultCode; 0045 } 0046 namespace eView { 0047 enum class Action; 0048 } 0049 namespace Icons { 0050 enum class Icon; 0051 } 0052 0053 class KMyMoneyApp; 0054 class KHomeView; 0055 class KAccountsView; 0056 class KCategoriesView; 0057 class KInstitutionsView; 0058 class KPayeesView; 0059 class KTagsView; 0060 class KBudgetView; 0061 class KScheduledView; 0062 class KGlobalLedgerView; 0063 class IMyMoneyOperationsFormat; 0064 class MyMoneyTransaction; 0065 class KInvestmentView; 0066 class KReportsView; 0067 class SimpleLedgerView; 0068 class MyMoneySchedule; 0069 class MyMoneySecurity; 0070 class MyMoneyReport; 0071 class TransactionEditor; 0072 class KOnlineJobOutbox; 0073 class MyMoneyAccount; 0074 class MyMoneyMoney; 0075 class MyMoneyObject; 0076 class QLabel; 0077 class KMyMoneyViewBase; 0078 class SelectedObjects; 0079 0080 /** 0081 * This class represents the view of the MyMoneyFile which contains 0082 * Banks/Accounts/Transactions, Recurring transactions (or Bills & Deposits) 0083 * and scripts (yet to be implemented). Each different aspect of the file 0084 * is represented by a tab within the view. 0085 * 0086 * @author Michael Edwardes 2001 Copyright 2000-2001 0087 * 0088 * @short Handles the view of the MyMoneyFile. 0089 */ 0090 enum class View; 0091 class KMyMoneyViewPrivate; 0092 class KMyMoneyView : public KPageWidget 0093 { 0094 Q_OBJECT 0095 Q_DECLARE_PRIVATE(KMyMoneyView) 0096 0097 private: 0098 const QScopedPointer<KMyMoneyViewPrivate> d_ptr; 0099 Q_PRIVATE_SLOT(d_func(), void _q_selectionChangeRequested(const SelectedObjects& selection)); 0100 0101 public: 0102 /** 0103 * The constructor for KMyMoneyView. Just creates all the tabs for the 0104 * different aspects of the MyMoneyFile. 0105 */ 0106 KMyMoneyView(); 0107 0108 /** 0109 * Destructor 0110 */ 0111 ~KMyMoneyView(); 0112 0113 /** 0114 * This method enables the state of all views (except home view) according 0115 * to an open file. 0116 */ 0117 void enableViewsIfFileOpen(bool fileOpen); 0118 void switchToHomeView(); 0119 0120 void addWidget(QWidget* w); 0121 0122 void showPageAndFocus(View idView); 0123 void showPage(View idView); 0124 0125 /** 0126 * This method changes the view type according to the settings. 0127 */ 0128 void updateViewType(); 0129 0130 void setOnlinePlugins(QMap<QString, KMyMoneyPlugin::OnlinePlugin*>* plugins); 0131 0132 // TODO: remove that function 0133 /** 0134 * ugly proxy function 0135 */ 0136 eDialogs::ScheduleResultCode enterSchedule(MyMoneySchedule& schedule, bool autoEnter, bool extendedKeys); 0137 0138 void addView(KMyMoneyViewBase* view, const QString& name, View idView, Icons::Icon icon); 0139 void removeView(View idView); 0140 0141 /** 0142 * @brief actionsToBeConnected are actions that need ActionCollection 0143 * which is available in KMyMoneyApp 0144 * @return QHash of action id and QAction itself 0145 */ 0146 QHash<eMenu::Action, QAction *> actionsToBeConnected(); 0147 0148 /** 0149 * Execute the @a action using the selected objects of @a selections 0150 */ 0151 void executeAction(eMenu::Action action, const SelectedObjects& selections); 0152 0153 void setupSharedActions(); 0154 0155 /** 0156 * Returns @c true if the current view has a closable tab/sub-view. 0157 */ 0158 bool hasClosableView() const; 0159 0160 /** 0161 * Closes the current selected closable tab/sub-view in the current view. 0162 */ 0163 void closeCurrentView(); 0164 0165 protected: 0166 /** 0167 * Overwritten because KMyMoney has it's custom header. 0168 */ 0169 bool showPageHeader() const final override; 0170 0171 0172 public Q_SLOTS: 0173 void slotSettingsChanged(); 0174 0175 void updateActions(const SelectedObjects& selections); 0176 0177 private Q_SLOTS: 0178 /** 0179 * This slot writes information about the page passed as argument @a current 0180 * in the kmymoney.rc file so that it can be selected automatically when 0181 * the application is started again. 0182 * 0183 * @param current KPageWidgetItem pointer to the current page item 0184 * @param previous KPageWidgetItem pointer to the previous page item 0185 */ 0186 void slotSwitchView(KPageWidgetItem* current, KPageWidgetItem* previous); 0187 0188 void switchToDefaultView(); 0189 0190 void slotRememberLastView(View view); 0191 0192 void switchView(QWidget* viewWidget, const QString& accountId, const QString& journalEntryId); 0193 0194 Q_SIGNALS: 0195 /** 0196 * This signal is emitted whenever a view is selected. 0197 * The parameter @p view is identified as one of KMyMoneyView::viewID. 0198 */ 0199 void viewActivated(View view); 0200 0201 void accountSelectedForContextMenu(const MyMoneyAccount& acc); 0202 0203 void viewStateChanged(bool enabled); 0204 /** 0205 * This signal is emitted to inform the kmmFile plugin when various file actions 0206 * occur. The Action parameter distinguishes between them. 0207 */ 0208 void kmmFilePlugin(unsigned int action); 0209 0210 /** 0211 * @brief proxy signal 0212 */ 0213 void statusMsg(const QString& txt); 0214 0215 /** 0216 * @brief proxy signal 0217 */ 0218 void statusProgress(int cnt, int base); 0219 0220 void accountReconciled(const MyMoneyAccount& account, 0221 const QDate& date, 0222 const MyMoneyMoney& startingBalance, 0223 const MyMoneyMoney& endingBalance, 0224 const QStringList& transactionList); 0225 0226 /** 0227 * This signal is emitted when a new account has been selected by 0228 * the GUI. If no account is selected or the selection is removed, 0229 * @a account is identical to MyMoneyAccount(). This signal is used 0230 * by plugins to get information about changes. 0231 */ 0232 void accountSelected(const MyMoneyAccount& account); 0233 0234 // these signals request a change by the application 0235 void requestSelectionChange (const SelectedObjects& selection); 0236 void requestCustomContextMenu(eMenu::Menu type, const QPoint& pos); 0237 void requestActionTrigger(eMenu::Action action); 0238 0239 void settingsChanged(); 0240 0241 void addSharedActionButton(eMenu::Action action, QAction* defaultAction); 0242 void selectSharedActionButton(eMenu::Action action, QAction* defaultAction); 0243 0244 void onlinePluginsChanged(QMap<QString, KMyMoneyPlugin::OnlinePlugin*>* plugins); 0245 }; 0246 0247 #endif