FileView: Create new file icon provider if icons are missing
This commit is contained in:
parent
9e835a23fd
commit
7dff6f26bc
|
@ -21,6 +21,7 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QFileIconProvider>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -266,6 +267,10 @@ void FileView::showEvent(QShowEvent *e) {
|
||||||
if (model_) return;
|
if (model_) return;
|
||||||
|
|
||||||
model_ = new QFileSystemModel(this);
|
model_ = new QFileSystemModel(this);
|
||||||
|
if (!model_->iconProvider() || model_->iconProvider()->icon(QAbstractFileIconProvider::Folder).isNull()) {
|
||||||
|
file_icon_provider_ = std::make_unique<QFileIconProvider>();
|
||||||
|
model_->setIconProvider(file_icon_provider_.get());
|
||||||
|
}
|
||||||
|
|
||||||
model_->setNameFilters(filter_list_);
|
model_->setNameFilters(filter_list_);
|
||||||
// if an item fails the filter, hide it
|
// if an item fails the filter, hide it
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
class QMimeData;
|
class QMimeData;
|
||||||
class QFileSystemModel;
|
class QFileSystemModel;
|
||||||
|
class QFileIconProvider;
|
||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
class QKeyEvent;
|
class QKeyEvent;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
|
@ -119,6 +120,8 @@ class FileView : public QWidget {
|
||||||
QString lazy_set_path_;
|
QString lazy_set_path_;
|
||||||
|
|
||||||
QStringList filter_list_;
|
QStringList filter_list_;
|
||||||
|
|
||||||
|
std::unique_ptr<QFileIconProvider> file_icon_provider_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILEVIEW_H
|
#endif // FILEVIEW_H
|
||||||
|
|
Loading…
Reference in New Issue