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>
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>
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>
Forgot to add planner-gtk.c

Oops

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove the toplevel ui directory

This is fron Alberto's first stab at MainWindow, but Tomaz is doing all
this work in the qt-ui directory now...

Reported-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Change tab widget names.

Names for individual tab widgets were not specific and caused warnings
from UIC. Rename the individual widgets to reflect purpose.

[Dirk Hohndel: removed some of the hunks that appeared to be unintentional
               changes not mentioned in the commit log]

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a slot to mainwindow but amend to use Q_SLOTS

For some reason, 'private slots:' causes a build error but private
Q_SLOTS: works.

The error was that 'slots' did not name a type and it appeared to be
insensitive to whether the Makefile rule for .moc was in its current
place or preceeded the rule for .cpp.

Add a slot using the connectByName idiom e.g. actionNew connects to slot
on_actionNew_triggered(). Use qDebug to show this fires if the menu
option is selected.

Above to demonstrate how to begin to link menu to code paths.

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make Qt branch cross-build for Windows

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Makefile: detect which files need moc and uic

Add some magic rules to detect which files need to be processed by the
moc or uic tools, as well as a way to manually specify exceptions.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add stub slots for all menu items

Naming of QActions was inconsistent wrt abbreviations - fixed.

Add stub slots for each action relying on connect by name.

Add qDebug() message to allow people to check that menu items fire
slots; not really necessary but may provide some reassurance as we build
familiarity with Qt.

Some changes to display text for menu items (e.g. Tree becomes View
All).

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>