-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDeviceSelect.cpp
More file actions
47 lines (36 loc) · 1.06 KB
/
DeviceSelect.cpp
File metadata and controls
47 lines (36 loc) · 1.06 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
#include "DeviceSelect.h"
DeviceSelectDialog::DeviceSelectDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
setupTree();
}
void DeviceSelectDialog::setupTree()
{
QStringList usbmonDevices;
usbmonModel = new QDirModel(QStringList("usbmon*"), QDir::System, QDir::Name);
devicesView->setAllColumnsShowFocus(true);
devicesView->setModel(usbmonModel);
devicesView->hideColumn(1);
devicesView->hideColumn(2);
devicesView->hideColumn(3);
devicesView->hideColumn(4);
devicesView->hideColumn(5);
devicesView->setRootIndex(usbmonModel->index("/dev"));
QObject::connect(devicesView, SIGNAL(activated(const QModelIndex&)), this, SLOT(selectedPath(const QModelIndex&)));
}
void DeviceSelectDialog::accept()
{
selectedPath(devicesView->selectionModel()->currentIndex());
QDialog::accept();
}
void DeviceSelectDialog::selectedPath(const QModelIndex& index)
{
if(!index.isValid() || index.data().value<QString>().size() == 0)
reject();
path = QString("/dev/") + index.data().value<QString>();
QDialog::accept();
}
DeviceSelectDialog::~DeviceSelectDialog()
{
}