-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmainwindow.cc
61 lines (49 loc) · 1.64 KB
/
mainwindow.cc
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
#include "mainwindow.hpp"
#include "listview.hpp"
#include "normaltreeview.hpp"
#include <QtWidgets>
class MainWindow::MainWindowPrivate
{
public:
MainWindowPrivate(QWidget *parent)
: q_ptr(parent)
{
listView = new ListView(q_ptr);
normalTreeView = new NormalTreeView(q_ptr);
}
QWidget *q_ptr;
ListView *listView;
NormalTreeView *normalTreeView;
};
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, d_ptr(new MainWindowPrivate(this))
{
QString path(qApp->applicationDirPath());
auto itemList = QDir(path).entryInfoList(QDir::AllEntries | QDir::Hidden | QDir::NoDotAndDotDot,
QDir::DirsFirst);
d_ptr->listView->setDatas(itemList);
int count = 2;
int index = path.lastIndexOf("/");
while (index > 0 && count > 0) {
path = path.left(index);
index = path.lastIndexOf("/");
count--;
}
path += "/";
itemList = QDir(path).entryInfoList(QDir::AllEntries | QDir::Hidden | QDir::NoDotAndDotDot,
QDir::DirsFirst);
d_ptr->normalTreeView->setDatas(itemList);
auto tabWidget = new QTabWidget(this);
tabWidget->addTab(d_ptr->normalTreeView, "Normal");
tabWidget->addTab(d_ptr->listView, "ListView");
setCentralWidget(tabWidget);
resize(1000, 618);
}
MainWindow::~MainWindow() {}
void MainWindow::resizeEvent(QResizeEvent *event)
{
QMainWindow::resizeEvent(event);
QMetaObject::invokeMethod(d_ptr->listView, "onResize", Qt::QueuedConnection);
QMetaObject::invokeMethod(d_ptr->normalTreeView, "onResize", Qt::QueuedConnection);
}