Commit 65cc8ae4 authored by hjk's avatar hjk

Core: Clean up FileIconProvider interface

Change-Id: I98c3c8796cb887f5bb3c5184854562ff36727836
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
parent 3bb7339f
......@@ -30,7 +30,6 @@
#include "coreplugin.h"
#include "designmode.h"
#include "editmode.h"
#include "fileiconprovider.h"
#include "helpmanager.h"
#include "mainwindow.h"
#include "mimedatabase.h"
......@@ -67,9 +66,6 @@ CorePlugin::~CorePlugin()
delete m_designMode;
}
// delete FileIconProvider singleton
delete FileIconProvider::instance();
delete m_mainWindow;
}
......
......@@ -370,7 +370,7 @@ void ReadOnlyFilesDialog::initDialog(const QStringList &fileNames)
// Setup a default entry with filename folder and make writable radio button.
QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
item->setText(FileName, visibleName);
item->setIcon(FileName, FileIconProvider::instance()->icon(QFileInfo(fileName)));
item->setIcon(FileName, FileIconProvider::icon(fileName));
item->setText(Folder, Utils::FileUtils::shortNativePath(Utils::FileName(QFileInfo(directory))));
QButtonGroup *radioButtonGroup = new QButtonGroup;
......
......@@ -73,7 +73,7 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList()
<< visibleName << QDir::toNativeSeparators(directory));
if (!fileName.isEmpty())
item->setIcon(0, FileIconProvider::instance()->icon(QFileInfo(fileName)));
item->setIcon(0, FileIconProvider::icon(fileName));
item->setData(0, Qt::UserRole, qVariantFromValue(document));
}
......
......@@ -49,94 +49,91 @@ using namespace Utils;
\class Core::FileIconProvider
Provides icons based on file suffixes with the ability to overwrite system
icons for specific subtypes. Implements the QFileIconProvider interface
and can therefore be used for QFileSystemModel.
icons for specific subtypes. The underlying QFileIconProvider
can be used for QFileSystemModel.
Note: Registering overlay icons currently completely replaces the system
icon and is therefore not recommended on platforms that have their
own overlay icon handling (Mac/Windows).
The class is a singleton: It's instance can be accessed via the static instance() method.
Plugins can register custom overlay icons via registerIconOverlayForSuffix(), and
retrieve icons via the icon() method.
The instance is explicitly deleted by the core plugin for destruction order reasons.
*/
// Cache icons in a list of pairs suffix/icon which should be faster than
// hashes for small lists.
namespace Core {
namespace FileIconProvider {
enum { debug = 0 };
typedef QPair<QString, QIcon> StringIconPair;
typedef QList<StringIconPair> StringIconPairList;
// Helper to find an icon by suffix in a list of pairs for const/non-const-iterators.
template <class StringIconPairListIterator>
inline StringIconPairListIterator
findBySuffix(const QString &suffix,
StringIconPairListIterator iter,
const StringIconPairListIterator &end)
class FileIconProviderImplementation : public QFileIconProvider
{
for (; iter != end; ++iter)
if ((*iter).first == suffix)
return iter;
return end;
}
public:
FileIconProviderImplementation()
: m_unknownFileIcon(qApp->style()->standardIcon(QStyle::SP_FileIcon))
{}
namespace Core {
QIcon icon(const QFileInfo &info) const;
using QFileIconProvider::icon;
struct FileIconProviderPrivate {
FileIconProviderPrivate();
void registerIconOverlayForSuffix(const QIcon &icon, const QString &suffix)
{
if (debug)
qDebug() << "FileIconProvider::registerIconOverlayForSuffix" << suffix;
// Mapping of file suffix to icon.
StringIconPairList m_cache;
QTC_ASSERT(!icon.isNull() && !suffix.isEmpty(), return);
QIcon m_unknownFileIcon;
const QPixmap fileIconPixmap = FileIconProvider::overlayIcon(QStyle::SP_FileIcon, icon, QSize(16, 16));
// singleton pattern
static FileIconProvider *m_instance;
};
// replace old icon, if it exists
for (int i = 0, n = m_cache.size(); i != n; ++i) {
if (m_cache.at(i).first == suffix) {
m_cache[i].second = fileIconPixmap;
return;
}
}
m_cache.append(StringIconPair(suffix, fileIconPixmap));
}
FileIconProviderPrivate::FileIconProviderPrivate() :
m_unknownFileIcon(qApp->style()->standardIcon(QStyle::SP_FileIcon))
{
}
void registerIconOverlayForMimeType(const QIcon &icon, const MimeType &mimeType)
{
foreach (const QString &suffix, mimeType.suffixes())
registerIconOverlayForSuffix(icon, suffix);
}
FileIconProvider *FileIconProviderPrivate::m_instance = 0;
// Mapping of file suffix to icon.
StringIconPairList m_cache;
// FileIconProvider
QIcon m_unknownFileIcon;
};
FileIconProvider::FileIconProvider() :
d(new FileIconProviderPrivate)
FileIconProviderImplementation *instance()
{
FileIconProviderPrivate::m_instance = this;
static FileIconProviderImplementation theInstance;
return &theInstance;
}
FileIconProvider::~FileIconProvider()
QFileIconProvider *iconProvider()
{
FileIconProviderPrivate::m_instance = 0;
delete d;
return instance();
}
/*!
Returns the icon associated with the file suffix in fileInfo. If there is none,
the default icon of the operating system is returned.
*/
QIcon FileIconProvider::icon(const QFileInfo &fileInfo) const
QIcon FileIconProviderImplementation::icon(const QFileInfo &fileInfo) const
{
typedef StringIconPairList::const_iterator CacheConstIterator;
if (debug)
qDebug() << "FileIconProvider::icon" << fileInfo.absoluteFilePath();
// Check for cached overlay icons by file suffix.
if (!d->m_cache.isEmpty() && !fileInfo.isDir()) {
if (!m_cache.isEmpty() && !fileInfo.isDir()) {
const QString suffix = fileInfo.suffix();
if (!suffix.isEmpty()) {
const CacheConstIterator it = findBySuffix(suffix, d->m_cache.constBegin(), d->m_cache.constEnd());
if (it != d->m_cache.constEnd())
return (*it).second;
for (int i = 0, n = m_cache.size(); i != n; ++i)
if (m_cache.at(i).first == suffix)
return m_cache[i].second;
}
}
// Get icon from OS.
......@@ -144,16 +141,32 @@ QIcon FileIconProvider::icon(const QFileInfo &fileInfo) const
return QFileIconProvider::icon(fileInfo);
// File icons are unknown on linux systems.
return (fileInfo.isDir()) ?
QFileIconProvider::icon(fileInfo) :
d->m_unknownFileIcon;
return fileInfo.isDir() ? QFileIconProvider::icon(fileInfo) : m_unknownFileIcon;
}
/*!
Returns the icon associated with the file suffix in fileInfo. If there is none,
the default icon of the operating system is returned.
*/
QIcon icon(const QFileInfo &info)
{
return instance()->icon(info);
}
/*!
* \overload
*/
QIcon icon(QFileIconProvider::IconType type)
{
return instance()->icon(type);
}
/*!
Creates a pixmap with baseicon at size and overlays overlayIcon over it.
See platform note in class documentation about recommended usage.
*/
QPixmap FileIconProvider::overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlayIcon, const QSize &size)
QPixmap overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlayIcon, const QSize &size)
{
QPixmap iconPixmap = qApp->style()->standardIcon(baseIcon).pixmap(size);
QPainter painter(&iconPixmap);
......@@ -166,43 +179,26 @@ QPixmap FileIconProvider::overlayIcon(QStyle::StandardPixmap baseIcon, const QIc
Registers an icon for a given suffix, overlaying the system file icon.
See platform note in class documentation about recommended usage.
*/
void FileIconProvider::registerIconOverlayForSuffix(const QIcon &icon,
const QString &suffix)
void registerIconOverlayForSuffix(const char *path, const char *suffix)
{
typedef StringIconPairList::iterator CacheIterator;
if (debug)
qDebug() << "FileIconProvider::registerIconOverlayForSuffix" << suffix;
QTC_ASSERT(!icon.isNull() && !suffix.isEmpty(), return);
const QPixmap fileIconPixmap = overlayIcon(QStyle::SP_FileIcon, icon, QSize(16, 16));
// replace old icon, if it exists
const CacheIterator it = findBySuffix(suffix, d->m_cache.begin(), d->m_cache.end());
if (it == d->m_cache.end())
d->m_cache.append(StringIconPair(suffix, fileIconPixmap));
else
(*it).second = fileIconPixmap;
instance()->registerIconOverlayForSuffix(QIcon(QLatin1String(path)), QLatin1String(suffix));
}
/*!
Registers an icon for all the suffixes of a given mime type, overlaying the system file icon.
*/
void FileIconProvider::registerIconOverlayForMimeType(const QIcon &icon, const MimeType &mimeType)
void registerIconOverlayForMimeType(const QIcon &icon, const char *mimeType)
{
foreach (const QString &suffix, mimeType.suffixes())
registerIconOverlayForSuffix(icon, suffix);
instance()->registerIconOverlayForMimeType(icon, MimeDatabase::findByType(QString::fromLatin1(mimeType)));
}
/*!
Returns the sole instance of FileIconProvider.
*/
FileIconProvider *FileIconProvider::instance()
* \overload
*/
void registerIconOverlayForMimeType(const char *path, const char *mimeType)
{
if (!FileIconProviderPrivate::m_instance)
FileIconProviderPrivate::m_instance = new FileIconProvider;
return FileIconProviderPrivate::m_instance;
instance()->registerIconOverlayForMimeType(QIcon(QLatin1String(path)), MimeDatabase::findByType(QString::fromLatin1(mimeType)));
}
} // namespace core
} // namespace FileIconProvider
} // namespace Core
......@@ -35,40 +35,26 @@
#include <QStyle>
#include <QFileIconProvider>
QT_BEGIN_NAMESPACE
class QFileInfo;
class QIcon;
class QPixmap;
class QString;
QT_END_NAMESPACE
namespace Core {
class MimeType;
struct FileIconProviderPrivate;
class CORE_EXPORT FileIconProvider : public QFileIconProvider
{
FileIconProvider();
public:
virtual ~FileIconProvider();
// Implement QFileIconProvider
virtual QIcon icon(const QFileInfo &info) const;
using QFileIconProvider::icon;
namespace FileIconProvider {
// Register additional overlay icons
static QPixmap overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlayIcon, const QSize &size);
void registerIconOverlayForSuffix(const QIcon &icon, const QString &suffix);
void registerIconOverlayForMimeType(const QIcon &icon, const MimeType &mimeType);
// Access to the single instance
CORE_EXPORT QFileIconProvider *iconProvider();
static FileIconProvider *instance();
// Access to individual items
CORE_EXPORT QIcon icon(const QFileInfo &info);
CORE_EXPORT QIcon icon(QFileIconProvider::IconType type);
private:
FileIconProviderPrivate *d;
};
// Register additional overlay icons
CORE_EXPORT QPixmap overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlayIcon, const QSize &size);
CORE_EXPORT void registerIconOverlayForSuffix(const char *path, const char *suffix);
CORE_EXPORT void registerIconOverlayForMimeType(const char *path, const char *mimeType);
CORE_EXPORT void registerIconOverlayForMimeType(const QIcon &icon, const char *mimeType);
} // namespace FileIconProvider
} // namespace Core
#endif // FILEICONPROVIDER_H
......@@ -78,13 +78,9 @@ CppEditorFactory::CppEditorFactory(CppEditorPlugin *owner) :
addMimeType(CppEditor::Constants::CPP_HEADER_MIMETYPE);
if (!Utils::HostOsInfo::isMacHost() && !Utils::HostOsInfo::isWindowsHost()) {
FileIconProvider *iconProvider = FileIconProvider::instance();
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/cppeditor/images/qt_cpp.png")),
MimeDatabase::findByType(QLatin1String(CppEditor::Constants::CPP_SOURCE_MIMETYPE)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/cppeditor/images/qt_c.png")),
MimeDatabase::findByType(QLatin1String(CppEditor::Constants::C_SOURCE_MIMETYPE)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/cppeditor/images/qt_h.png")),
MimeDatabase::findByType(QLatin1String(CppEditor::Constants::CPP_HEADER_MIMETYPE)));
FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_cpp.png", CppEditor::Constants::CPP_SOURCE_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_c.png", CppEditor::Constants::C_SOURCE_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_h.png", CppEditor::Constants::CPP_HEADER_MIMETYPE);
}
}
......
......@@ -54,9 +54,7 @@ FormEditorFactory::FormEditorFactory()
setDisplayName(qApp->translate("Designer", C_DESIGNER_XML_DISPLAY_NAME));
addMimeType(FORM_MIMETYPE);
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/formeditor/images/qt_ui.png")),
QLatin1String("ui"));
Core::FileIconProvider::registerIconOverlayForSuffix(":/formeditor/images/qt_ui.png", "ui");
}
Core::IEditor *FormEditorFactory::createEditor(QWidget *parent)
......
......@@ -257,7 +257,7 @@ QVariant SelectableFilesModel::data(const QModelIndex &index, int role) const
return t->checked;
if (role == Qt::DecorationRole) {
if (t->icon.isNull())
t->icon = Core::FileIconProvider::instance()->icon(QFileInfo(t->fullPath));
t->icon = Core::FileIconProvider::icon(t->fullPath);
return t->icon;
}
return QVariant();
......
......@@ -172,17 +172,11 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er
errorMessage->clear();
FileIconProvider *iconProvider = FileIconProvider::instance();
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
MimeDatabase::findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
MimeDatabase::findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
MimeDatabase::findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
MimeDatabase::findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
MimeDatabase::findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES)));
FileIconProvider::registerIconOverlayForMimeType(":/glsleditor/images/glslfile.png", Constants::GLSL_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(":/glsleditor/images/glslfile.png", Constants::GLSL_MIMETYPE_VERT);
FileIconProvider::registerIconOverlayForMimeType(":/glsleditor/images/glslfile.png", Constants::GLSL_MIMETYPE_FRAG);
FileIconProvider::registerIconOverlayForMimeType(":/glsleditor/images/glslfile.png", Constants::GLSL_MIMETYPE_VERT_ES);
FileIconProvider::registerIconOverlayForMimeType(":/glsleditor/images/glslfile.png", Constants::GLSL_MIMETYPE_FRAG_ES);
QObject *core = ICore::instance();
BaseFileWizardParameters fragWizardParameters(IWizard::FileWizard);
......
......@@ -173,7 +173,7 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const
FilterEntry &entry = mEntries[index.row()];
if (!entry.fileIconResolved && !entry.fileName.isEmpty() && entry.displayIcon.isNull()) {
entry.fileIconResolved = true;
entry.displayIcon = Core::FileIconProvider::instance()->icon(QFileInfo(entry.fileName));
entry.displayIcon = FileIconProvider::icon(entry.fileName);
}
return entry.displayIcon;
} else if (role == Qt::ForegroundRole && index.column() == 1) {
......
......@@ -97,7 +97,7 @@ QVariant DependenciesModel::data(const QModelIndex &index, int role) const
case Qt::CheckStateRole:
return SessionManager::hasDependency(m_project, p) ? Qt::Checked : Qt::Unchecked;
case Qt::DecorationRole:
return Core::FileIconProvider::instance()->icon(QFileInfo(p->projectFilePath()));
return Core::FileIconProvider::icon(p->projectFilePath());
default:
return QVariant();
}
......
......@@ -124,7 +124,7 @@ FolderNavigationWidget::FolderNavigationWidget(QWidget *parent)
m_toggleSync(new QToolButton(this))
{
m_fileSystemModel->setResolveSymlinks(false);
m_fileSystemModel->setIconProvider(Core::FileIconProvider::instance());
m_fileSystemModel->setIconProvider(Core::FileIconProvider::iconProvider());
QDir::Filters filters = QDir::AllDirs | QDir::Files | QDir::Drives
| QDir::Readable| QDir::Writable
| QDir::Executable | QDir::Hidden;
......
......@@ -42,7 +42,6 @@
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
using Core::FileIconProvider;
namespace {
......@@ -289,7 +288,7 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const
if (folderNode)
result = folderNode->icon();
else
result = FileIconProvider::instance()->icon(QFileInfo(node->path()));
result = Core::FileIconProvider::icon(node->path());
break;
}
case Qt::FontRole: {
......
......@@ -247,7 +247,7 @@ QIcon FolderNode::icon() const
{
// Instantiating the Icon provider is expensive.
if (m_icon.isNull())
m_icon = Core::FileIconProvider::instance()->icon(QFileIconProvider::Folder);
m_icon = Core::FileIconProvider::icon(QFileIconProvider::Folder);
return m_icon;
}
......
......@@ -222,9 +222,7 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error
m_factory = new EditorFactory(this);
addObject(m_factory);
////////////////////////////////////////////////////////////////////////////
// Initialize editor actions handler
////////////////////////////////////////////////////////////////////////////
m_actionHandler.reset(new TextEditor::TextEditorActionHandler(
C_PYTHONEDITOR_ID,
TextEditor::TextEditorActionHandler::Format
......@@ -232,19 +230,12 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error
| TextEditor::TextEditorActionHandler::UnCollapseAll));
m_actionHandler->initializeActions();
////////////////////////////////////////////////////////////////////////////
// Add MIME overlay icons (these icons displayed at Project dock panel)
////////////////////////////////////////////////////////////////////////////
const QIcon icon = QIcon::fromTheme(QLatin1String(C_PY_MIME_ICON));
if (!icon.isNull()) {
Core::FileIconProvider *iconProv = Core::FileIconProvider::instance();
iconProv->registerIconOverlayForMimeType(
icon, Core::MimeDatabase::findByType(QLatin1String(C_PY_MIMETYPE)));
}
if (!icon.isNull())
Core::FileIconProvider::registerIconOverlayForMimeType(icon, C_PY_MIMETYPE);
////////////////////////////////////////////////////////////////////////////
// Add Python files and classes creation dialogs
////////////////////////////////////////////////////////////////////////////
addAutoReleasedObject(new FileWizard(Core::ICore::instance()));
addAutoReleasedObject(new ClassWizard(Core::ICore::instance()));
addAutoReleasedObject(new Internal::PythonHighlighterFactory);
......
......@@ -86,17 +86,15 @@ QbsProjectManagerPlugin::QbsProjectManagerPlugin() :
bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments);
Q_UNUSED(errorMessage);
m_manager = new QbsManager(this);
m_projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
const Core::Context projectContext(::QbsProjectManager::Constants::PROJECT_ID);
const Core::Context globalcontext(Core::Constants::C_GLOBAL);
Q_UNUSED(arguments);
Core::FileIconProvider::instance()
->registerIconOverlayForSuffix(QIcon(QLatin1String(QtSupport::Constants::ICON_QT_PROJECT)),
QLatin1String("qbs"));
Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "qbs");
//create and register objects
addAutoReleasedObject(m_manager);
......
......@@ -232,8 +232,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
errorMessage->clear();
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/qmljseditor/images/qmlfile.png")), QLatin1String("qml"));
Core::FileIconProvider::registerIconOverlayForSuffix(":/qmljseditor/images/qmlfile.png", "qml");
registerQuickFixes(this);
......
......@@ -71,9 +71,7 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
Internal::QmlApplicationWizard::createInstances(this);
FileIconProvider *iconProvider = FileIconProvider::instance();
iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/qmlproject/images/qmlproject.png")),
QLatin1String("qmlproject"));
FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png", "qmlproject");
return true;
}
......
......@@ -52,13 +52,9 @@ ProFileEditorFactory::ProFileEditorFactory(Qt4Manager *manager, TextEditor::Text
addMimeType(Qt4ProjectManager::Constants::PROINCLUDEFILE_MIMETYPE);
addMimeType(Qt4ProjectManager::Constants::PROFEATUREFILE_MIMETYPE);
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(QtSupport::Constants::ICON_QT_PROJECT)),
QLatin1String("pro"));
iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(QtSupport::Constants::ICON_QT_PROJECT)),
QLatin1String("pri"));
iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(QtSupport::Constants::ICON_QT_PROJECT)),
QLatin1String("prf"));
Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "pro");
Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "pri");
Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "prf");
}
Core::IEditor *ProFileEditorFactory::createEditor(QWidget *parent)
......
......@@ -760,7 +760,7 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
if (iconFileExtension(path))
file->icon = QIcon(path);
else
file->icon = Core::FileIconProvider::instance()->icon(QFileInfo(path));
file->icon = Core::FileIconProvider::icon(path);
}
if (!file->icon.isNull())
result = file->icon;
......
......@@ -50,9 +50,7 @@ ResourceEditorFactory::ResourceEditorFactory(ResourceEditorPlugin *plugin) :
setMimeTypes(QStringList(QLatin1String(C_RESOURCE_MIMETYPE)));
setDisplayName(qApp->translate("OpenWith::Editors", C_RESOURCEEDITOR_DISPLAY_NAME));
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/resourceeditor/images/qt_qrc.png")),
QLatin1String("qrc"));
Core::FileIconProvider::registerIconOverlayForSuffix(":/resourceeditor/images/qt_qrc.png", "qrc");
}
Core::IEditor *ResourceEditorFactory::createEditor(QWidget *parent)
......
......@@ -57,7 +57,7 @@ static QList<QStandardItem *> createFileRow(const QString &fileName, const QStri
statusItem->setData(v);
QStandardItem *fileItem = new QStandardItem(fileName);
fileItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
fileItem->setIcon(Core::FileIconProvider::instance()->icon(QFileInfo(fileName)));
fileItem->setIcon(Core::FileIconProvider::icon(fileName));
QList<QStandardItem *> row;
row << statusItem << fileItem;
return row;
......
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