/trunk/DBViewer/mainwindow.cpp |
---|
1821,7 → 1821,7 |
TWmiVideoCard MainWindow::getWmiVideoGard(QString host, QString user_name, QString password){ |
TWmiVideoCard result; |
bool ok; |
wmiThread.moveToThread(&wmiThread); |
// wmiThread.moveToThread(&wmiThread); |
wmiThread.setHost(host); // çàäàåì õîñò |
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ |
wmiThread.setPassword( password); |
/trunk/DBViewer/mainwindow.h |
---|
11,6 → 11,7 |
#include "treedelegateform.h" |
#include "wmithread.h" |
#include <QMainWindow> |
#include <QStandardItemModel> |
#include <QStandardItem> |
/trunk/DBViewer/wmithread.cpp |
---|
3,21 → 3,27 |
WmiThread::WmiThread(QObject *parent) : |
QThread(parent) |
{ |
process.moveToThread(this); |
// woker.moveToThread(this); |
mutex.lock(); |
stopped = false; |
mutex.unlock(); |
connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput())); |
connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError())); |
// connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput())); |
// connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError())); |
} |
void WmiThread::run(){ |
QEventLoop * loop = new QEventLoop(); |
Woker woker; // îáúåêò äëÿ ðàáîòû â òåëå ïîòîêà |
// connect(&woker, SIGNAL(workEnd()), this, SLOT(wokerIsStopped())); |
connect(&woker, SIGNAL(workEnd()), loop, SLOT(quit())); |
/* |
QString query_string; |
error = false; //ñáðîñèì ôëàã îøèáêè |
33,8 → 39,13 |
// process.start(query_string); |
process.start("ls\n"); |
// while (!stopped) {;} |
exec(); |
// quit(); |
*/ |
woker.startProcess(); |
loop->exec(); |
} |
void WmiThread::stop(){ |
57,3 → 68,8 |
p_buffer = process.readAllStandardError(); |
error = true; // åñëè îøèáêà, óñòàíîâèì ôëàã îøèáêè âûïîëíåíèÿ WMI-çàïðîñà |
} |
void WmiThread::wokerIsStopped(){ |
exit(); |
} |
/trunk/DBViewer/DBViewer.pro |
---|
23,7 → 23,8 |
iconform.cpp \ |
fileform.cpp \ |
treedelegateform.cpp \ |
wmithread.cpp |
wmithread.cpp \ |
woker.cpp |
HEADERS += mainwindow.h \ |
delegate.h \ |
mymodel.h \ |
31,7 → 32,8 |
iconform.h \ |
fileform.h \ |
treedelegateform.h \ |
wmithread.h |
wmithread.h \ |
woker.h |
FORMS += mainwindow.ui \ |
settingform.ui \ |
iconform.ui \ |
/trunk/DBViewer/wmithread.h |
---|
5,6 → 5,8 |
#include <QProcess> |
#include <QMutex> |
#include <QDebug> |
#include <QEventLoop> |
#include "woker.h" |
class WmiThread : public QThread |
{ |
26,9 → 28,11 |
}; |
void setWmiString(QString new_wmi_string){wmi_string = new_wmi_string;} |
volatile bool stopped; |
private: |
volatile bool stopped; |
volatile bool error; |
QProcess process; |
QString host; |
QString user_name; |
42,6 → 46,7 |
public slots: |
void readStandartProcessOutput(); |
void readStandartProcessError(); |
void wokerIsStopped(); |
private slots: |