Commit graph

7890 commits

Author SHA1 Message Date
Gehad elrobey
b4e1563d10 Printing: remove the print_options struct from display.h
Move print_options struct to printoptions.h, its more relevant to be
placed here.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:59 -07:00
Gehad elrobey
1cff998f84 Printing: Remove more obsolete code from printlayout
This code can be removed as we don't need QT printing code anymore.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:55 -07:00
Gehad elrobey
a0b8eed612 Printing: Edit the print options widget
Remove obsolete code and add new customizable print code to the options
dialog.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:50 -07:00
Gehad elrobey
912606e1c7 Printing: Remove the obsolete code from PrintDialog
We don't need any further calls to printLayout as it will be replaced by
Printer class that handles the new custom printing capability.
Also fix one coding style issue.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:46 -07:00
Gehad elrobey
0307ae98c2 Printing: Change "NEW_PRINTING" to "NO_PRINTING"
If NO_PRINTING is not set, subsurface will require grantlee during
building. As Grantlee will be a hard dependency for Subsurface, so no
Grantlee means no printing.

[Dirk Hohndel: switched default for NO_PRINTING to ON]

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:41 -07:00
Gehad elrobey
6de5cfb7a4 Printing: Add Printer class that holds the rendering logic.
Render Html pages into a QWebView then print it using QPainter. the
Printer::print() is called that prepare the HTML file to be rendered by
the QWebView.
Printer::render() will do the rendering task.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:35 -07:00
Gehad elrobey
e2ad38189e Printing: Add TemplateLayout class
This is the main class to hold Grantlee engine logic.
TemplateLayout::generate() loads QT5Grantlee and initialize the
templates then returns a QString that contains the rendered HTML by
Grantlee library.

Also this class contains the Dive class which holds the logic that
formats the data before passing it to the templates.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:25 -07:00
Lubomir I. Ivanov
00f4b7b66b Cmake: add optional pkg-config for Grantlee
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:18 -07:00
Gehad elrobey
be7f8dde71 CMAKE: Require Grantlee library
-find Grantlee package
-install the printing_templates directory

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:06 -07:00
Gehad elrobey
672039c44f Printing: Create two dives per page grantlee template
This is just a HTML/CSS template file which will be used
as the basis for initial Grantlee development.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-04 10:05:11 -07:00
Dirk Hohndel
f8a3a85210 Fix potential crash using std::sort
It's entirely unclear why std::sort sometimes accesses the element with
index -1. In my limited testing switching to qSort avoids that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 08:45:45 -07:00
Tomaz Canabrava
37aebe0b2e Make the plus button work.
This fixes a signal being emitted.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 07:18:35 -07:00
Dirk Hohndel
778204d662 Cmake: handle the case of local libgit2 but pkg_config for libssh2
Yes, it's kinda weird but that's what I happen to have on one of my
systems and this seems easy enough to implement.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 22:15:26 -07:00
Tomaz Canabrava
4805f3c995 Set the MessageBox stretching rules.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:48:19 -07:00
Tomaz Canabrava
d29d2a43ec Connect the signals
Connect the signals and slots so we can use the stuff I programmed.

Sorry for the noise on the patch - most of this is whitespace
fixes done by the QtCreator.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:48:09 -07:00
Tomaz Canabrava
ddc7717ab8 Remove broken method
This method was written a long time ago, now we need to use the new
versions of it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:46:50 -07:00
Tomaz Canabrava
203c3e3077 Fix acceptChanges for add mode
We didn't save the uuid of the newly created dive site on the affected
dive.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:45:26 -07:00
Tomaz Canabrava
8ff7826302 Fix reject changes for add/edit
Reject changes was correct only for Edit, but not for Add. When in add
mode we need to retrieve the old dive site, and when in edit mode we
should do nothing.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:44:49 -07:00
Tomaz Canabrava
af22ebf3f1 Do not set the state of the application from here.
The mainwindow should manage the mainwindow.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:44:32 -07:00
Tomaz Canabrava
484fdee6fb Fire signals for edit and filtering
Edit will always fire,
Filtering only if the dive site already exists.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:43:53 -07:00
Tomaz Canabrava
6a09062065 Only filter by divesite if the divesite exists
And not when we are adding a new dive site.
Also, remove hide button call.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:43:30 -07:00
Tomaz Canabrava
db333226d9 Reset state: have a correct dive site being displayed
I'm not sure if this is the right approach, but it seems to work: when we
reset the state of the widget, we try to get the current dive site from
the current dive, and set it.

This way it will work for the globe later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:43:07 -07:00
Tomaz Canabrava
3561d34745 Current dive site has nothing to do with enableEdition
It will be set later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:42:40 -07:00
Tomaz Canabrava
9c34f196fa Fix the message buttons in dive_site_edit
Some button management operations where unnecessary.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:42:00 -07:00
Tomaz Canabrava
efeca58474 Correctly decrease the number of rows in the dive_site model
We were removing the dive site, but forgetting to decrease the amount of
rowCount, leading to crashes.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:41:21 -07:00
Tomaz Canabrava
537dcb15e0 Use CMake to find libssh2
This works on my system, I hope I don't break others.
Another possibility is to pass -libssh2 directly if it's NOTFOUND.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:39:26 -07:00
Tomaz Canabrava
09ca240c3e Do not reset the model when adding a new dive site
This makes insertion faster, and also it doesn't break the current
selection in the QComboBox.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:38:19 -07:00
Tomaz Canabrava
612b068e33 Different states for edit / add dive site
When we start the dive site edit dialog, either for add or for edit, we
don't save the state, so the reject state didn't know what to do with the
dive site.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:36:42 -07:00
Tomaz Canabrava
4c978eab2e Remove unnecessary calls
All those calls are unnecessary:
The first will be called when the QComboBox in the MainTab changes
its index, and the other two calls shouldn't be called: the only thing
that should change a dive site inside the LocationManagement is the
LocationManagement.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:35:34 -07:00
Tomaz Canabrava
f367414297 centerOnCurrentDive needs to be a slot
I'll connect this in the future with a few methods that will try to
maintain state between dive changes.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:35:08 -07:00
Tomaz Canabrava
ad5f1682ee Clear up editDiveGeoPosition for the new approach
We can only enter in editing state by opening the editing dialog, so the
mainwindow check is now invalid. and also we shouldn't set the editingmode
to false, since we will edit until the user clicks close.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:34:27 -07:00
Tomaz Canabrava
34b406556d Use for_each_dive_site to populate the dives in the globe
When we didn't have a proper dive_site_table, the dive sites where
scattered across all dives and so we looped over all dives to find the
dive sites and add them to the tree. Now this is a bit cleaner, a bit
faster.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:33:28 -07:00
Tomaz Canabrava
fa373fd544 Rework the method to pick a dive site via the globe
The globe used to allow the user to pick a dive site if the dive didn't
have coordinates, but this is now wrong since when in dive site editing
mode we can select multiple times new coordinates for it, and it should
only be marked as finished when the user actually finishes it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:32:36 -07:00
Tomaz Canabrava
7507c96dcd Do not trigger a dive site change when setting a dive
When setting a dive, we fire the dive site change a few times after the
index of the QComboBox is changed; we don't need that - fire just once.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:31:51 -07:00
Tomaz Canabrava
a0c396f5cf Don't clear the underline model of the combobox
Clear was the right method to call when we used a line edit, and the line
edit didn't had a model to provide data. Calling clear() on a QComboBox
will delete all itens inside of it, and what we wanted was to choose an
invalid index - and that's -1

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:31:10 -07:00
Tomaz Canabrava
744ab4bc48 Remove commented out code
This code was commented out when I started to port the locations to new
code, and it's harmless to remove it now.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:30:12 -07:00
Tomaz Canabrava
1ee96f4ad6 Don't rely on current_dive to get the dive site id
Since we are modifying the dive site inside of the dive, we can't ask the
dive for the new one, and we also can't use the name of the dive site, as
there's the possibility that two or more could have the same name, so rely
only on the index of it to get the uuid. The index is variable since we
will sort the dive_site_table alphabetically, but this doesn't matter
since we are using it only temporarely to get the uuid, and this one never
changes.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:28:04 -07:00
Tomaz Canabrava
ef10490e03 Update KMessageWidget to KF5
The KMessageWidget that we used was from an ancient version of KDE4, KF5
is out for quite a while, so it's good that we also update our software
that uses parts of KDE.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:26:31 -07:00
Robert C. Helling
be0a708db0 Two if's to prevent null pointer dereferencing
I need these to prevent subsurface from segfaulting when opening a new log.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:25:46 -07:00
Miika Turkia
16ac0bc45d Support for changed DM5 sample blob
Block size for sample is now variable, so detect the version and parse
proper blocks.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-02 10:48:46 -07:00
Dirk Hohndel (Intel)
0ae40b4069 Build script: remove Subsurface.app before building on Mac
The make install step otherwise will give some odd warnings as it tries to
adjust things from build to deploy.

Signed-off-by: Dirk Hohndel (Intel) <dhohndel@dhohndel-mac02.jf.intel.com>
2015-06-02 10:43:13 -07:00
Dirk Hohndel (Intel)
5823683229 Build script: use Subsurface-testing branches of marble and libdivecomputer
While in a release we'd want to use the corresponding release branches, it
seems to make more sense to me to switch to the testing branches for Subsurface
master.

Signed-off-by: Dirk Hohndel (Intel) <dhohndel@dhohndel-mac02.jf.intel.com>
2015-06-02 10:41:29 -07:00
Dirk Hohndel (Intel)
3de62f5275 Build script: build libssh on Mac
Signed-off-by: Dirk Hohndel (Intel) <dhohndel@dhohndel-mac02.jf.intel.com>
2015-06-02 10:40:28 -07:00
Dirk Hohndel (Intel)
e8f9a7c502 Build script: create log file by default
Signed-off-by: Dirk Hohndel (Intel) <dhohndel@dhohndel-mac02.jf.intel.com>
2015-06-02 10:22:10 -07:00
Tomaz Canabrava
6cd85d9b73 Simplify model handling and crashes fixes
So, there's only one crash left (that I put a big TODO: on the maintab.cpp
about) and I'll fix it tomorrow as it's quite late here and I'm almost
sleeping at the keyboard.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:36:48 -07:00
Tomaz Canabrava
ee9746c622 Remove unused method
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:36:36 -07:00
Tomaz Canabrava
9dc32de878 Remove Combobox from LocationManagement
I tought about it a bit, and the combobox of the location management was a
bit overkill - we already have another combobox to select the divesite and
also the plus button to add one.

If the user wanna edit the current divesite, he can go to menu and edit it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:35:50 -07:00
Tomaz Canabrava
3d63fc9855 Remove unused buttons on the ui.
We are not going to use the add, edit, remove buttons. Removing will be
automatical, addition will be triggered when clicking on the plus on the
dive site. edit is automatically enabled as soon as you try to edit
anything.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:35:06 -07:00
Tomaz Canabrava
a9ba98942c Correctly change the dive_site name
Correctly change and update the dive_site, updating the name on the
combobox or other attached views.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:31:16 -07:00
Dirk Hohndel
64753e0682 Fix dive site sorting
std::sort sorts [first,last) so last is excluded.

Also fix the mis-spelling of the compare function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 17:00:09 -07:00