From 6612b0963400e799df6bc0c90086e81fa29ce384 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sun, 13 May 2007 20:56:18 +0000 Subject: [PATCH] Add context sensitive option from joblist to view the logs associated with a job. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4774 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/PAGES | 6 ++ bacula/src/qt-console/TODO | 9 +- bacula/src/qt-console/bat.pro.in | 5 + bacula/src/qt-console/joblist/joblist.cpp | 13 +++ bacula/src/qt-console/joblist/joblist.h | 1 + bacula/src/qt-console/joblist/joblist.ui | 8 ++ bacula/src/qt-console/joblog/joblog.cpp | 118 ++++++++++++++++++++++ bacula/src/qt-console/joblog/joblog.h | 60 +++++++++++ bacula/src/qt-console/joblog/joblog.ui | 83 +++++++++++++++ 9 files changed, 301 insertions(+), 2 deletions(-) create mode 100644 bacula/src/qt-console/joblog/joblog.cpp create mode 100644 bacula/src/qt-console/joblog/joblog.h create mode 100644 bacula/src/qt-console/joblog/joblog.ui diff --git a/bacula/src/qt-console/PAGES b/bacula/src/qt-console/PAGES index a232cc929e..68f3f8d994 100644 --- a/bacula/src/qt-console/PAGES +++ b/bacula/src/qt-console/PAGES @@ -36,3 +36,9 @@ consoleCommand(QString &command) to execute a console command setTitle() for setting the title of a window that will display when undocked. setCurrent() for making the page and tree widget item of an object selected and in the front of the stack. + +Closing +Use the function closeDockPage() to close from within the class. Otherwise, if +there are pointers which need to be deleted, use a destructor. The m_closeable +page member will determine whether the option to close will appear in context +menu of page selector. diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index 6ffdc7d6fe..16d4678ff0 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -1,12 +1,14 @@ dhb ==================================================== -Create class to display messages from a specific job. Want the ability to -create an instance of that class from joblist. +Get status codes in dropdown for joblist select. Need to figure out the functionality and inteligence that the last restore window should have and give it to it. Right now it shows drop downs with no options. +See if it would be possible to have user provided console text show up in a +color + Test left pane of restore with 2 windows drives in one backup job. User preferences. With log to stdout options. @@ -83,6 +85,9 @@ global one defined in the mainWin class (if I remember right). ============================================================ DONE: ============================================================ +Create class to display messages from a specific job. Want the ability to +create an instance of that class from joblist. + Color code termination code in joblist. I also want a table to convert termination code into human readable text. diff --git a/bacula/src/qt-console/bat.pro.in b/bacula/src/qt-console/bat.pro.in index 93a4a0d5bd..5ec12d5e6b 100644 --- a/bacula/src/qt-console/bat.pro.in +++ b/bacula/src/qt-console/bat.pro.in @@ -38,6 +38,7 @@ FORMS += run/run.ui run/runcmd.ui FORMS += select/select.ui FORMS += medialist/medialist.ui mediaedit/mediaedit.ui joblist/joblist.ui FORMS += clients/clients.ui storage/storage.ui fileset/fileset.ui +FORMS += joblog/joblog.ui HEADERS += mainwin.h bat.h bat_conf.h qstd.h SOURCES += main.cpp bat_conf.cpp mainwin.cpp qstd.cpp @@ -98,5 +99,9 @@ SOURCES += storage/storage.cpp HEADERS += fileset/fileset.h SOURCES += fileset/fileset.cpp +## Fileset +HEADERS += joblog/joblog.h +SOURCES += joblog/joblog.cpp + INSTALLS += bins INSTALLS += confs diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 094e220512..889e9ec064 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -36,6 +36,7 @@ #include "bat.h" #include "joblist.h" #include "restore.h" +#include "joblog/joblog.h" /* * Constructor for the class @@ -339,6 +340,7 @@ void JobList::createConnections() mp_tableWidget->addAction(actionPurgeFiles); mp_tableWidget->addAction(actionRestoreFromJob); mp_tableWidget->addAction(actionRestoreFromTime); + mp_tableWidget->addAction(actionShowLogForJob); /* Make Connections */ connect(actionLongListJob, SIGNAL(triggered()), this, @@ -359,6 +361,8 @@ void JobList::createConnections() SLOT(preRestoreFromJob())); connect(actionRestoreFromTime, SIGNAL(triggered()), this, SLOT(preRestoreFromTime())); + connect(actionShowLogForJob, SIGNAL(triggered()), this, + SLOT(showLogForJob())); } /* @@ -447,3 +451,12 @@ void JobList::preRestoreFromTime() { new prerestorePage(m_currentJob, R_JOBDATETIME); } + +/* + * Subroutine to call class to show the log in the database from that job + */ +void JobList::showLogForJob() +{ + QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(this); + new JobLog(m_currentJob, pageSelectorTreeWidgetItem); +} diff --git a/bacula/src/qt-console/joblist/joblist.h b/bacula/src/qt-console/joblist/joblist.h index 85aa834fc4..6b56c8accb 100644 --- a/bacula/src/qt-console/joblist/joblist.h +++ b/bacula/src/qt-console/joblist/joblist.h @@ -63,6 +63,7 @@ private slots: void consolePurgeFiles(); void preRestoreFromJob(); void preRestoreFromTime(); + void showLogForJob(); private: void createConnections(); diff --git a/bacula/src/qt-console/joblist/joblist.ui b/bacula/src/qt-console/joblist/joblist.ui index eb50b2387e..25a1124ab8 100644 --- a/bacula/src/qt-console/joblist/joblist.ui +++ b/bacula/src/qt-console/joblist/joblist.ui @@ -343,6 +343,14 @@ Restore From Time + + + ../images/unmark.png + + + Show Log for Job + + diff --git a/bacula/src/qt-console/joblog/joblog.cpp b/bacula/src/qt-console/joblog/joblog.cpp new file mode 100644 index 0000000000..6ccfd54618 --- /dev/null +++ b/bacula/src/qt-console/joblog/joblog.cpp @@ -0,0 +1,118 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ + +/* + * Version $Id: medialist.cpp 4230 2007-02-21 20:07:37Z kerns $ + * + * JobLog Class + * + * Dirk Bartley, March 2007 + * + */ + +#include "bat.h" +#include "joblog.h" + +JobLog::JobLog(QString &jobId, QTreeWidgetItem *parentTreeWidgetItem) +{ + setupUi(this); + m_name = "JobLog"; + m_closeable = true; + pgInitialize(parentTreeWidgetItem); + m_cursor = new QTextCursor(textEdit->document()); + + m_jobId = jobId; + getFont(); + populateText(); + + dockPage(); + setCurrent(); +} + +void JobLog::getFont() +{ + QFont font = textEdit->font(); + + QString dirname; + m_console->getDirResName(dirname); + QSettings settings(dirname, "bat"); + settings.beginGroup("Console"); + font.setFamily(settings.value("consoleFont", "Courier").value()); + font.setPointSize(settings.value("consolePointSize", 10).toInt()); + font.setFixedPitch(settings.value("consoleFixedPitch", true).toBool()); + settings.endGroup(); + textEdit->setFont(font); +} + +void JobLog::populateText() +{ + QString heading("Log records for job "); + heading += m_jobId + "\n"; + textEdit->insertHtml(heading); + +/* display_text("Log records for job "); + display_text(m_jobId); + display_text("\n");*/ + QString query(""); + query = "SELECT Time, LogText FROM Log WHERE JobId='" + m_jobId + "'"; + + QStringList results; + if (m_console->sql_cmd(query, results)) { + QString field; + QStringList fieldlist; + + /* Iterate through the lines of results. */ + foreach (QString resultline, results) { + fieldlist = resultline.split("\t"); + + int column = 0; + /* Iterate through fields in the record */ + foreach (field, fieldlist) { + display_text(field); + if (column <= 1) display_text("\n"); + column += 1; + } /* foreach field */ + } /* foreach resultline */ + } /* if results from query */ + textEdit->scrollToAnchor("top"); +} + +/* + * Put text into the joblog window + */ +void JobLog::display_text(const QString buf) +{ + m_cursor->movePosition(QTextCursor::End); + m_cursor->insertText(buf); +} + +void JobLog::display_text(const char *buf) +{ + m_cursor->movePosition(QTextCursor::End); + m_cursor->insertText(buf); +} diff --git a/bacula/src/qt-console/joblog/joblog.h b/bacula/src/qt-console/joblog/joblog.h new file mode 100644 index 0000000000..c7e9418637 --- /dev/null +++ b/bacula/src/qt-console/joblog/joblog.h @@ -0,0 +1,60 @@ +#ifndef _JOBLOG_H_ +#define _JOBLOG_H_ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ +/* + * Version $Id: medialist.h 4230 2007-02-21 20:07:37Z kerns $ + * + * Dirk Bartley, March 2007 + */ + +#include +#include "ui_joblog.h" +#include "console.h" + +class JobLog : public Pages, public Ui::JobLogForm +{ + Q_OBJECT + +public: + JobLog(QString &jobId, QTreeWidgetItem *parentTreeWidgetItem); + +public slots: + +private slots: + +private: + void display_text(const char *buf); + void display_text(const QString buf); + void populateText(); + void getFont(); + QTextCursor *m_cursor; + QString m_jobId; +}; + +#endif /* _JOBLOG_H_ */ diff --git a/bacula/src/qt-console/joblog/joblog.ui b/bacula/src/qt-console/joblog/joblog.ui new file mode 100644 index 0000000000..5eb05665b4 --- /dev/null +++ b/bacula/src/qt-console/joblog/joblog.ui @@ -0,0 +1,83 @@ + + JobLogForm + + + + 0 + 0 + 432 + 456 + + + + Job Log + + + + 9 + + + 6 + + + + + + 7 + 7 + 200 + 0 + + + + + 0 + 0 + + + + + 1 + 0 + + + + Qt::StrongFocus + + + false + + + + + + + + + + + + Qt::ScrollBarAsNeeded + + + QTextEdit::AutoNone + + + false + + + + + + QTextEdit::NoWrap + + + true + + + + + + + + -- 2.39.5