Commit Graph
100 Commits
Author SHA1 Message Date
Geert Janssens 87a0cb7360 Gtk3: fix direct access issue for entry widget in cell renderer mode
The old code directly accessed a member variable of GtkEntry. This
direct access is no longer possible, but there is no public function
to get/set this variable. There is a private one  used by
GtkComboBox internally) but it's not exported so it can't be used either.

As an interim solution I peeked at how hesiod handled it in his earlier
(unmerged) gtk3 branch. He replaced this private access with setting
gtk_widget_set_visible, something I wouldn't have considered in this
situation. The issue is in the register2 code, so for now it's not
too important. We can investigate this more when the register rewrite
is picked up again.
2017-04-14 19:21:34 +02:00
Geert Janssens 2ca938bd67 Gtk3: Fix the remaining gtk direct access violations
These could not be fixed in Gtk2 because the accessor functions were only added as of Gtk3.
2017-04-14 19:21:34 +02:00
Geert Janssens 42264efd1b Gtk3: adapt to changed callback function signature 2017-04-14 19:21:34 +02:00
Geert Janssens 3065005f05 Gtk3: use CSS style instead of old GtkStyle interface 2017-04-14 19:21:20 +02:00
Geert Janssens b9abc0b5ba Gtk3: Fix cursor handling 2017-03-31 14:04:31 +02:00
Geert Janssens 9b5fbcb2cb Gtk3: GtkObject has been removed
Replace with GtkWidget instead
2017-03-31 14:04:31 +02:00
Geert Janssens 2528bfde6b Switch to building with the gtk+-3.0 toolkit 2017-03-31 14:04:31 +02:00
Geert Janssens 539ef52837 Whitespace cosmetics
Replace tabs with spaces
Align some related lines
Remove trailing whitespace
2017-03-23 23:16:10 +01:00
Geert Janssens 88a482c5d3 Use GncRational directly instead of gnc_numeric in gnc-trans-props 2017-02-20 18:04:27 +01:00
Geert Janssens 92969b4e39 Prevent the user from setting an invalid settings name
The keyfile that stores the settings won't accept '[' and ']' as settingss names,
so this commit will prevent the user from entering these characters. They are
automatically replaced with the valid '(' and ')' characters.

In addition any attempt to save settings with an invalid name via a code path
bypassing the gui will be refused.
2017-02-20 18:04:25 +01:00
Geert Janssens e92c5ebad4 Move column parsing earlier up the chain of events
In this form not all data needs reparsing when a single column
changes. The drawback is it makes the code slightly more complicated
because accounts can only be verified after the account match page
has completed, while most columns are set on the preview page.
2017-02-20 18:04:22 +01:00
Geert Janssens 1660276e29 Copyright updates 2017-02-20 18:04:19 +01:00
Geert Janssens 5ba4764a2d Add a reset member function to GncPreTrans and GncPreSplit
These will be used in future commits
2017-02-20 18:04:16 +01:00
Geert Janssens 5b446cd9a1 Make sure all lines are checked for errors, regardless of their skipped status
Which errors get actually reported the user remains filtered based on the
line skipping options the user has set.
2017-02-20 18:04:14 +01:00
Geert Janssens f8470ffa4c Isolate the gtk callbacks from the assistant class' member variables.
This required some refactoring of a number of callback funtions.
2017-02-20 18:04:11 +01:00
Geert Janssens f85e52beee Consistently use gnucash dialogs instead of generic gtk ones 2017-02-20 17:56:04 +01:00
Geert Janssens d2098bfc84 Use std::unique_ptr for the TxImport object for better memory management 2017-02-20 17:56:02 +01:00
Geert Janssens b629fc97a6 Convert assistant struct into a real c++ class 2017-02-20 17:55:58 +01:00
Geert Janssens b13718ee0b Handle error skipping on the preview page as well and drop the custom page forwarder
With the preview page blocking as long as there are (unskipped) errors
there is no need any more for the assistant to go back from the documentation
page to the preview page in case of errors - the documentation page
can only be reached if all required data is valid.
This required some additional tweaks to other functions that were
written to be called twice in TxImport and no longer will be.
2017-02-20 17:55:54 +01:00
Geert Janssens cfeb1f6388 Complete error checking on the preview page
- Not all possible issues were reported to the user.
- Report column conflicts above the table, and line issues in the first column of the line having the issue
2017-02-20 17:55:41 +01:00
Geert Janssens 522b75ee18 Move account searching to GncTxImport as it's responsible for the data
And use c++ containers to do the heavy lifting
2017-02-20 17:55:39 +01:00
Geert Janssens 1a1a3fc951 Remove redundant code 2017-02-20 17:55:35 +01:00
Geert Janssens e4fc93ffe0 Cleanup round - move functions up and down to group related ones 2017-02-20 17:55:33 +01:00
Geert Janssens 0d721b795c Cleanup round
- m_ prefix all member variables
- delay variable declarations until actually needed
- use auto where possible for variable declarations
- use standard c(++) types and constants where possible
- rename variables and functions to be more consistent
- set gui callbacks as much as possible in the glade file
- drop unused parameters
2017-02-20 17:55:31 +01:00
Geert Janssens 4032b553f4 Revisit csv settings
- Store importer settings in a separate object inside the CsvTxImport
- make CsvTxImport responsible for maintaining a consistent settings state
- reduce the assistant's responsability to passing settings changes to CsvTxImport and
  visual display. It no longer does validation
- Refine the gui some more
2017-02-20 17:55:27 +01:00
Geert Janssens 26e59c4e21 Revisit error checking on the preview page.
- make the CsvTxImport class responsible for the check
- guide the user with suggestions rather than have the user click through to the next page to find out things weren't set up properly
2017-02-20 17:55:23 +01:00
Geert Janssens e5a175a2c7 Move the base account selection to the preview page 2017-02-20 17:55:21 +01:00
Geert Janssens e6e36d648b Add account selector to the preview window 2017-02-20 17:55:16 +01:00
Geert Janssens 550a431cdc Some variable declaration cleanups 2017-02-20 17:55:13 +01:00
Geert Janssens 7a381cd88b Make sure row coloring happens each time the preview is updated 2017-02-20 17:55:11 +01:00
Geert Janssens 91c4202f2a Remove redundant check for valid column types
The CsvTransSettings object guarantees all types in the vector are valid
so there's no need any more to check this again in the assistant.
2017-02-20 17:55:08 +01:00
Geert Janssens 7fdf135a54 Revisit csv trans import settings handling
- move all gtk related stuff to the assistant code
- move all checks to the settings object, the assistant should query that
- handle sensitivity of the save and delete button more intelligently
2017-02-20 17:55:06 +01:00
Geert Janssens 718a755f67 Drop fixed-format csv importer
It's functionality has been completely replicated
in the generic csv importer.
2017-02-20 17:55:03 +01:00
Geert Janssens a0320d3a21 Allow user to only select column_types that make sense in the current context
The context being either multi-split or two-split. There's no use
in selecting a Transaction ID column in two-split mode for example.
Similarly none of the 'Transfer xzy' types will be used in
multi-split mode.
2017-02-20 17:55:00 +01:00
Geert Janssens 0b345d471e Drop balance column from csv importer
In its current state it will only work for a very restricted context.
However there's no code to validate this context so the importer will
happily produce wrong results in all other contexts.
A query on the mailing list didn't return any interest in this feature
so instead of fixing it I'd rather drop it to keep the code clean.
2017-02-20 17:54:57 +01:00
Geert Janssens 847b140b34 Adapt csv export format to new csv importer capabilities 2017-02-20 17:54:54 +01:00
Geert Janssens 35ba4ec92f Extend csv importer to be able to import multi-currency and stock transactions 2017-02-20 17:54:52 +01:00
Geert Janssens 49bbbca1d5 Extend csv importer to be able to import voided transactions 2017-02-20 17:54:46 +01:00
Geert Janssens 95d7e17c7b Extend csv importer to be able to import reconcile states
A detail worth noting: contrary to most other date fields
an empty value for a reconcile date is allowed if the reconcile
field is not set to 'y' (reconciled).
2017-02-20 17:54:43 +01:00
Geert Janssens 2492931094 Add additional check before creating splits or transactions
This allows the code following the check to make certain assumptions about the state
of the prop objects.
2017-02-20 17:54:40 +01:00
Geert Janssens d2597ef1e2 Defer testing boost:optionals until really needed
Similarly only lookup book when really needed
2017-02-20 17:54:38 +01:00
Geert Janssens 848c7b8f8e Create trans/split props only when needed and have them keep their own value of date/currency format 2017-02-20 17:54:35 +01:00
Geert Janssens 443237f2b9 Extend csv importer to be able to import split action fields
At the same time drop the exception handling for the num for action setting.
The importer can't possibly get this right automatically in all cases. It's
now up to the user to assign the right columns to the correct properties
based on how he/she wants gnucash to store it internally.
2017-02-20 17:54:33 +01:00
Geert Janssens 5950b902a4 Avoid assigning empty or null char*'s to a std::string
Apparently this can cause segfaults
2017-02-20 17:54:30 +01:00
Geert Janssens 6d304d3c3e csv import prefs - store coltypes as strings
Additionally use g_key_file_[gs]_<type>_list to store and retrieve coltypes and colwidths
instead of storing/retrieving a raw string to parse afterwards
2017-02-20 17:54:26 +01:00
Geert Janssens 1fc4b3cd9b Convert column_widths to a vector 2017-02-20 17:54:24 +01:00
Geert Janssens 9e70166b8e Drop superfluous code that sets the default in case of an error.
The returned values in case of an error from the g_key_file_get* are
the correct defaults in most cases already.
In addition:
- Reduce number of temporary variables
- Fix a memory leak while testing the saved data
2017-02-20 17:54:21 +01:00
Geert Janssens e8d24e193b Use std::vector to store column types, and a few other data type changes 2017-02-20 17:54:14 +01:00
Geert Janssens 7a69d552bd Convert CsvTransSettings into a c++ class 2017-02-20 17:54:12 +01:00
Geert Janssens dcce2d79cd Remove final dependencies on GOFFICE
This was still pulled in via the now removed gnc-csv-model.
In order to remove this, the fixed format csv importer
has been tweaked to get the required features from
the c++ csv importer code instead.
2017-02-20 17:54:09 +01:00
Geert Janssens 861bff3f3b Fix error handling in the multi-split case (and probaly in the other case as well)
Dereferencing an iterator and then assigning it to another variable
apparently copies the object the iterator points at, instead
of making a reference to it. C++ beginner mistakes...
Also do the multi-split parent dance before handling errors. Otherwise
child lines would be mistakenly added to the first working parent split
instead of also being skipped until the parent is fixed.
2017-02-20 17:54:06 +01:00
Geert Janssens 8e20c6404e Introduce multi-split imports in the csv importer
This should be the start for round-trip export-import.
Full roundtrip is not supported yet though. Missing
is multi-currency/commodity imports.
2017-02-20 17:54:03 +01:00
Geert Janssens 4f2980ef42 Rework csv import preview with additional cleanups
- The preview part should be less chaotic now. It already has an option for future multi-split
  import functionality, but that's not used yet
- rename a few variables
- change semantics on start/end lines; this is now communicated in number of lines to skip
- avoid a couple of double value storing (once in the assistant object and onece in the import object)
2017-02-20 17:54:00 +01:00
Geert Janssens 056d20c1f7 Fix memory leaks in the draft transactions object 2017-02-20 17:53:57 +01:00
Geert Janssens 854ee31989 Cleanup commit
- improve comments
- improve variable and function names (to be more concise and to the point
- use 'Transfer Account' instead of 'Other Account' as that's the term used in the rest of gnucash
2017-02-20 17:53:55 +01:00
Geert Janssens 90e5e96f8f Rework the intermediate properties storage
The overly complex templated class hierarchy is replaced
with two simple classes. One to keep the discovered transaction
properties and one for the discovered split properties. Make
both classes responsible for verifying it's state and creating
the necessary objects.
2017-02-20 17:53:52 +01:00
Geert Janssens d642d0804b Refactor parse_to_trans into smaller functions 2017-02-20 17:53:49 +01:00
Geert Janssens ab6dc0f590 Add property structs for transaction vs split properties 2017-02-20 17:52:17 +01:00
Geert Janssens 91df5edaa5 Refactor pair into a tuple in preparation of extending it 2017-02-20 17:51:51 +01:00
Geert Janssens ffa68c6b84 Factor out balance calculating function 2017-02-20 17:51:46 +01:00
Geert Janssens 0d4d92fbb4 Drop unused parameter 2017-02-20 17:51:43 +01:00
Geert Janssens f64d217ed3 Drop remaining GError boilerplate from the c++ importer 2017-02-20 17:51:40 +01:00
Geert Janssens 430875772b Replace GError usage in parse function with proper try catch blocks
In addition fix a crash while loading importer settings that would reduce
the number of columns found in the import file.
2017-02-20 17:51:38 +01:00
Geert Janssens d64c66e68d Replace GError usage in file_format and load_file with proper try catch blocks 2017-02-20 17:51:35 +01:00
Geert Janssens b9e73d923e Throw in case date can't be parsed instead of returning -1 as date 2017-02-20 17:51:33 +01:00
Geert Janssens bbac6aa1c5 Various small C++ and other cleanups
- Use CamelCase for type definitions and _ for function names
- m_ for member variables
- avoid typedef (not needed for structs, replace by using for aliases)
- use std::string for composing strings
- fix condition part in for loop (can't use , need &&)
- markup comment for doxygen inclusion
2017-02-20 17:51:31 +01:00
Geert Janssens 2638056203 Use gnc-date functions while parsing date strings for consistent timezone handling 2017-02-20 17:51:28 +01:00
Geert Janssens c0d518e870 Migrate the glib based test case for GncTxImport to google-test 2017-02-20 17:51:25 +01:00
Geert Janssens 9525d9b84b Use consistent name for importer class and its filename
The class was still called after the original struct in c and the file
had an almost ok name from when I started the conversion.
Add some usage information to the class as well.
2017-02-20 17:51:22 +01:00
Geert Janssens a6aa76fc76 Fix column sizing for fixed width data
It was written to work with absolute column positions (from stf)
but boost::tokenizer uses column widths instead.
2017-02-20 17:51:19 +01:00
Geert Janssens bce5eaaa1d Prevent crash when switching to fixed with in assistant
The problem was initially the user doesn't have any column offsets
defined which the tokenize function wasn't handling properly
2017-02-20 17:42:49 +01:00
Geert Janssens da0120d533 Readd a column for the error messages when reviewing parse errors 2017-02-20 17:42:46 +01:00
Geert Janssens c1d798d0b0 Return nullptr in case of invalid numeric field to allow proper error handling 2017-02-20 17:42:45 +01:00
Geert Janssens e0caec0e22 Rearrange statements in gnc_csv_preview_update_assist
- Use a more logical grouping for setting up liststores and columns
- Use one common store for all the header line's combo box entries
- Store column number in each combo box entry for later retrieval
2017-02-20 17:42:44 +01:00
Geert Janssens 6adbab1d38 Use one common liststore for all the combocells in the preview header treeview
They all show the same list anyway and this simplifies the code
2017-02-20 17:42:42 +01:00
Geert Janssens bbeb351aa8 Some changes to adhere better to the gnucash coding guidelines
- use m_ prefix on member variables
- prefer passing by reference over copying
2017-02-20 17:42:41 +01:00
Geert Janssens 737cbfb35b Drop fake test in fw tokenizer 2017-02-20 17:42:39 +01:00
Geert Janssens f47d12c373 Add test cases for tokenizer classes 2017-02-20 17:42:38 +01:00
Geert Janssens b425a5e7dd Trim whitespace in case of fixed width input 2017-02-20 17:42:37 +01:00
Geert Janssens 1b44310b04 Replace transactions GList with a std::multimap 2017-02-20 17:42:32 +01:00
Geert Janssens d557c01c88 Another round of small c to c++(11) conversions
- prefer c++ data types (auto, bool, int, std::string)
- iterate over vectors instead of accessing via the [] operator
- use boost::{u32}regex instead of directly manipulating a c-string
2017-02-20 17:42:30 +01:00
Geert Janssens 05c187960a Delay the test for a default account until it's needed 2017-02-20 17:42:29 +01:00
Geert Janssens 11ff8273e5 Fix memory management for the temporary trans properties
This is done by wrapping each property in a minimal template class hierarchy
and keep track of each using a std::shared_pointer
2017-02-20 17:42:28 +01:00
Geert Janssens bebc871fe8 Reduce code duplication by reusing trans_add_split 2017-02-20 17:42:24 +01:00
Geert Janssens 42c2f94b38 Fix memory corruption bug 2017-02-20 17:42:23 +01:00
Geert Janssens 2d42bf5920 Refactor TransProperty stuff to a simple void*
Needs more attention for memory management though.
2017-02-20 17:42:22 +01:00
Geert Janssens f26d3cea7d Replace private data structure TransPropertyList with a std::map
This required moving around a few other parameters
- currency_format and date_format will now be passed directly to the function that needs it
- Account is converted into a trans_prop just like all the other columns the user had selected
2017-02-20 17:42:20 +01:00
Geert Janssens 38b0b356e4 Remove fake csv parsing test 2017-02-20 17:42:19 +01:00
Geert Janssens e6d9a614ad Add some polish to csv_import_trans_file_chooser_confirm_cb
- avoid superfluous string copying
- flatten the nested if structures
- set a default file format before attempting to parse
2017-02-20 17:42:18 +01:00
Geert Janssens 8f9b3d322a Prevent c++ name mangling on functions used as callbacks by gtk 2017-02-20 17:42:17 +01:00
Geert Janssens 5c9f9059a1 csv-imp - use enum instead of strings to track user selected column types 2017-02-20 17:42:16 +01:00
Geert Janssens 0b73a56c29 Convert column type to name mapping into a std::map 2017-02-20 17:42:14 +01:00
Geert Janssens 6f15805c0b Adapt assistant for c++ guid changes 2017-02-20 17:42:12 +01:00
Geert Janssens c21cf18847 Refactor csv assistant code to use GncCsvParseData class instead of gnc-csv-model code 2017-02-20 17:42:11 +01:00
Geert Janssens b9646e9b9a Build assistant-csv-trans-import.c(pp) as c++ 2017-02-20 17:42:10 +01:00
Geert Janssens 142fb61724 Introduce parse error state 2017-02-20 17:42:08 +01:00
Geert Janssens 0f6dc53cd1 Small local variable cleanups 2017-02-20 17:42:07 +01:00
Geert Janssens d85de0124c C++ - use std::pair to store tokenized line together with its error message
Also drop a few variables that carry superfluous data and add more c++11 semantics
2017-02-20 17:42:06 +01:00
Geert Janssens 17b2b4668e C++11 Convert unscoped enum into scoped one
As per recommendation 10 in Meyer's Effective Modern C++

This also means the string array with column type names
can no longer be shared between c and c++ code, so
set up a separate one in c++
2017-02-20 17:42:05 +01:00
Geert Janssens 8f9d2ee826 Use more C++11 features
- use iterators to loop and std::find
  This allows us to use 'continue' on the loop in case
  of errors instead of using an ever more indenting if/else
- Use auto where possible
- Use constant iterators where possible
2017-02-20 17:42:03 +01:00