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

File diff suppressed because it is too large Load Diff

View File

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

View File

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