mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Move the XSLT files into a Qt resource
This means we no longer need to keep them on disk and worry about installing / uninstalling them. They will always be kept in-memory (compressed). Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5f12660870
commit
ca8aee4701
5 changed files with 52 additions and 63 deletions
|
@ -99,7 +99,6 @@ Section
|
||||||
|
|
||||||
# Files to include in installer
|
# Files to include in installer
|
||||||
File subsurface.exe
|
File subsurface.exe
|
||||||
File /r xslt
|
|
||||||
File /r data
|
File /r data
|
||||||
File /r images
|
File /r images
|
||||||
File /r plugins
|
File /r plugins
|
||||||
|
@ -156,14 +155,12 @@ Section "Uninstall"
|
||||||
|
|
||||||
# Delete installed files
|
# Delete installed files
|
||||||
Delete "$INSTDIR\*.dll"
|
Delete "$INSTDIR\*.dll"
|
||||||
Delete "$INSTDIR\xslt\*.xslt"
|
|
||||||
Delete "$INSTDIR\freetype-config"
|
Delete "$INSTDIR\freetype-config"
|
||||||
Delete "$INSTDIR\subsurface.exe"
|
Delete "$INSTDIR\subsurface.exe"
|
||||||
Delete "$INSTDIR\subsurface.ico"
|
Delete "$INSTDIR\subsurface.ico"
|
||||||
Delete "$INSTDIR\Uninstall.exe"
|
Delete "$INSTDIR\Uninstall.exe"
|
||||||
Delete "$INSTDIR\qt.conf"
|
Delete "$INSTDIR\qt.conf"
|
||||||
RMDir /r "$INSTDIR\share"
|
RMDir /r "$INSTDIR\share"
|
||||||
RMDir /r "$INSTDIR\xslt"
|
|
||||||
RMDir /r "$INSTDIR\data"
|
RMDir /r "$INSTDIR\data"
|
||||||
RMDir /r "$INSTDIR\images"
|
RMDir /r "$INSTDIR\images"
|
||||||
RMDir /r "$INSTDIR\translations"
|
RMDir /r "$INSTDIR\translations"
|
||||||
|
|
51
parse-xml.c
51
parse-xml.c
|
@ -1970,57 +1970,6 @@ void parse_xml_exit(void)
|
||||||
xmlCleanupParser();
|
xmlCleanupParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
static xsltStylesheetPtr try_get_stylesheet(const char *path, int len, const char *name)
|
|
||||||
{
|
|
||||||
xsltStylesheetPtr ret;
|
|
||||||
int namelen = strlen(name);
|
|
||||||
char *filename = malloc(len+1+namelen+1);
|
|
||||||
|
|
||||||
if (!filename)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
memcpy(filename, path, len);
|
|
||||||
#ifdef WIN32
|
|
||||||
filename[len] = '\\';
|
|
||||||
#else
|
|
||||||
filename[len] = '/';
|
|
||||||
#endif
|
|
||||||
memcpy(filename + len + 1, name, namelen+1);
|
|
||||||
|
|
||||||
ret = NULL;
|
|
||||||
if (!access(filename, R_OK))
|
|
||||||
ret = xsltParseStylesheetFile(filename);
|
|
||||||
free(filename);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
xsltStylesheetPtr get_stylesheet(const char *name)
|
|
||||||
{
|
|
||||||
const char *path, *next;
|
|
||||||
|
|
||||||
path = getenv("SUBSURFACE_XSLT_PATH");
|
|
||||||
if (!path)
|
|
||||||
path = xslt_path;
|
|
||||||
|
|
||||||
do {
|
|
||||||
int len;
|
|
||||||
xsltStylesheetPtr ret;
|
|
||||||
|
|
||||||
next = strchr(path, ':');
|
|
||||||
len = strlen(path);
|
|
||||||
if (next) {
|
|
||||||
len = next - path;
|
|
||||||
next++;
|
|
||||||
}
|
|
||||||
ret = try_get_stylesheet(path, len, name);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
} while ((path = next) != NULL);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct xslt_files {
|
static struct xslt_files {
|
||||||
const char *root;
|
const char *root;
|
||||||
const char *file;
|
const char *file;
|
||||||
|
|
36
qt-gui.cpp
36
qt-gui.cpp
|
@ -9,6 +9,8 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <libxslt/documents.h>
|
||||||
|
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
#include "divelist.h"
|
#include "divelist.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
@ -35,6 +37,7 @@
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
#include <QResource>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
|
|
||||||
#include <gettextfromc.h>
|
#include <gettextfromc.h>
|
||||||
|
@ -507,3 +510,36 @@ QString get_trip_date_string(timestamp_t when, int nr)
|
||||||
.arg(monthname(tm.tm_mon))
|
.arg(monthname(tm.tm_mon))
|
||||||
.arg(tm.tm_year + 1900);
|
.arg(tm.tm_year + 1900);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static xmlDocPtr get_stylesheet_doc(const xmlChar *uri, xmlDictPtr, int, void *, xsltLoadType)
|
||||||
|
{
|
||||||
|
QFile f(QLatin1String(":/xslt/") + (const char *)uri);
|
||||||
|
if (!f.open(QIODevice::ReadOnly))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Load and parse the data */
|
||||||
|
QByteArray source = f.readAll();
|
||||||
|
|
||||||
|
xmlDocPtr doc = xmlParseMemory(source, source.size());
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
xsltStylesheetPtr get_stylesheet(const char *name)
|
||||||
|
{
|
||||||
|
// this needs to be done only once, but doesn't hurt to run every time
|
||||||
|
xsltSetLoaderFunc(get_stylesheet_doc);
|
||||||
|
|
||||||
|
// get main document:
|
||||||
|
xmlDocPtr doc = get_stylesheet_doc((const xmlChar *)name, NULL, 0, NULL, XSLT_LOAD_START);
|
||||||
|
if (!doc)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// xsltSetGenericErrorFunc(stderr, NULL);
|
||||||
|
xsltStylesheetPtr xslt = xsltParseStylesheetDoc(doc);
|
||||||
|
if (!xslt) {
|
||||||
|
xmlFreeDoc(doc);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return xslt;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
marbledir.files = $$MARBLEDIR
|
marbledir.files = $$MARBLEDIR
|
||||||
xslt.files = $$XSLT_FILES
|
|
||||||
doc.files = $$DOC_FILES
|
doc.files = $$DOC_FILES
|
||||||
translation.files = $$replace(TRANSLATIONS, .ts, .qm)
|
translation.files = $$replace(TRANSLATIONS, .ts, .qm)
|
||||||
exists($$[QT_INSTALL_TRANSLATIONS]) {
|
exists($$[QT_INSTALL_TRANSLATIONS]) {
|
||||||
|
@ -27,11 +26,10 @@ mac {
|
||||||
|
|
||||||
datadir = Contents/Resources/share
|
datadir = Contents/Resources/share
|
||||||
marbledir.path = Contents/Resources/data
|
marbledir.path = Contents/Resources/data
|
||||||
xslt.path = $$datadir
|
|
||||||
doc.path = $$datadir/Documentation
|
doc.path = $$datadir/Documentation
|
||||||
translation.path = Contents/Resources/translations
|
translation.path = Contents/Resources/translations
|
||||||
qttranslation.path = Contents/Resources/translations
|
qttranslation.path = Contents/Resources/translations
|
||||||
QMAKE_BUNDLE_DATA += marbledir xslt doc translation qttranslation
|
QMAKE_BUNDLE_DATA += marbledir doc translation qttranslation
|
||||||
|
|
||||||
mac_deploy.target = mac-deploy
|
mac_deploy.target = mac-deploy
|
||||||
mac_deploy.commands += $$[QT_INSTALL_BINS]/macdeployqt $${TARGET}.app
|
mac_deploy.commands += $$[QT_INSTALL_BINS]/macdeployqt $${TARGET}.app
|
||||||
|
@ -54,7 +52,6 @@ mac {
|
||||||
doc.path = $$WINDOWSSTAGING/Documentation
|
doc.path = $$WINDOWSSTAGING/Documentation
|
||||||
CONFIG -= copy_dir_files
|
CONFIG -= copy_dir_files
|
||||||
deploy.path = $$WINDOWSSTAGING
|
deploy.path = $$WINDOWSSTAGING
|
||||||
deploy.files += $$xslt.files
|
|
||||||
deploy.CONFIG += no_check_exist
|
deploy.CONFIG += no_check_exist
|
||||||
target.path = $$WINDOWSSTAGING
|
target.path = $$WINDOWSSTAGING
|
||||||
marbledir.path = $$WINDOWSSTAGING/data
|
marbledir.path = $$WINDOWSSTAGING/data
|
||||||
|
@ -127,13 +124,12 @@ mac {
|
||||||
# This is a fake rule just to create some rules in the target file
|
# This is a fake rule just to create some rules in the target file
|
||||||
nl = $$escape_expand(\\n)
|
nl = $$escape_expand(\\n)
|
||||||
dummy.target = dummy-only-for-var-expansion
|
dummy.target = dummy-only-for-var-expansion
|
||||||
dummy.commands = $${nl}prefix = /usr$${nl}\
|
dummy.commands = $${nl}prefix = /usr$${nl}\
|
||||||
BINDIR = $(prefix)/bin$${nl}\
|
BINDIR = $(prefix)/bin$${nl}\
|
||||||
DATADIR = $(prefix)/share$${nl}\
|
DATADIR = $(prefix)/share$${nl}\
|
||||||
DOCDIR = $(DATADIR)/subsurface/Documentation$${nl}\
|
DOCDIR = $(DATADIR)/subsurface/Documentation$${nl}\
|
||||||
DESKTOPDIR = $(DATADIR)/applications$${nl}\
|
DESKTOPDIR = $(DATADIR)/applications$${nl}\
|
||||||
MANDIR = $(DATADIR)/man/man1$${nl}\
|
MANDIR = $(DATADIR)/man/man1$${nl}\
|
||||||
XSLTDIR = $(DATADIR)/subsurface
|
|
||||||
QMAKE_EXTRA_TARGETS += dummy
|
QMAKE_EXTRA_TARGETS += dummy
|
||||||
|
|
||||||
WINDOWSSTAGING = ./packaging/windows
|
WINDOWSSTAGING = ./packaging/windows
|
||||||
|
@ -146,7 +142,6 @@ XSLTDIR = $(DATADIR)/subsurface
|
||||||
manpage.path = /$(MANDIR)
|
manpage.path = /$(MANDIR)
|
||||||
manpage.files = $$MANPAGE
|
manpage.files = $$MANPAGE
|
||||||
|
|
||||||
xslt.path = /$(XSLTDIR)
|
|
||||||
marbledir.path = /$(DATADIR)/subsurface/data
|
marbledir.path = /$(DATADIR)/subsurface/data
|
||||||
doc.path = /$(DOCDIR)
|
doc.path = /$(DOCDIR)
|
||||||
|
|
||||||
|
@ -155,7 +150,7 @@ XSLTDIR = $(DATADIR)/subsurface
|
||||||
translation.path = /$(DATADIR)/subsurface/translations
|
translation.path = /$(DATADIR)/subsurface/translations
|
||||||
translation.CONFIG += no_check_exist
|
translation.CONFIG += no_check_exist
|
||||||
|
|
||||||
INSTALLS += target desktop manpage xslt doc marbledir translation
|
INSTALLS += target desktop manpage doc marbledir translation
|
||||||
install.target = install
|
install.target = install
|
||||||
}
|
}
|
||||||
!isEmpty(TRANSLATIONS) {
|
!isEmpty(TRANSLATIONS) {
|
||||||
|
|
|
@ -29,5 +29,17 @@
|
||||||
<file alias="left_wing">icons/planner/left_wing.png</file>
|
<file alias="left_wing">icons/planner/left_wing.png</file>
|
||||||
<file alias="plan_minus">icons/planner/minus.png</file>
|
<file alias="plan_minus">icons/planner/minus.png</file>
|
||||||
<file alias="plan_plus">icons/planner/plus.png</file>
|
<file alias="plan_plus">icons/planner/plus.png</file>
|
||||||
|
<file>xslt/commonTemplates.xsl</file>
|
||||||
|
<file>xslt/csv2xml.xslt</file>
|
||||||
|
<file>xslt/divelogs-export.xslt</file>
|
||||||
|
<file>xslt/divelogs.xslt</file>
|
||||||
|
<file>xslt/DivingLog.xslt</file>
|
||||||
|
<file>xslt/jdivelog2subsurface.xslt</file>
|
||||||
|
<file>xslt/MacDive.xslt</file>
|
||||||
|
<file>xslt/SuuntoDM4.xslt</file>
|
||||||
|
<file>xslt/SuuntoSDM.xslt</file>
|
||||||
|
<file>xslt/udcf.xslt</file>
|
||||||
|
<file>xslt/uddf-export.xslt</file>
|
||||||
|
<file>xslt/uddf.xslt</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Add table
Reference in a new issue