28 #include <QApplication>
31 #include <QMessageBox>
32 #include <QStandardItemModel>
34 #include <QHeaderView>
39 LogDecorators::Decorator::Decorator() :
43 LogDecorators::Decorator::~Decorator() {
82 return tr(
"Plugin Information Update");
86 return tr(
"Output of update process:");
93 if (!settings.value(
"delayExecution",
false).toBool()) {
94 args <<
"--non-interactive" <<
"update";
102 if (settings.value(
"delayExecution",
false).toBool()) {
103 QMessageBox::information(
105 tr(
"wait before plugin update"),
107 "Waiting because <em>delayExecution</em> option set. "
108 "You can now attach your debugger to the update process. "
109 "Update will be started, when you close this message box."
112 cmds <<
"update" <<
"quit";
118 return QDir::home().absoluteFilePath(
"update-modules.log");
123 .absoluteFilePath(
"updateLog.txt");
126 LogDecorators::Update::Update() :
127 _curStatus(Invalid), _result(0), _view(new QTableView),
128 _ttFont(QFont(
"fixed")), _sfFont(QFont(
"sans"))
130 QString p =
"\\(\\w+\\)\\s+";
132 _passRegex = QRegExp(p+
"Created Instance \"\\w+\" of the plugin \"(.+)\".*");
133 _finishRegex = QRegExp(p+
"Successfully unloaded plugin \"(.+)\".*");
135 _failRegex = QRegExp(p+
"Could not generate metadata for module \"(.+)\".*");
137 _ttFont.setStyleHint(QFont::TypeWriter);
138 _sfFont.setStyleHint(QFont::SansSerif);
139 _result =
new QStandardItemModel(0,2,
this);
140 QStandardItem* head =
new QStandardItem(tr(
"file"));
141 _result->setHorizontalHeaderItem(0,head);
142 head =
new QStandardItem(tr(
"module"));
143 _result->setHorizontalHeaderItem(1,head);
144 head =
new QStandardItem(tr(
"status"));
145 _result->setHorizontalHeaderItem(2,head);
146 _result->setSortRole(Qt::UserRole);
148 _view->setEditTriggers(QAbstractItemView::NoEditTriggers);
149 _view->horizontalHeader()->setStretchLastSection(
true);
150 _view->verticalHeader()->hide();
151 _view->setSortingEnabled(
true);
152 _view->setAlternatingRowColors(
true);
153 _view->setGridStyle(Qt::NoPen);
154 _view->setSelectionBehavior(QAbstractItemView::SelectRows);
155 _view->setSelectionMode(QAbstractItemView::SingleSelection);
156 connect(
_view->selectionModel(),
157 SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
163 if (_curStatus == Invalid) {
166 QList<QStandardItem*> row;
167 QStandardItem* curItem = 0;
170 curItem =
new QStandardItem();
172 if (_curFile.isEmpty()) {
173 _curFile = tr(
"[no file available]");
174 curFont.setItalic(
true);
175 curItem->setData(_curFile, Qt::DisplayRole);
176 curItem->setData(QColor(Qt::gray), Qt::ForegroundRole);
177 curItem->setData(QString(), Qt::UserRole);
180 curItem->setData(_curFile, Qt::DisplayRole);
181 curItem->setData(_curFile, Qt::UserRole);
183 curItem->setData(curFont, Qt::FontRole);
186 curItem =
new QStandardItem();
187 curItem->setData(_curPlugin, Qt::DisplayRole);
188 curItem->setData(_curPlugin, Qt::UserRole);
189 curItem->setData(_ttFont, Qt::FontRole);
192 curItem =
new QStandardItem();
193 curItem->setData(_curStatus, Qt::UserRole);
195 switch (_curStatus) {
197 curItem->setData(tr(
"passed"), Qt::DisplayRole);
198 curItem->setData(QBrush(QColor(
"#0A2")),Qt::ForegroundRole);
201 curItem->setData(tr(
"no plugin"), Qt::DisplayRole);
202 curItem->setData(QBrush(QColor(
"#777")),Qt::ForegroundRole);
205 curItem->setData(tr(
"warnings"), Qt::DisplayRole);
206 curItem->setData(QBrush(QColor(
"#F84")),Qt::ForegroundRole);
207 curFont.setWeight(QFont::DemiBold);
210 curItem->setData(tr(
"failed"), Qt::DisplayRole);
211 curItem->setData(QBrush(QColor(
"#F20")),Qt::ForegroundRole);
212 curFont.setWeight(QFont::DemiBold);
215 qDebug() <<
"unhandled status code:" << _curStatus;
218 curItem->setData(curFont, Qt::FontRole);
221 _result->appendRow(row);
222 _view->setRowHeight(_result->rowCount()-1,20);
223 _view->setColumnWidth(0,_view->width()/2);
224 _view->setColumnWidth(1,_view->width()/4);
227 _curStatus = Invalid;
228 _curFile = QString();
229 _curPlugin = QString();
233 if (_fileRegex.exactMatch(line)) {
235 _curFile = _fileRegex.cap(1);
238 else if (_noPluginRegex.exactMatch(line)) {
239 _curStatus = NoPlugin;
240 if (!_curPlugin.isEmpty() && _curPlugin != _noPluginRegex.cap(1)) {
241 qDebug() <<
"Plugin Mismatch (noPlugin):"
242 << _curPlugin << _noPluginRegex.cap(1);
244 _curPlugin = _noPluginRegex.cap(1);
246 else if (_failRegex.exactMatch(line)) {
247 if (!_curPlugin.isEmpty() && _curPlugin != _failRegex.cap(1)) {
248 qDebug() <<
"Plugin Mismatch (fail):"
249 << _curPlugin << _failRegex.cap(1);
252 _curPlugin = _failRegex.cap(1);
255 else if (_warnRegex.exactMatch(line)) {
256 _curStatus = Warnings;
258 else if (_passRegex.exactMatch(line)) {
259 if (!_curPlugin.isEmpty() && _curPlugin != _passRegex.cap(1)) {
260 qDebug() <<
"Plugin Mismatch (pass):"
261 << _curPlugin << _passRegex.cap(1);
263 _curPlugin = _passRegex.cap(1);
264 if (_curStatus != Warnings) {
268 else if (_finishRegex.exactMatch(line)) {
269 if (!_curPlugin.isEmpty() && _curPlugin != _finishRegex.cap(1)) {
270 qDebug() <<
"Plugin Mismatch (finish):"
271 << _curPlugin << _finishRegex.cap(1);
273 if (_curStatus != Passed && _curStatus != Warnings) {
274 qDebug() <<
"Strange Plugin Status (finish):" << _curStatus;
276 _curPlugin = _finishRegex.cap(1);
282 _view->sortByColumn(2,Qt::DescendingOrder);
290 emit filter(QString(
"\"%1\"").arg(
291 _result->data(_result->index(idx.row(),1),Qt::DisplayRole).toString()));
295 return QString(
"#update-metadata");
300 _fileName(fileName) {
304 return tr(
"Plugin Information Update of Dynamic Modules");
308 return tr(
"Output of update-dynamics process:");
313 .absoluteFilePath(
"updateDynLog.txt");
319 if (settings.value(
"delayExecution",
false).toBool()) {
320 QMessageBox::information(
322 tr(
"wait before plugin update"),
324 "Waiting because <em>delayExecution</em> option set. "
325 "You can now attach your debugger to the update process. "
326 "Update will be started, when you close this message box."
329 cmds << QString(
"update-dynamics ")+_fileName <<
"quit";
338 if (!settings.value(
"delayExecution",
false).toBool()) {
339 args <<
"--non-interactive" <<
"update-dynamics" << _fileName;
346 _fileName(fileName) {
350 if(_fileName.isEmpty()) {
351 QMessageBox::warning(
353 tr(
"missing workflow file"),
355 "The workflow cannot be started because it has not "
356 "been saved to disk (empty filename given). "
357 "Please save it and retry execution."
369 if (!settings.value(
"delayExecution",
false).toBool()) {
370 args <<
"run" << _fileName;
378 if (settings.value(
"delayExecution",
false).toBool()) {
379 QMessageBox::information(
381 tr(
"wait before workflow execution"),
383 "Waiting because <em>delayExecution</em> option set. "
384 "You can now attach your debugger to the run process. "
385 "Workflow will be started, when you close this message box."
388 cmds << QString(
"run %1").arg(_fileName);
395 QRegExp curObj(
"\\(II\\) Executing\\s*\\w*\\s*\"(\\w*)\"\\s*");
396 if (curObj.exactMatch(line)) {
397 emit highlightObject(curObj.cap(1));
401 QCoreApplication::translate(
"CharonRun",
"Execution finished.")) ||
403 QCoreApplication::translate(
"CharonRun",
"Error during execution:"))) {
405 emit message(finishMessage());
410 return QString(
"<br><span class=\"success\">%1</span><br>%2<br>")
411 .arg(tr(
"Workflow execution finished."))
412 .arg(tr(
"Plugins stay loaded until you close this dialog."));
416 QFileInfo wrpFile(_fileName);
417 return QString(
"%1/%2.log")
418 .arg(wrpFile.absolutePath()).arg(wrpFile.baseName());
423 .absoluteFilePath(
"executeLog.txt");
427 return QString(
"#run-workflow");
virtual QString finishMessage() const
finish message to display when workflow finished
Declaration of class FileManager.
QRegExp _failRegex
fail regex
virtual QString title() const
title string
static const FileManager & instance()
get a reference to the file Manager instance
QRegExp _warnRegex
no plugin info
virtual void processLine(QString line)
decorator hook to allow log line parsing
QRegExp _noPluginRegex
no plugin info
QRegExp _finishRegex
plugin unloaded
virtual QStringList arguments() const
determine command line arguments
QDir configDir() const
get config directory
void _appendSummaryRow()
append log row with current information
virtual QString desc() const
description string
virtual QString desc() const
description string
virtual QString title() const
title string
virtual QStringList postStartCommands(QWidget *pp) const
commands sent to the proccess after start
Declaration of classes in the LogDecorators namespace.
QFont _ttFont
typewriter font
virtual void finishProcessing()
inform about finished processing
RunWorkflow(QString fileName)
constructor
QStandardItemModel * _result
update summary
virtual QStringList postStartCommands(QWidget *parent) const
commands sent to the proccess after start
QFont _sfFont
sans-serif font
virtual bool ready(QWidget *parent) const
check if process may be started
virtual QString logFileName() const
logfile name for output logging
virtual QWidget * statusWidget()
custom status widget
virtual void processLine(QString line)
decorator hook to allow log line parsing
virtual QStringList postStartCommands(QWidget *parent) const
commands sent to the proccess after start
QTableView * _view
summary list
virtual void finishProcessing()
inform about finished processing
virtual QString desc() const
description string
virtual QString filenameHint() const
hint for filename on save dialog
virtual QWidget * statusWidget()
custom status widget
virtual QString logFileName() const
logfile name for output logging
UpdateDynamics(QString fileName)
constructor
virtual QString helpAnchor()
html anchor on help page
virtual QString helpAnchor()
html anchor on help page
virtual QString title() const
title string
virtual QString filenameHint() const
hint for filename on save dialog
QRegExp _fileRegex
file name regexp
virtual bool ready(QWidget *parent) const
check if process may be started
QRegExp _passRegex
plugin passed regexp
virtual QString helpAnchor()
html anchor on help page
virtual QString filenameHint() const
hint for filename on save dialog
virtual QStringList postStartCommands(QWidget *parent) const
commands sent to the proccess after start
void _searchOutput(const QModelIndex &)
show corresponding log line on selection
virtual QStringList arguments() const
determine command line arguments
virtual void processLine(QString line)
decorator hook to allow log line parsing
virtual QStringList arguments() const
determine command line arguments
virtual QString logFileName() const
logfile name for output logging