mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Cleanup: Unify qthelper.h and qthelperfromc.h
Since all qt-helpers are defined in qthelper.cpp, there seems to be no reason to have two include files. By unifying the two files, duplication and inconsistencies are removed. The C++-only part is simply compiled away with #ifdefs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									e2a6b96db8
								
							
						
					
					
						commit
						cd5e17cf79
					
				
					 19 changed files with 65 additions and 73 deletions
				
			
		| 
						 | 
				
			
			@ -22,7 +22,7 @@
 | 
			
		|||
#include "dive.h"
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include "core/planner.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
 | 
			
		||||
#define cube(x) (x * x * x)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -31,8 +31,6 @@
 | 
			
		|||
// was introduced in v4.6.3 this can be set to a value of 1.0 which means no correction.
 | 
			
		||||
#define subsurface_conservatism_factor 1.0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
extern bool in_planner();
 | 
			
		||||
extern int plot_depth;
 | 
			
		||||
 | 
			
		||||
//! Option structure for Buehlmann decompression.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,7 @@
 | 
			
		|||
#include "libdivecomputer.h"
 | 
			
		||||
#include "device.h"
 | 
			
		||||
#include "divelist.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
 | 
			
		||||
/* one could argue about the best place to have this variable -
 | 
			
		||||
 * it's used in the UI, but it seems to make the most sense to have it
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,7 +44,7 @@
 | 
			
		|||
#include "divelist.h"
 | 
			
		||||
#include "display.h"
 | 
			
		||||
#include "planner.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
#include "git-access.h"
 | 
			
		||||
 | 
			
		||||
static bool dive_list_changed = false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,7 @@
 | 
			
		|||
#include "divelist.h"
 | 
			
		||||
#include "file.h"
 | 
			
		||||
#include "git-access.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
#include "import-csv.h"
 | 
			
		||||
 | 
			
		||||
/* For SAMPLE_* */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@
 | 
			
		|||
#include "dive.h"
 | 
			
		||||
#include "membuffer.h"
 | 
			
		||||
#include "strndup.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
#include "git-access.h"
 | 
			
		||||
#include "gettext.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@
 | 
			
		|||
#include "divelist.h"
 | 
			
		||||
#include "gettext.h"
 | 
			
		||||
#include "import-csv.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
 | 
			
		||||
#define MATCH(buffer, pattern) \
 | 
			
		||||
	memcmp(buffer, pattern, strlen(pattern))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,7 @@
 | 
			
		|||
#include "device.h"
 | 
			
		||||
#include "membuffer.h"
 | 
			
		||||
#include "git-access.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
 | 
			
		||||
const char *saved_git_id = NULL;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -173,9 +173,6 @@ static int get_index(const char *line)
 | 
			
		|||
static int get_hex(const char *line)
 | 
			
		||||
{ return strtoul(line, NULL, 16); }
 | 
			
		||||
 | 
			
		||||
/* this is in qthelper.cpp, so including the .h file is a pain */
 | 
			
		||||
extern const char *printGPSCoords(int lat, int lon);
 | 
			
		||||
 | 
			
		||||
static void parse_dive_gps(char *line, struct membuffer *str, void *_dive)
 | 
			
		||||
{
 | 
			
		||||
	(void) str;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1102,9 +1102,6 @@ static void gps_location(char *buffer, struct dive_site *ds)
 | 
			
		|||
	ds->longitude = parse_degrees(end, &end);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* this is in qthelper.cpp, so including the .h file is a pain */
 | 
			
		||||
extern const char *printGPSCoords(int lat, int lon);
 | 
			
		||||
 | 
			
		||||
static void gps_in_dive(char *buffer, struct dive *dive)
 | 
			
		||||
{
 | 
			
		||||
	char *end;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@
 | 
			
		|||
#include "planner.h"
 | 
			
		||||
#include "gettext.h"
 | 
			
		||||
#include "libdivecomputer/parser.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
#include "version.h"
 | 
			
		||||
 | 
			
		||||
#define TIMESTEP 2 /* second */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@
 | 
			
		|||
#include "planner.h"
 | 
			
		||||
#include "gettext.h"
 | 
			
		||||
#include "libdivecomputer/parser.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
#include "version.h"
 | 
			
		||||
 | 
			
		||||
int diveplan_duration(struct diveplan *diveplan)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@
 | 
			
		|||
#include "libdivecomputer/parser.h"
 | 
			
		||||
#include "libdivecomputer/version.h"
 | 
			
		||||
#include "membuffer.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
 | 
			
		||||
//#define DEBUG_GAS 1
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -30,8 +30,6 @@ unsigned int dc_number = 0;
 | 
			
		|||
static struct plot_data *last_pi_entry_new = NULL;
 | 
			
		||||
void populate_pressure_information(struct dive *, struct divecomputer *, struct plot_info *, int);
 | 
			
		||||
 | 
			
		||||
extern bool in_planner();
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG_PI
 | 
			
		||||
/* debugging tool - not normally used */
 | 
			
		||||
static void dump_pi(struct plot_info *pi)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,19 +2,25 @@
 | 
			
		|||
#ifndef QTHELPER_H
 | 
			
		||||
#define QTHELPER_H
 | 
			
		||||
 | 
			
		||||
#include <QMultiMap>
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include "dive.h"
 | 
			
		||||
#include "divelist.h"
 | 
			
		||||
 | 
			
		||||
// 1) Types
 | 
			
		||||
 | 
			
		||||
enum inertgas {N2, HE};
 | 
			
		||||
 | 
			
		||||
// 2) Functions visible only to C++ parts
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
 | 
			
		||||
#include <QMultiMap>
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QTranslator>
 | 
			
		||||
#include <QDir>
 | 
			
		||||
 | 
			
		||||
QString weight_string(int weight_in_grams);
 | 
			
		||||
QString distance_string(int distanceInMeters);
 | 
			
		||||
bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_text, bool *parsed_out = 0);
 | 
			
		||||
extern "C" const char *printGPSCoords(int lat, int lon);
 | 
			
		||||
extern "C" const char *get_current_date();
 | 
			
		||||
QList<int> getDivesInTrip(dive_trip_t *trip);
 | 
			
		||||
QString get_gas_string(struct gasmix gas);
 | 
			
		||||
QString get_divepoint_gas_string(struct dive *d, const divedatapoint& dp);
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +34,6 @@ void hashPicture(struct picture *picture);
 | 
			
		|||
QString localFilePath(const QString originalFilename);
 | 
			
		||||
QString fileFromHash(const char *hash);
 | 
			
		||||
void learnHash(struct picture *picture, QByteArray hash);
 | 
			
		||||
extern "C" void cache_picture(struct picture *picture);
 | 
			
		||||
weight_t string_to_weight(const char *str);
 | 
			
		||||
depth_t string_to_depth(const char *str);
 | 
			
		||||
pressure_t string_to_pressure(const char *str);
 | 
			
		||||
| 
						 | 
				
			
			@ -38,17 +43,48 @@ int getCloudURL(QString &filename);
 | 
			
		|||
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
 | 
			
		||||
QByteArray getCurrentAppState();
 | 
			
		||||
void setCurrentAppState(QByteArray state);
 | 
			
		||||
extern "C" bool in_planner();
 | 
			
		||||
extern "C" enum deco_mode decoMode();
 | 
			
		||||
extern "C" void subsurface_mkdir(const char *dir);
 | 
			
		||||
void init_proxy();
 | 
			
		||||
QString getUUID();
 | 
			
		||||
QStringList imageExtensionFilters();
 | 
			
		||||
char *intdup(int index);
 | 
			
		||||
extern "C" int parse_seabear_header(const char *filename, char **params, int pnr);
 | 
			
		||||
enum inertgas {N2, HE};
 | 
			
		||||
extern "C" double cache_value(int tissue, int timestep, enum inertgas gas);
 | 
			
		||||
extern "C" void cache_insert(int tissue, int timestep, enum inertgas gas, double value);
 | 
			
		||||
extern "C" void lock_planner();
 | 
			
		||||
extern "C" void unlock_planner();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// 3) Functions visible to C and C++
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
const char *printGPSCoords(int lat, int lon);
 | 
			
		||||
bool in_planner();
 | 
			
		||||
bool getProxyString(char **buffer);
 | 
			
		||||
bool canReachCloudServer();
 | 
			
		||||
void updateWindowTitle();
 | 
			
		||||
void subsurface_mkdir(const char *dir);
 | 
			
		||||
char *get_file_name(const char *fileName);
 | 
			
		||||
void copy_image_and_overwrite(const char *cfileName, const char *path, const char *cnewName);
 | 
			
		||||
char *hashstring(const char *filename);
 | 
			
		||||
bool picture_exists(struct picture *picture);
 | 
			
		||||
char *move_away(const char *path);
 | 
			
		||||
const char *local_file_path(struct picture *picture);
 | 
			
		||||
void savePictureLocal(struct picture *picture, const char *data, int len);
 | 
			
		||||
void cache_picture(struct picture *picture);
 | 
			
		||||
char *cloud_url();
 | 
			
		||||
char *hashfile_name_string();
 | 
			
		||||
char *picturedir_string();
 | 
			
		||||
const char *subsurface_user_agent();
 | 
			
		||||
enum deco_mode decoMode();
 | 
			
		||||
int parse_seabear_header(const char *filename, char **params, int pnr);
 | 
			
		||||
const char *get_current_date();
 | 
			
		||||
double cache_value(int tissue, int timestep, enum inertgas gas);
 | 
			
		||||
void cache_insert(int tissue, int timestep, enum inertgas gas, double value);
 | 
			
		||||
void print_qt_versions();
 | 
			
		||||
void lock_planner();
 | 
			
		||||
void unlock_planner();
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif // QTHELPER_H
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,31 +0,0 @@
 | 
			
		|||
// SPDX-License-Identifier: GPL-2.0
 | 
			
		||||
#ifndef QTHELPERFROMC_H
 | 
			
		||||
#define QTHELPERFROMC_H
 | 
			
		||||
 | 
			
		||||
bool getProxyString(char **buffer);
 | 
			
		||||
bool canReachCloudServer();
 | 
			
		||||
void updateWindowTitle();
 | 
			
		||||
void subsurface_mkdir(const char *dir);
 | 
			
		||||
char *get_file_name(const char *fileName);
 | 
			
		||||
void copy_image_and_overwrite(const char *cfileName, const char *path, const char *cnewName);
 | 
			
		||||
char *hashstring(char *filename);
 | 
			
		||||
bool picture_exists(struct picture *picture);
 | 
			
		||||
char *move_away(const char *path);
 | 
			
		||||
const char *local_file_path(struct picture *picture);
 | 
			
		||||
void savePictureLocal(struct picture *picture, const char *data, int len);
 | 
			
		||||
void cache_picture(struct picture *picture);
 | 
			
		||||
char *cloud_url();
 | 
			
		||||
char *hashfile_name_string();
 | 
			
		||||
char *picturedir_string();
 | 
			
		||||
const char *subsurface_user_agent();
 | 
			
		||||
enum deco_mode decoMode();
 | 
			
		||||
int parse_seabear_header(const char *filename, char **params, int pnr);
 | 
			
		||||
extern const char *get_current_date();
 | 
			
		||||
enum inertgas {N2, HE};
 | 
			
		||||
double cache_value(int tissue, int timestep, enum inertgas gas);
 | 
			
		||||
void cache_insert(int tissue, int timestep, enum inertgas gas, double value);
 | 
			
		||||
void print_qt_versions();
 | 
			
		||||
void lock_planner();
 | 
			
		||||
void unlock_planner();
 | 
			
		||||
 | 
			
		||||
#endif // QTHELPERFROMC_H
 | 
			
		||||
| 
						 | 
				
			
			@ -22,7 +22,7 @@
 | 
			
		|||
#include "membuffer.h"
 | 
			
		||||
#include "git-access.h"
 | 
			
		||||
#include "version.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
#include "gettext.h"
 | 
			
		||||
 | 
			
		||||
#define VA_BUF(b, fmt) do { va_list args; va_start(args, fmt); put_vformat(b, fmt, args); va_end(args); } while (0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
#include "save-html.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
#include "gettext.h"
 | 
			
		||||
#include "stdio.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@
 | 
			
		|||
#include "membuffer.h"
 | 
			
		||||
#include "strndup.h"
 | 
			
		||||
#include "git-access.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * We're outputting utf8 in xml.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@
 | 
			
		|||
#include <stdbool.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "gettext.h"
 | 
			
		||||
#include "qthelperfromc.h"
 | 
			
		||||
#include "qthelper.h"
 | 
			
		||||
#include "git-access.h"
 | 
			
		||||
#include "libdivecomputer/version.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,6 +49,4 @@ signals:
 | 
			
		|||
	void pluginObjectChanged();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern "C" const char *printGPSCoords(int lat, int lon);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -137,7 +137,6 @@ HEADERS += \
 | 
			
		|||
    ../../../core/save-html.h \
 | 
			
		||||
    ../../../core/statistics.h \
 | 
			
		||||
    ../../../core/units.h \
 | 
			
		||||
    ../../../core/qthelperfromc.h \
 | 
			
		||||
    ../../../core/version.h \
 | 
			
		||||
    ../../../core/planner.h \
 | 
			
		||||
    ../../../core/divesite.h \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue