using signal slot to update the combobox entries
This commit is contained in:
		@@ -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();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user