More no need to cache QIcon::fromTheme result ourselves in a static var

parent 1223d630
......@@ -85,20 +85,16 @@ bool EnumNode::getIcon(QIcon& a_resultIcon)
auto* decl = dynamic_cast<ClassMemberDeclaration*>(declaration());
if (decl == nullptr) {
static QIcon Icon = QIcon::fromTheme(QStringLiteral("enum"));
a_resultIcon = Icon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("enum"));
} else
{
if (decl->accessPolicy() == Declaration::Protected) {
static QIcon Icon = QIcon::fromTheme(QStringLiteral("protected_enum"));
a_resultIcon = Icon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("protected_enum"));
} else if (decl->accessPolicy() == Declaration::Private) {
static QIcon Icon = QIcon::fromTheme(QStringLiteral("private_enum"));
a_resultIcon = Icon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("private_enum"));
} else
{
static QIcon Icon = QIcon::fromTheme(QStringLiteral("enum"));
a_resultIcon = Icon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("enum"));
}
}
......@@ -314,18 +310,14 @@ bool ClassMemberNode::getIcon(QIcon& a_resultIcon)
return false;
if (decl->isTypeAlias()) {
static QIcon Icon = QIcon::fromTheme(QStringLiteral("typedef"));
a_resultIcon = Icon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("typedef"));
} else if (decl->accessPolicy() == Declaration::Protected) {
static QIcon Icon = QIcon::fromTheme(QStringLiteral("protected_field"));
a_resultIcon = Icon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("protected_field"));
} else if (decl->accessPolicy() == Declaration::Private) {
static QIcon Icon = QIcon::fromTheme(QStringLiteral("private_field"));
a_resultIcon = Icon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("private_field"));
} else
{
static QIcon Icon = QIcon::fromTheme(QStringLiteral("field"));
a_resultIcon = Icon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("field"));
}
return true;
......@@ -341,8 +333,7 @@ DynamicFolderNode::DynamicFolderNode(const QString& a_displayName, NodesModelInt
bool DynamicFolderNode::getIcon(QIcon& a_resultIcon)
{
static QIcon folderIcon = QIcon::fromTheme(QStringLiteral("folder"));
a_resultIcon = folderIcon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("folder"));
return true;
}
......@@ -356,8 +347,7 @@ FolderNode::FolderNode(const QString& a_displayName, NodesModelInterface* a_mode
bool FolderNode::getIcon(QIcon& a_resultIcon)
{
static QIcon folderIcon = QIcon::fromTheme(QStringLiteral("folder"));
a_resultIcon = folderIcon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("folder"));
return true;
}
......
......@@ -66,8 +66,7 @@ StaticNamespaceFolderNode::StaticNamespaceFolderNode(const KDevelop::QualifiedId
bool StaticNamespaceFolderNode::getIcon(QIcon& a_resultIcon)
{
static QIcon folderIcon = QIcon::fromTheme(QStringLiteral("namespace"));
a_resultIcon = folderIcon;
a_resultIcon = QIcon::fromTheme(QStringLiteral("namespace"));
return true;
}
......
......@@ -33,9 +33,6 @@
#include "expandingdelegate.h"
#include <debug.h>
QIcon ExpandingWidgetModel::m_expandedIcon;
QIcon ExpandingWidgetModel::m_collapsedIcon;
using namespace KTextEditor;
inline QModelIndex firstColumn(const QModelIndex& index)
......@@ -502,17 +499,6 @@ QWidget* ExpandingWidgetModel::expandingWidget(const QModelIndex& idx_) const
}
}
void ExpandingWidgetModel::cacheIcons() const
{
if (m_expandedIcon.isNull()) {
m_expandedIcon = QIcon::fromTheme(QStringLiteral("arrow-down"));
}
if (m_collapsedIcon.isNull()) {
m_collapsedIcon = QIcon::fromTheme(QStringLiteral("arrow-right"));
}
}
QList<QVariant> mergeCustomHighlighting(int leftSize, const QList<QVariant>& left, int rightSize, const QList<QVariant>& right)
{
QList<QVariant> ret = left;
......
......@@ -22,13 +22,11 @@
#define KDEVPLATFORM_PLUGIN_EXPANDING_WIDGET_MODEL_H
#include <QAbstractTableModel>
#include <QIcon>
#include <QPointer>
class ExpandingDelegate;
class ExpandingTree;
class KWidget;
class QTreeView;
/**
......@@ -135,12 +133,6 @@ protected:
QModelIndex mapFromSource(const QModelIndex& index) const;
QModelIndex mapToSource(const QModelIndex& index) const;
//Makes sure m_expandedIcon and m_collapsedIcon are loaded
void cacheIcons() const;
static QIcon m_expandedIcon;
static QIcon m_collapsedIcon;
//Does not update the view
void partiallyUnExpand(const QModelIndex& index);
//Finds out the basic height of the row represented by the given index. Basic means without respecting any expansion.
......
......@@ -353,11 +353,10 @@ QVariant QuickOpenModel::data(const QModelIndex& index, int role) const
{
if (isExpandable(index)) {
//Show the expanded/unexpanded handles
cacheIcons();
if (isExpanded(index)) {
return m_expandedIcon;
return QIcon::fromTheme(QStringLiteral("arrow-down"));
} else {
return m_collapsedIcon;
return QIcon::fromTheme(QStringLiteral("arrow-right"));
}
}
}
......
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