Implemented recursive scan for mesh files on selection of dir path. Setup name instead of full path in list.
This commit is contained in:
parent
c6d82f5f55
commit
c2f7118ed6
|
@ -4,16 +4,16 @@
|
||||||
<widget class="QMainWindow" name="MainWindowClass">
|
<widget class="QMainWindow" name="MainWindowClass">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>800</width>
|
||||||
<height>600</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>600</width>
|
<width>600</width>
|
||||||
<height>400</height>
|
<height>400</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -24,60 +24,63 @@
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="mainToolBar">
|
<widget class="QToolBar" name="mainToolBar">
|
||||||
<property name="allowedAreas">
|
<property name="allowedAreas">
|
||||||
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea</set>
|
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea</set>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="toolBarArea">
|
<attribute name="toolBarArea">
|
||||||
<enum>LeftToolBarArea</enum>
|
<enum>LeftToolBarArea</enum>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="toolBarBreak">
|
<attribute name="toolBarBreak">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
<widget class="QDockWidget" name="dockWidget">
|
<widget class="QDockWidget" name="dockWidget">
|
||||||
<property name="autoFillBackground">
|
<property name="autoFillBackground">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="floating">
|
||||||
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="features">
|
<property name="features">
|
||||||
<set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable</set>
|
<set>QDockWidget::DockWidgetFloatable</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="allowedAreas">
|
<property name="allowedAreas">
|
||||||
<set>Qt::RightDockWidgetArea</set>
|
<set>Qt::RightDockWidgetArea</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Asset library</string>
|
<string>Asset library</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="dockWidgetArea">
|
<attribute name="dockWidgetArea">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QWidget" name="dockWidgetContents">
|
<widget class="QWidget" name="dockWidgetContents">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="dirDropDownList"/>
|
<widget class="QComboBox" name="dirDropDownList"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="fileListView"/>
|
<widget class="QListWidget" name="fileListWidget"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "ui_MainWindow.h"
|
#include "ui_MainWindow.h"
|
||||||
#include "FileInfoWindow.h"
|
#include "FileInfoWindow.h"
|
||||||
#include <QFileSystemModel>
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
|
@ -26,15 +25,14 @@ private:
|
||||||
int m_curSeverity;
|
int m_curSeverity;
|
||||||
|
|
||||||
FileInfoWindow* m_infoWindow;
|
FileInfoWindow* m_infoWindow;
|
||||||
QFileSystemModel* m_fmodel;
|
|
||||||
QStringList m_filters;
|
QStringList m_filters;
|
||||||
|
QStringList m_Paths;
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
private:
|
private:
|
||||||
void setupWidgets();
|
void setupWidgets();
|
||||||
void setupAssetLibrary();
|
void setupAssetLibrary();
|
||||||
void updateAssetTree(QString);
|
void updateAssetTree(QString);
|
||||||
void searchMeshFiles(QString path);
|
|
||||||
void openFileDialog();
|
void openFileDialog();
|
||||||
void openFile(QString);
|
void openFile(QString);
|
||||||
void takeScreenShot();
|
void takeScreenShot();
|
||||||
|
@ -54,6 +52,6 @@ signals:
|
||||||
|
|
||||||
// private slots
|
// private slots
|
||||||
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);
|
void on_dirDropDownList_currentTextChanged(const QString &arg1);
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
|
#include <QDirIterator>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
|
||||||
#define WINDOW_NAME "Mesh Viewer"
|
#define WINDOW_NAME "Mesh Viewer"
|
||||||
|
|
||||||
|
@ -42,18 +45,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
// set default text to file info
|
// set default text to file info
|
||||||
m_fileInfo = "Filename: -\nMaterials: -\nVertices: -\nTriangle: -<detail>No file is open";
|
m_fileInfo = "Filename: -\nMaterials: -\nVertices: -\nTriangle: -<detail>No file is open";
|
||||||
|
|
||||||
// set filter and apply drop down tabs/links
|
ui->dirDropDownList->addItem("BF1_ModTools", "C:/BF1_ModTools/Assets/Shipped Worlds/");
|
||||||
m_filters << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH";
|
ui->dirDropDownList->addItem("BF2_ModTools", "C:/BF2_ModTools/assets/Sides/");
|
||||||
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
|
|
||||||
|
|
||||||
// add widgets to the window
|
// add widgets to the window
|
||||||
// the settingsmanger is alive now. So use it ;)
|
|
||||||
setupWidgets();
|
setupWidgets();
|
||||||
|
|
||||||
// load stylesheet
|
// load stylesheet
|
||||||
|
@ -61,6 +56,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
styleSheet.open(QIODevice::ReadOnly);
|
styleSheet.open(QIODevice::ReadOnly);
|
||||||
this->setStyleSheet(styleSheet.readAll());
|
this->setStyleSheet(styleSheet.readAll());
|
||||||
|
|
||||||
|
// setup dropdown
|
||||||
setupAssetLibrary();
|
setupAssetLibrary();
|
||||||
printMessage("MeshViewer by Anakin", 0);
|
printMessage("MeshViewer by Anakin", 0);
|
||||||
}
|
}
|
||||||
|
@ -185,30 +181,17 @@ void MainWindow::setupAssetLibrary()
|
||||||
|
|
||||||
void MainWindow::updateAssetTree(QString path)
|
void MainWindow::updateAssetTree(QString path)
|
||||||
{
|
{
|
||||||
// TODO: deep search seams to be missing.
|
ui->fileListWidget->clear();
|
||||||
// take a look at the search MeshFiles function. I already implemented something like
|
m_Paths.clear();
|
||||||
// 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::searchMeshFiles(QString path)
|
QDirIterator itterator(path, QStringList() << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH",
|
||||||
{
|
QDir::Files, QDirIterator::Subdirectories);
|
||||||
QDir directory(path);
|
|
||||||
directory.setNameFilters(QStringList("*.msh"));
|
|
||||||
|
|
||||||
QStringList childDirectories = directory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
while (itterator.hasNext()) {
|
||||||
|
|
||||||
QStringList fileNames = directory.entryList(QDir::Files);
|
|
||||||
|
|
||||||
for (auto &it : childDirectories)
|
|
||||||
qDebug() << it;
|
|
||||||
|
|
||||||
for (auto &it : fileNames)
|
|
||||||
qDebug() << it;
|
|
||||||
|
|
||||||
|
ui->fileListWidget->insertItem(0, new QListWidgetItem(itterator.fileName()));
|
||||||
|
m_Paths.append(itterator.next());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::openFileDialog()
|
void MainWindow::openFileDialog()
|
||||||
|
@ -260,9 +243,10 @@ void MainWindow::resizeEvent(QResizeEvent * e)
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// slots
|
// 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);
|
openFile(clickedFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,4 +398,3 @@ void MainWindow::setFileInfo(QString name, QVector<Material>* materials, int ver
|
||||||
m_infoWindow->setDetailText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8)));
|
m_infoWindow->setDetailText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue