3 #include "branchitem.h"
4 #include "mainwindow.h"
7 extern Main *mainWindow;
9 BugAgent::BugAgent (BranchItem *bi,const QString &bug)
13 qWarning ("Const BugAgent: bi==NULL");
17 modelID=bi->getModel()->getID();
20 script="test/vym-bug.pl";
24 connect (p, SIGNAL (finished(int,QProcess::ExitStatus) ),
25 this, SLOT (processFinished(int,QProcess::ExitStatus) ));
27 p->start (script,QStringList()<<bugID);
28 if (!p->waitForStarted())
30 qWarning()<<"BugAgent::getBugzillaData couldn't start "<<script;
35 BugAgent::~BugAgent ()
40 void BugAgent::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
42 if (exitStatus==QProcess::NormalExit)
44 VymModel *model=mainWindow->getModel (modelID);
47 BranchItem *bi=(BranchItem*)(model->findID (branchID));
50 QString oldsel=model->getSelectString ();
53 // Now do needed changes:
55 QString result=p->getStdout();
56 while (result.endsWith("\n")) result.chop(1);
57 //qWarning() << QString(result);
58 QString err=p->getErrout();
61 qWarning() << "VM::BugAgent Error:\n";
64 else if (!result.isEmpty())
66 QString heading,cdate,mdate,state,whiteboard;
67 QRegExp re("short_desc:(.*)\n");
69 if (re.indexIn (result) !=-1) heading=re.cap(1);
71 re.setPattern ("creation_ts:(.*)\n");
72 if (re.indexIn (result) !=-1) cdate=re.cap(1);
74 re.setPattern ("delta_ts:(.*)\n");
75 if (re.indexIn (result) !=-1) mdate=re.cap(1);
77 re.setPattern ("bug_status:(.*)\n");
78 if (re.indexIn (result) !=-1) state=re.cap(1);
80 re.setPattern ("status_whiteboard:(.*)\n");
81 if (re.indexIn (result) !=-1) whiteboard=re.cap(1);
83 model->setHeading (bugID + " - " + heading);
84 qDebug() << "VM: heading="<<heading;
85 qDebug() << "VM: cdate="<<cdate;
86 qDebug() << "VM: mdate="<<mdate;
87 qDebug() << "VM: state="<<state;
88 qDebug() << "VM: wboard="<<whiteboard;
90 //qDebug() <<"VM::getBugzillaData "<<script<<" returned:\n";
91 //qDebug() <<QString(result);
93 qWarning() << "VM::getBugzillaData "<<script<<" returned nothing\n";
98 model->select (oldsel);
100 qWarning ()<<"BugAgent: Found model, but not branch #"<<branchID;
102 qWarning ()<<"BugAgent: Couldn't find model #"<<modelID;
104 qWarning()<< "BugAgent: Process finished with exitCode="<<exitCode;