Commit e4e26a91 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Optimized qrc editor in case of large images

Prevented it from re-generating an icon for the large image every time
it needed to be drawn.
parent 8b97b66e
......@@ -619,12 +619,12 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
void * const internalPointer = index.internalPointer();
Node * const node = reinterpret_cast<Node *>(internalPointer);
Prefix const * const prefix = node->prefix();
File const * const file = node->file();
const void *internalPointer = index.internalPointer();
const Node *node = reinterpret_cast<const Node *>(internalPointer);
const Prefix *prefix = node->prefix();
File *file = node->file();
Q_ASSERT(prefix);
bool const isFileNode = (prefix != node);
const bool isFileNode = (prefix != node);
QVariant result;
......@@ -654,12 +654,13 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
if (isFileNode) {
// File node
Q_ASSERT(file);
const QString path = m_resource_file.absolutePath(file->name);
if (iconFileExtension(path)) {
const QIcon icon(path);
if (!icon.isNull())
result = icon;
if (file->icon.isNull()) {
const QString path = m_resource_file.absolutePath(file->name);
if (iconFileExtension(path))
file->icon = QIcon(path);
}
if (!file->icon.isNull())
result = file->icon;
}
break;
default:
......
......@@ -40,6 +40,7 @@
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtGui/QIcon>
#include "shared_global_p.h"
......@@ -89,6 +90,7 @@ struct File : public Node {
bool operator != (const File &other) const { return name != other.name; }
QString name;
QString alias;
QIcon icon;
};
class FileList : public QList<File *>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment