Setup Makefile for Qt/C++ builds

Setup the build variables for building with QtWidgets, and add rules for
processing the Q_OBJECT macros with moc and generate widget code from
.ui files with uic.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Have some C++ file in the project

Rename gtk-gui.c to qt-gui.cpp, and make the necessary changes so that
the project still builds.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Introduce QApplication

Instantiate a QApplication and let Qt handle the event loop.
Add a QTranslator subclass to translate the UI via gettext.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Match subsurface_get_conf* in windows/macos.c with linux.c

The signatures for subsurface_get_conf* in windows.c and macos.c
was slightly different from those in linux.c, which broke the
build (at least on Mac).

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Define QT_NO_KEYWORDS

This prevents Qt headers from defining macro symbols such as "emit" and
"signals", therefore avoiding conflicts when struct members with the
same names are defined in some C header.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Improve Makefile rules for running moc

The previous rules were conflicting, and the naming of the moc-generated
file to be included in .cpp files was deviating from what's most used in
Qt: the usual way is to
  #include "file.moc"
and not
  #include "file.moc.cpp"

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Move set_filename() calls outside of parse_file()

Remove the boolean parameter from parse_file; the code is more readable
by having an explicit call to set_filename() where necessary, rather
than a boolean parameter.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Add a Qt main window

This is just an empty window with a File menu and a few items.
It shows how to hook up functions to menu actions.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
planning: Add option to have last stop at 6m/20ft

When diving in areas where there are risk of boats passing above you,
its common practise to do the last stop at 6m to better stay out of
harms way. When doing o2-deco, it doesn't matter for the deco time if
you are doing all the time at 6m, due to that you don't have any inert
gas in your breathing gas.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Windows installer needs libsqlite

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Separate Gtk related code from core logic: divelist

This is simplistic & brute force: any function that touches Gtk related
data structures is moved to divelist-gtk.c, everything else stays in
divelist.c.

Header files have been adjusted so that this still compiles and appears to
work. More thought is needed to truly abstract this out, but this seems to
be a good point to commit this change.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Continue to separate Gtk related code from core logic: divelist

Move some more logic out of the divelist-gtk.c file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Move set_filename() calls outside of parse_file()

Remove the boolean parameter from parse_file; the code is more readable
by having an explicit call to set_filename() where necessary, rather
than a boolean parameter.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Separate Gtk related code from core logic: divelist

This is simplistic & brute force: any function that touches Gtk related
data structures is moved to divelist-gtk.c, everything else stays in
divelist.c.

Header files have been adjusted so that this still compiles and appears to
work. More thought is needed to truly abstract this out, but this seems to
be a good point to commit this change.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Continue to separate Gtk related code from core logic: divelist

Move some more logic out of the divelist-gtk.c file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge branch 'cleanup-from-Qt-branch' of github.com:henrik242/subsurface
Start creating the Qt UI

This is based on several commits from Tomaz - mingled together and mildly
extended by Dirk (mostly Makefile hacking).

All Qt UI related stuff should eventually move into the qt-ui directory.
So the Makefile rules for moc and uic have been adjusted accordingly.

The MainWindow class has been moved into its own file in qt-ui (but just
with a placeholder, the existing class has simply been ifdef'ed out in
qt-gui.cpp for the moment).

We still have a couple of Qt things in qt-gui.cpp in the main directory...
all this needs to move into the qt-ui directory and be built with separate
.h files. Right now we have the one-off Makefile rule to create the
qt-gui.moc file from the qt-gui.cpp file.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Separate Gtk related code from core logic: planner

Relatively straight forward, just a handful of places where we call
show_error() (a UI function) from the logic code. In the process I noticed
a few places where error returns weren't dealt with correctly.

Added a new planner.h files for the necessary declarations.

This should make no difference to functionality.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix some of the gcc-4.8 warnings

Most of the warnings are IMHO false positives:
e.g.: an enum variable is initialized in a switch statement that has a case for
      each possible enum value - yet gcc 4.8 warns that it could be used
      uninitialized;
or:   two variables are initialized together in the code - second one of them
      is previously initialized to -1 at declaration time, both are initialized
      in an if (second one == -1) clause - so they are guaranteed to both be
      initialized...
I did not "fix" those as the code is actually correct.

But there are three spots where it catches things that could indeed go wrong
(with odd input data in one of them).

This commit also adds a check to only call g_type_init() for older versions of
glib as in newer ones it is deprecated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix some of the gcc-4.8 warnings

Most of the warnings are IMHO false positives:
e.g.: an enum variable is initialized in a switch statement that has a case for
      each possible enum value - yet gcc 4.8 warns that it could be used
      uninitialized;
or:   two variables are initialized together in the code - second one of them
      is previously initialized to -1 at declaration time, both are initialized
      in an if (second one == -1) clause - so they are guaranteed to both be
      initialized...
I did not "fix" those as the code is actually correct.

But there are three spots where it catches things that could indeed go wrong
(with odd input data in one of them).

This commit also adds a check to only call g_type_init() for older versions of
glib as in newer ones it is deprecated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>