]> git.sur5r.net Git - bacula/bacula/commitdiff
Add context sensitive option from joblist to view the logs associated with a job.
authorDirk H Bartley <dbartley@schupan.com>
Sun, 13 May 2007 20:56:18 +0000 (20:56 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sun, 13 May 2007 20:56:18 +0000 (20:56 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4774 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/PAGES
bacula/src/qt-console/TODO
bacula/src/qt-console/bat.pro.in
bacula/src/qt-console/joblist/joblist.cpp
bacula/src/qt-console/joblist/joblist.h
bacula/src/qt-console/joblist/joblist.ui
bacula/src/qt-console/joblog/joblog.cpp [new file with mode: 0644]
bacula/src/qt-console/joblog/joblog.h [new file with mode: 0644]
bacula/src/qt-console/joblog/joblog.ui [new file with mode: 0644]

index a232cc929e3031b44e61f37faa467f0ac0c4ed4c..68f3f8d9945c15a175830bdc3a1aeb9d4c63c1af 100644 (file)
@@ -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.
index 6ffdc7d6fe67186efa5dc305113618b022599fe8..16d4678ff03df057a131b5222d40aefd3cf50d19 100644 (file)
@@ -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.
 
index 93a4a0d5bdfda48694128aeceb064929e0f849e0..5ec12d5e6b2a6b0f2c470a81a16f499961bfe27f 100644 (file)
@@ -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
index 094e220512210139d54afa8d50d85092290fae42..889e9ec0646abf0d4e2e8190c627e74ff2030e74 100644 (file)
@@ -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);
+}
index 85aa834fc4965a0537d54e0f0970e08011610883..6b56c8accb7fad4b502a218bd8a0f635526fbc5f 100644 (file)
@@ -63,6 +63,7 @@ private slots:
    void consolePurgeFiles();
    void preRestoreFromJob();
    void preRestoreFromTime();
+   void showLogForJob();
 
 private:
    void createConnections();
index eb50b2387e3f6b4545ef1486fdcd686de3c8bf2b..25a1124ab8845d47c122eff38b9d1a823ea5490f 100644 (file)
     <string>Restore From Time</string>
    </property>
   </action>
+  <action name="actionShowLogForJob" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>Show Log for Job</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>
diff --git a/bacula/src/qt-console/joblog/joblog.cpp b/bacula/src/qt-console/joblog/joblog.cpp
new file mode 100644 (file)
index 0000000..6ccfd54
--- /dev/null
@@ -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<QString>());
+   font.setPointSize(settings.value("consolePointSize", 10).toInt());
+   font.setFixedPitch(settings.value("consoleFixedPitch", true).toBool());
+   settings.endGroup();
+   textEdit->setFont(font);
+}
+
+void JobLog::populateText()
+{
+   QString heading("<A href=\"#top\">Log records for job ");
+   heading += m_jobId + "</A>\n";
+   textEdit->insertHtml(heading);
+   
+/*   display_text("<A href=\"#top\">Log records for job ");
+   display_text(m_jobId);
+   display_text("</A>\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 (file)
index 0000000..c7e9418
--- /dev/null
@@ -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 <QtGui>
+#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 (file)
index 0000000..5eb0566
--- /dev/null
@@ -0,0 +1,83 @@
+<ui version="4.0" >
+ <class>JobLogForm</class>
+ <widget class="QWidget" name="JobLogForm" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>432</width>
+    <height>456</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Job Log</string>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item row="0" column="0" >
+    <widget class="QTextEdit" name="textEdit" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>7</hsizetype>
+       <vsizetype>7</vsizetype>
+       <horstretch>200</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="minimumSize" >
+      <size>
+       <width>0</width>
+       <height>0</height>
+      </size>
+     </property>
+     <property name="sizeIncrement" >
+      <size>
+       <width>1</width>
+       <height>0</height>
+      </size>
+     </property>
+     <property name="focusPolicy" >
+      <enum>Qt::StrongFocus</enum>
+     </property>
+     <property name="acceptDrops" >
+      <bool>false</bool>
+     </property>
+     <property name="toolTip" >
+      <string comment="Joblog Window" />
+     </property>
+     <property name="statusTip" >
+      <string comment="Joblog Window" />
+     </property>
+     <property name="whatsThis" >
+      <string comment="Joblog Window" />
+     </property>
+     <property name="horizontalScrollBarPolicy" >
+      <enum>Qt::ScrollBarAsNeeded</enum>
+     </property>
+     <property name="autoFormatting" >
+      <set>QTextEdit::AutoNone</set>
+     </property>
+     <property name="tabChangesFocus" >
+      <bool>false</bool>
+     </property>
+     <property name="documentTitle" >
+      <string comment="Joblog Window" />
+     </property>
+     <property name="lineWrapMode" >
+      <enum>QTextEdit::NoWrap</enum>
+     </property>
+     <property name="readOnly" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>