From: Eric Bollengier Date: Sun, 3 Oct 2010 20:51:29 +0000 (+0200) Subject: bat: more work on brestore panel X-Git-Tag: Release-5.2.1~1053 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2c77e588c4b4939cef0984414743e3670447e24a;p=bacula%2Fbacula bat: more work on brestore panel --- diff --git a/bacula/src/qt-console/images/page-next.gif b/bacula/src/qt-console/images/page-next.gif new file mode 100644 index 0000000000..9601635301 Binary files /dev/null and b/bacula/src/qt-console/images/page-next.gif differ diff --git a/bacula/src/qt-console/images/page-prev.gif b/bacula/src/qt-console/images/page-prev.gif new file mode 100644 index 0000000000..eb70cf8f6a Binary files /dev/null and b/bacula/src/qt-console/images/page-prev.gif differ diff --git a/bacula/src/qt-console/main.qrc b/bacula/src/qt-console/main.qrc index 224154e91d..f8fb90fba9 100644 --- a/bacula/src/qt-console/main.qrc +++ b/bacula/src/qt-console/main.qrc @@ -1,73 +1,75 @@ - - images/0p.png - images/16p.png - images/32p.png - images/48p.png - images/64p.png - images/80p.png - images/96p.png - images/A.png - images/R.png - images/T.png - images/W.png - images/applications-graphics.png - images/bat.png - images/bat_icon.png - images/browse.png - images/cartridge-edit.png - images/cartridge.png - images/check.png - images/connected.png - images/copy.png - images/cut.png - images/disconnected.png - images/edit-cut.png - images/edit-delete.png - images/edit.png - images/emblem-system.png - images/estimate-job.png - images/extern.png - images/f.png - images/folder.png - images/folderbothchecked.png - images/folderchecked.png - images/folderunchecked.png - images/go-down.png - images/go-jump.png - images/go-up.png - images/graph1.png - images/help-browser.png - images/inflag0.png - images/inflag1.png - images/inflag2.png - images/intern.png - images/joblog.png - images/label.png - images/mail-message-new.png - images/mail-message-pending.png - images/mark.png - images/network-server.png - images/new.png - images/open.png - images/package-x-generic.png - images/paste.png - images/print.png - images/purge.png - images/restore.png - images/run.png - images/runit.png - images/save.png - images/status-console.png - images/status.png - images/system-file-manager.png - images/unchecked.png - images/undo.png - images/unmark.png - images/up.png - images/utilities-terminal.png - images/view-refresh.png - images/weather-severe-alert.png - images/zoom.png - + + images/page-prev.gif + images/page-next.gif + images/0p.png + images/16p.png + images/32p.png + images/48p.png + images/64p.png + images/80p.png + images/96p.png + images/A.png + images/R.png + images/T.png + images/W.png + images/applications-graphics.png + images/bat.png + images/bat_icon.png + images/browse.png + images/cartridge-edit.png + images/cartridge.png + images/check.png + images/connected.png + images/copy.png + images/cut.png + images/disconnected.png + images/edit-cut.png + images/edit-delete.png + images/edit.png + images/emblem-system.png + images/estimate-job.png + images/extern.png + images/f.png + images/folder.png + images/folderbothchecked.png + images/folderchecked.png + images/folderunchecked.png + images/go-down.png + images/go-jump.png + images/go-up.png + images/graph1.png + images/help-browser.png + images/inflag0.png + images/inflag1.png + images/inflag2.png + images/intern.png + images/joblog.png + images/label.png + images/mail-message-new.png + images/mail-message-pending.png + images/mark.png + images/network-server.png + images/new.png + images/open.png + images/package-x-generic.png + images/paste.png + images/print.png + images/purge.png + images/restore.png + images/run.png + images/runit.png + images/save.png + images/status-console.png + images/status.png + images/system-file-manager.png + images/unchecked.png + images/undo.png + images/unmark.png + images/up.png + images/utilities-terminal.png + images/view-refresh.png + images/weather-severe-alert.png + images/zoom.png + diff --git a/bacula/src/qt-console/restore/brestore.cpp b/bacula/src/qt-console/restore/brestore.cpp index 65908b990a..9e592a9f26 100644 --- a/bacula/src/qt-console/restore/brestore.cpp +++ b/bacula/src/qt-console/restore/brestore.cpp @@ -174,8 +174,10 @@ void bRestore::displayFiles(int64_t pathid, QString path) arg = " path=\"" + m_path + "\""; } LocationEntry->setText(m_path); - - QString q = ".bvfs_lsdir jobid=" + m_jobids + arg; + QString offset = QString().setNum(Offset1Spin->value()); + QString limit=QString().setNum(Offset2Spin->value() - Offset1Spin->value()); + QString q = ".bvfs_lsdir jobid=" + m_jobids + arg + + " limit=" + limit + " offset=" + offset ; if (m_console->dir_cmd(q, results)) { nb = results.size(); FileList->setRowCount(nb); @@ -188,6 +190,7 @@ void bRestore::displayFiles(int64_t pathid, QString path) item.setTextFld(col++, fieldlist.at(5)); // path decode_stat(fieldlist.at(4).toLocal8Bit().data(), &statp, &LinkFI); + item.setBytesFld(col++, QString().setNum(statp.st_size)); item.setDateFld(col++, statp.st_mtime); // date fieldlist.replace(3, m_jobids); // use current jobids selection item.widget(1)->setData(Qt::UserRole, fieldlist.join("\t")); // keep info @@ -195,7 +198,8 @@ void bRestore::displayFiles(int64_t pathid, QString path) } results.clear(); - q = ".bvfs_lsfiles jobid=" + m_jobids + arg; + q = ".bvfs_lsfiles jobid=" + m_jobids + arg + + " limit=" + limit + " offset=" + offset ; if (m_console->dir_cmd(q, results)) { FileList->setRowCount(results.size() + nb); foreach (QString resultline, results) { @@ -483,6 +487,7 @@ void bRunRestore::useRegexp() bRunRestore::bRunRestore(bRestore *parent) { + brestore = parent; setupUi(this); ClientCb->addItems(parent->console()->client_list); int i = ClientCb->findText(parent->m_client); @@ -495,8 +500,108 @@ bRunRestore::bRunRestore(bRestore *parent) StorageCb->addItems(parent->console()->storage_list); connect(UseFileRelocationChk, SIGNAL(clicked()), this, SLOT(UFRcb())); connect(UseRegexpChk, SIGNAL(clicked()), this, SLOT(useRegexp())); + connect(ActionBp, SIGNAL(accepted()), this, SLOT(computeRestore())); struct job_defaults jd; jd.job_name = parent->console()->restore_list[0]; - parent->console()->get_job_defaults(jd); + brestore->console()->get_job_defaults(jd); WhereEntry->setText(jd.where); + computeVolumeList(); +} + +void bRestore::get_info_from_selection(QStringList &fileids, + QStringList &jobids, + QStringList &dirids, + QStringList &findexes) +{ + struct stat statp; + int32_t LinkFI; + for (int i=0; i < RestoreList->rowCount(); i++) { + QTableWidgetItem *item = RestoreList->item(i, 1); + QString data = item->data(Qt::UserRole).toString(); + QStringList lst = data.split("\t"); + if (lst.at(1) != "0") { // skip path + fileids << lst.at(2); + jobids << lst.at(3); + decode_stat(lst.at(4).toLocal8Bit().data(), + &statp, &LinkFI); + if (LinkFI) { + findexes << lst.at(3) + "," + QString().setNum(LinkFI); + } + } else { + dirids << lst.at(0); + jobids << lst.at(3).split(","); // Can have multiple jobids + } + } + fileids.removeDuplicates(); + jobids.removeDuplicates(); + dirids.removeDuplicates(); + findexes.removeDuplicates(); + qDebug() << fileids << jobids << dirids << findexes; +} + +void bRunRestore::computeVolumeList() +{ + brestore->get_info_from_selection(m_fileids, m_jobids, m_dirids, m_findexes); + if (m_fileids.size() == 0) { + return; + } + + Freeze frz_lst(*TableMedia); /* disable updating*/ + QString q = +" SELECT DISTINCT VolumeName, Enabled, InChanger " + " FROM File, " + " ( " // -- Get all media from this job + " SELECT MIN(FirstIndex) AS FirstIndex, MAX(LastIndex) AS LastIndex, " + " VolumeName, Enabled, Inchanger " + " FROM JobMedia JOIN Media USING (MediaId) " + " WHERE JobId IN (" + m_jobids.join(",") + ") " + " GROUP BY VolumeName,Enabled,InChanger " + " ) AS allmedia " + " WHERE File.FileId IN (" + m_fileids.join(",") + ") " + " AND File.FileIndex >= allmedia.FirstIndex " + " AND File.FileIndex <= allmedia.LastIndex "; + int row=0; + QStringList results; + if (brestore->console()->sql_cmd(q, results)) { + QStringList fieldlist; + TableMedia->setRowCount(results.size()); + /* Iterate through the record returned from the query */ + foreach (QString resultline, results) { + // 0 1 2 + //volname, enabled, inchanger + fieldlist = resultline.split("\t"); + int col=0; + TableItemFormatter item(*TableMedia, row++); + item.setInChanger(col++, fieldlist.at(2)); // inchanger + item.setTextFld(col++, fieldlist.at(0)); // Volume + } + } + TableMedia->verticalHeader()->hide(); + TableMedia->resizeColumnsToContents(); + TableMedia->resizeRowsToContents(); + TableMedia->setEditTriggers(QAbstractItemView::NoEditTriggers); +} + +void bRunRestore::computeRestore() +{ + QString q = ".bvfs_restore path=b2123 jobid=" + m_jobids.join(","); + if (m_fileids.size() > 0) { + q += " fileid=" + m_fileids.join(","); + } + if (m_dirids.size() > 0) { + q += " dirid=" + m_dirids.join(","); + } + if (m_findexes.size() > 0) { + q += " hardlink=" + m_findexes.join(","); + } + qDebug() << q; + + QStringList results; + if (brestore->console()->dir_cmd(q, results)) { + if (results.size() == 1 && results[0] == "OK") { + qDebug() << "Run restore!"; + q = ".bvfs_cleanup path=b2123"; + brestore->console()->dir_cmd(q, results); + } + } } diff --git a/bacula/src/qt-console/restore/brestore.ui b/bacula/src/qt-console/restore/brestore.ui index 5023098ad0..7750264f5a 100644 --- a/bacula/src/qt-console/restore/brestore.ui +++ b/bacula/src/qt-console/restore/brestore.ui @@ -20,6 +20,88 @@ 6 + + + + 6 + + + 0 + + + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + + + + + false + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + Merge Jobs + + + true + + + + + + + View all Versions + + + + + + + Location + + + + + + + + @@ -39,13 +121,7 @@ File list - - - 6 - - - 9 - + @@ -97,6 +173,159 @@ + + + + QLayout::SetMinimumSize + + + + + + 0 + 0 + + + + + 25 + 25 + + + + + + + + :/images/page-prev.gif:/images/page-prev.gif + + + + + + + QAbstractSpinBox::NoButtons + + + 9000000 + + + 500 + + + + + + + + 0 + 0 + + + + + 16 + 16 + + + + - + + + + + + + QAbstractSpinBox::NoButtons + + + false + + + 0 + + + 9999999 + + + 500 + + + 500 + + + + + + + + 0 + 0 + + + + + 25 + 25 + + + + + + + + :/images/page-next.gif:/images/page-next.gif + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 111 + 23 + + + + + + + + + 25 + 25 + + + + + + + + :/images/view-refresh.png:/images/view-refresh.png + + + + + @@ -303,88 +532,6 @@ p, li { white-space: pre-wrap; } - - - - 6 - - - 0 - - - - - - 0 - 0 - - - - QComboBox::AdjustToContents - - - - - - - false - - - - 0 - 0 - - - - QComboBox::AdjustToContents - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 40 - 20 - - - - - - - - Merge Jobs - - - true - - - - - - - View all Versions - - - - - - - Location - - - - - - - - @@ -394,6 +541,73 @@ p, li { white-space: pre-wrap; }
restore.h
- - + + + + + + OffsetNextBp + clicked() + Offset2Spin + stepUp() + + + 275 + 279 + + + 232 + 279 + + + + + OffsetNextBp + clicked() + Offset1Spin + stepUp() + + + 272 + 281 + + + 92 + 279 + + + + + OffsetPrevBp + clicked() + Offset1Spin + stepDown() + + + 44 + 287 + + + 123 + 282 + + + + + OffsetPrevBp + clicked() + Offset2Spin + stepDown() + + + 50 + 284 + + + 221 + 282 + + + + diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index 8280a5d6c6..e7e3705cec 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -143,6 +143,8 @@ public: void PgSeltreeWidgetClicked(); QString m_client; QString m_jobids; + void get_info_from_selection(QStringList &fileids, QStringList &jobids, + QStringList &dirids, QStringList &fileindexes); public slots: void setClient(); @@ -166,13 +168,19 @@ private: class bRunRestore : public QDialog, public Ui::bRunRestoreForm { Q_OBJECT +private: + bRestore *brestore; + QStringList m_fileids, m_jobids, m_dirids, m_findexes; public: bRunRestore(bRestore *parent); ~bRunRestore() {} + void computeVolumeList(); + public slots: void useRegexp(); void UFRcb(); + void computeRestore(); }; #endif /* _RESTORE_H_ */ diff --git a/bacula/src/qt-console/restore/runrestore.ui b/bacula/src/qt-console/restore/runrestore.ui index 558febdffe..20ff1609de 100644 --- a/bacula/src/qt-console/restore/runrestore.ui +++ b/bacula/src/qt-console/restore/runrestore.ui @@ -95,7 +95,24 @@ - + + + false + + + Qt::NoPen + + + + InChanger + + + + + Volume + + + @@ -284,7 +301,7 @@ regexp: - + Qt::Horizontal @@ -298,7 +315,7 @@ regexp: - buttonBox + ActionBp accepted() bRunRestoreForm accept() @@ -314,7 +331,7 @@ regexp: - buttonBox + ActionBp rejected() bRunRestoreForm reject()