diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.cpp index 77a69272d73..db70b664008 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include enum { debug = 0 }; @@ -120,9 +120,9 @@ void ItemLibraryTreeView::startDrag(Qt::DropActions /* supportedActions */) if (!mimeData) return; - QDirModel *dirModel = qobject_cast(model()); - Q_ASSERT(dirModel); - QFileInfo fileInfo = dirModel->fileInfo(selectedIndexes().front()); + QFileSystemModel *fileSystemModel = qobject_cast(model()); + Q_ASSERT(fileSystemModel); + QFileInfo fileInfo = fileSystemModel->fileInfo(selectedIndexes().front()); QPixmap pixmap(fileInfo.absoluteFilePath()); if (!pixmap.isNull()) { CustomItemLibraryDrag *drag = new CustomItemLibraryDrag(this); @@ -137,10 +137,10 @@ void ItemLibraryTreeView::startDrag(Qt::DropActions /* supportedActions */) void ItemLibraryTreeView::setModel(QAbstractItemModel *model) { - QDirModel *dirModel = dynamic_cast(model); - if (dirModel) { + QFileSystemModel *fileSystemModel = dynamic_cast(model); + if (fileSystemModel) { QTreeView::setModel(model); - m_delegate->setModel(dirModel); + m_delegate->setModel(fileSystemModel); setColumnHidden(1, true); setColumnHidden(2, true); setColumnHidden(3, true); @@ -155,9 +155,9 @@ void ItemLibraryTreeView::activateItem( const QModelIndex & /*index*/) return; QString name; - QDirModel *dirModel = qobject_cast(model()); - Q_ASSERT(dirModel); - QFileInfo fileInfo = dirModel->fileInfo(selectedIndexes().front()); + QFileSystemModel *fileSystemModel = qobject_cast(model()); + Q_ASSERT(fileSystemModel); + QFileInfo fileInfo = fileSystemModel->fileInfo(selectedIndexes().front()); QPixmap pixmap(fileInfo.absoluteFilePath()); if (!pixmap.isNull()) { name = "image^" + fileInfo.absoluteFilePath(); @@ -195,7 +195,7 @@ QSize ResourceItemDelegate::sizeHint(const QStyleOptionViewItem &/*option*/, return icon.availableSizes().front() + QSize(25, 4); } -void ResourceItemDelegate::setModel(QDirModel *model) +void ResourceItemDelegate::setModel(QFileSystemModel *model) { m_model = model; } diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.h index c576cf15f77..4b420bdb7bb 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.h +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.h @@ -42,7 +42,7 @@ #include QT_BEGIN_NAMESPACE -class QDirModel; +class QFileSystemModel; class QLabel; QT_END_NAMESPACE @@ -83,10 +83,10 @@ public: QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - void setModel(QDirModel *model); + void setModel(QFileSystemModel *model); private: - QDirModel *m_model; + QFileSystemModel *m_model; }; } // namespace Internal diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp index 3fe167f2eeb..2397c974e78 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include #include @@ -107,7 +107,7 @@ public: ItemLibraryWidgetPrivate(QObject *object); Internal::ItemLibraryModel *m_itemLibraryModel; - QDirModel *m_resourcesDirModel; + QFileSystemModel *m_resourcesFileSystemModel; QStackedWidget *m_stackedWidget; Utils::FilterLineEdit *m_lineEdit; @@ -122,7 +122,7 @@ public: ItemLibraryWidgetPrivate::ItemLibraryWidgetPrivate(QObject *object) : m_itemLibraryModel(0), - m_resourcesDirModel(0), + m_resourcesFileSystemModel(0), m_stackedWidget(0), m_lineEdit(0), m_itemsView(0), @@ -172,10 +172,10 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) : connect(this, SIGNAL(resetItemsView()), rootItem, SLOT(resetView())); /* create Resources view and its model */ - m_d->m_resourcesDirModel = new QDirModel(this); - m_d->m_resourcesDirModel->setIconProvider(&m_d->m_iconProvider); + m_d->m_resourcesFileSystemModel = new QFileSystemModel(this); + m_d->m_resourcesFileSystemModel->setIconProvider(&m_d->m_iconProvider); m_d->m_resourcesView = new Internal::ItemLibraryTreeView(this); - m_d->m_resourcesView->setModel(m_d->m_resourcesDirModel); + m_d->m_resourcesView->setModel(m_d->m_resourcesFileSystemModel); m_d->m_resourcesView->setIconSize(m_d->m_resIconSize); /* create image provider for loading item icons */ @@ -333,8 +333,9 @@ void ItemLibraryWidget::setSearchFilter(const QString &searchFilter) } } - m_d->m_resourcesDirModel->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); - m_d->m_resourcesDirModel->setNameFilters(nameFilterList); + m_d->m_resourcesFileSystemModel->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); + m_d->m_resourcesFileSystemModel->setNameFilterDisables(false); + m_d->m_resourcesFileSystemModel->setNameFilters(nameFilterList); m_d->m_resourcesView->expandToDepth(1); m_d->m_resourcesView->scrollToTop(); } @@ -454,8 +455,10 @@ void ItemLibraryWidget::updateSearch() void ItemLibraryWidget::setResourcePath(const QString &resourcePath) { - if (m_d->m_resourcesView->model() == m_d->m_resourcesDirModel) - m_d->m_resourcesView->setRootIndex(m_d->m_resourcesDirModel->index(resourcePath)); + if (m_d->m_resourcesView->model() == m_d->m_resourcesFileSystemModel) { + m_d->m_resourcesFileSystemModel->setRootPath(resourcePath); + m_d->m_resourcesView->setRootIndex(m_d->m_resourcesFileSystemModel->index(resourcePath)); + } updateSearch(); }