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

@ -4,16 +4,16 @@
<widget class="QMainWindow" name="MainWindowClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>400</height>
<width>600</width>
<height>400</height>
</size>
</property>
<property name="windowTitle">
@ -24,63 +24,74 @@
</widget>
<widget class="QToolBar" name="mainToolBar">
<property name="allowedAreas">
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea</set>
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea</set>
</property>
<attribute name="toolBarArea">
<enum>LeftToolBarArea</enum>
<enum>LeftToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QDockWidget" name="dockWidget">
<property name="autoFillBackground">
<bool>false</bool>
<bool>false</bool>
</property>
<property name="floating">
<bool>false</bool>
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable</set>
<set>QDockWidget::DockWidgetFloatable</set>
</property>
<property name="allowedAreas">
<set>Qt::RightDockWidgetArea</set>
<set>Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Asset library</string>
<string>Asset library</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="dirDropDownList"/>
</item>
<item>
<widget class="QListWidget" name="fileListWidget"/>
</item>
</layout>
</item>
</layout>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="dirDropDownList">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="fileTreeWidget">
<property name="autoExpandDelay">
<number>0</number>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</widget>

File diff suppressed because it is too large Load Diff

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,15 +182,15 @@ void MainWindow::setupAssetLibrary()
void MainWindow::updateAssetTree(QString path)
{
ui->fileListWidget->clear();
m_Paths.clear();
QDirIterator itterator(path, QStringList() << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH",
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());
itterator.next();
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);
}