]> git.sur5r.net Git - bacula/bacula/commitdiff
bat: Use BVFS on bRestore view
authorEric Bollengier <eric@eb.homelinux.org>
Thu, 30 Sep 2010 21:49:17 +0000 (23:49 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Wed, 6 Oct 2010 09:10:47 +0000 (11:10 +0200)
bacula/src/qt-console/mainwin.cpp
bacula/src/qt-console/restore/brestore.cpp
bacula/src/qt-console/restore/brestore.ui
bacula/src/qt-console/restore/restore.h

index c3d803c046ef8d36463f93664660dc41921da463..8b74f6e07f2d5564af40e1a4e4e459109379701e 100644 (file)
@@ -172,7 +172,7 @@ void MainWin::createPages()
        * Create instances in alphabetic order of the rest 
        *  of the classes that will by default exist under each Director.  
        */
-//      new bRestore();
+      new bRestore();
       new Clients();
       new FileSet();
       new Jobs();
index 2a2b18c55697c4dc4d8a2f7d95fcc61e181389a0..240dc90344657371488519f3a95cb41a10f4077a 100644 (file)
 
 bRestore::bRestore()
 {
-   m_name = "bRestore";
+   m_name = tr("bRestore");
+   m_client = "";
    setupUi(this);
    pgInitialize();
+   QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
+   thisitem->setIcon(0, QIcon(QString::fromUtf8(":images/browse.png")));
    dockPage();
+   m_populated = false;
+}
+
+void bRestore::setClient()
+{
+   Pmsg0(000, "Repopulating client table\n");
+   // Select the same client, don't touch
+   if (m_client == ClientList->currentText()) {
+      return;
+   }
+   m_client = ClientList->currentText();
+   FileList->clearContents();
+   FileRevisions->clearContents();
+   JobList->clear();
+   JobList->setEnabled(true);
+   LocationEntry->clear();
+
+   if (ClientList->currentIndex() < 1) {
+      return;
+   }
+
+   JobList->addItem("Job list for " + m_client);
+
+   QString jobQuery =
+      "SELECT Job.Jobid AS JobId, Job.StartTime AS StartTime,"
+      " Job.Level AS Level,"
+      " Job.Name AS Name"
+      " FROM Job JOIN Client USING (ClientId)"
+      " WHERE"
+      " Job.JobStatus IN ('T','W') AND Job.Type='B' AND"
+      " Client.Name='" + m_client + "' ORDER BY StartTime DESC" ;
+
+   QString job;
+   QStringList results;
+   if (m_console->sql_cmd(jobQuery, results)) {
+      QString field;
+      QStringList fieldlist;
+
+      /* Iterate through the record returned from the query */
+      foreach (QString resultline, results) {
+         fieldlist = resultline.split("\t");
+         job = fieldlist[1] + " " + fieldlist[3] + "(" + fieldlist[2] + ")";
+         JobList->addItem(job, QVariant(fieldlist[0]));
+      }
+   }
+}
+
+
+void bRestore::setJob()
+{
+   if (JobList->currentIndex() < 1) {
+      return ;
+   }
+   QStringList results;
+   QVariant tmp = JobList->itemData(JobList->currentIndex(), Qt::UserRole);
+   m_jobids = tmp.toString(); 
+   QString cmd = ".bvfs_update jobid=" + m_jobids;
+   m_console->dir_cmd(cmd, results);
+   displayFiles("/");
+   Pmsg0(000, "update done\n");
+}
+
+void bRestore::displayFiles(uint64_t pathid)
+{
+
+}
+
+void bRestore::displayFiles(QString path)
+{
+   QString q = ".bvfs_lsdir jobid=" + m_jobids + " path=" + path;
+   QStringList results;
+   if (m_console->dir_cmd(q, results)) {
+      QString field;
+      QStringList fieldlist;
+
+      foreach (QString resultline, results) {
+         fieldlist = resultline.split("\t");
+      }
+   }
+}
+
+void bRestore::PgSeltreeWidgetClicked()
+{
+   if(!m_populated) {
+      setupPage();
+   }
+   if (!isOnceDocked()) {
+      dockPage();
+   }
+}
+
+void bRestore::setupPage()
+{
+   Pmsg0(000, "Setup page\n");
+   ClientList->addItem("Client list");
+   ClientList->addItems(m_console->client_list);
+   connect(ClientList, SIGNAL(currentIndexChanged(int)), this, SLOT(setClient()));
+   connect(JobList, SIGNAL(currentIndexChanged(int)), this, SLOT(setJob()));
+   m_populated = true;
 }
 
 bRestore::~bRestore()
index c61d75b97f04b4999bf0519900cda0b05235e986..c67b0202ab6463833dafd5d576134676847eff59 100644 (file)
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>bRestoreForm</class>
- <widget class="QWidget" name="bRestoreForm" >
-  <property name="geometry" >
+ <widget class="QWidget" name="bRestoreForm">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <height>555</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>brestore</string>
   </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
+  <layout class="QGridLayout">
+   <property name="margin">
     <number>9</number>
    </property>
-   <property name="spacing" >
+   <property name="spacing">
     <number>6</number>
    </property>
-   <item row="1" column="0" >
-    <widget class="QSplitter" name="splitter_2" >
-     <property name="orientation" >
+   <item row="1" column="0">
+    <widget class="QSplitter" name="splitter_2">
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <widget class="QSplitter" name="splitter" >
-      <property name="orientation" >
+     <widget class="QSplitter" name="splitter">
+      <property name="orientation">
        <enum>Qt::Horizontal</enum>
       </property>
-      <widget class="QGroupBox" name="groupBox" >
-       <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>7</hsizetype>
-         <vsizetype>7</vsizetype>
+      <widget class="QGroupBox" name="groupBox">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="title" >
+       <property name="title">
         <string>File list</string>
        </property>
-       <layout class="QVBoxLayout" >
-        <property name="margin" >
-         <number>9</number>
-        </property>
-        <property name="spacing" >
+       <layout class="QVBoxLayout">
+        <property name="spacing">
          <number>6</number>
         </property>
+        <property name="margin">
+         <number>9</number>
+        </property>
         <item>
-         <widget class="QTableWidget" name="FileList" >
-          <property name="sizePolicy" >
-           <sizepolicy>
-            <hsizetype>7</hsizetype>
-            <vsizetype>7</vsizetype>
+         <widget class="QTableWidget" name="FileList">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
             <horstretch>5</horstretch>
             <verstretch>5</verstretch>
            </sizepolicy>
           </property>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>Type</string>
            </property>
           </column>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>File Name</string>
            </property>
           </column>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>Size</string>
            </property>
           </column>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>Date</string>
            </property>
           </column>
         </item>
        </layout>
       </widget>
-      <widget class="QGroupBox" name="groupBox_2" >
-       <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>7</hsizetype>
-         <vsizetype>7</vsizetype>
+      <widget class="QGroupBox" name="groupBox_2">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="title" >
+       <property name="title">
         <string>File revisions</string>
        </property>
-       <layout class="QVBoxLayout" >
-        <property name="margin" >
-         <number>9</number>
-        </property>
-        <property name="spacing" >
+       <layout class="QVBoxLayout">
+        <property name="spacing">
          <number>6</number>
         </property>
+        <property name="margin">
+         <number>9</number>
+        </property>
         <item>
-         <widget class="QTableWidget" name="FileRevisions" >
-          <property name="sizePolicy" >
-           <sizepolicy>
-            <hsizetype>7</hsizetype>
-            <vsizetype>7</vsizetype>
+         <widget class="QTableWidget" name="FileRevisions">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
             <horstretch>0</horstretch>
             <verstretch>0</verstretch>
            </sizepolicy>
           </property>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>InChanger</string>
            </property>
           </column>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>Volume</string>
            </property>
           </column>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>JobId</string>
            </property>
           </column>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>Size</string>
            </property>
           </column>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>Date</string>
            </property>
           </column>
           <column>
-           <property name="text" >
+           <property name="text">
             <string>Chksum</string>
            </property>
           </column>
        </layout>
       </widget>
      </widget>
-     <widget class="QWidget" name="layoutWidget_2" >
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
-        <number>0</number>
-       </property>
-       <property name="spacing" >
+     <widget class="QWidget" name="layoutWidget_2">
+      <layout class="QVBoxLayout">
+       <property name="spacing">
         <number>6</number>
        </property>
+       <property name="margin">
+        <number>0</number>
+       </property>
        <item>
-        <layout class="QHBoxLayout" >
-         <property name="margin" >
-          <number>0</number>
-         </property>
-         <property name="spacing" >
+        <layout class="QHBoxLayout">
+         <property name="spacing">
           <number>6</number>
          </property>
+         <property name="margin">
+          <number>0</number>
+         </property>
          <item>
-          <widget class="QLabel" name="label" >
-           <property name="text" >
-            <string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+          <widget class="QLabel" name="label">
+           <property name="text">
+            <string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
 p, li { white-space: pre-wrap; }
-&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Restore items list&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Restore items list&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
            </property>
           </widget>
          </item>
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
@@ -185,22 +178,22 @@ p, li { white-space: pre-wrap; }
           </spacer>
          </item>
          <item>
-          <widget class="QPushButton" name="pushButton" >
-           <property name="text" >
+          <widget class="QPushButton" name="pushButton">
+           <property name="text">
             <string>Clear</string>
            </property>
           </widget>
          </item>
          <item>
-          <widget class="QPushButton" name="pushButton_2" >
-           <property name="text" >
+          <widget class="QPushButton" name="pushButton_2">
+           <property name="text">
             <string>Estimate</string>
            </property>
           </widget>
          </item>
          <item>
-          <widget class="QPushButton" name="pushButton_3" >
-           <property name="text" >
+          <widget class="QPushButton" name="pushButton_3">
+           <property name="text">
             <string>Restore</string>
            </property>
           </widget>
@@ -208,37 +201,37 @@ p, li { white-space: pre-wrap; }
         </layout>
        </item>
        <item>
-        <widget class="QTableWidget" name="RestoreList" >
-         <property name="acceptDrops" >
+        <widget class="QTableWidget" name="RestoreList">
+         <property name="acceptDrops">
           <bool>true</bool>
          </property>
          <column>
-          <property name="text" >
+          <property name="text">
            <string>Type</string>
           </property>
          </column>
          <column>
-          <property name="text" >
+          <property name="text">
            <string>FileName</string>
           </property>
          </column>
          <column>
-          <property name="text" >
+          <property name="text">
            <string>JobId</string>
           </property>
          </column>
          <column>
-          <property name="text" >
+          <property name="text">
            <string>FileIndex</string>
           </property>
          </column>
          <column>
-          <property name="text" >
+          <property name="text">
            <string>Nb Files</string>
           </property>
          </column>
          <column>
-          <property name="text" >
+          <property name="text">
            <string>Size</string>
           </property>
          </column>
@@ -248,33 +241,52 @@ p, li { white-space: pre-wrap; }
      </widget>
     </widget>
    </item>
-   <item row="0" column="0" >
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
-     </property>
-     <property name="spacing" >
+   <item row="0" column="0">
+    <layout class="QHBoxLayout">
+     <property name="spacing">
       <number>6</number>
      </property>
+     <property name="margin">
+      <number>0</number>
+     </property>
      <item>
-      <widget class="QComboBox" name="ClientList" />
+      <widget class="QComboBox" name="ClientList">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="sizeAdjustPolicy">
+        <enum>QComboBox::AdjustToContents</enum>
+       </property>
+      </widget>
      </item>
      <item>
-      <widget class="QComboBox" name="JobList" >
-       <property name="enabled" >
+      <widget class="QComboBox" name="JobList">
+       <property name="enabled">
         <bool>false</bool>
        </property>
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="sizeAdjustPolicy">
+        <enum>QComboBox::AdjustToContents</enum>
+       </property>
       </widget>
      </item>
      <item>
       <spacer>
-       <property name="orientation" >
+       <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeType" >
+       <property name="sizeType">
         <enum>QSizePolicy::Expanding</enum>
        </property>
-       <property name="sizeHint" >
+       <property name="sizeHint" stdset="0">
         <size>
          <width>40</width>
          <height>20</height>
@@ -283,14 +295,14 @@ p, li { white-space: pre-wrap; }
       </spacer>
      </item>
      <item>
-      <widget class="QPushButton" name="pushButton_4" >
-       <property name="text" >
+      <widget class="QPushButton" name="LocationBp">
+       <property name="text">
         <string>Location</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QLineEdit" name="lineEdit" />
+      <widget class="QLineEdit" name="LocationEntry"/>
      </item>
     </layout>
    </item>
index 279ee5ba365cee465de081ff4a07a75bd9bdf6fc..2a8fa5b49ffbe52a623bee9c10d81e5a2adc32e0 100644 (file)
@@ -121,11 +121,19 @@ class bRestore : public Pages, public Ui::bRestoreForm
 public:
    bRestore();
    ~bRestore();
+   void PgSeltreeWidgetClicked();
 
 public slots:
+   void setClient();
+   void setJob();
 
-private:
 
+private:
+   QString m_client;
+   void setupPage();
+   bool m_populated;
+   void displayFiles(QString path);
+   void displayFiles(uint64_t pathid);
 };
 
 #endif /* _RESTORE_H_ */