]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/medialist/medialist.cpp
bat: cleanup MediaView
[bacula/bacula] / bacula / src / qt-console / medialist / medialist.cpp
index 96d3bc2cd27e43e63efca346e66fb63006bd92e2..96b9f1ee4b0ee6bd483c0ee911e72f5e419e4294 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2007-2009 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.
@@ -41,6 +41,7 @@
 #include <math.h>
 #include "medialist.h"
 #include "mediaedit/mediaedit.h"
+#include "mediainfo/mediainfo.h"
 #include "joblist/joblist.h"
 #include "relabel/relabel.h"
 #include "run/run.h"
@@ -49,7 +50,7 @@
 MediaList::MediaList()
 {
    setupUi(this);
-   m_name = tr("Media");
+   m_name = tr("Pools");
    pgInitialize();
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge.png")));
@@ -61,7 +62,6 @@ 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()
@@ -86,7 +86,8 @@ void MediaList::populateTree()
       << tr("Volume Name") << tr("Id") << tr("Status") << tr("Enabled") << tr("Bytes") << tr("Files")
       << tr("Jobs") << tr("Retention") << tr("Media Type") << tr("Slot") << tr("Use Duration")
       << tr("Max Jobs") << tr("Max Files") << tr("Max Bytes") << tr("Recycle")
-      << tr("RecyclePool") << tr("Last Written"));
+      << tr("Last Written") << tr("First Written") << tr("Read Time")
+      << tr("Write Time") << tr("Recycle Count") << tr("Recycle Pool"));
 
    m_checkcurwidget = false;
    mp_treeWidget->clear();
@@ -128,10 +129,14 @@ void MediaList::populateTree()
          " Media.VolUseDuration AS UseDuration,"
          " Media.MaxVolJobs AS MaxJobs, Media.MaxVolFiles AS MaxFiles,"
          " Media.MaxVolBytes AS MaxBytes, Media.Recycle AS Recycle,"
-         " Pol.Name AS RecyclePool, Media.LastWritten AS LastWritten"
+         " Media.LastWritten AS LastWritten,"
+         " Media.FirstWritten AS FirstWritten,"
+         " (VolReadTime/1000000) AS ReadTime, (VolWriteTime/1000000) AS WriteTime,"
+         " RecycleCount AS ReCyCount,"
+         " RecPool.Name AS RecyclePool"
          " FROM Media"
          " JOIN Pool ON (Media.PoolId=Pool.PoolId)"
-         " LEFT OUTER JOIN Pool AS Pol ON (Media.RecyclePoolId=Pol.PoolId)"
+         " LEFT OUTER JOIN Pool AS RecPool ON (Media.RecyclePoolId=RecPool.PoolId)"
          " WHERE ";
       query += " Pool.Name IN (" + pool_comsep + ")";
       query += " ORDER BY Pool.Name, Media";
@@ -224,10 +229,22 @@ void MediaList::populateTree()
             /* recycle */
             mediaitem.setBoolFld(index++, fld.next());
 
-            /* recycle pool */
+            /* last written */
             mediaitem.setTextFld(index++, fld.next()); 
 
-            /* last written */
+            /* first written */
+            mediaitem.setTextFld(index++, fld.next()); 
+
+            /* read time */
+            mediaitem.setDurationFld(index++, fld.next());
+
+            /* write time */
+            mediaitem.setDurationFld(index++, fld.next());
+
+            /* Recycle Count */
+            mediaitem.setNumericFld(index++, fld.next()); 
+
+            /* recycle pool */
             mediaitem.setTextFld(index++, fld.next()); 
 
          } /* foreach resultline */
@@ -259,6 +276,17 @@ void MediaList::showJobs()
    mainWin->createPageJobList(m_currentVolumeName, "", "", "", parentItem);
 }
 
+/*
+ * Called from the signal of the context sensitive menu!
+ */
+void MediaList::viewVolume()
+{
+   QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
+   MediaInfo* view = new MediaInfo(parentItem, m_currentVolumeName);
+   connect(view, SIGNAL(destroyed()), this, SLOT(populateTree()));
+
+}
+
 /*
  * When the treeWidgetItem in the page selector tree is singleclicked, Make sure
  * The tree has been populated.
@@ -269,6 +297,7 @@ void MediaList::PgSeltreeWidgetClicked()
       populateTree();
       createContextMenu();
    }
+   dockPage();
 }
 
 /*
@@ -312,6 +341,7 @@ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetI
 void MediaList::createContextMenu()
 {
    mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
+   connect(mp_treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(viewVolume()));
    connect(actionEditVolume, SIGNAL(triggered()), this, SLOT(editVolume()));
    connect(actionListJobsOnVolume, SIGNAL(triggered()), this, SLOT(showJobs()));
    connect(actionDeleteVolume, SIGNAL(triggered()), this, SLOT(deleteVolume()));