Added settings for getting drop down filled and set list to hide folders.

Need to make a dirList setter plus get settings window to keep dirList for editing.
This commit is contained in:
Maxim Stewart 2017-05-30 21:37:17 -05:00
parent cdda1922fa
commit b089fcdaf6
3 changed files with 46 additions and 15 deletions

View File

@ -73,7 +73,7 @@
<widget class="QComboBox" name="dirDropDownList"/> <widget class="QComboBox" name="dirDropDownList"/>
</item> </item>
<item> <item>
<widget class="QTreeView" name="fileListView"/> <widget class="QListView" name="fileListView"/>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -36,6 +36,7 @@ private:
void setAsset(QString); void setAsset(QString);
void searchMeshFiles(QString path); void searchMeshFiles(QString path);
void openFile(); void openFile();
void open(QString);
void takeScreenShot(); void takeScreenShot();
void aboutTool(); void aboutTool();
@ -50,4 +51,9 @@ public slots:
// signals // signals
signals: signals:
void loadFile(QString); void loadFile(QString);
// private slots
private slots:
void on_fileListView_doubleClicked(const QModelIndex &index);
void on_dirDropDownList_currentTextChanged(const QString &arg1);
}; };

View File

@ -41,13 +41,20 @@ 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
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" << "*/"; ui->dirDropDownList->addItem("BF1_ModTools", "C:/BF1_ModTools/Assets/Shipped Worlds/"); // temp here
fmodel = new QFileSystemModel(this); ui->dirDropDownList->addItem("BF2_ModTools", "C:/BF2_ModTools/assets/Sides/"); // temp here
fmodel->setNameFilters(filters);
// fmodel->setFilter(QDir::NoDotAndDotDot | QDir::Files); // Need to get a way to scan dirs recursivly for mush files SettingsWindow obj;
// maybe add it to a qstringlist and then set it as a model. QStringList tmpList = obj.getDirList().split(";");
fmodel->setNameFilterDisables(false); for (int i = 0; i < tmpList.size(); i++)
ui->dirDropDownList->addItem(tmpList[i], tmpList[i]); // temp here
// add widgets to the window // add widgets to the window
setupWidgets(); setupWidgets();
@ -58,7 +65,6 @@ MainWindow::MainWindow(QWidget *parent)
this->setStyleSheet(styleSheet.readAll()); this->setStyleSheet(styleSheet.readAll());
getAssetLibrary(); getAssetLibrary();
printMessage("MeshViewer by Anakin", 0); printMessage("MeshViewer by Anakin", 0);
} }
@ -168,21 +174,20 @@ void MainWindow::setupWidgets()
m_output->setAlignment(Qt::AlignTop); m_output->setAlignment(Qt::AlignTop);
m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))); m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>")));
m_output->raise(); m_output->raise();
} }
void MainWindow::getAssetLibrary() void MainWindow::getAssetLibrary()
{ {
QString path; QString path;
path = "C:/BF2_ModTools/data_MAX/Worlds/MAX/msh"; // temp path setting path = "C:/BF2_ModTools/data_MAX/Worlds/MAX/msh"; // temp path setting
setAsset(path); setAsset(path);
} }
void MainWindow::setAsset(QString path) void MainWindow::setAsset(QString path)
{ {
fmodel->setRootPath(path); fmodel->setRootPath(path);
ui->fileListView->setModel(fmodel); ui->fileListView->setModel(fmodel);
ui->fileListView->setRootIndex(fmodel->index(path)); ui->fileListView->setRootIndex(fmodel->index(path));
} }
void MainWindow::searchMeshFiles(QString path) void MainWindow::searchMeshFiles(QString path)
@ -205,10 +210,16 @@ void MainWindow::searchMeshFiles(QString path)
void MainWindow::openFile() void MainWindow::openFile()
{ {
QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)"); QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)");
open(fileName);
}
void MainWindow::open(QString fileName)
{
if(!fileName.isEmpty()) if(!fileName.isEmpty())
emit loadFile(fileName); emit loadFile(fileName);
} }
void MainWindow::takeScreenShot() void MainWindow::takeScreenShot()
{ {
QString destination = QFileDialog::getSaveFileName(this, "Save as...", "", "PNG (*.png);; BMP (*.bmp);;TIFF (*.tiff, *.tif);;JPEG (*.jpg *jpeg)"); 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 // 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) void MainWindow::printMessage(QString message, int severity)
{ {
if (!ui->statusBar->currentMessage().isEmpty() && severity < m_curSeverity) if (!ui->statusBar->currentMessage().isEmpty() && severity < m_curSeverity)