diff --git a/QtMeshViewer/Form Files/MainWindow.ui b/QtMeshViewer/Form Files/MainWindow.ui index 1aa5d0b..6ea1c7d 100644 --- a/QtMeshViewer/Form Files/MainWindow.ui +++ b/QtMeshViewer/Form Files/MainWindow.ui @@ -4,16 +4,16 @@ - 0 - 0 - 800 - 600 + 0 + 0 + 800 + 600 - 600 - 400 + 600 + 400 @@ -24,60 +24,63 @@ - Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea + Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea - LeftToolBarArea + LeftToolBarArea - false + false - false + false + + + false - QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable + QDockWidget::DockWidgetFloatable - Qt::RightDockWidgetArea + Qt::RightDockWidgetArea - Asset library + Asset library - 2 + 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + diff --git a/QtMeshViewer/Header/MainWindow.h b/QtMeshViewer/Header/MainWindow.h index 86f5a64..25b4312 100644 --- a/QtMeshViewer/Header/MainWindow.h +++ b/QtMeshViewer/Header/MainWindow.h @@ -3,7 +3,6 @@ #include #include "ui_MainWindow.h" #include "FileInfoWindow.h" -#include #include #include @@ -26,15 +25,14 @@ private: int m_curSeverity; FileInfoWindow* m_infoWindow; - QFileSystemModel* m_fmodel; QStringList m_filters; + QStringList m_Paths; // functions private: void setupWidgets(); void setupAssetLibrary(); void updateAssetTree(QString); - void searchMeshFiles(QString path); void openFileDialog(); void openFile(QString); void takeScreenShot(); @@ -54,6 +52,6 @@ signals: // private slots private slots: - void on_fileListView_doubleClicked(const QModelIndex &index); + void on_fileListWidget_doubleClicked(const QModelIndex &index); void on_dirDropDownList_currentTextChanged(const QString &arg1); }; diff --git a/QtMeshViewer/Source/MainWindow.cpp b/QtMeshViewer/Source/MainWindow.cpp index 4c6c67d..0371df8 100644 --- a/QtMeshViewer/Source/MainWindow.cpp +++ b/QtMeshViewer/Source/MainWindow.cpp @@ -11,6 +11,9 @@ #include #include #include +#include + #include + #define WINDOW_NAME "Mesh Viewer" @@ -42,18 +45,10 @@ MainWindow::MainWindow(QWidget *parent) // set default text to file info m_fileInfo = "Filename: -\nMaterials: -\nVertices: -\nTriangle: -No file is open"; - // set filter and apply drop down tabs/links - m_filters << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH"; - m_fmodel = new QFileSystemModel(this); - m_fmodel->setNameFilters(m_filters); - m_fmodel->setFilter(QDir::NoDotAndDotDot | QDir::Files); - m_fmodel->setNameFilterDisables(false); - - ui->dirDropDownList->addItem("BF1_ModTools", "C:/BF1_ModTools/Assets/Shipped Worlds/"); // temp here - ui->dirDropDownList->addItem("BF2_ModTools", "C:/BF2_ModTools/assets/Sides/"); // temp here + ui->dirDropDownList->addItem("BF1_ModTools", "C:/BF1_ModTools/Assets/Shipped Worlds/"); + ui->dirDropDownList->addItem("BF2_ModTools", "C:/BF2_ModTools/assets/Sides/"); // add widgets to the window - // the settingsmanger is alive now. So use it ;) setupWidgets(); // load stylesheet @@ -61,6 +56,7 @@ MainWindow::MainWindow(QWidget *parent) styleSheet.open(QIODevice::ReadOnly); this->setStyleSheet(styleSheet.readAll()); + // setup dropdown setupAssetLibrary(); printMessage("MeshViewer by Anakin", 0); } @@ -185,30 +181,17 @@ void MainWindow::setupAssetLibrary() void MainWindow::updateAssetTree(QString path) { - // TODO: deep search seams to be missing. - // take a look at the search MeshFiles function. I already implemented something like - // that but never finsihed. But you can use this function. Just adjust it as it fits - // to the m_fmodel. I never used those model based trees before. - m_fmodel->setRootPath(path); - ui->fileListView->setModel(m_fmodel); - ui->fileListView->setRootIndex(m_fmodel->index(path)); -} + ui->fileListWidget->clear(); + m_Paths.clear(); -void MainWindow::searchMeshFiles(QString path) -{ - QDir directory(path); - directory.setNameFilters(QStringList("*.msh")); + QDirIterator itterator(path, QStringList() << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH", + QDir::Files, QDirIterator::Subdirectories); - QStringList childDirectories = directory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); - - QStringList fileNames = directory.entryList(QDir::Files); - - for (auto &it : childDirectories) - qDebug() << it; - - for (auto &it : fileNames) - qDebug() << it; + while (itterator.hasNext()) { + ui->fileListWidget->insertItem(0, new QListWidgetItem(itterator.fileName())); + m_Paths.append(itterator.next()); + } } void MainWindow::openFileDialog() @@ -260,9 +243,10 @@ void MainWindow::resizeEvent(QResizeEvent * e) ///////////////////////////////////////////////////////////////////////// // slots -void MainWindow::on_fileListView_doubleClicked(const QModelIndex &index) +void MainWindow::on_fileListWidget_doubleClicked(const QModelIndex &index) { - QString clickedFile = m_fmodel->fileInfo(index).absoluteFilePath(); + int slotVal = index.row(); + QString clickedFile = m_Paths.at(slotVal); openFile(clickedFile); } @@ -414,4 +398,3 @@ void MainWindow::setFileInfo(QString name, QVector* materials, int ver m_infoWindow->setDetailText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("") - 8))); } -