]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/medialist/medialist.cpp
Joblist: change page select widget name to "JobList"
[bacula/bacula] / bacula / src / qt-console / medialist / medialist.cpp
index f5585726276c9f5310b81957511787fa003efd8a..dc1e974c6f6886251c341a27606daecb2fbfadd2 100644 (file)
@@ -50,7 +50,7 @@ MediaList::MediaList()
    m_name = "Media";
    pgInitialize();
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
-   thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge.png")));
+   thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge.svg")));
 
    /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_medialist.h */
    m_populated = false;
@@ -59,6 +59,7 @@ MediaList::MediaList()
    /* add context sensitive menu items specific to this classto the page
     * selector tree. m_contextActions is QList of QActions */
    m_contextActions.append(actionRefreshMediaList);
+   dockPage();
 }
 
 MediaList::~MediaList()
@@ -77,9 +78,10 @@ void MediaList::populateTree()
        return;
 
    QStringList headerlist = (QStringList()
-      << "Volume Name" << "Id" << "Status" << "Enabled"
-      << "Bytes" << "Files" << "Jobs" << "Retention" 
-      << "Media Type" << "Slot" << "Last Written");
+      << "Volume Name" << "Id" << "Status" << "Enabled" << "Bytes" << "Files"
+      << "Jobs" << "Retention" << "Media Type" << "Slot" << "Use Duration"
+      << "Max Jobs" << "Max Files" << "Max Bytes" << "Recycle" << "Enabled"
+      << "RecyclePool" << "Last Written");
    int statusIndex = headerlist.indexOf("Status");
 
    m_checkcurwidget = false;
@@ -106,10 +108,16 @@ void MediaList::populateTree()
          " Media.Enabled AS Enabled, Media.VolBytes AS Bytes,"
          " Media.VolFiles AS FileCount, Media.VolJobs AS JobCount,"
          " Media.VolRetention AS VolumeRetention, Media.MediaType AS MediaType,"
-         " Media.Slot AS Slot, Media.LastWritten AS LastWritten"
-         " FROM Media, Pool"
-         " WHERE Media.PoolId=Pool.PoolId";
-      query += " AND Pool.Name='" + pool_listItem + "'";
+         " Media.Slot AS Slot, Media.VolUseDuration AS UseDuration,"
+         " Media.MaxVolJobs AS MaxJobs, Media.MaxVolFiles AS MaxFiles,"
+         " Media.MaxVolBytes AS MaxBytes, Media.Recycle AS Recycle,"
+         " Media.Enabled AS enabled, Pol.Name AS RecyclePool,"
+         " Media.LastWritten AS LastWritten"
+         " FROM Media"
+         " LEFT OUTER JOIN Pool ON (Media.PoolId=Pool.PoolId)"
+         " LEFT OUTER JOIN Pool AS Pol ON (Media.recyclepoolid=Pol.PoolId)"
+         " WHERE";
+      query += " Pool.Name='" + pool_listItem + "'";
       query += " ORDER BY Media";
    
       if (mainWin->m_sqlDebug) {
@@ -164,7 +172,7 @@ void MediaList::setStatusColor(QTreeWidgetItem *item, QString &field, int &index
  */
 void MediaList::editVolume()
 {
-   MediaEdit* edit = new MediaEdit(m_console, m_currentVolumeId);
+   MediaEdit* edit = new MediaEdit(mainWin->getFromHash(this), m_currentVolumeId);
    connect(edit, SIGNAL(destroyed()), this, SLOT(populateTree()));
 }
 
@@ -201,20 +209,18 @@ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetI
    if (m_checkcurwidget) {
       /* The Previous item */
       if (previouswidgetitem) { /* avoid a segfault if first time */
-         int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt();
-         if (treedepth == 2){
-            mp_treeWidget->removeAction(actionEditVolume);
-            mp_treeWidget->removeAction(actionListJobsOnVolume);
-            mp_treeWidget->removeAction(actionDeleteVolume);
-            mp_treeWidget->removeAction(actionPruneVolume);
-            mp_treeWidget->removeAction(actionPurgeVolume);
-            mp_treeWidget->removeAction(actionRelabelVolume);
-         }
+         mp_treeWidget->removeAction(actionEditVolume);
+         mp_treeWidget->removeAction(actionListJobsOnVolume);
+         mp_treeWidget->removeAction(actionDeleteVolume);
+         mp_treeWidget->removeAction(actionPruneVolume);
+         mp_treeWidget->removeAction(actionPurgeVolume);
+          mp_treeWidget->removeAction(actionRelabelVolume);
+         mp_treeWidget->removeAction(actionAllVolumesFromPool);
       }
 
       int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt();
+      m_currentVolumeName=currentwidgetitem->text(0);
       if (treedepth == 2){
-         m_currentVolumeName=currentwidgetitem->text(0);
          m_currentVolumeId=currentwidgetitem->text(1);
          mp_treeWidget->addAction(actionEditVolume);
          mp_treeWidget->addAction(actionListJobsOnVolume);
@@ -222,6 +228,12 @@ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetI
          mp_treeWidget->addAction(actionPruneVolume);
          mp_treeWidget->addAction(actionPurgeVolume);
          mp_treeWidget->addAction(actionRelabelVolume);
+      } else if (treedepth == 1) {
+/*  *******FIXME******
+ *  I can't seem to get "All volumes from pool" or "Volume from pool" to work
+ *  in one sentence command.   Works when you do it one step at a time vi console
+         mp_treeWidget->addAction(actionAllVolumesFromPool);
+*/
       }
    }
 }
@@ -247,6 +259,7 @@ void MediaList::createContextMenu()
    /* connect to the action specific to this pages class */
    connect(actionRefreshMediaList, SIGNAL(triggered()), this,
                 SLOT(populateTree()));
+   connect(actionAllVolumesFromPool, SIGNAL(triggered()), this, SLOT(allVolumesFromPool()));
 }
 
 /*
@@ -323,3 +336,14 @@ void MediaList::relabelVolume()
    setConsoleCurrent();
    new relabelDialog(m_console, m_currentVolumeName);
 }
+
+/*
+ * Called from the signal of the context sensitive menu to purge!
+ */
+void MediaList::allVolumesFromPool()
+{
+   QString cmd("update pool=");
+   cmd += m_currentVolumeName + " All Volumes From Pool";
+   consoleCommand(cmd);
+   populateTree();
+}