Implemented qtreeviewwidget instead of a list

This commit is contained in:
Maxim Stewart 2017-06-18 09:32:19 -05:00
parent 3f2713bd16
commit 2d34492517
4 changed files with 615 additions and 605 deletions

View File

@ -73,10 +73,21 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="dirDropDownList"/>
<widget class="QComboBox" name="dirDropDownList">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="fileListWidget"/>
<widget class="QTreeWidget" name="fileTreeWidget">
<property name="autoExpandDelay">
<number>0</number>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>503</width>
<width>584</width>
<height>645</height>
</rect>
</property>

View File

@ -26,7 +26,6 @@ private:
FileInfoWindow* m_infoWindow;
QStringList m_filters;
QStringList m_Paths;
// functions
private:
@ -52,6 +51,6 @@ signals:
// private slots
private slots:
void on_fileListWidget_doubleClicked(const QModelIndex &index);
void on_fileTreeWidget_doubleClicked();
void on_dirDropDownList_currentTextChanged(const QString &arg1);
};

View File

@ -13,7 +13,7 @@
#include <QResizeEvent>
#include <QDirIterator>
#include <QFileInfo>
#include <QTreeWidgetItem>
#define WINDOW_NAME "Mesh Viewer"
@ -68,6 +68,7 @@ MainWindow::~MainWindow()
delete m_infoWindow;
}
/////////////////////////////////////////////////////////////////////////
// functions
void MainWindow::setupWidgets()
@ -181,14 +182,14 @@ void MainWindow::setupAssetLibrary()
void MainWindow::updateAssetTree(QString path)
{
ui->fileListWidget->clear();
m_Paths.clear();
ui->fileTreeWidget->clear();
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());
QTreeWidgetItem* sub = new QTreeWidgetItem(ui->fileTreeWidget);
sub->setData(0, Qt::DisplayRole, itterator.fileName());
sub->setData(1, Qt::DisplayRole, itterator.fileInfo().absoluteFilePath());
itterator.next();
}
}
@ -242,10 +243,9 @@ void MainWindow::resizeEvent(QResizeEvent * e)
/////////////////////////////////////////////////////////////////////////
// slots
void MainWindow::on_fileListWidget_doubleClicked(const QModelIndex &index)
void MainWindow::on_fileTreeWidget_doubleClicked()
{
int slotVal = index.row();
QString clickedFile = m_Paths.at(slotVal);
QString clickedFile = ui->fileTreeWidget->currentItem()->text(1);
openFile(clickedFile);
}