From: Dirk H Bartley Date: Thu, 7 Jun 2007 20:40:27 +0000 (+0000) Subject: Clear list before populating lists in console. X-Git-Tag: Release-7.0.0~6150 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b360620999bfe9c46e30efaf928634f969988cbf;p=bacula%2Fbacula Clear list before populating lists in console. Add a table in restore tree to show what jobs were selected. Use IN keyword in sql statements to represent better what the selections really are. They are show me stuff for this condition preselecting a list of jobs. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4996 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 90ca1100f4..269c423066 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -230,6 +230,15 @@ void Console::connect_dir() displayToPrompt(); beginNewCommand(); + job_list.clear(); + client_list.clear(); + fileset_list.clear(); + fileset_list.clear(); + messages_list.clear(); + pool_list.clear(); + storage_list.clear(); + type_list.clear(); + level_list.clear(); dir_cmd(".jobs", job_list); dir_cmd(".clients", client_list); dir_cmd(".filesets", fileset_list); diff --git a/bacula/src/qt-console/restore/restoretree.cpp b/bacula/src/qt-console/restore/restoretree.cpp index 14b815202c..0b8573960f 100644 --- a/bacula/src/qt-console/restore/restoretree.cpp +++ b/bacula/src/qt-console/restore/restoretree.cpp @@ -97,13 +97,15 @@ void restoreTree::populateDirectoryTree() m_dirPaths.clear(); directoryTree->clear(); fileTable->clear(); + fileTable->setRowCount(0); + fileTable->setColumnCount(0); versionTable->clear(); - QString cmd = - "SELECT DISTINCT Path.Path FROM Path" - " LEFT OUTER JOIN File ON (File.PathId=Path.PathId)" - " LEFT OUTER JOIN Job ON (File.JobId=Job.JobId)" - " LEFT OUTER JOIN Client ON (Job.ClientId=Client.ClientId)" - " LEFT OUTER JOIN FileSet ON (Job.FileSetId=FileSet.FileSetId) WHERE"; + versionTable->setRowCount(0); + versionTable->setColumnCount(0); + jobTable->clear(); + jobTable->setRowCount(0); + jobTable->setColumnCount(0); + m_condition = " Job.name = '" + jobCombo->itemText(jobCombo->currentIndex()) + "'"; int clientIndex = clientCombo->currentIndex(); if ((clientIndex >= 0) && (clientCombo->itemText(clientIndex) != "Any")) { @@ -113,7 +115,25 @@ void restoreTree::populateDirectoryTree() if ((fileSetIndex >= 0) && (fileSetCombo->itemText(fileSetIndex) != "Any")) { m_condition.append(" AND FileSet.FileSet='" + fileSetCombo->itemText(fileSetIndex) + "'"); } - cmd += m_condition; + m_jobQueryPart = + " LEFT OUTER JOIN Client ON (Job.ClientId=Client.ClientId)" + " LEFT OUTER JOIN FileSet ON (Job.FileSetId=FileSet.FileSetId)" + " WHERE" + m_condition + + " AND Job.purgedfiles=0"; + m_jobQuery = + "SELECT Job.Jobid" + " From Job" + m_jobQueryPart; + if (mainWin->m_sqlDebug) { + Pmsg1(000, "Query cmd : %s\n",m_jobQuery.toUtf8().data()); + } + populateJobTable(); + + QString cmd = + "SELECT DISTINCT Path.Path" + " FROM Path" + " LEFT OUTER JOIN File ON (File.PathId=Path.PathId)" + " LEFT OUTER JOIN Job ON (File.JobId=Job.JobId)" + " WHERE Job.Jobid IN (" + m_jobQuery + ")"; if (mainWin->m_sqlDebug) { Pmsg1(000, "Query cmd : %s\n",cmd.toUtf8().data()); } @@ -306,12 +326,13 @@ void restoreTree::directoryItemChanged(QTreeWidgetItem *item, QTreeWidgetItem *) directoryLabel->setText("Present Working Directory : " + directory); QString cmd = "SELECT DISTINCT Filename.Name" - " FROM File LEFT OUTER JOIN Filename on (Filename.FilenameId=File.FilenameId)" + " FROM File " + " LEFT OUTER JOIN Filename on (Filename.FilenameId=File.FilenameId)" " LEFT OUTER JOIN Path ON (Path.PathId=File.PathId)" " LEFT OUTER JOIN Job ON (File.JobId=Job.JobId)" - " LEFT OUTER JOIN Client ON (Job.ClientId=Client.ClientId)" - " LEFT OUTER JOIN FileSet ON (Job.FileSetId=FileSet.FileSetId)"; - cmd += " WHERE Path.Path='" + directory + "' AND Filename.Name!='' AND " + m_condition; + " WHERE Path.Path='" + directory + "' AND Filename.Name!=''" + " AND Job.Jobid IN (" + m_jobQuery + ")"; + QStringList headerlist = (QStringList() << "File Name"); fileTable->clear(); @@ -327,7 +348,6 @@ void restoreTree::directoryItemChanged(QTreeWidgetItem *item, QTreeWidgetItem *) } QStringList results; if (m_console->sql_cmd(cmd, results)) { - m_resultCount = results.count(); QTableWidgetItem* tableItem; QString field; @@ -375,9 +395,8 @@ void restoreTree::fileItemChanged(QTableWidgetItem *fileTableItem, QTableWidgetI " LEFT OUTER JOIN Filename on (Filename.FilenameId=File.FilenameId)" " LEFT OUTER JOIN Path ON (Path.PathId=File.PathId)" " LEFT OUTER JOIN Job ON (File.JobId=Job.JobId)" - " LEFT OUTER JOIN Client ON (Job.ClientId=Client.ClientId)" - " LEFT OUTER JOIN FileSet ON (Job.FileSetId=FileSet.FileSetId)"; - cmd += " WHERE Filename.Name='" + file + "' AND Path.Path='" + directory + "' AND " + m_condition; + " WHERE Filename.Name='" + file + "' AND Path.Path='" + directory + "'" + " AND Job.Jobid IN (" + m_jobQuery + ")"; QStringList headerlist = (QStringList() << "File Id" << "Job Id" << "End Time" << "Md5"); versionTable->clear(); @@ -389,7 +408,6 @@ void restoreTree::fileItemChanged(QTableWidgetItem *fileTableItem, QTableWidgetI } QStringList results; if (m_console->sql_cmd(cmd, results)) { - m_resultCount = results.count(); QTableWidgetItem* tableItem; QString field; @@ -456,3 +474,51 @@ void restoreTree::directoryItemExpanded(QTreeWidgetItem *item) child->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png"))); } } + +void restoreTree::populateJobTable() +{ + QBrush blackBrush(Qt::black); + QStringList headerlist = (QStringList() << "Job Id" << "End Time" << "Type"); + jobTable->clear(); + jobTable->setColumnCount(headerlist.size()); + jobTable->setHorizontalHeaderLabels(headerlist); + QString jobQuery = + "SELECT Job.Jobid AS Id, Job.Endtime AS EndTime, Job.Level AS Level" + " FROM Job" + m_jobQueryPart + + " ORDER BY Job.Endtime DESC"; + if (mainWin->m_sqlDebug) { + Pmsg1(000, "Query cmd : %s\n",jobQuery.toUtf8().data()); + } + + QStringList results; + if (m_console->sql_cmd(jobQuery, results)) { + + QTableWidgetItem* tableItem; + QString field; + QStringList fieldlist; + jobTable->setRowCount(results.size()); + + int row = 0; + /* Iterate through the record returned from the query */ + foreach (QString resultline, results) { + fieldlist = resultline.split("\t"); + int column = 0; + /* remove directory */ + if (fieldlist[0].trimmed() != "") { + /* Iterate through fields in the record */ + foreach (field, fieldlist) { + field = field.trimmed(); /* strip leading & trailing spaces */ + tableItem = new QTableWidgetItem(field,1); + tableItem->setFlags(0); + tableItem->setForeground(blackBrush); + jobTable->setItem(row, column, tableItem); + column++; + } + row++; + } + } + } + jobTable->resizeColumnsToContents(); + jobTable->resizeRowsToContents(); + jobTable->verticalHeader()->hide(); +} diff --git a/bacula/src/qt-console/restore/restoretree.h b/bacula/src/qt-console/restore/restoretree.h index 589d2cd4e5..8666ce6910 100644 --- a/bacula/src/qt-console/restore/restoretree.h +++ b/bacula/src/qt-console/restore/restoretree.h @@ -59,6 +59,7 @@ private slots: private: void populateDirectoryTree(); + void populateJobTable(); void parseDirectory(QString &dir_in); bool addDirectory(QString &, QString &); void setupPage(); @@ -72,7 +73,8 @@ private: //QString m_jobCondition; QHash m_dirPaths; QString m_condition; - int m_resultCount; + QString m_jobQuery; + QString m_jobQueryPart; int m_debugCnt; bool m_debugTrap; }; diff --git a/bacula/src/qt-console/restore/restoretree.ui b/bacula/src/qt-console/restore/restoretree.ui index 8a01cff03f..e6a08ff115 100644 --- a/bacula/src/qt-console/restore/restoretree.ui +++ b/bacula/src/qt-console/restore/restoretree.ui @@ -5,8 +5,8 @@ 0 0 - 515 - 333 + 400 + 319 @@ -21,19 +21,34 @@ - - - 7 - 7 - 0 - 0 - - Qt::Horizontal + + + + 0 + + + 6 + + + + + + + + Jobs + + + Qt::AlignCenter + + + + + - + 0 @@ -56,7 +71,7 @@ - + 0