Commit 44732057 authored by Anakin's avatar Anakin

using signal slot to update the combobox entries

parent 3f2713bd
......@@ -31,7 +31,6 @@ private:
// functions
private:
void setupWidgets();
void setupAssetLibrary();
void updateAssetTree(QString);
void openFileDialog();
void openFile(QString);
......@@ -46,12 +45,13 @@ public slots:
void printMessage(QString message, int severity);
void setFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle);
// signals
signals:
void loadFile(QString);
// private slots
private slots:
void setupAssetLibrary();
void on_fileListWidget_doubleClicked(const QModelIndex &index);
void on_dirDropDownList_currentTextChanged(const QString &arg1);
// signals
signals:
void loadFile(QString);
};
......@@ -72,4 +72,8 @@ public:
void setAutoColor(int value);
void updateDirectories(QString path);
// signals
signals:
void dirsChanged();
};
......@@ -58,6 +58,8 @@ MainWindow::MainWindow(QWidget *parent)
// setup dropdown
setupAssetLibrary();
connect(SettingsManager::getInstance(), &SettingsManager::dirsChanged, this, &MainWindow::setupAssetLibrary);
printMessage("MeshViewer by Anakin", 0);
}
......@@ -167,29 +169,17 @@ void MainWindow::setupWidgets()
m_output->raise();
}
void MainWindow::setupAssetLibrary()
{
// get all directories and put them in the dropdown.
QStringList tmp_list = SettingsManager::getInstance()->getListOfDirs();
for (QString &it : tmp_list)
ui->dirDropDownList->addItem(it, it);
// choose the current path and display it.
if (ui->dirDropDownList->currentData().isValid())
updateAssetTree(ui->dirDropDownList->currentData().toString());
}
void MainWindow::updateAssetTree(QString path)
{
ui->fileListWidget->clear();
m_Paths.clear();
QDirIterator itterator(path, QStringList() << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH",
QDirIterator itterator(path, QStringList() << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH",
QDir::Files, QDirIterator::Subdirectories);
while (itterator.hasNext()) {
ui->fileListWidget->insertItem(0, new QListWidgetItem(itterator.fileName()));
m_Paths.prepend(itterator.fileInfo().absoluteFilePath());
itterator.next();
ui->fileListWidget->insertItem(0, new QListWidgetItem(itterator.fileName()));
m_Paths.prepend(itterator.fileInfo().absoluteFilePath());
itterator.next();
}
}
......@@ -242,6 +232,21 @@ void MainWindow::resizeEvent(QResizeEvent * e)
/////////////////////////////////////////////////////////////////////////
// slots
void MainWindow::setupAssetLibrary()
{
// get all directories and put them in the dropdown.
while (ui->dirDropDownList->count() != 0)
ui->dirDropDownList->removeItem(0);
QStringList tmp_list = SettingsManager::getInstance()->getListOfDirs();
for (QString &it : tmp_list)
ui->dirDropDownList->addItem(it, it);
// choose the current path and display it.
if (ui->dirDropDownList->currentData().isValid())
updateAssetTree(ui->dirDropDownList->currentData().toString());
}
void MainWindow::on_fileListWidget_doubleClicked(const QModelIndex &index)
{
int slotVal = index.row();
......
......@@ -238,5 +238,6 @@ void SettingsManager::updateDirectories(QString path)
m_listOfDirs.removeAll(path);
else
m_listOfDirs.append(path);
}
emit dirsChanged();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment