-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
63 lines (51 loc) · 1.92 KB
/
mainwindow.cpp
File metadata and controls
63 lines (51 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
directories.setRootPath(QDir::currentPath());
directories.setResolveSymlinks(true);
directories.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);
QModelIndex index = directories.index("Z:/Work/Matlab/ProbeStation/Data");
ui->treeView->setModel(&directories);
ui->treeView->setColumnHidden(1, true);
ui->treeView->setColumnHidden(2, true);
ui->treeView->setColumnHidden(3, true);
ui->treeView->setHeaderHidden(true);
ui->treeView->setCurrentIndex(index);
ui->treeView->expand(index);
files.setRootPath(directories.rootPath());
files.setFilter(QDir::Files);
files.setNameFilters(QStringList("*.mat"));
files.setNameFilterDisables(false);
ui->filesView->setModel(&files);
ui->filesView->setWordWrap(false);
ui->filesView->resizeColumnsToContents();
ui->filesView->resizeRowsToContents();
ui->filesView->verticalHeader()->hide();
ui->filesView->setShowGrid(false);
ui->filesView->horizontalHeader()->setStretchLastSection(true);
ui->filesView->setSelectionBehavior(QAbstractItemView::SelectRows);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_treeView_clicked(const QModelIndex &index)
{
QFileInfo info = directories.fileInfo(index);
if (ui->treeView->isExpanded(index))
ui->treeView->collapse(index);
else
ui->treeView->expand(index);
qDebug() << "Tree View Clicked: " << info.canonicalPath() << "\n";
files.setRootPath(info.canonicalFilePath());
QModelIndex newindex = files.index(info.canonicalFilePath());
ui->filesView->setRootIndex(newindex);
ui->filesView->resizeRowsToContents();
ui->filesView->resizeColumnsToContents();
//ui->filesView->horizontalHeader()->setStretchLastSection(true);
}