-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
86 lines (75 loc) · 2.37 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSettings>
#include <QThread>
#include "AccessListThread.h"
#include "CheckHostThread.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
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_readHostButton_clicked(bool checked)
{
ui->listWidget->clear();
ui->listWidget_2->clear();
QSettings *hostini=new QSettings("host.ini",QSettings::IniFormat);
QStringList childGroups=hostini->childGroups();
CheckHostThread *hostthread=0;
foreach (const QString &childGroup, childGroups){
hostini->beginGroup(childGroup);
QString host=hostini->value("filename").toString();
hostini->endGroup();
//produce threads for every host
hostthread=new CheckHostThread(host);
QObject::connect(hostthread,SIGNAL(send_to_list1(QString)),this,SLOT(receive_hosts_thread(QString)));
QObject::connect(hostthread,SIGNAL(send_to_list2(QString)),this,SLOT(receive_files_thread(QString)));
//hostthread->list1=ui->listWidget;
//hostthread->list2=ui->listWidget_2;
hostthread->start();
}
//Connect thread'signal and ui's slot
//connect(readini, SIGNAL(read_host()),ui->listWidget, SLOT(clear()));
}
// Read host's shared files using on_listWidget_itemSelectionChanged function
void MainWindow::on_listWidget_itemSelectionChanged()
{
//produce threads for every host
/*
foreach (const QString &childGroup, childGroups){
QString checkhost="checkhost";
//hostthread=checkhost+childGroup;
CheckHostThread *hostthread=new CheckHostThread();
hostthread->start();
}
*/
AccessListThread *readshared=new AccessListThread();
readshared->list1=ui->listWidget;
readshared->list2=ui->listWidget_2;
readshared->selected=true;
ui->listWidget_2->clear();
readshared->start();
}
//Processing the received data from threads
void MainWindow::receive_hosts_thread(QString host){
ui->listWidget->addItem(host);
}
void MainWindow::receive_files_thread(QString file){
ui->listWidget_2->addItem(file);
}