summaryrefslogtreecommitdiffstats
path: root/client/browser
diff options
context:
space:
mode:
authoradelcastillo <adelcastillo@us.es>2009-11-05 12:40:27 +0000
committeradelcastillo <adelcastillo@us.es>2009-11-05 12:40:27 +0000
commitaf6c52a7574972217a928c9b329cecbbc53098d5 (patch)
tree0ceb48ed40bdc263d7ced3c5bce582a31642a00a /client/browser
parent318efac2f89ea37128104c6731333bc62eee0d18 (diff)
Parsea la salida del comando y mueve la barra.
git-svn-id: https://opengnsys.es/svn/trunk@497 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'client/browser')
-rw-r--r--client/browser/mainwindow.cpp73
-rw-r--r--client/browser/mainwindow.h3
2 files changed, 62 insertions, 14 deletions
diff --git a/client/browser/mainwindow.cpp b/client/browser/mainwindow.cpp
index 885e4e3d..86ccdae9 100644
--- a/client/browser/mainwindow.cpp
+++ b/client/browser/mainwindow.cpp
@@ -19,6 +19,8 @@
#include "mainwindow.moc"
#define BUFFERSIZE 2048
+#define EXPREG_RESET "^\\[(\\d+),(\\d+)\\]\\n"
+#define EXPREG_A_PASS "^\\[(\\d+)\\]\\s"
#define CURRENT_TIME() QDateTime::currentDateTime().toString("dd/MM/yy hh:mm:ss")
@@ -80,8 +82,6 @@ MainWindow::MainWindow(QWidget *parent)
QStatusBar* st=statusBar();
st->setSizeGripEnabled(false);
m_progressBar=new QProgressBar(this);
- m_progressBar->setMinimum(0);
- m_progressBar->setMaximum(100);
m_web->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
@@ -166,7 +166,7 @@ void MainWindow::slotLinkHandle(const QUrl &url)
m_process->setEnvironment(QProcess::systemEnvironment());
m_process->start(program,list);
print(tr("Launching the command: ")+program+" "+list.join(" ")+".");
- m_web->setEnabled(false);
+ startProgressBar();
}
else
{
@@ -176,11 +176,10 @@ void MainWindow::slotLinkHandle(const QUrl &url)
void MainWindow::slotWebLoadStarted()
{
- QStatusBar* st=statusBar();
- st->clearMessage();
- st->addWidget(m_progressBar,100);
- m_progressBar->show();
+ startProgressBar();
m_progressBar->setFormat("%p% Loading");
+ m_progressBar->setMinimum(0);
+ m_progressBar->setMaximum(100);
}
void MainWindow::slotWebLoadProgress(int progress)
@@ -214,13 +213,10 @@ void MainWindow::slotWebLoadFinished(bool ok)
}
else
{
- QStatusBar* st=statusBar();
- st->removeWidget(m_progressBar);
- st->showMessage(tr("Ready"));
+ finishProgressBar();
}
}
-
void MainWindow::slotUrlChanged(const QUrl &url)
{
m_webBar->setText(url.toString());
@@ -229,6 +225,9 @@ void MainWindow::slotUrlChanged(const QUrl &url)
void MainWindow::slotProcessStarted()
{
print(tr("Launched successfully."));
+ startProgressBar();
+ m_progressBar->setMinimum(0);
+ m_progressBar->setMaximum(0);
}
void MainWindow::slotProcessOutput()
@@ -238,6 +237,8 @@ void MainWindow::slotProcessOutput()
while((m_process->readLine(buf,BUFFERSIZE) > 0))
{
print(tr("Proc. Output: ")+buf,false);
+ QString s(buf);
+ captureOutputForStatusBar(s);
}
}
@@ -261,7 +262,7 @@ void MainWindow::slotProcessFinished(int code,QProcess::ExitStatus status)
{
print(tr("Process crashed. Output: "+code));
}
- m_web->setEnabled(true);
+ finishProgressBar();
}
void MainWindow::slotProcessError(QProcess::ProcessError error)
@@ -286,7 +287,7 @@ void MainWindow::slotProcessError(QProcess::ProcessError error)
print(tr("Unknown error."));
break;
}
- m_web->setEnabled(true);
+ startProgressBar();
}
void MainWindow::slotCreateTerminal()
@@ -360,10 +361,54 @@ int MainWindow::readEnvironmentValues()
void MainWindow::print(QString s,bool newLine)
{
- if(newLine)
+ if(!s.endsWith("\n"))
s+="\n";
if(m_logstream)
*m_logstream<<CURRENT_TIME()<<": "<<s;
if(m_output)
m_output->insertPlainText(s);
}
+
+void MainWindow::captureOutputForStatusBar(QString output)
+{
+ // Capturar para modificar status bar
+
+ output.trimmed();
+
+ QRegExp rxReset(EXPREG_RESET);
+ QRegExp rxPass(EXPREG_A_PASS);
+ if(rxReset.exactMatch(output))
+ {
+ int minimum=rxReset.cap(1).toInt();
+ int maximum=rxReset.cap(2).toInt();
+ m_progressBar->setMinimum(minimum);
+ m_progressBar->setMaximum(maximum);
+ m_progressBar->setValue(minimum);
+ }
+ else if(rxPass.indexIn(output)!=-1)
+ {
+ print("goo");
+ int pass=rxPass.cap(1).toInt();
+ output.replace(rxPass,"");
+ qDebug()<<pass<<output;
+ m_progressBar->setValue(pass);
+ m_progressBar->setFormat("%p% "+output);
+ }
+}
+
+void MainWindow::startProgressBar()
+{
+ QStatusBar* st=statusBar();
+ st->clearMessage();
+ st->addWidget(m_progressBar,100);
+ m_progressBar->show();
+ m_web->setEnabled(false);
+}
+
+void MainWindow::finishProgressBar()
+{
+ QStatusBar* st=statusBar();
+ st->removeWidget(m_progressBar);
+ st->showMessage(tr("Ready"));
+ m_web->setEnabled(true);
+}
diff --git a/client/browser/mainwindow.h b/client/browser/mainwindow.h
index 4d23fb25..e42e0c2b 100644
--- a/client/browser/mainwindow.h
+++ b/client/browser/mainwindow.h
@@ -57,6 +57,9 @@ class MainWindow : public QMainWindow
protected:
int readEnvironmentValues();
void print(QString s,bool newLine=true);
+ void captureOutputForStatusBar(QString output);
+ void startProgressBar();
+ void finishProgressBar();
protected: