-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfolderdialog.cpp
53 lines (43 loc) · 1.13 KB
/
folderdialog.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
#include "folderdialog.h"
#include "ui_folderdialog.h"
FolderDialog::FolderDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FolderDialog)
{
ui->setupUi(this);
//set title
this->setWindowTitle(tr("Select folders"));
// Creates our new model and populate
QString mPath = "C:/";
dirModel = new CheckableFileSystemModel();
// Set filter
dirModel->setFilter(QDir::Dirs|QDir::Drives|QDir::NoDotAndDotDot|QDir::AllDirs);
// QFileSystemModel requires root path
dirModel->setRootPath(mPath);
// Attach the model to the view
ui->treeView->setModel(dirModel);
ui->treeView->hideColumn(1);
ui->treeView->hideColumn(2);
ui->treeView->hideColumn(3);
this->setLayout(ui->verticalLayout);
ui->verticalLayout->setMargin(20);
}
FolderDialog::~FolderDialog()
{
delete ui;
}
void FolderDialog::accept()
{
list = dirModel->getFolders();
if (list.length() == 0)
{
QMessageBox msgBox;
msgBox.setText(tr("Please select at least one folder!"));
msgBox.exec();
}
else
{
emit createdFolderList(list);
this->close();
}
}