From 031c620f5220aaf2f62921f42e52c554f2fadb5a Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Tue, 30 May 2017 07:42:11 -0500 Subject: [PATCH] Added filter to QFileSystemModel fmodel Setup some comments regarding a setFilter part Edited getAssetLibrary to pass arguments to setAsset -- Note will be used for dropdown interaction. Set a temp path for testing purposes. --- QtMeshViewer/Source/MainWindow.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/QtMeshViewer/Source/MainWindow.cpp b/QtMeshViewer/Source/MainWindow.cpp index 17fd835..2c03ba7 100644 --- a/QtMeshViewer/Source/MainWindow.cpp +++ b/QtMeshViewer/Source/MainWindow.cpp @@ -41,6 +41,14 @@ MainWindow::MainWindow(QWidget *parent) // set default text to file info m_fileInfo = "Filename: -\nMaterials: -\nVertices: -\nTriangle: -No file is open"; + + filters << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH" << "*/"; + fmodel = new QFileSystemModel(this); + fmodel->setNameFilters(filters); +// fmodel->setFilter(QDir::NoDotAndDotDot | QDir::Files); // Need to get a way to scan dirs recursivly for mush files + // maybe add it to a qstringlist and then set it as a model. + fmodel->setNameFilterDisables(false); + // add widgets to the window setupWidgets(); @@ -165,12 +173,16 @@ void MainWindow::setupWidgets() void MainWindow::getAssetLibrary() { - QTreeWidgetItem* item = new QTreeWidgetItem; - item->setData(0, Qt::DisplayRole, "Wuhu"); - ui->treeWidget->addTopLevelItem(item); - - searchMeshFiles("D:/workspaces/Visual Studio 2015/Projects/OpenGL/Release"); + QString path; + path = "C:/BF2_ModTools/data_MAX/Worlds/MAX/msh"; // temp path setting + setAsset(path); +} +void MainWindow::setAsset(QString path) +{ + fmodel->setRootPath(path); + ui->fileListView->setModel(fmodel); + ui->fileListView->setRootIndex(fmodel->index(path)); } void MainWindow::searchMeshFiles(QString path)