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;
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++;
}
}
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();
}
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");
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);
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();
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;
+ }
+}
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 *);
bool m_rtRestore1Debug;
bool m_rtRestore2Debug;
bool m_rtRestore3Debug;
+ int m_radioConvert;
public slots:
void input_line();
<< "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)
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 */
<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" >