Rev 16 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
#include "src/form.h"
#include "ui_form.h"
Form::Form(QWidget *parent) :
QWidget(parent),
m_ui(new Ui::Form)
{
m_ui->setupUi(this);
connect(&wmiProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
}
Form::~Form()
{
delete m_ui;
}
void Form::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
void Form::on_wmiButton_clicked(){
// QString program = tr(" wmic -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\"");
QString program = tr("wmic");
QStringList arguments;
// arguments << tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\"");
program.append(tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\""));
int i;
i++;
wmiProcess.start(program);
}
void Form::readStandartProcessOutput(){
QByteArray arr;
QStringList result;
QString str1, str2, str_tmp;
int i;
arr = wmiProcess.readAllStandardOutput();
QTextCodec *codecUTF = QTextCodec::codecForName("utf8");
QTextCodec *codec = QTextCodec::codecForName("cp1251");
QTextCodec::setCodecForTr(codecUTF);
str1 = QString(tr(arr));
QTextCodec::setCodecForTr(codec);
result << QStringList(arr);
// str2 << arr;
i = result.size();
// str1 = result.at(0);
i++;
i = str1.indexOf("\r");
i = str1.indexOf("\n");
str_tmp = str1.left(i);
m_ui->lineEdit->insert(str1);
while (i != -1){
i = str1.indexOf("\n");
if (i != -1) {
str_tmp = str1.left(i);
result << str_tmp;
str1.remove(0, i+1);}
}
document = m_ui->textEdit->document();
cursor = new QTextCursor(document);
cursor->movePosition(QTextCursor::Start);
QTextCharFormat format(cursor->charFormat());
//format.setFontFamily("Courier");
format.setFontFamily("Arial");
//format.setFontItalic(false);
format.setFontWeight(QFont::Normal);
QTextCharFormat boldFormat = format;
boldFormat.setFontWeight(QFont::Bold);
QTextCharFormat italicFormat = format;
//format.setFontFamily("Courier");
// format.setFontFamily("Arial");
italicFormat.setFontItalic(true);
for (int m = 0; m < result.size(); ++m){
cursor->insertText(result.at(m), format);
cursor->insertBlock();
cursor->insertText(tr("--------------------------"), format);
cursor->insertBlock();
}
/*
cursor->insertText(result.at(2), format);
cursor->insertBlock();
cursor->insertText(tr("--------------------------"), format);
cursor->insertBlock();
cursor->insertText(result.at(3), format);
*/
}
void Form::readStandartProcessError(){
QByteArray arr;
arr = wmiProcess.readAllStandardError();
}