]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/jobs/jobs.cpp
Add preference to have the status dir screen auto refresh.
[bacula/bacula] / bacula / src / qt-console / jobs / jobs.cpp
index ce31a381b02c3151485c37003e02fe1103c8dbea..579c5e3e26dc15bd0774a5a625ee56a46d0ab306 100644 (file)
@@ -1,14 +1,14 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2007-2008 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.
+   License as published by the Free Software Foundation and included
+   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
@@ -27,7 +27,7 @@
 */
  
 /*
- *   Version $Id: client.cpp 4230 2007-02-21 20:07:37Z kerns $
+ *   Version $Id$
  *
  *  Jobs Class
  *
  *
  */ 
 
-//#include <QAbstractEventDispatcher>
-//#include <QMenu>
 #include "bat.h"
 #include "jobs/jobs.h"
+#include "run/run.h"
 
 Jobs::Jobs()
 {
    setupUi(this);
-   m_name = "Jobs";
+   m_name = tr("Jobs");
    pgInitialize();
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/run.png")));
@@ -76,12 +75,14 @@ void Jobs::populateTree()
    m_checkcurwidget = false;
    mp_treeWidget->clear();
    m_checkcurwidget = true;
-   QStringList headerlist = (QStringList() << "Job Name" << "Pool" << "Messages"
-      << "Client" << "Storage" << "Where" << "Level" << "Type" << "FileSet" 
-      << "Catalog" << "Enabled");
+   QStringList headerlist = (QStringList() << tr("Job Name") << tr("Pool") << tr("Messages")
+      << tr("Client") << tr("Storage") << tr("Where") << tr("Level") << tr("Type") 
+      << tr("FileSet") 
+      << tr("Catalog") << tr("Enabled"));
 
+   m_typeIndex = headerlist.indexOf(tr("Type"));
    topItem = new QTreeWidgetItem(mp_treeWidget);
-   topItem->setText(0, "Jobs");
+   topItem->setText(0, tr("Jobs"));
    topItem->setData(0, Qt::UserRole, 0);
    topItem->setExpanded(true);
 
@@ -144,15 +145,8 @@ void Jobs::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *
    if (m_checkcurwidget) {
       /* The Previous item */
       if (previouswidgetitem) { /* avoid a segfault if first time */
-         int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt();
-         if (treedepth == 1){
-            mp_treeWidget->removeAction(actionConsoleListFiles);
-            mp_treeWidget->removeAction(actionConsoleListVolumes);
-            mp_treeWidget->removeAction(actionConsoleListNextVolume);
-            mp_treeWidget->removeAction(actionConsoleEnableJob);
-            mp_treeWidget->removeAction(actionConsoleDisableJob);
-            mp_treeWidget->removeAction(actionConsoleCancel);
-            mp_treeWidget->removeAction(actionJobListQuery);
+         foreach(QAction* jobAction, mp_treeWidget->actions()) {
+            mp_treeWidget->removeAction(jobAction);
          }
       }
 
@@ -168,6 +162,8 @@ void Jobs::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *
          mp_treeWidget->addAction(actionConsoleDisableJob);
          mp_treeWidget->addAction(actionConsoleCancel);
          mp_treeWidget->addAction(actionJobListQuery);
+         if (currentwidgetitem->text(m_typeIndex) == tr("Backup"))
+            mp_treeWidget->addAction(actionRunJob);
       }
    }
 }
@@ -194,6 +190,7 @@ void Jobs::createContextMenu()
    connect(actionConsoleDisableJob, SIGNAL(triggered()), this, SLOT(consoleDisable()));
    connect(actionConsoleCancel, SIGNAL(triggered()), this, SLOT(consoleCancel()));
    connect(actionJobListQuery, SIGNAL(triggered()), this, SLOT(listJobs()));
+   connect(actionRunJob, SIGNAL(triggered()), this, SLOT(runJob()));
 }
 
 /*
@@ -215,48 +212,54 @@ void Jobs::currentStackItem()
 
 void Jobs::consoleListFiles()
 {
-   QString cmd("list files job=");
-   cmd += m_currentlyselected;
+   QString cmd = "list files job=\"" + m_currentlyselected + "\"";
+   if (mainWin->m_longList) { cmd.prepend("l"); }
    consoleCommand(cmd);
 }
 
 void Jobs::consoleListVolume()
 {
-   QString cmd("list volumes job=");
-   cmd += m_currentlyselected;
+   QString cmd = "list volumes job=\"" + m_currentlyselected + "\"";
+   if (mainWin->m_longList) { cmd.prepend("l"); }
    consoleCommand(cmd);
 }
 
 void Jobs::consoleListNextVolume()
 {
-   QString cmd("list nextvolume job=");
-   cmd += m_currentlyselected;
+   QString cmd = "list nextvolume job=\"" + m_currentlyselected + "\"";
+   if (mainWin->m_longList) { cmd.prepend("l"); }
    consoleCommand(cmd);
 }
 
 void Jobs::consoleEnable()
 {
-   QString cmd("enable job=");
-   cmd += m_currentlyselected;
+   QString cmd = "enable job=\"" + m_currentlyselected + "\"";
    consoleCommand(cmd);
 }
 
 void Jobs::consoleDisable()
 {
-   QString cmd("disable job=");
-   cmd += m_currentlyselected;
+   QString cmd = "disable job=\"" + m_currentlyselected + "\"";
    consoleCommand(cmd);
 }
 
 void Jobs::consoleCancel()
 {
-   QString cmd("cancel job=");
-   cmd += m_currentlyselected;
+   QString cmd = "cancel job=\"" + m_currentlyselected + "\"";
    consoleCommand(cmd);
 }
 
 void Jobs::listJobs()
 {
    QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
-   mainWin->createPageJobList("", "", m_currentlyselected, parentItem);
+   mainWin->createPageJobList("", "", m_currentlyselected, "", parentItem);
+}
+
+/*
+ * Open a new job run page with the currentley selected "Backup" job 
+ * defaulted In
+ */
+void Jobs::runJob()
+{
+   new runPage(m_currentlyselected);
 }