#include <QPainter>
#include <QLabel>
#include <itemlibraryinfo.h>
-#include <QDirModel>
+#include <QFileSystemModel>
#include <QProxyStyle>
enum { debug = 0 };
if (!mimeData)
return;
- QDirModel *dirModel = qobject_cast<QDirModel*>(model());
- Q_ASSERT(dirModel);
- QFileInfo fileInfo = dirModel->fileInfo(selectedIndexes().front());
+ QFileSystemModel *fileSystemModel = qobject_cast<QFileSystemModel*>(model());
+ Q_ASSERT(fileSystemModel);
+ QFileInfo fileInfo = fileSystemModel->fileInfo(selectedIndexes().front());
QPixmap pixmap(fileInfo.absoluteFilePath());
if (!pixmap.isNull()) {
CustomItemLibraryDrag *drag = new CustomItemLibraryDrag(this);
void ItemLibraryTreeView::setModel(QAbstractItemModel *model)
{
- QDirModel *dirModel = dynamic_cast<QDirModel *>(model);
- if (dirModel) {
+ QFileSystemModel *fileSystemModel = dynamic_cast<QFileSystemModel *>(model);
+ if (fileSystemModel) {
QTreeView::setModel(model);
- m_delegate->setModel(dirModel);
+ m_delegate->setModel(fileSystemModel);
setColumnHidden(1, true);
setColumnHidden(2, true);
setColumnHidden(3, true);
return;
QString name;
- QDirModel *dirModel = qobject_cast<QDirModel*>(model());
- Q_ASSERT(dirModel);
- QFileInfo fileInfo = dirModel->fileInfo(selectedIndexes().front());
+ QFileSystemModel *fileSystemModel = qobject_cast<QFileSystemModel*>(model());
+ Q_ASSERT(fileSystemModel);
+ QFileInfo fileInfo = fileSystemModel->fileInfo(selectedIndexes().front());
QPixmap pixmap(fileInfo.absoluteFilePath());
if (!pixmap.isNull()) {
name = "image^" + fileInfo.absoluteFilePath();
return icon.availableSizes().front() + QSize(25, 4);
}
-void ResourceItemDelegate::setModel(QDirModel *model)
+void ResourceItemDelegate::setModel(QFileSystemModel *model)
{
m_model = model;
}
#include <QFileInfo>
#include <QFileIconProvider>
-#include <QDirModel>
+#include <QFileSystemModel>
#include <QStackedWidget>
#include <QGridLayout>
#include <QTabBar>
ItemLibraryWidgetPrivate(QObject *object);
Internal::ItemLibraryModel *m_itemLibraryModel;
- QDirModel *m_resourcesDirModel;
+ QFileSystemModel *m_resourcesFileSystemModel;
QStackedWidget *m_stackedWidget;
Utils::FilterLineEdit *m_lineEdit;
ItemLibraryWidgetPrivate::ItemLibraryWidgetPrivate(QObject *object) :
m_itemLibraryModel(0),
- m_resourcesDirModel(0),
+ m_resourcesFileSystemModel(0),
m_stackedWidget(0),
m_lineEdit(0),
m_itemsView(0),
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 */
}
}
- 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();
}
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();
}