diff --git a/QtMeshViewer/Form Files/MainWindow.ui b/QtMeshViewer/Form Files/MainWindow.ui index 3fa1a4b..1aa5d0b 100644 --- a/QtMeshViewer/Form Files/MainWindow.ui +++ b/QtMeshViewer/Form Files/MainWindow.ui @@ -73,7 +73,7 @@ - + diff --git a/QtMeshViewer/Header/MainWindow.h b/QtMeshViewer/Header/MainWindow.h index 2827ba2..fdcdc7d 100644 --- a/QtMeshViewer/Header/MainWindow.h +++ b/QtMeshViewer/Header/MainWindow.h @@ -36,6 +36,7 @@ private: void setAsset(QString); void searchMeshFiles(QString path); void openFile(); + void open(QString); void takeScreenShot(); void aboutTool(); @@ -50,4 +51,9 @@ public slots: // signals signals: void loadFile(QString); + +// private slots +private slots: + void on_fileListView_doubleClicked(const QModelIndex &index); + void on_dirDropDownList_currentTextChanged(const QString &arg1); }; diff --git a/QtMeshViewer/Source/MainWindow.cpp b/QtMeshViewer/Source/MainWindow.cpp index 2c03ba7..e3aafc4 100644 --- a/QtMeshViewer/Source/MainWindow.cpp +++ b/QtMeshViewer/Source/MainWindow.cpp @@ -41,13 +41,20 @@ 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 + filters << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH"; + fmodel = new QFileSystemModel(this); + fmodel->setNameFilters(filters); + fmodel->setFilter(QDir::NoDotAndDotDot | QDir::Files); + fmodel->setNameFilterDisables(false); - 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); + 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 + + SettingsWindow obj; + QStringList tmpList = obj.getDirList().split(";"); + for (int i = 0; i < tmpList.size(); i++) + ui->dirDropDownList->addItem(tmpList[i], tmpList[i]); // temp here // add widgets to the window setupWidgets(); @@ -58,7 +65,6 @@ MainWindow::MainWindow(QWidget *parent) this->setStyleSheet(styleSheet.readAll()); getAssetLibrary(); - printMessage("MeshViewer by Anakin", 0); } @@ -168,21 +174,20 @@ void MainWindow::setupWidgets() m_output->setAlignment(Qt::AlignTop); m_output->setText(m_fileInfo.left(m_fileInfo.indexOf(""))); m_output->raise(); - } void MainWindow::getAssetLibrary() { - QString path; - path = "C:/BF2_ModTools/data_MAX/Worlds/MAX/msh"; // temp path setting - setAsset(path); + 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)); + fmodel->setRootPath(path); + ui->fileListView->setModel(fmodel); + ui->fileListView->setRootIndex(fmodel->index(path)); } void MainWindow::searchMeshFiles(QString path) @@ -205,10 +210,16 @@ void MainWindow::searchMeshFiles(QString path) void MainWindow::openFile() { QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)"); + open(fileName); +} + +void MainWindow::open(QString fileName) +{ if(!fileName.isEmpty()) emit loadFile(fileName); } + void MainWindow::takeScreenShot() { QString destination = QFileDialog::getSaveFileName(this, "Save as...", "", "PNG (*.png);; BMP (*.bmp);;TIFF (*.tiff, *.tif);;JPEG (*.jpg *jpeg)"); @@ -246,6 +257,20 @@ void MainWindow::resizeEvent(QResizeEvent * e) ///////////////////////////////////////////////////////////////////////// // slots +void MainWindow::on_fileListView_doubleClicked(const QModelIndex &index) +{ + QString clickedFile = fmodel->fileInfo(index).absoluteFilePath(); + open(clickedFile); +} + +void MainWindow::on_dirDropDownList_currentTextChanged(const QString &arg1) +{ + QString selectedDir; + selectedDir = ui->dirDropDownList->itemData(ui->dirDropDownList->currentIndex()).toString(); + printMessage(arg1 + " : " + selectedDir, 0); + setAsset(selectedDir); +} + void MainWindow::printMessage(QString message, int severity) { if (!ui->statusBar->currentMessage().isEmpty() && severity < m_curSeverity)