mirror of
https://github.com/tumic0/QtPBFImagePlugin.git
synced 2024-11-24 03:35:54 +01:00
38 lines
907 B
C++
38 lines
907 B
C++
#include <QDir>
|
|
#include <QDebug>
|
|
#include "pbfplugin.h"
|
|
#include "pbfhandler.h"
|
|
#include "style.h"
|
|
|
|
|
|
#define GLOBAL_CONFIG "/usr/share/pbf/style.json"
|
|
#define USER_CONFIG QDir::homePath() + "/.pbf/style.json"
|
|
|
|
PBFPlugin::PBFPlugin()
|
|
{
|
|
_style = new Style();
|
|
|
|
if (!_style->load(USER_CONFIG))
|
|
if (!_style->load(GLOBAL_CONFIG))
|
|
qCritical() << "Map style not found";
|
|
}
|
|
|
|
QImageIOPlugin::Capabilities PBFPlugin::capabilities(QIODevice *device,
|
|
const QByteArray &format) const
|
|
{
|
|
if (device == 0)
|
|
return (format == "pbf") ? Capabilities(CanRead) : Capabilities();
|
|
else
|
|
return (device->isReadable() && PBFHandler::canRead(device))
|
|
? Capabilities(CanRead) : Capabilities();
|
|
}
|
|
|
|
QImageIOHandler *PBFPlugin::create(QIODevice *device,
|
|
const QByteArray &format) const
|
|
{
|
|
QImageIOHandler *handler = new PBFHandler(_style);
|
|
handler->setDevice(device);
|
|
handler->setFormat(format);
|
|
return handler;
|
|
}
|