Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/views/kinvestmentview.h
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | kinvestmentview.h - description | 2 | kinvestmentview.h - description | ||
3 | ------------------- | 3 | ------------------- | ||
4 | begin : Tue Jan 29 2002 | 4 | begin : Tue Jan 29 2002 | ||
5 | copyright : (C) 2000-2002 by Michael Edwardes | 5 | copyright : (C) 2000-2002 by Michael Edwardes | ||
6 | email : mte@users.sourceforge.net | 6 | email : mte@users.sourceforge.net | ||
7 | Javier Campos Morales <javi_c@users.sourceforge.net> | 7 | Javier Campos Morales <javi_c@users.sourceforge.net> | ||
8 | Felix Rodriguez <frodriguez@users.sourceforge.net> | 8 | Felix Rodriguez <frodriguez@users.sourceforge.net> | ||
9 | John C <thetacoturtle@users.sourceforge.net> | 9 | John C <thetacoturtle@users.sourceforge.net> | ||
10 | Thomas Baumgart <ipwizard@users.sourceforge.net> | 10 | Thomas Baumgart <ipwizard@users.sourceforge.net> | ||
11 | Kevin Tambascio <ktambascio@users.sourceforge.net> | 11 | Kevin Tambascio <ktambascio@users.sourceforge.net> | ||
12 | (C) 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> | ||||
12 | ***************************************************************************/ | 13 | ***************************************************************************/ | ||
13 | 14 | | |||
14 | /*************************************************************************** | 15 | /*************************************************************************** | ||
15 | * * | 16 | * * | ||
16 | * This program is free software; you can redistribute it and/or modify * | 17 | * This program is free software; you can redistribute it and/or modify * | ||
17 | * it under the terms of the GNU General Public License as published by * | 18 | * it under the terms of the GNU General Public License as published by * | ||
18 | * the Free Software Foundation; either version 2 of the License, or * | 19 | * the Free Software Foundation; either version 2 of the License, or * | ||
19 | * (at your option) any later version. * | 20 | * (at your option) any later version. * | ||
20 | * * | 21 | * * | ||
21 | ***************************************************************************/ | 22 | ***************************************************************************/ | ||
22 | 23 | | |||
23 | #ifndef KINVESTMENTVIEW_H | 24 | #ifndef KINVESTMENTVIEW_H | ||
24 | #define KINVESTMENTVIEW_H | 25 | #define KINVESTMENTVIEW_H | ||
25 | 26 | | |||
26 | // ---------------------------------------------------------------------------- | 27 | // ---------------------------------------------------------------------------- | ||
27 | // QT Includes | 28 | // QT Includes | ||
28 | 29 | | |||
29 | // ---------------------------------------------------------------------------- | 30 | // ---------------------------------------------------------------------------- | ||
30 | // KDE Includes | 31 | // KDE Includes | ||
31 | 32 | | |||
32 | #include <ktreewidgetsearchlinewidget.h> | | |||
33 | | ||||
34 | // ---------------------------------------------------------------------------- | 33 | // ---------------------------------------------------------------------------- | ||
35 | // Project Includes | 34 | // Project Includes | ||
36 | 35 | | |||
37 | #include <mymoneysecurity.h> | 36 | #include "ui_kinvestmentview.h" | ||
38 | #include <mymoneyaccount.h> | | |||
39 | #include "ui_kinvestmentviewdecl.h" | | |||
40 | | ||||
41 | enum eInvestmentColumn { eInvestmentNameColumn, eInvestmentSymbolColumn, eValueColumn, eQuantityColumn, ePriceColumn }; | | |||
42 | 37 | | |||
43 | enum eSecurityColum { eIdColumn, eTypeColumn, eSecurityNameColumn, eSecuritySymbolColumn, eMarketColumn, eCurrencyColumn, eAcctFractionColumn, eCashFractionColumn }; | 38 | class KMyMoneyApp; | ||
39 | class KMyMoneyView; | ||||
40 | class MyMoneySecurity; | ||||
44 | 41 | | |||
45 | /** | 42 | /** | ||
46 | * @author Kevin Tambascio | 43 | * @author Kevin Tambascio | ||
44 | * @author Łukasz Wojniłowicz | ||||
47 | */ | 45 | */ | ||
48 | class KInvestmentView : public QWidget, private Ui::KInvestmentViewDecl | 46 | class KInvestmentView : public QWidget, private Ui::KInvestmentView | ||
49 | { | 47 | { | ||
50 | Q_OBJECT | 48 | Q_OBJECT | ||
51 | 49 | | |||
52 | public: | 50 | public: | ||
53 | KInvestmentView(QWidget *parent = 0); | 51 | explicit KInvestmentView(KMyMoneyApp *kmymoney, KMyMoneyView *kmymoneyview); | ||
54 | ~KInvestmentView(); | 52 | ~KInvestmentView(); | ||
55 | 53 | | |||
56 | /** | | |||
57 | * Start reconciliation for the account in the current view | | |||
58 | */ | | |||
59 | void reconcileAccount(); | | |||
60 | | ||||
61 | public slots: | 54 | public slots: | ||
62 | /** | 55 | /** | ||
63 | * This slot is used to reload all data from the MyMoneyFile engine. | 56 | * This slot is used to reload all data from the MyMoneyFile engine. | ||
64 | * All existing data in the view will be discarded. | 57 | * All existing data in the view will be invalidated. | ||
65 | * Call this e.g. if a new file has been loaded. | 58 | * Call this e.g. if a new file has been loaded. | ||
66 | */ | 59 | */ | ||
67 | void slotLoadView(); | 60 | void slotLoadView(); | ||
68 | 61 | | |||
69 | /** | 62 | /** | ||
70 | * This slot is used to select the correct ledger view type for | 63 | * This slot is used to preselect investment account from ledger view | ||
71 | * the account specified by @p id. If @p transactionId is not | | |||
72 | * empty, then the respective transaction will be selected. | | |||
73 | * | | |||
74 | * @param accountId Internal id used for the account to show | | |||
75 | * @param transactionId Internal id used for the transaction to select | | |||
76 | * @param reconciliation if true, the account will be selected in | | |||
77 | * reconciliation mode. If false, it will | | |||
78 | * be selected in regular ledger mode. | | |||
79 | * | | |||
80 | * @retval true selection of account referenced by @p id succeeded | | |||
81 | * @retval false selection of account failed | | |||
82 | */ | 64 | */ | ||
83 | bool slotSelectAccount(const QString& accountId, const QString& transactionId = QString(), const bool reconciliation = false); | 65 | void slotSelectAccount(const MyMoneyObject &obj); | ||
84 | | ||||
85 | /** | | |||
86 | * This method is provided for convenience and acts as the method above. | | |||
87 | */ | | |||
88 | bool slotSelectAccount(const MyMoneyObject& acc); | | |||
89 | 66 | | |||
90 | void showEvent(QShowEvent* event); | 67 | void showEvent(QShowEvent* event); | ||
91 | 68 | | |||
92 | protected: | 69 | private slots: | ||
93 | | ||||
94 | typedef enum { | | |||
95 | EquitiesTab = 0, | | |||
96 | SecuritiesTab, | | |||
97 | // insert new values above this line | | |||
98 | MaxViewTabs | | |||
99 | } InvestmentsViewTab; | | |||
100 | | ||||
101 | /** | | |||
102 | * This method loads the investments and securities for the respective tab. | | |||
103 | * | | |||
104 | * @param tab which tab should be loaded | | |||
105 | */ | | |||
106 | void loadView(InvestmentsViewTab tab); | | |||
107 | | ||||
108 | /** | | |||
109 | * This method reloads the account selection combo box of the | | |||
110 | * view with all asset and liability accounts from the engine. | | |||
111 | * If the account id of the current account held in @p m_accountId is | | |||
112 | * empty or if the referenced account does not exist in the engine, | | |||
113 | * the first account found in the list will be made the current account. | | |||
114 | */ | | |||
115 | void loadAccounts(); | | |||
116 | | ||||
117 | /** | | |||
118 | * clear the view | | |||
119 | */ | | |||
120 | void clear(); | | |||
121 | | ||||
122 | void loadInvestmentTab(); | | |||
123 | | ||||
124 | void loadInvestmentItem(const MyMoneyAccount& account); | | |||
125 | | ||||
126 | void loadSecuritiesList(); | | |||
127 | | ||||
128 | void loadSecurityItem(QTreeWidgetItem* item, const MyMoneySecurity& security); | | |||
129 | | ||||
130 | protected slots: | | |||
131 | void slotTabCurrentChanged(int index); | | |||
132 | /** | 70 | /** | ||
133 | * This slot receives the signal from the listview @c lv control that the context menu | 71 | * This slot is used to reload (filters + equities account) specific tab | ||
134 | * was requested for @c item at @c point. | | |||
135 | */ | 72 | */ | ||
136 | void slotInvestmentContextMenu(const QPoint& point); | 73 | void slotLoadTab(int index); | ||
137 | 74 | | |||
138 | void slotInvestmentSelectionChanged(); | 75 | void slotEquitySelected(const QModelIndex ¤t, const QModelIndex &previous); | ||
76 | void slotEquityRightClicked(const QPoint& point); | ||||
77 | void slotEquityDoubleClicked(); | ||||
78 | void slotSecuritySelected(const QModelIndex ¤t, const QModelIndex &previous); | ||||
139 | 79 | | |||
140 | void slotUpdateSecuritiesButtons(); | | |||
141 | void slotEditSecurity(); | 80 | void slotEditSecurity(); | ||
142 | void slotDeleteSecurity(); | 81 | void slotDeleteSecurity(); | ||
143 | 82 | | |||
83 | /** | ||||
84 | * This slot is used to programatically preselect account in investment view | ||||
85 | */ | ||||
86 | void slotSelectAccount(const QString &id); | ||||
144 | 87 | | |||
145 | signals: | | |||
146 | /** | 88 | /** | ||
147 | * This signal is emitted, if an account has been selected | 89 | * This slot is used to load investment account into tree view | ||
148 | * which cannot be handled by this view. | | |||
149 | */ | 90 | */ | ||
150 | void accountSelected(const QString& accountId, const QString& transactionId); | 91 | void slotLoadAccount(const QString &id); | ||
151 | 92 | | |||
93 | signals: | ||||
152 | void accountSelected(const MyMoneyObject&); | 94 | void accountSelected(const MyMoneyObject&); | ||
153 | 95 | | |||
154 | void investmentRightMouseClick(); | 96 | void equityRightClicked(); | ||
155 | 97 | | |||
156 | /** | 98 | /** | ||
157 | * This signal is emitted whenever the view is about to be shown. | 99 | * This signal is emitted whenever the view is about to be shown. | ||
158 | */ | 100 | */ | ||
159 | void aboutToShow(); | 101 | void aboutToShow(); | ||
160 | 102 | | |||
161 | private: | 103 | private: | ||
162 | /// \internal d-pointer class. | | |||
163 | class Private; | 104 | class Private; | ||
164 | /// \internal d-pointer instance. | | |||
165 | Private* const d; | 105 | Private* const d; | ||
166 | 106 | | |||
167 | const QString m_currencyMarket; | 107 | KMyMoneyApp *m_kmymoney; | ||
108 | KMyMoneyView *m_kmymoneyview; | ||||
109 | | ||||
110 | /** Initializes page and sets its load status to initialized | ||||
111 | */ | ||||
112 | void init(); | ||||
113 | | ||||
168 | /** | 114 | /** | ||
169 | * Search widget for the securities list | 115 | * This slot is used to programatically preselect default account in investment view | ||
170 | */ | 116 | */ | ||
171 | KTreeWidgetSearchLineWidget* m_searchSecuritiesWidget; | 117 | void selectDefaultInvestmentAccount(); | ||
118 | enum Tab { Equities = 0, Securities }; | ||||
172 | 119 | | |||
173 | /** | 120 | /** | ||
174 | * This member holds the load state of page | 121 | * This slots are used to reload tabs | ||
175 | */ | 122 | */ | ||
176 | bool m_needLoad; | 123 | void loadInvestmentTab(); | ||
124 | void loadSecuritiesTab(); | ||||
177 | 125 | | |||
178 | /** Initializes page and sets its load status to initialized | 126 | /** | ||
127 | * This slots returns security currently selected in tree view | ||||
179 | */ | 128 | */ | ||
180 | void init(); | 129 | MyMoneySecurity currentSecurity(); | ||
130 | | ||||
131 | /** | ||||
132 | * This member holds the load state of page | ||||
133 | */ | ||||
134 | bool m_needLoad; | ||||
181 | }; | 135 | }; | ||
182 | 136 | | |||
183 | #endif | 137 | #endif |