if (previouswidgetitem) { /* avoid a segfault if first time */
int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt();
if (treedepth == 1){
-// mp_treeWidget->removeAction(actionEditVolume);
+ mp_treeWidget->removeAction(actionListJobsofClient);
}
}
if (treedepth == 1){
/* set a hold variable to the client name in case the context sensitive
* menu is used */
- m_currentlyselected=currentwidgetitem->text(1);
-// mp_treeWidget->addAction(actionEditVolume);
+ m_currentlyselected=currentwidgetitem->text(0);
+ mp_treeWidget->addAction(actionListJobsofClient);
}
}
}
/* connect to the action specific to this pages class */
connect(actionRefreshClients, SIGNAL(triggered()), this,
SLOT(populateTree()));
+ connect(actionListJobsofClient, SIGNAL(triggered()), this,
+ SLOT(showJobs()));
+}
+
+/*
+ * Function responding to actionListJobsofClient which calls mainwin function
+ * to create a window of a list of jobs of this client.
+ */
+void Clients::showJobs()
+{
+ QString emptymedia("");
+ mainWin->createPageJobList(emptymedia, m_currentlyselected);
}
/*
/*
* Constructor for the class
*/
-JobList::JobList(QStackedWidget *parent, Console *console, QString &medianame)
+JobList::JobList(QStackedWidget *parent, Console *console, QString &medianame,
+ QString &clientname)
{
setupUi(this);
/* Store passed variables in member variables */
mp_console = console;
m_parent = parent;
m_medianame = medianame;
+ m_clientname = clientname;
m_resultCount = 0;
m_populated = false;
m_closeable = false;
/* Set up query QString and header QStringList */
QString query("");
- query += "SELECT j.Jobid,j.Name,j.Starttime,j.Type,j.Level,j.Jobfiles,"
- "j.JobBytes,j.JobStatus"
- " FROM job j, jobmedia jm, media m"
- " WHERE jm.jobid=j.jobid and jm.mediaid=m.mediaid";
+ query += "SELECT Job.Jobid AS Id, Job.Name AS JobName, Client.Name AS Client,"
+ " Job.Starttime AS JobStart, Job.Type AS JobType,"
+ " Job.Level AS BackupLevel, Job.Jobfiles AS FileCount,"
+ " Job.JobBytes AS Bytes, Job.JobStatus AS Status"
+ " FROM Job, JobMedia, Media, Client"
+ " WHERE JobMedia.JobId=Job.JobId and JobMedia.MediaId=Media.MediaId"
+ " and Client.ClientId=Job.ClientId";
if (m_medianame != "") {
- query += " and m.VolumeName='" + m_medianame + "'";
+ query += " and Media.VolumeName='" + m_medianame + "'";
m_closeable=true;
}
- query += " ORDER BY j.Starttime";
+ if (m_clientname != "") {
+ query += " and Client.Name='" + m_clientname + "'";
+ m_closeable=true;
+ }
+ query += " ORDER BY Job.Starttime";
QStringList headerlist = (QStringList()
- << "Job Id" << "Job Name" << "Job Starttime" << "Job Type" << "Job Level"
- << "Job Files" << "Job Bytes" << "Job Status");
+ << "Job Id" << "Job Name" << "Client" << "Job Starttime" << "Job Type"
+ << "Job Level" << "Job Files" << "Job Bytes" << "Job Status" );
/* Initialize the QTableWidget */
mp_tableWidget->clear();
mp_tableWidget->setColumnCount(headerlist.size());
mp_tableWidget->setHorizontalHeaderLabels(headerlist);
- /* This could be a debug message?? */
- /* printf("Query cmd : %s\n",query.toUtf8().data()); */
+ /* This could be a user preference debug message?? */
+ printf("Query cmd : %s\n",query.toUtf8().data());
if (mp_console->sql_cmd(query, results)) {
m_resultCount = results.count();
}
}
if ((m_medianame != "") && (m_resultCount == 0)){
- /* for context sensitive searches, let the user know if there were no results */
- QMessageBox::warning(this, tr("Bat"), tr("The Jobs query returned no results.\n"
+ /* for context sensitive searches, let the user know if there were no
+ * results */
+ QMessageBox::warning(this, tr("Bat"),
+ tr("The Jobs query returned no results.\n"
"Press OK to continue?"), QMessageBox::Ok );
}
}
/*
- * * When the treeWidgetItem in the page selector tree is singleclicked, Make sure
- * * The tree has been populated.
- * */
+ * When the treeWidgetItem in the page selector tree is singleclicked, Make sure
+ * The tree has been populated.
+ */
void JobList::PgSeltreeWidgetClicked()
{
if (!m_populated) {
}
/*
- * Virtual function which is called when this page is visible on the stack
+ * Virtual function override of pages function which is called when this page
+ * is visible on the stack
*/
void JobList::currentStackItem()
{
* under each director */
createPagebRestore();
createPageMediaList();
- QString emptymedia("");
- createPageJobList(emptymedia);
+ QString emptymedia(""), emptyclient("");
+ createPageJobList(emptymedia, emptyclient);
createPageClients();
treeWidget->expandItem(m_topItem);
/*
* create an instance of the the joblist class on the stack
*/
-void MainWin::createPageJobList(QString &media)
+void MainWin::createPageJobList(QString &media, QString &client)
{
QTreeWidgetItem *item, *holdItem;
/* save current tree widget item in case query produces no results */
holdItem = treeWidget->currentItem();
- if (media == "") {
+ if ((media == "") && (client == "")) {
item=createPage("All Jobs", m_topItem);
} else {
- QString desc("Jobs on ");
- desc += media;
+ QString desc("Jobs ");
+ if (media != "" ) {
+ desc += "on Volume " + media;
+ }
+ if (client != "" ) {
+ desc += "of Client " + client;
+ }
item=createPage(desc.toUtf8().data(), m_topItem);
- }
- JobList* joblist = new JobList(stackedWidget, m_console, media);
+ }
+ JobList* joblist = new JobList(stackedWidget, m_console, media, client);
hashInsert(item, joblist);
joblist->dockPage();
/* If this is a query of jobs on a specific media */
- if (media != "") {
+ if ((media != "") || (client != "")) {
stackedWidget->setCurrentWidget(joblist);
treeWidget->setCurrentItem(item);
/* did query produce results, if not close window and set back to hold */