From: Eric Bollengier Date: Thu, 30 Sep 2010 21:49:17 +0000 (+0200) Subject: bat: Use BVFS on bRestore view X-Git-Tag: Release-5.2.1~1070 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=58ad8245d0f61a4da1d13e10f674f3c9d81c493f;p=bacula%2Fbacula bat: Use BVFS on bRestore view --- diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index c3d803c046..8b74f6e07f 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -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(); diff --git a/bacula/src/qt-console/restore/brestore.cpp b/bacula/src/qt-console/restore/brestore.cpp index 2a2b18c556..240dc90344 100644 --- a/bacula/src/qt-console/restore/brestore.cpp +++ b/bacula/src/qt-console/restore/brestore.cpp @@ -40,10 +40,112 @@ 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() diff --git a/bacula/src/qt-console/restore/brestore.ui b/bacula/src/qt-console/restore/brestore.ui index c61d75b97f..c67b0202ab 100644 --- a/bacula/src/qt-console/restore/brestore.ui +++ b/bacula/src/qt-console/restore/brestore.ui @@ -1,7 +1,8 @@ - + + bRestoreForm - - + + 0 0 @@ -9,71 +10,67 @@ 555 - + brestore - - + + 9 - + 6 - - - + + + Qt::Vertical - - + + Qt::Horizontal - - - - 7 - 7 + + + 0 0 - + File list - - - 9 - - + + 6 + + 9 + - - - - 7 - 7 + + + 5 5 - + Type - + File Name - + Size - + Date @@ -81,62 +78,58 @@ - - - - 7 - 7 + + + 0 0 - + File revisions - - - 9 - - + + 6 + + 9 + - - - - 7 - 7 + + + 0 0 - + InChanger - + Volume - + JobId - + Size - + Date - + Chksum @@ -145,38 +138,38 @@ - - - - 0 - - + + + 6 + + 0 + - - - 0 - - + + 6 + + 0 + - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Restore items list</span></p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Restore items list</span></p></body></html> - + Qt::Horizontal - + 40 20 @@ -185,22 +178,22 @@ p, li { white-space: pre-wrap; } - - + + Clear - - + + Estimate - - + + Restore @@ -208,37 +201,37 @@ p, li { white-space: pre-wrap; } - - + + true - + Type - + FileName - + JobId - + FileIndex - + Nb Files - + Size @@ -248,33 +241,52 @@ p, li { white-space: pre-wrap; } - - - - 0 - - + + + 6 + + 0 + - + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + - - + + false + + + 0 + 0 + + + + QComboBox::AdjustToContents + - + Qt::Horizontal - + QSizePolicy::Expanding - + 40 20 @@ -283,14 +295,14 @@ p, li { white-space: pre-wrap; } - - + + Location - + diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index 279ee5ba36..2a8fa5b49f 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -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_ */