In my opinion opening file has little to do with views, so I moved it to KMyMoneyApp. KMyMoneyApp in many places already called KMyMoneyView in this regard, so the move around seems like a good choice.
It also serves as a one step forward in making KMyMoneyView independent of KMyMoneyApp.
The next step would be to reduce a rather long code to open a simple file.
Details
- Reviewers
tbaumgart - Commits
- R261:10a45740e867: Move opening files to KMyMoneyApp
I opened and saved: database, kmy file, gnc file.
Diff Detail
- Repository
- R261 KMyMoney
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Code in KMyMoneyApp has been refactored in following way:
- no deep and long "if trees" to improve code readability,
- gnc file is opened like a normal kmy file,
- all file related methods were moved to pimpl,
- code path for opening database and nondatabase has been explicitly divided, as it differs too much right now,
- code for initializing storage has been divided into functional blocks, for better readability,
- opening nondatabase throws lot of exceptions for debugging purposes.
I have not yet tested to compile or run the patch but still have to do that before I can give a judgment.
kmymoney/kmymoney.cpp | ||
---|---|---|
468 | Isn't q->d->fixFile_0(); the same as fixFile_0(); ? | |
850 | Ah, here's a nice one: can't we add a method to the plugin that takes care of the detection? We pass the qbaFileHeader and the plugin tells us, if it is capable of reading the file (no matter how). This way, we can eliminate the GNC stuff here and move it into the plugin. | |
996 | Can't the QString::fromLatin1("~") be a QLatin1String("~") ? | |
2515 | Same here: the plugin should take care of adding it's own stuff that it supports. E.g. const QString fileExtension = plugin->fileExtension(); if (!fileExtension.isEmpty()) { fileExtensions.append(fileExtension); fileExtensions.append(QLatin1String(";;")); } No break, because it could have multiple plugins which can read their data file. |
kmymoney/kmymoney.cpp | ||
---|---|---|
850 | I think it's a good idea to have all GNC stuff in GNC plugin. I think, that instead of moulding every storage plugin to pReader we could only require MyMoneyStorageMgr filled up like in the case of SQL. I think it's not good to pass qbaFileHeader, because database can be just a url to connect to and not a physical file you can read through. I would like to divide that method further, shake off some more unneeded stuff and create XML storage plugin. Then we could have handlers of files in plugins which would be self contained units. I think the change you request could go in follow-up patches. | |
996 | QStringLiteral is more appropriate here. Please check header file of KBackup::numberedBackupFile. | |
2515 | I think it could be arranged. |