]> 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 2174a7df922a709c99f9a0753497ad949f61cce4..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/emblem-system.svg")));
+   thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/run.png")));
 
    /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_client.h */
    m_populated = false;
@@ -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);
 
@@ -95,19 +96,7 @@ void Jobs::populateTree()
 
       for (int i=0; i<headerlist.count(); i++)
          jobsItem->setData(i, Qt::UserRole, 1);
-/*struct job_defaults {
-   QString job_name;
-   QString pool_name;
-   QString messages_name;
-   QString client_name;
-   QString store_name;
-   QString where;
-   QString level;
-   QString type;
-   QString fileset_name;
-   QString catalog_name;
-   bool enabled;
-};*/
+
       job_defaults job_defs;
       job_defs.job_name = jobName;
       if (m_console->get_job_defaults(job_defs)) {
@@ -127,7 +116,6 @@ void Jobs::populateTree()
             jobsItem->setText(col++, "No");
          }
       }
-
    }
    /* Resize the columns */
    for(int cnter=0; cnter<headerlist.size(); cnter++) {
@@ -157,9 +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(actionListJobsofClient);
+         foreach(QAction* jobAction, mp_treeWidget->actions()) {
+            mp_treeWidget->removeAction(jobAction);
          }
       }
 
@@ -168,7 +155,15 @@ void Jobs::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *
          /* set a hold variable to the client name in case the context sensitive
           * menu is used */
          m_currentlyselected=currentwidgetitem->text(0);
-         //mp_treeWidget->addAction(actionListJobsofClient);
+         mp_treeWidget->addAction(actionConsoleListFiles);
+         mp_treeWidget->addAction(actionConsoleListVolumes);
+         mp_treeWidget->addAction(actionConsoleListNextVolume);
+         mp_treeWidget->addAction(actionConsoleEnableJob);
+         mp_treeWidget->addAction(actionConsoleDisableJob);
+         mp_treeWidget->addAction(actionConsoleCancel);
+         mp_treeWidget->addAction(actionJobListQuery);
+         if (currentwidgetitem->text(m_typeIndex) == tr("Backup"))
+            mp_treeWidget->addAction(actionRunJob);
       }
    }
 }
@@ -188,6 +183,14 @@ void Jobs::createContextMenu()
    /* connect to the action specific to this pages class */
    connect(actionRefreshJobs, SIGNAL(triggered()), this,
                 SLOT(populateTree()));
+   connect(actionConsoleListFiles, SIGNAL(triggered()), this, SLOT(consoleListFiles()));
+   connect(actionConsoleListVolumes, SIGNAL(triggered()), this, SLOT(consoleListVolume()));
+   connect(actionConsoleListNextVolume, SIGNAL(triggered()), this, SLOT(consoleListNextVolume()));
+   connect(actionConsoleEnableJob, SIGNAL(triggered()), this, SLOT(consoleEnable()));
+   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()));
 }
 
 /*
@@ -195,9 +198,68 @@ void Jobs::createContextMenu()
  */
 void Jobs::currentStackItem()
 {
+   populateTree();
    if(!m_populated) {
-      populateTree();
       /* Create the context menu for the client tree */
       m_populated=true;
    }
 }
+
+/*
+ * The following functions are slots responding to users clicking on the context
+ * sensitive menu
+ */
+
+void Jobs::consoleListFiles()
+{
+   QString cmd = "list files job=\"" + m_currentlyselected + "\"";
+   if (mainWin->m_longList) { cmd.prepend("l"); }
+   consoleCommand(cmd);
+}
+
+void Jobs::consoleListVolume()
+{
+   QString cmd = "list volumes job=\"" + m_currentlyselected + "\"";
+   if (mainWin->m_longList) { cmd.prepend("l"); }
+   consoleCommand(cmd);
+}
+
+void Jobs::consoleListNextVolume()
+{
+   QString cmd = "list nextvolume job=\"" + m_currentlyselected + "\"";
+   if (mainWin->m_longList) { cmd.prepend("l"); }
+   consoleCommand(cmd);
+}
+
+void Jobs::consoleEnable()
+{
+   QString cmd = "enable job=\"" + m_currentlyselected + "\"";
+   consoleCommand(cmd);
+}
+
+void Jobs::consoleDisable()
+{
+   QString cmd = "disable job=\"" + m_currentlyselected + "\"";
+   consoleCommand(cmd);
+}
+
+void Jobs::consoleCancel()
+{
+   QString cmd = "cancel job=\"" + m_currentlyselected + "\"";
+   consoleCommand(cmd);
+}
+
+void Jobs::listJobs()
+{
+   QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
+   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);
+}