mp_console = console;
m_parent = parent;
m_medianame = medianame;
+ m_resultCount = 0;
m_populated = false;
m_closeable = false;
/* connect to the action specific to this pages class */
/* Set up query QString and header QStringList */
QString query("");
- query += "SELECT j.jobid,j.name,j.starttime,j.type,j.level,j.jobfiles,"
- "j.jobstatus"
+ query += "SELECT j.Jobid,j.Name,j.Starttime,j.Type,j.Level,j.Jobfiles,"
+ "j.Jobstatus"
" FROM job j, jobmedia jm, media m"
" WHERE jm.jobid=j.jobid and jm.mediaid=m.mediaid";
if (m_medianame != "") {
query += " and m.VolumeName='" + m_medianame + "'";
m_closeable=true;
}
- query += " ORDER BY j.starttime";
+ query += " ORDER BY j.Starttime";
QStringList headerlist = (QStringList()
<< "Job Id" << "Job Name" << "Job Starttime" << "Job Type" << "Job Level"
<< "Job Files" << "Job Status");
mp_tableWidget->setColumnCount(headerlist.size());
mp_tableWidget->setHorizontalHeaderLabels(headerlist);
+ /* printf("Query cmd : %s\n",query.toUtf8().data());
+ * This could be a debug message?? */
if (mp_console->sql_cmd(query, results)) {
+ m_resultCount = results.count();
+
QTableWidgetItem* p_tableitem;
QString field;
QStringList fieldlist;
}
row++;
}
+ }
+ 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"
+ "Press OK to continue?"), QMessageBox::Ok );
}
}
*/
void MainWin::createPagejoblist(QString &media)
{
- QTreeWidgetItem *item;
+ QTreeWidgetItem *item, *holdItem;
+ /* save current tree widget item in case query produces no results */
+ holdItem = treeWidget->currentItem();
if (media == "") {
item=createPage("All Jobs", m_topItem);
} else {
JobList* joblist = new JobList(stackedWidget, m_console, media);
hashInsert(item, joblist);
joblist->dockPage();
+ /* If this is a query of jobs on a specific media */
if (media != "") {
stackedWidget->setCurrentWidget(joblist);
treeWidget->setCurrentItem(item);
+ /* did query produce results, if not close window and set back to hold */
+ if (joblist->m_resultCount == 0) {
+ joblist->closeStackPage();
+ treeWidget->setCurrentItem(holdItem);
+ }
}
}
/* The Previous item */
if (previousitem) {
+ /* make sure the close window and toggle dock options are removed */
+ treeWidget->removeAction(actionClosePage);
+ treeWidget->removeAction(actionToggleDock);
/* Is this a page that has been inserted into the hash */
if (getFromHash(previousitem)) {
Pages* page = getFromHash(previousitem);
- treeWidget->removeAction(actionToggleDock);
- /* make sure the close window option is removed */
- if (page->isCloseable()) {
- treeWidget->removeAction(actionClosePage);
- }
foreach(QAction* pageaction, page->m_contextActions) {
treeWidget->removeAction(pageaction);
}
QStringList results;
const char *query =
"SELECT p.Name,m.VolumeName,m.MediaId,m.VolStatus,m.Enabled,m.VolBytes,"
- "m.VolFiles,m.VolRetention,m.MediaType,m.LastWritten"
+ "m.VolFiles,m.VolJobs,m.VolRetention,m.MediaType,m.LastWritten"
" FROM Media m,Pool p"
" WHERE m.PoolId=p.PoolId"
" ORDER BY p.Name";
QStringList headerlist = (QStringList()
<< "Pool Name" << "Volume Name" << "Media Id" << "Volume Status" << "Enabled"
- << "Volume Bytes" << "Volume Files" << "Volume Retention"
+ << "Volume Bytes" << "Volume Files" << "Volume Jobs" << "Volume Retention"
<< "Media Type" << "Last Written");
m_checkcurwidget = false;
mp_treeWidget->clear();
m_checkcurwidget = true;
- mp_treeWidget->setColumnCount(9);
+ mp_treeWidget->setColumnCount(headerlist.count());
topItem = new QTreeWidgetItem(mp_treeWidget);
topItem->setText(0, "Pools");
topItem->setData(0, Qt::UserRole, 0);
- topItem->setExpanded( true );
+ topItem->setExpanded(true);
mp_treeWidget->setHeaderLabels(headerlist);
+ //printf("MediaList query cmd : %s\n",query);
if (mp_console->sql_cmd(query, results)) {
QString field;
QStringList fieldlist;
* Added to set the context menu policy based on currently active treeWidgetItem
* signaled by currentItemChanged
*/
-void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *) /*previouswidgetitem*/
+void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *previouswidgetitem )
{
+ /* m_checkcurwidget checks to see if this is during a refresh, which will segfault */
if (m_checkcurwidget) {
+ /* The Previous item */
+ if (previouswidgetitem) { /* avoid a segfault if first time */
+ int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt();
+ if (treedepth == 2){
+ mp_treeWidget->removeAction(actionEditVolume);
+ mp_treeWidget->removeAction(actionListJobsOnVolume);
+ }
+ }
+
int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt();
if (treedepth == 2){
- mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
m_currentlyselected=currentwidgetitem->text(1);
- } else {
- mp_treeWidget->setContextMenuPolicy(Qt::NoContextMenu);
+ mp_treeWidget->addAction(actionEditVolume);
+ mp_treeWidget->addAction(actionListJobsOnVolume);
}
}
}
*/
void MediaList::createContextMenu()
{
- QAction *editAction = new QAction("Edit Properties", mp_treeWidget);
- QAction *listAction = new QAction("List Jobs On Media", mp_treeWidget);
- mp_treeWidget->addAction(editAction);
- mp_treeWidget->addAction(listAction);
- connect(editAction, SIGNAL(triggered()), this, SLOT(editMedia()));
- connect(listAction, SIGNAL(triggered()), this, SLOT(showJobs()));
+ mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
+ /*mp_treeWidget->setContextMenuPolicy(Qt::NoContextMenu);*/
+ mp_treeWidget->addAction(actionRefreshMediaList);
+ connect(actionEditVolume, SIGNAL(triggered()), this, SLOT(editMedia()));
+ connect(actionListJobsOnVolume, SIGNAL(triggered()), this, SLOT(showJobs()));
mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(mp_treeWidget, SIGNAL(
currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
/* connect to the action specific to this pages class */
- connect(actionRepopulateMediaTree, SIGNAL(triggered()), this,
+ connect(actionRefreshMediaList, SIGNAL(triggered()), this,
SLOT(populateTree()));
}
/* add context sensitive menu items specific to this classto the page
* selector tree. m_m_contextActions is QList of QActions, so this is
* only done once with the first population. */
- m_contextActions.append(actionRepopulateMediaTree);
+ m_contextActions.append(actionRefreshMediaList);
/* Create the context menu for the medialist tree */
createContextMenu();
m_populated=true;
<widget class="QTreeWidget" name="mp_treeWidget" />
</item>
</layout>
- <action name="actionRepopulateMediaTree" >
+ <action name="actionRefreshMediaList" >
<property name="icon" >
<iconset>../images/run.png</iconset>
</property>
<property name="text" >
- <string>Repopulate Media Tree</string>
+ <string>Refresh Media List</string>
</property>
<property name="statusTip" >
- <string>Requery the director for the media.</string>
+ <string>Requery the director for the list of media.</string>
+ </property>
+ </action>
+ <action name="actionEditVolume" >
+ <property name="icon" >
+ <iconset>../images/status.png</iconset>
+ </property>
+ <property name="text" >
+ <string>Edit Volume</string>
+ </property>
+ </action>
+ <action name="actionListJobsOnVolume" >
+ <property name="icon" >
+ <iconset>../images/unmark.png</iconset>
+ </property>
+ <property name="text" >
+ <string>List Jobs On Volume</string>
</property>
</action>
</widget>