]> git.sur5r.net Git - bacula/bacula/commitdiff
Add six context sensitive menu options to the joblist. I think I got
authorDirk H Bartley <dbartley@schupan.com>
Mon, 23 Apr 2007 03:09:12 +0000 (03:09 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Mon, 23 Apr 2007 03:09:12 +0000 (03:09 +0000)
all the ones that made sense doing "jobid=" searches in documentation.
Commented out one passed value in line 122 of console.cpp to get a
successful compilation.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4604 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/TODO
bacula/src/qt-console/console/console.cpp
bacula/src/qt-console/joblist/joblist.cpp
bacula/src/qt-console/joblist/joblist.h
bacula/src/qt-console/joblist/joblist.ui

index 1c203662b70f2ca6fdfb3fc72bc56da49ae0d9d7..a728b0816330d98f2bf34595f544bad2f7e6d8f5 100644 (file)
@@ -1,7 +1,10 @@
 dhb
 ====================================================
+Must preempt all connections to console with if connected.
+
 Add context sensitive options for most commands
 status dir on page select director item
+All items with jobid= that I thought could work from joblist are done.
 
 Create list of what does not work.
 
index ac90518935ace2e0182fe13ea90ddbe30841b869..d5701612059d3e342e7d8a6e004bb1b99fda2e88 100644 (file)
@@ -119,7 +119,7 @@ void Console::connect()
       heart_beat = 0;
    }        
 
-   m_sock = bnet_connect(NULL, 5, 15, heart_beat,
+   m_sock = bnet_connect(NULL, 5, /*15,*/ heart_beat,
                           _("Director daemon"), m_dir->address,
                           NULL, m_dir->DIRport, 0);
    if (m_sock == NULL) {
index 1e62bf9f9ba64278ba0ab43e8f03c640e5b14e99..fe0b54e8c13b67cc41a4f2b16001c4de6a12ff9c 100644 (file)
 /*
  * Constructor for the class
  */
-JobList::JobList(QString &medianame, QString &clientname,
+JobList::JobList(QString &mediaName, QString &clientname,
          QTreeWidgetItem *parentTreeWidgetItem)
 {
    setupUi(this);
    m_name = "Clients";
-   m_medianame = medianame;
-   m_clientname = clientname;
+   m_mediaName = mediaName;
+   m_clientName = clientname;
    pgInitialize(parentTreeWidgetItem);
    m_resultCount = 0;
    m_populated = false;
    m_closeable = false;
-   /* connect to the action specific to this pages class */
-   connect(actionRefreshJobList, SIGNAL(triggered()), this,
-                SLOT(populateTable()));
+   m_checkCurrentWidget = true;
+   createConnections();
    setTitle();
 }
 
@@ -61,12 +60,13 @@ JobList::JobList(QString &medianame, QString &clientname,
  * The Meat of the class.
  * This function will populate the QTableWidget, mp_tablewidget, with
  * QTableWidgetItems representing the results of a query for what jobs exist on
- * the media name passed from the constructor stored in m_medianame.
+ * the media name passed from the constructor stored in m_mediaName.
  */
 void JobList::populateTable()
 {
    QStringList results;
    QString resultline;
+   QBrush blackBrush(Qt::black);
 
    /* Set up query QString and header QStringList */
    QString query("");
@@ -77,12 +77,12 @@ void JobList::populateTable()
             " FROM Job, JobMedia, Media, Client"
             " WHERE JobMedia.JobId=Job.JobId and JobMedia.MediaId=Media.MediaId"
             " and Client.ClientId=Job.ClientId";
-   if (m_medianame != "") {
-      query += " and Media.VolumeName='" + m_medianame + "'";
+   if (m_mediaName != "") {
+      query += " and Media.VolumeName='" + m_mediaName + "'";
       m_closeable=true;
    }
-   if (m_clientname != "") {
-      query += " and Client.Name='" + m_clientname + "'";
+   if (m_clientName != "") {
+      query += " and Client.Name='" + m_clientName + "'";
       m_closeable=true;
    }
    query += " ORDER BY Job.Starttime";
@@ -91,7 +91,9 @@ void JobList::populateTable()
       << "Job Level" << "Job Files" << "Job Bytes" << "Job Status"  );
 
    /* Initialize the QTableWidget */
+   m_checkCurrentWidget = false;
    mp_tableWidget->clear();
+   m_checkCurrentWidget = true;
    mp_tableWidget->setColumnCount(headerlist.size());
    mp_tableWidget->setHorizontalHeaderLabels(headerlist);
 
@@ -115,6 +117,7 @@ void JobList::populateTable()
             field = field.trimmed();  /* strip leading & trailing spaces */
             p_tableitem = new QTableWidgetItem(field,1);
             p_tableitem->setFlags(0);
+            p_tableitem->setForeground(blackBrush);
             mp_tableWidget->setItem(row, column, p_tableitem);
             column++;
          }
@@ -125,7 +128,7 @@ void JobList::populateTable()
    for(int cnter=0; cnter<headerlist.size(); cnter++) {
       mp_tableWidget->resizeColumnToContents(cnter);
    }
-   if ((m_medianame != "") && (m_resultCount == 0)){
+   if ((m_mediaName != "") && (m_resultCount == 0)){
       /* for context sensitive searches, let the user know if there were no
        * results */
       QMessageBox::warning(this, tr("Bat"),
@@ -164,15 +167,123 @@ void JobList::currentStackItem()
  */
 void JobList::treeWidgetName(QString &desc)
 {
-   if ((m_medianame == "") && (m_clientname == "")) {
+   if ((m_mediaName == "") && (m_clientName == "")) {
       desc = "All Jobs";
    } else {
       desc = "Jobs ";
-      if (m_medianame != "" ) {
-         desc += "on Volume " + m_medianame;
+      if (m_mediaName != "" ) {
+         desc += "on Volume " + m_mediaName;
       }
-      if (m_clientname != "" ) {
-         desc += "of Client " + m_clientname;
+      if (m_clientName != "" ) {
+         desc += "of Client " + m_clientName;
       }
    }
 }
+
+/*
+ * This functions much line tableItemChanged for trees like the page selector,
+ * but I will do much less here
+ */
+void JobList::tableItemChanged(QTableWidgetItem *currentItem, QTableWidgetItem * /*previousItem*/)
+{
+   if (m_checkCurrentWidget) {
+      int row = currentItem->row();
+      QTableWidgetItem* jobitem = mp_tableWidget->item(row, 0);
+      m_currentJob = jobitem->text();
+   }
+}
+
+/*
+ * Function to create connections for context sensitive menu for this and
+ * the page selector
+ */
+void JobList::createConnections()
+{
+   /* connect to the action specific to this pages class that shows up in the 
+    * page selector tree */
+   connect(actionRefreshJobList, SIGNAL(triggered()), this,
+                SLOT(populateTable()));
+   /* for the tableItemChanged to maintain m_currentJob */
+   connect(mp_tableWidget, SIGNAL(
+           currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
+           this, SLOT(tableItemChanged(QTableWidgetItem *, QTableWidgetItem *)));
+
+   /* Do what is required for the local context sensitive menu */
+
+
+   /* setContextMenuPolicy is required */
+   mp_tableWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
+
+   /* Add Actions */
+   mp_tableWidget->addAction(actionRefreshJobList);
+   mp_tableWidget->addAction(actionLongListJob);
+   mp_tableWidget->addAction(actionListJobid);
+   mp_tableWidget->addAction(actionListFilesOnJob);
+   mp_tableWidget->addAction(actionListJobMedia);
+   mp_tableWidget->addAction(actionListVolumes);
+   mp_tableWidget->addAction(actionDeleteJob);
+   mp_tableWidget->addAction(actionPurgeFiles);
+
+   /* Make Connections */
+   connect(actionLongListJob, SIGNAL(triggered()), this,
+                SLOT(consoleLongListJob()));
+   connect(actionListJobid, SIGNAL(triggered()), this,
+                SLOT(consoleListJobid()));
+   connect(actionListFilesOnJob, SIGNAL(triggered()), this,
+                SLOT(consoleListFilesOnJob()));
+   connect(actionListJobMedia, SIGNAL(triggered()), this,
+                SLOT(consoleListJobMedia()));
+   connect(actionListVolumes, SIGNAL(triggered()), this,
+                SLOT(consoleListVolumes()));
+   connect(actionDeleteJob, SIGNAL(triggered()), this,
+                SLOT(consoleDeleteJob()));
+   connect(actionPurgeFiles, SIGNAL(triggered()), this,
+                SLOT(consolePurgeFiles()));
+}
+
+/*
+ * Functions to respond to local context sensitive menu sending console commands
+ * If I could figure out how to make these one function passing a string, Yaaaaaa
+ */
+void JobList::consoleLongListJob()
+{
+   QString cmd("llist jobid=");
+   cmd += m_currentJob;
+   consoleCommand(cmd);
+}
+void JobList::consoleListJobid()
+{
+   QString cmd("list jobid=");
+   cmd += m_currentJob;
+   consoleCommand(cmd);
+}
+void JobList::consoleListFilesOnJob()
+{
+   QString cmd("list files jobid=");
+   cmd += m_currentJob;
+   consoleCommand(cmd);
+}
+void JobList::consoleListJobMedia()
+{
+   QString cmd("list jobmedia jobid=");
+   cmd += m_currentJob;
+   consoleCommand(cmd);
+}
+void JobList::consoleListVolumes()
+{
+   QString cmd("list volumes jobid=");
+   cmd += m_currentJob;
+   consoleCommand(cmd);
+}
+void JobList::consoleDeleteJob()
+{
+   QString cmd("delete job jobid=");
+   cmd += m_currentJob;
+   consoleCommand(cmd);
+}
+void JobList::consolePurgeFiles()
+{
+   QString cmd("purge files jobid=");
+   cmd += m_currentJob;
+   consoleCommand(cmd);
+}
index c3ee1fa28f778c81758ede5e953e447afe26a44a..989f988f157b4e21ca8b6e37f1a0210dfd8c187d 100644 (file)
@@ -51,11 +51,24 @@ public:
 public slots:
    void populateTable();
    virtual void treeWidgetName(QString &);
+   void tableItemChanged(QTableWidgetItem *, QTableWidgetItem *);
+
+private slots:
+   void consoleLongListJob();
+   void consoleListJobid();
+   void consoleListFilesOnJob();
+   void consoleListJobMedia();
+   void consoleListVolumes();
+   void consoleDeleteJob();
+   void consolePurgeFiles();
 
 private:
-   QString m_medianame;
-   QString m_clientname;
+   void createConnections();
+   QString m_mediaName;
+   QString m_clientName;
+   QString m_currentJob;
    bool m_populated;
+   bool m_checkCurrentWidget;
 };
 
 #endif /* _JOBLIST_H_ */
index 872e241ad70d84987005674af20dff77e29e8f1b..b19baa9931d146a2e0478314bc5833fd575b162a 100644 (file)
     <string>Requery the director for the list of jobs.</string>
    </property>
   </action>
+  <action name="actionListJobid" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>ListJobid</string>
+   </property>
+  </action>
+  <action name="actionListFilesOnJob" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>List Files On Job</string>
+   </property>
+  </action>
+  <action name="actionListJobMedia" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>ListJobMedia</string>
+   </property>
+  </action>
+  <action name="actionListVolumes" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>ListVolumes</string>
+   </property>
+  </action>
+  <action name="actionLongListJob" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>LongListJob</string>
+   </property>
+  </action>
+  <action name="actionDeleteJob" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>DeleteJob</string>
+   </property>
+  </action>
+  <action name="actionPurgeFiles" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>PurgeFiles</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>