Commit Graph

17848 Commits

Author SHA1 Message Date
John Ralls
4fef04c17b Remove #ifdef __cplusplus from gnu-numeric.cpp
It’s always compiled with C++.
2017-02-20 15:50:31 -08:00
John Ralls
570c8a8d60 Fix GncInt128 shift operators when shift amount will clear a leg. 2017-02-20 15:50:31 -08:00
John Ralls
4a134ae0b1 Declare GncInt128::div() const
Because it doesn’t change the value of *this, it returns the results in
the return value args.
2017-02-20 15:50:31 -08:00
John Ralls
06d22718f5 Fix minor typos and whitespace issues. 2017-02-20 15:50:30 -08:00
John Ralls
3975b0b465 Change signature of GncRational::round from taking a GncDenominator…
to a separate denominator and RoundType.
2017-02-20 15:50:30 -08:00
John Ralls
6f5d628b12 Move test-numeric from src/engine to src/libqof/qof.
It’s testing a file in qof and doesn’t need to be in engine just because
it uses some functions from test-engine-stuff.
2017-02-20 15:50:30 -08:00
John Ralls
b0dfd96a93 Add GncRational::reduce() and GncRational::round_to_numeric(). 2017-02-20 15:50:30 -08:00
John Ralls
340fb9761c Fix inverted subtraction. 2017-02-20 15:50:30 -08:00
John Ralls
a88d21245e Add guard macro to gnu-rational.hpp. 2017-02-20 15:50:30 -08:00
John Ralls
e1b280b36b Untabify gnu-numeric.cpp. 2017-02-20 15:50:30 -08:00
John Ralls
b1995932fc Remove unused gnc_numeric_foo_with_error functions. 2017-02-20 15:50:30 -08:00
John Ralls
a852dfb4ef Implement basic arithmetic operators for GncRational.
The operators do no rounding or reducing yet.
2017-02-20 15:50:30 -08:00
John Ralls
d9aa5e1ad5 Reorder test parameters so that the expected value is first. 2017-02-20 15:50:30 -08:00
John Ralls
b5f06ab6dc Add an error parameter on the GncInt128 constructor. 2017-02-20 15:50:30 -08:00
John Ralls
43fbb338af Add GTest test program for GncRational.
Starting off with the constructors.
2017-02-20 15:50:29 -08:00
John Ralls
848f77dacf Add explicit and correct default GncRational constructor.
As suggested by Geert Janssens.
2017-02-20 15:50:29 -08:00
John Ralls
b30a547d18 Add ICU libraries on which Boost:locale is dependent to CSV-Import LINK_LIBRARIES. 2017-02-20 15:50:14 -08:00
Geert Janssens
2c5f6b9cc3 Merge branch 'csv_imp_cpp'
This feature branch is about the c++ conversion of the
csv transaction importer.
2017-02-20 20:42:21 +01:00
Geert Janssens
1d552fbe7f Use boost::locale:conv:utf_to_uft instead of codecvt_utf8
The latter is not available until gcc 5.x and we still depend on
gcc 4.8 on some platforms (RHEL/Centos, Travis/Ubuntu 14.04, Windows).
2017-02-20 20:23:20 +01:00
Geert Janssens
558d4b43b2 Properly test for invalid dates (gnc-date C interface no longer throws - rightfully so) 2017-02-20 18:05:05 +01:00
Geert Janssens
cd66fb2e2d Some ui refinement
- Adjust description on the assistant's start page to match current behavior
- Hide separator buttons in case the file format is set to fixed width
- For fixed width display some instructions on how to manipulate columns
- Move the error messages to below the preview table
2017-02-20 18:05:03 +01:00
Geert Janssens
a295680212 Cleanup - use less ambiguous variable name for an iterator 2017-02-20 18:04:59 +01:00
Geert Janssens
372c46cc0f Fix base account reset when an account column is selected
This got broken somehow while refactoring the assistant.
2017-02-20 18:04:57 +01:00
Geert Janssens
61244301f2 Recover separators or column_widths when juggling file format more than once 2017-02-20 18:04:54 +01:00
Geert Janssens
5d96e47b39 Prevent multi-byte characters from erroneously being split in fixed-width mode
This happens because in case std::string is the base type for the tokenizer
the offsets are interpreted as byte offsets although some characters
may consist of more that one byte in utf-8. This is not so for std::wstring
so to solve this issue the fixed width tokenizer is changed to use
wide character strings internally.
2017-02-20 18:04:52 +01:00
Geert Janssens
8d03abac19 Include glib.h as everywhere else 2017-02-20 18:04:49 +01:00
Geert Janssens
6657e6660b Remove some obsolete comments and commented out code 2017-02-20 18:04:46 +01:00
Geert Janssens
4687eb649b Trim newlines from csv data
If the newline happens in the middle some field, replace it with a space.
We can't import newlines in gnucash.
2017-02-20 18:04:44 +01:00
Geert Janssens
9fbbd7366c Fix crash when adding columns by double-clicking the preview data
Each column change would cause the code to completely delete the
existing columns and then add new ones from scratch. For some
reason his upsets the MOVE_NOTIFY event, which is triggered
whenever you move the mouse pointer around. I suspect it internally
keeps a link to the last hovered column to check if the move action
moves the mouse to a different column. As the code removed the columns
this internal references becomes invalid.

I have worked around this by no longer completely recreating the
columns. Instead columns are added or removed as needed to follow
the changes in the data model.

At the same time the refresh function has been split into several
smaller ones.
2017-02-20 18:04:38 +01:00
Geert Janssens
449db62921 Fix settings loading and saving
- fixed width columns widths weren't saved
- column types were lost when loading a fixed width preset
2017-02-20 18:04:35 +01:00
Geert Janssens
5953543573 Improve visual feedback when previewing importable data 2017-02-20 18:04:33 +01:00
Geert Janssens
9ecde3a05d Improve preview table handling
- Properly enable/disable context menu for managing columns in fixed width data mode
- Make this context menu work on the table body instead of the table headers
- Both of the above is done a well for the double-click column creation behaviour
- Migrate the column type setting widgets to the table header cells and remove
  the second (one-row) table, which was only used to allow type selection.
- Use enums instead of magic numbers to access associated treeview models

To fix: for some reason the column headers are no responding to clicks when
the preview page is first opened. However the first time the preview table
is regenerated (pretty much whenever an option is changed) they are. This
should still be debugged.
2017-02-20 18:04:30 +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