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"/>
</item>
<item>
<widget class="QTreeView" name="fileListView"/>
<widget class="QListView" name="fileListView"/>
</item>
</layout>
</item>

View File

@ -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);
};

View File

@ -41,14 +41,21 @@ MainWindow::MainWindow(QWidget *parent)
// set default text to file info
m_fileInfo = "Filename: -\nMaterials: -\nVertices: -\nTriangle: -<detail>No file is open";
filters << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH" << "*/";
// 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); // 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->setFilter(QDir::NoDotAndDotDot | QDir::Files);
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,7 +174,6 @@ void MainWindow::setupWidgets()
m_output->setAlignment(Qt::AlignTop);
m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>")));
m_output->raise();
}
void MainWindow::getAssetLibrary()
@ -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)