Skip to content
Snippets Groups Projects
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
Branches
Tags
No related merge requests found
...@@ -619,12 +619,12 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const ...@@ -619,12 +619,12 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
if (!index.isValid()) if (!index.isValid())
return QVariant(); return QVariant();
void * const internalPointer = index.internalPointer(); const void *internalPointer = index.internalPointer();
Node * const node = reinterpret_cast<Node *>(internalPointer); const Node *node = reinterpret_cast<const Node *>(internalPointer);
Prefix const * const prefix = node->prefix(); const Prefix *prefix = node->prefix();
File const * const file = node->file(); File *file = node->file();
Q_ASSERT(prefix); Q_ASSERT(prefix);
bool const isFileNode = (prefix != node); const bool isFileNode = (prefix != node);
QVariant result; QVariant result;
...@@ -654,12 +654,13 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const ...@@ -654,12 +654,13 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
if (isFileNode) { if (isFileNode) {
// File node // File node
Q_ASSERT(file); Q_ASSERT(file);
const QString path = m_resource_file.absolutePath(file->name); if (file->icon.isNull()) {
if (iconFileExtension(path)) { const QString path = m_resource_file.absolutePath(file->name);
const QIcon icon(path); if (iconFileExtension(path))
if (!icon.isNull()) file->icon = QIcon(path);
result = icon;
} }
if (!file->icon.isNull())
result = file->icon;
} }
break; break;
default: default:
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtGui/QIcon>
#include "shared_global_p.h" #include "shared_global_p.h"
...@@ -89,6 +90,7 @@ struct File : public Node { ...@@ -89,6 +90,7 @@ struct File : public Node {
bool operator != (const File &other) const { return name != other.name; } bool operator != (const File &other) const { return name != other.name; }
QString name; QString name;
QString alias; QString alias;
QIcon icon;
}; };
class FileList : public QList<File *> class FileList : public QList<File *>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment