-
Notifications
You must be signed in to change notification settings - Fork 4
/
mainwindow.cpp
66 lines (58 loc) · 1.72 KB
/
mainwindow.cpp
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
64
65
66
#include "mainwindow.h"
#include "imagelistmodel.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QFileInfo>
#include <QFileSystemModel>
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
imageListModel = new ImageListModel{ this };
fileSystemModel = new QFileSystemModel{ this };
fileSystemModel->setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
fileSystemModel->setRootPath("");
ui->treeView->setModel(fileSystemModel);
for (int hiddenColumn = fileSystemModel->columnCount(); hiddenColumn > 1; --hiddenColumn) {
ui->treeView->hideColumn(hiddenColumn - 1);
}
ui->listView->setColumnCount(3);
ui->actionThree_Columns->setChecked(true);
ui->listView->setModel(imageListModel);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeEvent(QEvent* e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void MainWindow::on_treeView_clicked(const QModelIndex& index)
{
QFileInfo fileInfo = fileSystemModel->fileInfo(index);
qDebug() << "New folder " << fileInfo.absoluteFilePath() << "has been selected";
if (fileInfo.isDir()) {
imageListModel->loadDirectoryImageList(fileInfo.absoluteFilePath());
}
}
void MainWindow::on_actionTwo_Columns_triggered()
{
ui->actionTwo_Columns->setChecked(true);
ui->actionThree_Columns->setChecked(false);
ui->listView->setColumnCount(2);
}
void MainWindow::on_actionThree_Columns_triggered()
{
ui->actionTwo_Columns->setChecked(false);
ui->actionThree_Columns->setChecked(true);
ui->listView->setColumnCount(3);
}