-
Notifications
You must be signed in to change notification settings - Fork 1
/
QPathViewer.cpp
45 lines (38 loc) · 1.14 KB
/
QPathViewer.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
#include "qpathviewer.h"
QPathViewer::QPathViewer(QWidget* parent) :QTreeWidget(parent)
{
}
QPathViewer::~QPathViewer()
{
}
void QPathViewer::update_interface_elements() {
clear();
interface_lock_ptr->lock();
for (int i = 0; i < interface_elements_ptr->size(); i++) {
QTreeWidgetItem* top_level_item = new QTreeWidgetItem(this);
interface_element* elem = &interface_elements_ptr->at(i);
std::string display_name = elem->get_full_path();
std::string type_name;
switch (elem->type) {
case interface_type::interface_alias:
type_name = "Alias";
break;
case interface_type::interface_device:
type_name = "Device";
break;
case interface_type::interface_null:
type_name = "Null";
break;
default:
type_name = "Unknown";
}
top_level_item->setText(0, type_name.c_str());
top_level_item->setText(1, display_name.c_str());
QTreeWidget::addTopLevelItem(top_level_item);
}
interface_lock_ptr->unlock();
}
void QPathViewer::set_path_ptr(std::vector<interface_element>* i_elems_ptr, std::mutex* i_lock_ptr) {
interface_elements_ptr = i_elems_ptr;
interface_lock_ptr = i_lock_ptr;
}