Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/views/kmymoneyview.h
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
57 | class KTagsView; | 57 | class KTagsView; | ||
58 | class KBudgetView; | 58 | class KBudgetView; | ||
59 | class KScheduledView; | 59 | class KScheduledView; | ||
60 | class KGlobalLedgerView; | 60 | class KGlobalLedgerView; | ||
61 | class IMyMoneyOperationsFormat; | 61 | class IMyMoneyOperationsFormat; | ||
62 | class MyMoneyTransaction; | 62 | class MyMoneyTransaction; | ||
63 | class KInvestmentView; | 63 | class KInvestmentView; | ||
64 | class KReportsView; | 64 | class KReportsView; | ||
65 | class SimpleLedgerView; | ||||
65 | class MyMoneySchedule; | 66 | class MyMoneySchedule; | ||
66 | class MyMoneySecurity; | 67 | class MyMoneySecurity; | ||
67 | class MyMoneyReport; | 68 | class MyMoneyReport; | ||
68 | class TransactionEditor; | 69 | class TransactionEditor; | ||
69 | class KOnlineJobOutbox; | 70 | class KOnlineJobOutbox; | ||
70 | class KMyMoneyTitleLabel; | 71 | class KMyMoneyTitleLabel; | ||
71 | class MyMoneyAccount; | 72 | class MyMoneyAccount; | ||
72 | class MyMoneyMoney; | 73 | class MyMoneyMoney; | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 98 | private: | |||
122 | KTagsView *m_tagsView; | 123 | KTagsView *m_tagsView; | ||
123 | KBudgetView *m_budgetView; | 124 | KBudgetView *m_budgetView; | ||
124 | KScheduledView *m_scheduledView; | 125 | KScheduledView *m_scheduledView; | ||
125 | KGlobalLedgerView *m_ledgerView; | 126 | KGlobalLedgerView *m_ledgerView; | ||
126 | KInvestmentView *m_investmentView; | 127 | KInvestmentView *m_investmentView; | ||
127 | KReportsView* m_reportsView; | 128 | KReportsView* m_reportsView; | ||
128 | KOnlineJobOutbox* m_onlineJobOutboxView; | 129 | KOnlineJobOutbox* m_onlineJobOutboxView; | ||
129 | 130 | | |||
131 | #ifdef ENABLE_UNFINISHEDFEATURES | ||||
132 | SimpleLedgerView* m_simpleLedgerView; | ||||
133 | #endif | ||||
134 | | ||||
130 | QHash<View, KPageWidgetItem*> viewFrames; | 135 | QHash<View, KPageWidgetItem*> viewFrames; | ||
131 | QHash<View, KMyMoneyViewBase*> viewBases; | 136 | QHash<View, KMyMoneyViewBase*> viewBases; | ||
132 | 137 | | |||
133 | KMyMoneyTitleLabel* m_header; | 138 | KMyMoneyTitleLabel* m_header; | ||
134 | bool m_inConstructor; | 139 | bool m_inConstructor; | ||
135 | bool m_fileOpen; | | |||
136 | QFileDevice::Permissions m_fmode; | | |||
137 | int m_lastViewSelected; | 140 | int m_lastViewSelected; | ||
138 | 141 | | |||
139 | QMap<QString, KMyMoneyPlugin::StoragePlugin*>* m_storagePlugins; | 142 | QMap<QString, KMyMoneyPlugin::StoragePlugin*>* m_storagePlugins; | ||
140 | 143 | | |||
141 | // Keep a note of the file type | | |||
142 | typedef enum _fileTypeE { | | |||
143 | KmmBinary = 0, // native, binary | | |||
144 | KmmXML, // native, XML | | |||
145 | KmmDb, // SQL database | | |||
146 | /* insert new native file types above this line */ | | |||
147 | MaxNativeFileType, | | |||
148 | /* and non-native types below */ | | |||
149 | GncXML // Gnucash XML | | |||
150 | } fileTypeE; | | |||
151 | fileTypeE m_fileType; | | |||
152 | | ||||
153 | #ifdef KF5Activities_FOUND | 144 | #ifdef KF5Activities_FOUND | ||
154 | private: | 145 | private: | ||
155 | KActivities::ResourceInstance * m_activityResourceInstance; | 146 | KActivities::ResourceInstance * m_activityResourceInstance; | ||
156 | #endif | 147 | #endif | ||
157 | 148 | | |||
158 | private: | 149 | private: | ||
159 | void ungetString(QIODevice *qfile, char * buf, int len); | | |||
160 | | ||||
161 | /** | | |||
162 | * if no base currency is defined, start the dialog and force it to be set | | |||
163 | */ | | |||
164 | void selectBaseCurrency(); | | |||
165 | | ||||
166 | /** | | |||
167 | * This method attaches an empty storage object to the MyMoneyFile | | |||
168 | * object. It calls removeStorage() to remove a possibly attached | | |||
169 | * storage object. | | |||
170 | */ | | |||
171 | void newStorage(); | | |||
172 | | ||||
173 | /** | | |||
174 | * This method removes an attached storage from the MyMoneyFile | | |||
175 | * object. | | |||
176 | */ | | |||
177 | void removeStorage(); | | |||
178 | | ||||
179 | void viewAccountList(const QString& selectAccount); // Show the accounts view | 150 | void viewAccountList(const QString& selectAccount); // Show the accounts view | ||
180 | 151 | | |||
181 | static void progressCallback(int current, int total, const QString&); | | |||
182 | | ||||
183 | /** | | |||
184 | */ | | |||
185 | void fixFile_0(); | | |||
186 | void fixFile_1(); | | |||
187 | void fixFile_2(); | | |||
188 | void fixFile_3(); | | |||
189 | | ||||
190 | /** | | |||
191 | */ | | |||
192 | void fixLoanAccount_0(MyMoneyAccount acc); | | |||
193 | | ||||
194 | /** | | |||
195 | */ | | |||
196 | void fixTransactions_0(); | | |||
197 | void fixSchedule_0(MyMoneySchedule sched); | | |||
198 | void fixDuplicateAccounts_0(MyMoneyTransaction& t); | | |||
199 | | ||||
200 | void createSchedule(MyMoneySchedule s, MyMoneyAccount& a); | 152 | void createSchedule(MyMoneySchedule s, MyMoneyAccount& a); | ||
201 | 153 | | |||
202 | void checkAccountName(const MyMoneyAccount& acc, const QString& name) const; | | |||
203 | | ||||
204 | public: | 154 | public: | ||
205 | /** | 155 | /** | ||
206 | * The constructor for KMyMoneyView. Just creates all the tabs for the | 156 | * The constructor for KMyMoneyView. Just creates all the tabs for the | ||
207 | * different aspects of the MyMoneyFile. | 157 | * different aspects of the MyMoneyFile. | ||
208 | */ | 158 | */ | ||
209 | explicit KMyMoneyView(KMyMoneyApp *kmymoney); | 159 | explicit KMyMoneyView(KMyMoneyApp *kmymoney); | ||
210 | 160 | | |||
211 | /** | 161 | /** | ||
212 | * Destructor | 162 | * Destructor | ||
213 | */ | 163 | */ | ||
214 | ~KMyMoneyView(); | 164 | ~KMyMoneyView(); | ||
215 | 165 | | |||
216 | /** | 166 | /** | ||
217 | * Makes sure that a MyMoneyFile is open and has been created successfully. | | |||
218 | * | | |||
219 | * @return Whether the file is open and initialised | | |||
220 | */ | | |||
221 | bool fileOpen(); | | |||
222 | | ||||
223 | /** | | |||
224 | * Closes the open MyMoneyFile and frees all the allocated memory, I hope ! | | |||
225 | */ | | |||
226 | void closeFile(); | | |||
227 | | ||||
228 | | ||||
229 | /** | | |||
230 | * Calls MyMoneyFile::readAllData which reads a MyMoneyFile into appropriate | | |||
231 | * data structures in memory. The return result is examined to make sure no | | |||
232 | * errors occurred whilst parsing. | | |||
233 | * | | |||
234 | * @param url The URL to read from. | | |||
235 | * If no protocol is specified, file:// is assumed. | | |||
236 | * | | |||
237 | * @return Whether the read was successful. | | |||
238 | */ | | |||
239 | bool readFile(const QUrl &url, IMyMoneyOperationsFormat *pExtReader = nullptr); | | |||
240 | | ||||
241 | /** | | |||
242 | * Saves the data into permanent storage using the XML format. | | |||
243 | * | | |||
244 | * @param url The URL to save into. | | |||
245 | * If no protocol is specified, file:// is assumed. | | |||
246 | * @param keyList QString containing a comma separated list of keys | | |||
247 | * to be used for encryption. If @p keyList is empty, | | |||
248 | * the file will be saved unencrypted (the default) | | |||
249 | * | | |||
250 | * @retval false save operation failed | | |||
251 | * @retval true save operation was successful | | |||
252 | */ | | |||
253 | bool saveFile(const QUrl &url, const QString& keyList = QString()); | | |||
254 | | ||||
255 | /** | | |||
256 | * Call this to find out if the currently open file is native KMM | | |||
257 | * | | |||
258 | * @retval true file is native | | |||
259 | * @retval false file is foreign | | |||
260 | */ | | |||
261 | bool isNativeFile() { | | |||
262 | return (m_fileOpen && (m_fileType < MaxNativeFileType)); | | |||
263 | } | | |||
264 | | ||||
265 | /** | | |||
266 | * Call this to find out if the currently open file is a sql database | | |||
267 | * | | |||
268 | * @retval true file is database | | |||
269 | * @retval false file is serial | | |||
270 | */ | | |||
271 | bool isDatabase() { | | |||
272 | return (m_fileOpen && ((m_fileType == KmmDb))); | | |||
273 | } | | |||
274 | | ||||
275 | /** | | |||
276 | * Call this to see if the MyMoneyFile contains any unsaved data. | | |||
277 | * | | |||
278 | * @retval true if any data has been modified but not saved | | |||
279 | * @retval false otherwise | | |||
280 | */ | | |||
281 | bool dirty(); | | |||
282 | | ||||
283 | /** | | |||
284 | * Close the currently opened file and create an empty new file. | | |||
285 | * | | |||
286 | * @see MyMoneyFile | | |||
287 | */ | | |||
288 | void newFile(); | | |||
289 | | ||||
290 | /** | | |||
291 | * This method enables the state of all views (except home view) according | 167 | * This method enables the state of all views (except home view) according | ||
292 | * to an open file. | 168 | * to an open file. | ||
293 | */ | 169 | */ | ||
294 | void enableViewsIfFileOpen(); | 170 | void enableViewsIfFileOpen(bool fileOpen); | ||
171 | void switchToDefaultView(); | ||||
172 | void switchToHomeView(); | ||||
295 | 173 | | |||
296 | void addWidget(QWidget* w); | 174 | void addWidget(QWidget* w); | ||
297 | 175 | | |||
298 | void showPage(KPageWidgetItem* pageItem); | 176 | void showPage(KPageWidgetItem* pageItem); | ||
299 | 177 | | |||
300 | /** | 178 | /** | ||
301 | * check if the current view allows to print something | 179 | * check if the current view allows to print something | ||
302 | * | 180 | * | ||
303 | * @retval true Yes, view allows to print | 181 | * @retval true Yes, view allows to print | ||
304 | * @retval false No, view cannot print | 182 | * @retval false No, view cannot print | ||
305 | */ | 183 | */ | ||
306 | bool canPrint(); | 184 | bool canPrint(); | ||
307 | 185 | | |||
308 | void finishReconciliation(const MyMoneyAccount& account); | 186 | void finishReconciliation(const MyMoneyAccount& account); | ||
309 | 187 | | |||
310 | /** | | |||
311 | * This method updates names of currencies from file to localized names | | |||
312 | */ | | |||
313 | void updateCurrencyNames(); | | |||
314 | | ||||
315 | /** | | |||
316 | * This method loads all known currencies and saves them to the storage | | |||
317 | */ | | |||
318 | void loadAllCurrencies(); | | |||
319 | | ||||
320 | void showTitleBar(bool show); | 188 | void showTitleBar(bool show); | ||
321 | 189 | | |||
322 | /** | 190 | /** | ||
323 | * This method changes the view type according to the settings. | 191 | * This method changes the view type according to the settings. | ||
324 | */ | 192 | */ | ||
325 | void updateViewType(); | 193 | void updateViewType(); | ||
326 | 194 | | |||
327 | void slotAccountTreeViewChanged(const eAccountsModel::Column column, const bool show); | 195 | void slotAccountTreeViewChanged(const eAccountsModel::Column column, const bool show); | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 216 | public Q_SLOTS: | |||
394 | /** | 262 | /** | ||
395 | * Called when the user changes the detail | 263 | * Called when the user changes the detail | ||
396 | * setting of the transaction register | 264 | * setting of the transaction register | ||
397 | * | 265 | * | ||
398 | * @param detailed if true, the register is shown with all details | 266 | * @param detailed if true, the register is shown with all details | ||
399 | */ | 267 | */ | ||
400 | void slotShowTransactionDetail(bool detailed); | 268 | void slotShowTransactionDetail(bool detailed); | ||
401 | 269 | | |||
402 | | ||||
403 | | ||||
404 | /** | 270 | /** | ||
405 | * Informs respective views about selected object, so they can | 271 | * Informs respective views about selected object, so they can | ||
406 | * update action states and current object. | 272 | * update action states and current object. | ||
407 | * @param obj Account, Category, Investment, Stock, Institution | 273 | * @param obj Account, Category, Investment, Stock, Institution | ||
408 | */ | 274 | */ | ||
409 | void slotObjectSelected(const MyMoneyObject& obj); | 275 | void slotObjectSelected(const MyMoneyObject& obj); | ||
410 | 276 | | |||
411 | void slotTransactionsSelected(const KMyMoneyRegister::SelectedTransactions& list); | 277 | void slotTransactionsSelected(const KMyMoneyRegister::SelectedTransactions& list); | ||
412 | 278 | | |||
279 | void slotFileOpened(); | ||||
280 | void slotFileClosed(); | ||||
281 | | ||||
413 | private Q_SLOTS: | 282 | private Q_SLOTS: | ||
414 | /** | 283 | /** | ||
415 | * This slots switches the view to the specific page | 284 | * This slots switches the view to the specific page | ||
416 | */ | 285 | */ | ||
417 | void slotShowHomePage(); | 286 | void slotShowHomePage(); | ||
418 | void slotShowInstitutionsPage(); | 287 | void slotShowInstitutionsPage(); | ||
419 | void slotShowAccountsPage(); | 288 | void slotShowAccountsPage(); | ||
420 | void slotShowSchedulesPage(); | 289 | void slotShowSchedulesPage(); | ||
Show All 28 Lines | 316 | protected Q_SLOTS: | |||
449 | * eventually replace this with KMyMoneyApp::slotCurrencySetBase(). | 318 | * eventually replace this with KMyMoneyApp::slotCurrencySetBase(). | ||
450 | * it contains the same code | 319 | * it contains the same code | ||
451 | * | 320 | * | ||
452 | * @deprecated | 321 | * @deprecated | ||
453 | */ | 322 | */ | ||
454 | void slotSetBaseCurrency(const MyMoneySecurity& baseCurrency); | 323 | void slotSetBaseCurrency(const MyMoneySecurity& baseCurrency); | ||
455 | 324 | | |||
456 | private: | 325 | private: | ||
457 | /** | | |||
458 | * This method is called from readFile to open a database file which | | |||
459 | * is to be processed in 'proper' database mode, i.e. in-place updates | | |||
460 | * | | |||
461 | * @param dbaseURL pseudo-QUrl representation of database | | |||
462 | * | | |||
463 | * @retval true Database opened successfully | | |||
464 | * @retval false Could not open or read database | | |||
465 | */ | | |||
466 | bool openDatabase(const QUrl &dbaseURL); | | |||
467 | /** | | |||
468 | * This method is used after a file or database has been | | |||
469 | * read into storage, and performs various initialization tasks | | |||
470 | * | | |||
471 | * @retval true all went okay | | |||
472 | * @retval false an exception occurred during this process | | |||
473 | */ | | |||
474 | bool initializeStorage(); | | |||
475 | /** | | |||
476 | * This method is used by saveFile() to store the data | | |||
477 | * either directly in the destination file if it is on | | |||
478 | * the local file system or in a temporary file when | | |||
479 | * the final destination is reached over a network | | |||
480 | * protocol (e.g. FTP) | | |||
481 | * | | |||
482 | * @param localFile the name of the local file | | |||
483 | * @param writer pointer to the formatter | | |||
484 | * @param plaintext whether to override any compression & encryption settings | | |||
485 | * @param keyList QString containing a comma separated list of keys to be used for encryption | | |||
486 | * If @p keyList is empty, the file will be saved unencrypted | | |||
487 | * | | |||
488 | * @note This method will close the file when it is written. | | |||
489 | */ | | |||
490 | void saveToLocalFile(const QString& localFile, IMyMoneyOperationsFormat* writer, bool plaintext = false, const QString& keyList = QString()); | | |||
491 | 326 | | |||
492 | /** | 327 | /** | ||
493 | * Internal method used by slotAccountNew() and slotAccountCategory(). | 328 | * Internal method used by slotAccountNew() and slotAccountCategory(). | ||
494 | */ | 329 | */ | ||
495 | void accountNew(const bool createCategory); | 330 | void accountNew(const bool createCategory); | ||
496 | 331 | | |||
497 | void resetViewSelection(const View); | 332 | void resetViewSelection(const View); | ||
498 | void connectView(const View); | 333 | void connectView(const View); | ||
Show All 15 Lines | 335 | Q_SIGNALS: | |||
514 | void viewStateChanged(bool enabled); | 349 | void viewStateChanged(bool enabled); | ||
515 | /** | 350 | /** | ||
516 | * This signal is emitted to inform the kmmFile plugin when various file actions | 351 | * This signal is emitted to inform the kmmFile plugin when various file actions | ||
517 | * occur. The Action parameter distinguishes between them. | 352 | * occur. The Action parameter distinguishes between them. | ||
518 | */ | 353 | */ | ||
519 | void kmmFilePlugin(unsigned int action); | 354 | void kmmFilePlugin(unsigned int action); | ||
520 | 355 | | |||
521 | /** | 356 | /** | ||
522 | * This signal is emitted after a data source has been closed | | |||
523 | */ | | |||
524 | void fileClosed(); | | |||
525 | | ||||
526 | /** | | |||
527 | * This signal is emitted after a data source has been opened | | |||
528 | */ | | |||
529 | void fileOpened(); | | |||
530 | | ||||
531 | /** | | |||
532 | * @brief proxy signal | 357 | * @brief proxy signal | ||
533 | */ | 358 | */ | ||
534 | void statusMsg(const QString& txt); | 359 | void statusMsg(const QString& txt); | ||
535 | 360 | | |||
536 | /** | 361 | /** | ||
537 | * @brief proxy signal | 362 | * @brief proxy signal | ||
538 | */ | 363 | */ | ||
539 | void statusProgress(int cnt, int base); | 364 | void statusProgress(int cnt, int base); | ||
Show All 21 Lines |