mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Allow images to be added via the web
This adds a new divelist context menu entry which asks for a URL. The file is retrieved and if it is an image it is added to the cache and the url is associated to dives as with local files. NB this currently only works with URLs pointing directly to images. But it should not be too hard to add the possibility to add a direction via an html file and its image tags. To test: open dives/test43.xml and delete the image and then add the URL http://euve10195.vserver.de/~robert/wreck.jpg Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
98ae7b1f86
commit
757c4aab20
9 changed files with 219 additions and 26 deletions
44
qthelper.cpp
44
qthelper.cpp
|
@ -337,22 +337,6 @@ extern "C" xsltStylesheetPtr get_stylesheet(const char *name)
|
|||
return xslt;
|
||||
}
|
||||
|
||||
extern "C" void picture_load_exif_data(struct picture *p)
|
||||
{
|
||||
EXIFInfo exif;
|
||||
memblock mem;
|
||||
|
||||
if (readfile(p->filename, &mem) <= 0)
|
||||
goto picture_load_exit;
|
||||
if (exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size) != PARSE_EXIF_SUCCESS)
|
||||
goto picture_load_exit;
|
||||
p->longitude.udeg= lrint(1000000.0 * exif.GeoLocation.Longitude);
|
||||
p->latitude.udeg = lrint(1000000.0 * exif.GeoLocation.Latitude);
|
||||
|
||||
picture_load_exit:
|
||||
free(mem.buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
extern "C" timestamp_t picture_get_timestamp(char *filename)
|
||||
{
|
||||
|
@ -360,7 +344,8 @@ extern "C" timestamp_t picture_get_timestamp(char *filename)
|
|||
memblock mem;
|
||||
int retval;
|
||||
|
||||
if (readfile(filename, &mem) <= 0)
|
||||
// filename might not be the actual filename, so let's go via the hash.
|
||||
if (readfile(localFilePath(QString(filename)).toUtf8().data(), &mem) <= 0)
|
||||
return 0;
|
||||
retval = exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size);
|
||||
free(mem.buffer);
|
||||
|
@ -853,7 +838,8 @@ QByteArray hashFile(const QString filename)
|
|||
|
||||
void learnHash(struct picture *picture, QByteArray hash)
|
||||
{
|
||||
free(picture->hash);
|
||||
if (picture->hash)
|
||||
free(picture->hash);
|
||||
QMutexLocker locker(&hashOfMutex);
|
||||
hashOf[QString(picture->filename)] = hash;
|
||||
picture->hash = strdup(hash.toHex());
|
||||
|
@ -861,7 +847,10 @@ void learnHash(struct picture *picture, QByteArray hash)
|
|||
|
||||
QString localFilePath(const QString originalFilename)
|
||||
{
|
||||
return localFilenameOf[hashOf[originalFilename]];
|
||||
if (hashOf.contains(originalFilename) && localFilenameOf.contains(hashOf[originalFilename]))
|
||||
return localFilenameOf[hashOf[originalFilename]];
|
||||
else
|
||||
return originalFilename;
|
||||
}
|
||||
|
||||
QString fileFromHash(char *hash)
|
||||
|
@ -899,3 +888,20 @@ void learnImages(const QDir dir, int max_recursions, bool recursed)
|
|||
|
||||
QtConcurrent::blockingMap(files, hashFile);
|
||||
}
|
||||
|
||||
extern "C" void picture_load_exif_data(struct picture *p)
|
||||
{
|
||||
EXIFInfo exif;
|
||||
memblock mem;
|
||||
|
||||
if (readfile(localFilePath(QString(p->filename)).toUtf8().data(), &mem) <= 0)
|
||||
goto picture_load_exit;
|
||||
if (exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size) != PARSE_EXIF_SUCCESS)
|
||||
goto picture_load_exit;
|
||||
p->longitude.udeg= lrint(1000000.0 * exif.GeoLocation.Longitude);
|
||||
p->latitude.udeg = lrint(1000000.0 * exif.GeoLocation.Latitude);
|
||||
|
||||
picture_load_exit:
|
||||
free(mem.buffer);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue