From fe59ca9708aa759a05d3d6105252b5743f45a2d4 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Thu, 5 Apr 2007 02:41:42 +0000 Subject: [PATCH] dhb Medialist : created context menu function and moved lines which create the context menu function there. Call this function from MediaList::PgSeltreeWidgetClicked() so that the menu items only get added once instead of every time the tree gets repopulated. Otherwise the popup menu ends up with repeats. Joblist : Set all flags of the table items to 0 so that the defaults of editable are not active. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4513 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/joblist/joblist.cpp | 1 + bacula/src/qt-console/medialist/medialist.cpp | 39 +++++++++---------- bacula/src/qt-console/medialist/medialist.h | 1 + 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 96c863376c..2c54b893d5 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -92,6 +92,7 @@ void JobList::populateTable() foreach (field, fieldlist) { field = field.trimmed(); /* strip leading & trailing spaces */ p_tableitem = new QTableWidgetItem(field,1); + p_tableitem->setFlags(0); mp_tableWidget->setItem(row, column, p_tableitem); column++; } diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 855f66b1a5..3489e8aa44 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -88,29 +88,8 @@ void MediaList::populateTree() topItem->setData(0, Qt::UserRole, 0); topItem->setExpanded( true ); -#ifdef xxx -#include -***** FIXME ***** -//how to get the size of a column to be larger -//topItem->setSizeHint(0,QSize(1050,50)); -#endif - mp_treeWidget->setHeaderLabels(headerlist); - /* - * Setup a context menu - */ - 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); - connect(mp_treeWidget, SIGNAL( - currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), - this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); - if (mp_console->sql_cmd(query, results)) { QString field; QStringList fieldlist; @@ -197,6 +176,7 @@ void MediaList::PgSeltreeWidgetClicked() { if(!m_populated) { populateTree(); + createContextMenu(); m_populated=true; } } @@ -228,3 +208,20 @@ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetI } } } + +/* + * Setup a context menu + */ +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); + connect(mp_treeWidget, SIGNAL( + currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), + this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); +} diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index a29e30dbcc..7d66bba80a 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -58,6 +58,7 @@ public slots: private: void createConnections(); void populateTree(); + void createContextMenu(); private: Console *mp_console; -- 2.39.5