]> git.sur5r.net Git - bacula/bacula/commitdiff
Modifications to get human readable information into fields in the
authorDirk H Bartley <dbartley@schupan.com>
Sun, 3 Feb 2008 20:57:29 +0000 (20:57 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sun, 3 Feb 2008 20:57:29 +0000 (20:57 +0000)
medialist and joblist interfaces.

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

bacula/src/qt-console/joblist/joblist.cpp
bacula/src/qt-console/mainwin.cpp
bacula/src/qt-console/mainwin.h
bacula/src/qt-console/medialist/medialist.cpp
bacula/src/qt-console/prefs.ui

index 2157970ba685b0a899caf543eb6fc48d32c87b6c..0bb7930d7b73b4ee7b18d12e01c5a365363734f0 100644 (file)
@@ -238,6 +238,7 @@ void JobList::populateTable()
    m_startIndex = headerlist.indexOf("Job Starttime");
    m_filesIndex = headerlist.indexOf("Job Files");
    m_bytesIndex = headerlist.indexOf("Job Bytes");
+   int jobLevelIndex = headerlist.indexOf("Job Level");
 
    /* Initialize the QTableWidget */
    m_checkCurrentWidget = false;
@@ -277,6 +278,33 @@ void JobList::populateTable()
                mp_tableWidget->setItem(row, column, p_tableitem);
                if (column == m_statusIndex)
                   setStatusColor(p_tableitem, statusCode);
+               if (column == m_bytesIndex) {
+                  QString text;
+                  bool okay;
+                  qlonglong bytes = field.toULongLong(&okay);
+                  if (okay){
+                     QString test =  QString("%1").arg(bytes);
+                     mainWin->hrConvert(text, bytes);
+                     p_tableitem->setText(text);
+                  } else { Pmsg1(000, "conversion error %s\n", field.toUtf8().data()); }
+               } else if (column == m_purgedIndex) {
+                  bool okay;
+                  int isPurged = field.toInt(&okay);
+                  if (okay){
+                     if (isPurged) { p_tableitem->setText("IS");
+                     } else { p_tableitem->setText("NOT"); }
+                  }
+               } else if (column == m_typeIndex) {
+                  if (field == "B") { p_tableitem->setText("Backup"); }
+                  else if (field == "R") { p_tableitem->setText("Restore"); }
+               } else if (column == jobLevelIndex) {
+                  if (field == "F") { p_tableitem->setText("Full"); }
+                  else if (field == "D") { p_tableitem->setText("Diff"); }
+                  else if (field == "I") { p_tableitem->setText("Incr"); }
+               }   
+               if ((column == m_bytesIndex) || (column == m_filesIndex)){
+                  p_tableitem->setTextAlignment(Qt::AlignRight);
+               }
                column++;
             }
          }
index e3c43ed6623a89c8ede793e96fa7e7b222b963ac..7add181b43dce2de8752a13800993be5a7350514 100644 (file)
@@ -632,6 +632,14 @@ void MainWin::setPreferences()
    prefs.rtRestore1CheckBox->setCheckState(m_rtRestore1Debug ? Qt::Checked : Qt::Unchecked);
    prefs.rtRestore2CheckBox->setCheckState(m_rtRestore2Debug ? Qt::Checked : Qt::Unchecked);
    prefs.rtRestore3CheckBox->setCheckState(m_rtRestore3Debug ? Qt::Checked : Qt::Unchecked);
+   if (m_radioConvert == 0) {
+      prefs.radioConvertOff->setChecked(Qt::Checked);
+   } else if (m_radioConvert == 1){
+      prefs.radioConvertIEC->setChecked(Qt::Checked);
+   } else {
+      m_radioConvert = 2;
+      prefs.radioConvertStandard->setChecked(Qt::Checked);
+   }
    prefs.exec();
 }
 
@@ -669,6 +677,13 @@ void prefsDialog::accept()
    mainWin->m_rtRestore1Debug = this->rtRestore1CheckBox->checkState() == Qt::Checked;
    mainWin->m_rtRestore2Debug = this->rtRestore2CheckBox->checkState() == Qt::Checked;
    mainWin->m_rtRestore3Debug = this->rtRestore3CheckBox->checkState() == Qt::Checked;
+   if (this->radioConvertOff->isChecked()) {
+      mainWin->m_radioConvert = 0;
+   } else if (this->radioConvertIEC->isChecked()){
+      mainWin->m_radioConvert = 1;
+   } else {
+      mainWin->m_radioConvert = 2;
+   }
 
    QSettings settings("www.bacula.org", "bat");
    settings.beginGroup("Debug");
@@ -690,6 +705,7 @@ void prefsDialog::accept()
    settings.endGroup();
    settings.beginGroup("Misc");
    settings.setValue("longList", mainWin->m_longList);
+   settings.setValue("byteConvert", mainWin->m_radioConvert);
    settings.endGroup();
    settings.beginGroup("RestoreTree");
    settings.setValue("rtPopDirDebug", mainWin->m_rtPopDirDebug);
@@ -739,6 +755,7 @@ void MainWin::readPreferences()
    settings.endGroup();
    settings.beginGroup("Misc");
    m_longList = settings.value("longList", false).toBool();
+   m_radioConvert = settings.value("byteConvert", false).toInt();
    settings.endGroup();
    settings.beginGroup("RestoreTree");
    m_rtPopDirDebug = settings.value("rtPopDirDebug", false).toBool();
@@ -755,3 +772,71 @@ void MainWin::readPreferences()
    m_rtRestore3Debug = settings.value("rtRestore3Debug", false).toBool();
    settings.endGroup();
 }
+
+void MainWin::hrConvert(QString &ret, qlonglong &inval)
+{
+   double net = 0;
+   qlonglong base;
+   QStringList suflist;
+
+   if (m_radioConvert == 0) {
+      ret =  QString("%1").arg(inval);
+      return;
+   } else if (m_radioConvert == 1){
+      base = 1000;
+      suflist = (QStringList() << "B" << "KiB" << "MiB" << "GiB" << "TiB" << "PiB" << "EiB" << "ZiB");
+   } else {
+      base = 1024;
+      suflist = (QStringList() << "B" << "KB" << "MB" << "GB" << "TB" << "PB" << "EB" << "ZB");
+   }
+   qlonglong running = base;
+   bool done = false;
+   int count = 1;
+   while (done == false) {
+      QString test1 =  QString("%1").arg(inval);
+      QString test2 =  QString("%1").arg(running);
+      if (float(inval) < (float)(running)) {
+         done = true;
+         ret = suflist[count - 1];
+         net = (float)inval / (float)(running/base);
+      }
+      count += 1;
+      if (count > suflist.count()) done = true;
+      running *= base;
+   }
+   char format = 'f';
+   if (net != 0)
+      ret =  QString("%1 %2")
+                  .arg(net, 0, format, 2, QLatin1Char(' '))
+                  .arg(ret);
+   else ret = "0 B";
+}
+
+void MainWin::hrConvertSeconds(QString &ret, qlonglong &inval)
+{
+   double net = 0;
+   QList<qlonglong> durations;
+   durations.append(1);
+   durations.append(60);
+   durations.append(3600);
+   durations.append(86400);
+   durations.append(2592000);
+   durations.append(31536000);
+   QStringList abbrlist = (QStringList() << "Sec" << "Min" << "Hrs" << "Days" << "Mnth" << "Yrs");
+   bool done = false;
+   int count = 1;
+   while (done == false) {
+      QString test1 =  QString("%1").arg(inval);
+      QString test2 =  QString("%1").arg(durations[count]);
+      if ((inval < durations[count]) || (count >= abbrlist.count() - 1)) { 
+         done = true;
+         net = (float)inval / (float)(durations[count - 1]);
+         if (net != 0)
+            ret =  QString("%1 %2")
+                  .arg(net, 0, 'f', 2, QLatin1Char(' '))
+                  .arg(abbrlist[count - 1]);
+         else ret = "0 S";
+      }
+      count += 1;
+   }
+}
index 1db143c3a1c134e9117cb390842c60917d1888d2..84fc76b5f48b2bcc3fceb8461f1efbf093f73a11 100644 (file)
@@ -58,6 +58,8 @@ public:
    void hashInsert(QTreeWidgetItem *, Pages *);
    void hashRemove(Pages *);
    void hashRemove(QTreeWidgetItem *, Pages *);
+   void hrConvert(QString &, qlonglong &);
+   void hrConvertSeconds(QString &, qlonglong &);
    Console *currentConsole();
    QTreeWidgetItem *currentTopItem();
    Pages* getFromHash(QTreeWidgetItem *);
@@ -96,6 +98,7 @@ public:
    bool m_rtRestore1Debug;
    bool m_rtRestore2Debug;
    bool m_rtRestore3Debug;
+   int m_radioConvert;
 
 public slots:
    void input_line();
index a9e792460cad7cfddfb5e5b904e052c3b7f28267..8a871dcf55d69fed570517f855698ae65c008577 100644 (file)
@@ -85,6 +85,11 @@ void MediaList::populateTree()
       << "Max Jobs" << "Max Files" << "Max Bytes" << "Recycle" << "Enabled"
       << "RecyclePool" << "Last Written");
    int statusIndex = headerlist.indexOf("Status");
+   QStringList flaglist = (QStringList()
+      << "L" << "R" << "L" << "R" << "BR" << "R"
+      << "R" << "RS" << "L" << "R" << "RS"
+      << "R" << "R" << "BR" << "R" << "R"
+      << "L" << "L");
 
    m_checkcurwidget = false;
    if (m_populated)
@@ -153,7 +158,29 @@ void MediaList::populateTree()
                   mediatreeitem->setText(index, field);
                   if (index == statusIndex) {
                      setStatusColor(mediatreeitem, field, index);
+                  } 
+                  if (flaglist[index].contains("B")) {
+                     QString text;
+                     bool okay;
+                     qlonglong bytes = field.toULongLong(&okay);
+                     if (okay){
+                        QString test =  QString("%1").arg(bytes);
+                        mainWin->hrConvert(text, bytes);
+                        mediatreeitem->setText(index, text);
+                     } else { Pmsg1(000, "conversion error %s\n", field.toUtf8().data()); }
                   }
+                  if (flaglist[index].contains("S")) {
+                     QString text;
+                     bool okay;
+                     qlonglong seconds = field.toULongLong(&okay);
+                     if (okay){
+                        QString test =  QString("%1").arg(seconds);
+                        mainWin->hrConvertSeconds(text, seconds);
+                        mediatreeitem->setText(index, text);
+                     } else { Pmsg1(000, "conversion error %s\n", field.toUtf8().data()); }
+                  }
+                  if (flaglist[index].contains("R"))
+                     mediatreeitem->setTextAlignment(index, Qt::AlignRight);
                }
                index++;
             } /* foreach field */
index 9454dd7f7c41106f0b674a63f1b248fd4241fe6f..cc4d8fb3612a3c0c4330c7843946a15519225b8d 100644 (file)
@@ -33,7 +33,7 @@
    <item row="1" column="0" >
     <widget class="QTabWidget" name="tabWidget" >
      <property name="currentIndex" >
-      <number>0</number>
+      <number>2</number>
      </property>
      <widget class="QWidget" name="tab" >
       <attribute name="title" >
       <widget class="QGroupBox" name="groupBox_4" >
        <property name="geometry" >
         <rect>
-         <x>70</x>
-         <y>120</y>
+         <x>40</x>
+         <y>40</y>
          <width>190</width>
          <height>55</height>
         </rect>
         </item>
        </layout>
       </widget>
+      <widget class="QGroupBox" name="groupBox_6" >
+       <property name="geometry" >
+        <rect>
+         <x>40</x>
+         <y>160</y>
+         <width>261</width>
+         <height>131</height>
+        </rect>
+       </property>
+       <property name="title" >
+        <string>Convert</string>
+       </property>
+       <widget class="QRadioButton" name="radioConvertOff" >
+        <property name="geometry" >
+         <rect>
+          <x>20</x>
+          <y>20</y>
+          <width>231</width>
+          <height>22</height>
+         </rect>
+        </property>
+        <property name="text" >
+         <string>Convert Off</string>
+        </property>
+       </widget>
+       <widget class="QRadioButton" name="radioConvertIEC" >
+        <property name="geometry" >
+         <rect>
+          <x>20</x>
+          <y>60</y>
+          <width>231</width>
+          <height>22</height>
+         </rect>
+        </property>
+        <property name="text" >
+         <string>Convert Bytes with IEC 1000B = KB</string>
+        </property>
+       </widget>
+       <widget class="QRadioButton" name="radioConvertStandard" >
+        <property name="geometry" >
+         <rect>
+          <x>20</x>
+          <y>100</y>
+          <width>231</width>
+          <height>22</height>
+         </rect>
+        </property>
+        <property name="text" >
+         <string>Convert Bytes with 1024B = KB</string>
+        </property>
+       </widget>
+      </widget>
      </widget>
      <widget class="QWidget" name="tab_3" >
       <attribute name="title" >