From: Dirk H Bartley Date: Mon, 23 Apr 2007 03:09:12 +0000 (+0000) Subject: Add six context sensitive menu options to the joblist. I think I got X-Git-Tag: Release-7.0.0~6524 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0fe41266c83998f2971f23e2356156633ff45b7f;p=bacula%2Fbacula Add six context sensitive menu options to the joblist. I think I got all the ones that made sense doing "jobid=" searches in documentation. Commented out one passed value in line 122 of console.cpp to get a successful compilation. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4604 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index 1c203662b7..a728b08163 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -1,7 +1,10 @@ dhb ==================================================== +Must preempt all connections to console with if connected. + Add context sensitive options for most commands status dir on page select director item +All items with jobid= that I thought could work from joblist are done. Create list of what does not work. diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index ac90518935..d570161205 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -119,7 +119,7 @@ void Console::connect() heart_beat = 0; } - m_sock = bnet_connect(NULL, 5, 15, heart_beat, + m_sock = bnet_connect(NULL, 5, /*15,*/ heart_beat, _("Director daemon"), m_dir->address, NULL, m_dir->DIRport, 0); if (m_sock == NULL) { diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 1e62bf9f9b..fe0b54e8c1 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -40,20 +40,19 @@ /* * Constructor for the class */ -JobList::JobList(QString &medianame, QString &clientname, +JobList::JobList(QString &mediaName, QString &clientname, QTreeWidgetItem *parentTreeWidgetItem) { setupUi(this); m_name = "Clients"; - m_medianame = medianame; - m_clientname = clientname; + m_mediaName = mediaName; + m_clientName = clientname; pgInitialize(parentTreeWidgetItem); m_resultCount = 0; m_populated = false; m_closeable = false; - /* connect to the action specific to this pages class */ - connect(actionRefreshJobList, SIGNAL(triggered()), this, - SLOT(populateTable())); + m_checkCurrentWidget = true; + createConnections(); setTitle(); } @@ -61,12 +60,13 @@ JobList::JobList(QString &medianame, QString &clientname, * The Meat of the class. * This function will populate the QTableWidget, mp_tablewidget, with * QTableWidgetItems representing the results of a query for what jobs exist on - * the media name passed from the constructor stored in m_medianame. + * the media name passed from the constructor stored in m_mediaName. */ void JobList::populateTable() { QStringList results; QString resultline; + QBrush blackBrush(Qt::black); /* Set up query QString and header QStringList */ QString query(""); @@ -77,12 +77,12 @@ void JobList::populateTable() " 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 Media.VolumeName='" + m_medianame + "'"; + if (m_mediaName != "") { + query += " and Media.VolumeName='" + m_mediaName + "'"; m_closeable=true; } - if (m_clientname != "") { - query += " and Client.Name='" + m_clientname + "'"; + if (m_clientName != "") { + query += " and Client.Name='" + m_clientName + "'"; m_closeable=true; } query += " ORDER BY Job.Starttime"; @@ -91,7 +91,9 @@ void JobList::populateTable() << "Job Level" << "Job Files" << "Job Bytes" << "Job Status" ); /* Initialize the QTableWidget */ + m_checkCurrentWidget = false; mp_tableWidget->clear(); + m_checkCurrentWidget = true; mp_tableWidget->setColumnCount(headerlist.size()); mp_tableWidget->setHorizontalHeaderLabels(headerlist); @@ -115,6 +117,7 @@ void JobList::populateTable() field = field.trimmed(); /* strip leading & trailing spaces */ p_tableitem = new QTableWidgetItem(field,1); p_tableitem->setFlags(0); + p_tableitem->setForeground(blackBrush); mp_tableWidget->setItem(row, column, p_tableitem); column++; } @@ -125,7 +128,7 @@ void JobList::populateTable() for(int cnter=0; cnterresizeColumnToContents(cnter); } - if ((m_medianame != "") && (m_resultCount == 0)){ + if ((m_mediaName != "") && (m_resultCount == 0)){ /* for context sensitive searches, let the user know if there were no * results */ QMessageBox::warning(this, tr("Bat"), @@ -164,15 +167,123 @@ void JobList::currentStackItem() */ void JobList::treeWidgetName(QString &desc) { - if ((m_medianame == "") && (m_clientname == "")) { + if ((m_mediaName == "") && (m_clientName == "")) { desc = "All Jobs"; } else { desc = "Jobs "; - if (m_medianame != "" ) { - desc += "on Volume " + m_medianame; + if (m_mediaName != "" ) { + desc += "on Volume " + m_mediaName; } - if (m_clientname != "" ) { - desc += "of Client " + m_clientname; + if (m_clientName != "" ) { + desc += "of Client " + m_clientName; } } } + +/* + * This functions much line tableItemChanged for trees like the page selector, + * but I will do much less here + */ +void JobList::tableItemChanged(QTableWidgetItem *currentItem, QTableWidgetItem * /*previousItem*/) +{ + if (m_checkCurrentWidget) { + int row = currentItem->row(); + QTableWidgetItem* jobitem = mp_tableWidget->item(row, 0); + m_currentJob = jobitem->text(); + } +} + +/* + * Function to create connections for context sensitive menu for this and + * the page selector + */ +void JobList::createConnections() +{ + /* connect to the action specific to this pages class that shows up in the + * page selector tree */ + connect(actionRefreshJobList, SIGNAL(triggered()), this, + SLOT(populateTable())); + /* for the tableItemChanged to maintain m_currentJob */ + connect(mp_tableWidget, SIGNAL( + currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), + this, SLOT(tableItemChanged(QTableWidgetItem *, QTableWidgetItem *))); + + /* Do what is required for the local context sensitive menu */ + + + /* setContextMenuPolicy is required */ + mp_tableWidget->setContextMenuPolicy(Qt::ActionsContextMenu); + + /* Add Actions */ + mp_tableWidget->addAction(actionRefreshJobList); + mp_tableWidget->addAction(actionLongListJob); + mp_tableWidget->addAction(actionListJobid); + mp_tableWidget->addAction(actionListFilesOnJob); + mp_tableWidget->addAction(actionListJobMedia); + mp_tableWidget->addAction(actionListVolumes); + mp_tableWidget->addAction(actionDeleteJob); + mp_tableWidget->addAction(actionPurgeFiles); + + /* Make Connections */ + connect(actionLongListJob, SIGNAL(triggered()), this, + SLOT(consoleLongListJob())); + connect(actionListJobid, SIGNAL(triggered()), this, + SLOT(consoleListJobid())); + connect(actionListFilesOnJob, SIGNAL(triggered()), this, + SLOT(consoleListFilesOnJob())); + connect(actionListJobMedia, SIGNAL(triggered()), this, + SLOT(consoleListJobMedia())); + connect(actionListVolumes, SIGNAL(triggered()), this, + SLOT(consoleListVolumes())); + connect(actionDeleteJob, SIGNAL(triggered()), this, + SLOT(consoleDeleteJob())); + connect(actionPurgeFiles, SIGNAL(triggered()), this, + SLOT(consolePurgeFiles())); +} + +/* + * Functions to respond to local context sensitive menu sending console commands + * If I could figure out how to make these one function passing a string, Yaaaaaa + */ +void JobList::consoleLongListJob() +{ + QString cmd("llist jobid="); + cmd += m_currentJob; + consoleCommand(cmd); +} +void JobList::consoleListJobid() +{ + QString cmd("list jobid="); + cmd += m_currentJob; + consoleCommand(cmd); +} +void JobList::consoleListFilesOnJob() +{ + QString cmd("list files jobid="); + cmd += m_currentJob; + consoleCommand(cmd); +} +void JobList::consoleListJobMedia() +{ + QString cmd("list jobmedia jobid="); + cmd += m_currentJob; + consoleCommand(cmd); +} +void JobList::consoleListVolumes() +{ + QString cmd("list volumes jobid="); + cmd += m_currentJob; + consoleCommand(cmd); +} +void JobList::consoleDeleteJob() +{ + QString cmd("delete job jobid="); + cmd += m_currentJob; + consoleCommand(cmd); +} +void JobList::consolePurgeFiles() +{ + QString cmd("purge files jobid="); + cmd += m_currentJob; + consoleCommand(cmd); +} diff --git a/bacula/src/qt-console/joblist/joblist.h b/bacula/src/qt-console/joblist/joblist.h index c3ee1fa28f..989f988f15 100644 --- a/bacula/src/qt-console/joblist/joblist.h +++ b/bacula/src/qt-console/joblist/joblist.h @@ -51,11 +51,24 @@ public: public slots: void populateTable(); virtual void treeWidgetName(QString &); + void tableItemChanged(QTableWidgetItem *, QTableWidgetItem *); + +private slots: + void consoleLongListJob(); + void consoleListJobid(); + void consoleListFilesOnJob(); + void consoleListJobMedia(); + void consoleListVolumes(); + void consoleDeleteJob(); + void consolePurgeFiles(); private: - QString m_medianame; - QString m_clientname; + void createConnections(); + QString m_mediaName; + QString m_clientName; + QString m_currentJob; bool m_populated; + bool m_checkCurrentWidget; }; #endif /* _JOBLIST_H_ */ diff --git a/bacula/src/qt-console/joblist/joblist.ui b/bacula/src/qt-console/joblist/joblist.ui index 872e241ad7..b19baa9931 100644 --- a/bacula/src/qt-console/joblist/joblist.ui +++ b/bacula/src/qt-console/joblist/joblist.ui @@ -34,6 +34,62 @@ Requery the director for the list of jobs. + + + ../images/unmark.png + + + ListJobid + + + + + ../images/unmark.png + + + List Files On Job + + + + + ../images/unmark.png + + + ListJobMedia + + + + + ../images/unmark.png + + + ListVolumes + + + + + ../images/unmark.png + + + LongListJob + + + + + ../images/unmark.png + + + DeleteJob + + + + + ../images/unmark.png + + + PurgeFiles + +