make the caching workg again
This commit is contained in:
parent
39e70977cf
commit
188adb974d
|
@ -60,12 +60,9 @@ const QImage &Icon::image() const{
|
|||
return d->image();
|
||||
}
|
||||
|
||||
QString Icon::localUrl()const{
|
||||
if(!QFile(d->m_localUrl).exists())
|
||||
{
|
||||
image().save(d->m_localUrl ,"PNG");
|
||||
}
|
||||
return d->m_localUrl;
|
||||
QString Icon::localUrl()const
|
||||
{
|
||||
return d->localUrl();
|
||||
}
|
||||
|
||||
const QByteArray &Icon::imageData() const{
|
||||
|
|
|
@ -30,22 +30,19 @@ using namespace Snore;
|
|||
IconData::IconData(const QString &url):
|
||||
m_url(url),
|
||||
m_hash(SnoreCorePrivate::computeHash(m_url.toLatin1())),
|
||||
m_localUrl(QString("%1%2.png").arg(SnoreCorePrivate::snoreTMP(), m_hash)),
|
||||
m_isLocalFile(false),
|
||||
m_isResource(m_url.startsWith(":/"))
|
||||
{
|
||||
if(!m_isResource && QFile(url).exists())
|
||||
{
|
||||
m_isLocalFile = true;
|
||||
m_localUrl = url;
|
||||
}
|
||||
m_isRemoteFile = !m_isLocalFile && ! m_isResource;
|
||||
}
|
||||
|
||||
IconData::IconData(const QImage &img):
|
||||
m_img(img),
|
||||
m_hash(QString::number(img.cacheKey(), 16)),
|
||||
m_localUrl(QString("%1%2.png").arg(SnoreCorePrivate::snoreTMP(), m_hash)),
|
||||
m_hash(SnoreCorePrivate::computeHash((char*)img.constBits())),
|
||||
m_isLocalFile(false),
|
||||
m_isResource(false),
|
||||
m_isRemoteFile(false)
|
||||
|
@ -96,6 +93,23 @@ const QImage &IconData::image()
|
|||
return m_img;
|
||||
}
|
||||
|
||||
QString IconData::localUrl()
|
||||
{
|
||||
if(m_isLocalFile)
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString out(QString("%1%2.png").arg(SnoreCorePrivate::snoreTMP(), m_hash));
|
||||
if(!QFile(out).exists())
|
||||
{
|
||||
image().save(out ,"PNG");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IconData::download()
|
||||
{
|
||||
|
|
|
@ -41,13 +41,13 @@ public:
|
|||
|
||||
const QByteArray &imageData();
|
||||
const QImage &image();
|
||||
QString localUrl();
|
||||
void download();
|
||||
|
||||
QImage m_img;
|
||||
QByteArray m_data;
|
||||
QString m_url;
|
||||
QString m_hash;
|
||||
QString m_localUrl;
|
||||
bool m_isLocalFile;
|
||||
bool m_isResource;
|
||||
bool m_isRemoteFile;
|
||||
|
|
Loading…
Reference in New Issue