QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/network-server.png")));
- /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_client.h */
+ /* tableWidget, Storage Tree Tree Widget inherited from ui_client.h */
m_populated = false;
m_checkcurwidget = true;
m_closeable = false;
* The main meat of the class!! The function that querries the director and
* creates the widgets with appropriate values.
*/
-void Clients::populateTree()
+void Clients::populateTable()
{
- QTreeWidgetItem *clientItem, *topItem;
+ QTableWidgetItem *tableItem;
+ QBrush blackBrush(Qt::black);
if (!m_console->preventInUseConnect())
return;
m_checkcurwidget = false;
- mp_treeWidget->clear();
+ tableWidget->clear();
m_checkcurwidget = true;
QStringList headerlist = (QStringList() << tr("Client Name") << tr("File Retention")
<< tr("Job Retention") << tr("AutoPrune") << tr("ClientId") << tr("Uname") );
- topItem = new QTreeWidgetItem(mp_treeWidget);
- topItem->setText(0, tr("Clients"));
- topItem->setData(0, Qt::UserRole, 0);
- topItem->setExpanded(true);
-
- mp_treeWidget->setColumnCount(headerlist.count());
- mp_treeWidget->setHeaderLabels(headerlist);
+ tableWidget->setColumnCount(headerlist.count());
+ tableWidget->setHorizontalHeaderLabels(headerlist);
+ tableWidget->setRowCount(m_console->client_list.count());
+ tableWidget->verticalHeader()->hide();
+ int row = 0;
foreach (QString clientName, m_console->client_list){
- clientItem = new QTreeWidgetItem(topItem);
- clientItem->setText(0, clientName);
- clientItem->setData(0, Qt::UserRole, 1);
- clientItem->setExpanded(true);
-
/* Set up query QString and header QStringList */
QString query("");
- query += "SELECT FileRetention, JobRetention, AutoPrune, ClientId, Uname"
+ query += "SELECT Name, FileRetention, JobRetention, AutoPrune, ClientId, Uname"
" FROM Client"
" WHERE ";
query += " Name='" + clientName + "'";
/* there will only be one of these */
foreach (resultline, results) {
fieldlist = resultline.split("\t");
- int index = 0;
+ int column = 0;
/* Iterate through fields in the record */
foreach (field, fieldlist) {
field = field.trimmed(); /* strip leading & trailing spaces */
- clientItem->setData(index+1, Qt::UserRole, 1);
- /* Put media fields under the pool tree item */
- clientItem->setData(index+1, Qt::UserRole, 1);
- clientItem->setText(index+1, field);
- index++;
+ tableItem = new QTableWidgetItem(field, 1);
+ tableItem->setFlags(Qt::ItemIsSelectable);
+ tableItem->setForeground(blackBrush);
+ tableItem->setData(Qt::UserRole, 1);
+ tableWidget->setItem(row, column, tableItem);
+ column++;
}
}
}
}
+ row ++;
}
/* Resize the columns */
for(int cnter=0; cnter<headerlist.size(); cnter++) {
- mp_treeWidget->resizeColumnToContents(cnter);
+ tableWidget->resizeColumnToContents(cnter);
}
}
void Clients::PgSeltreeWidgetClicked()
{
if(!m_populated) {
- populateTree();
+ populateTable();
m_populated=true;
}
}
* Added to set the context menu policy based on currently active treeWidgetItem
* signaled by currentItemChanged
*/
-void Clients::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *previouswidgetitem )
+void Clients::tableItemChanged(QTableWidgetItem *currentwidgetitem, QTableWidgetItem *previouswidgetitem )
{
/* m_checkcurwidget checks to see if this is during a refresh, which will segfault */
if (m_checkcurwidget) {
+ int currentRow = currentwidgetitem->row();
+ QTableWidgetItem *currentrowzeroitem = tableWidget->item(currentRow, 0);
+ m_currentlyselected = currentrowzeroitem->text();
+
/* The Previous item */
if (previouswidgetitem) { /* avoid a segfault if first time */
- int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt();
- if (treedepth == 1){
- mp_treeWidget->removeAction(actionListJobsofClient);
- mp_treeWidget->removeAction(actionStatusClientInConsole);
- mp_treeWidget->removeAction(actionStatusClientWindow);
- mp_treeWidget->removeAction(actionPurgeJobs);
- mp_treeWidget->removeAction(actionPrune);
- }
+ tableWidget->removeAction(actionListJobsofClient);
+ tableWidget->removeAction(actionStatusClientInConsole);
+ tableWidget->removeAction(actionStatusClientWindow);
+ tableWidget->removeAction(actionPurgeJobs);
+ tableWidget->removeAction(actionPrune);
}
- int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt();
- if (treedepth == 1){
+ if (m_currentlyselected.length() != 0) {
/* set a hold variable to the client name in case the context sensitive
* menu is used */
- m_currentlyselected=currentwidgetitem->text(0);
- mp_treeWidget->addAction(actionListJobsofClient);
- mp_treeWidget->addAction(actionStatusClientInConsole);
- mp_treeWidget->addAction(actionStatusClientWindow);
- mp_treeWidget->addAction(actionPurgeJobs);
- mp_treeWidget->addAction(actionPrune);
+ tableWidget->addAction(actionListJobsofClient);
+ tableWidget->addAction(actionStatusClientInConsole);
+ tableWidget->addAction(actionStatusClientWindow);
+ tableWidget->addAction(actionPurgeJobs);
+ tableWidget->addAction(actionPrune);
}
}
}
*/
void Clients::createContextMenu()
{
- mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
- mp_treeWidget->addAction(actionRefreshClients);
- connect(mp_treeWidget, SIGNAL(
- currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
- this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+ tableWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
+ tableWidget->addAction(actionRefreshClients);
+ /* for the tableItemChanged to maintain m_currentJob */
+ connect(tableWidget, SIGNAL(
+ currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
+ this, SLOT(tableItemChanged(QTableWidgetItem *, QTableWidgetItem *)));
+
/* connect to the action specific to this pages class */
connect(actionRefreshClients, SIGNAL(triggered()), this,
- SLOT(populateTree()));
+ SLOT(populateTable()));
connect(actionListJobsofClient, SIGNAL(triggered()), this,
SLOT(showJobs()));
connect(actionStatusClientInConsole, SIGNAL(triggered()), this,
void Clients::currentStackItem()
{
if(!m_populated) {
- populateTree();
- /* Create the context menu for the client tree */
+ populateTable();
+ /* Create the context menu for the client table */
m_populated=true;
}
}
virtual void currentStackItem();
public slots:
- void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
+ void tableItemChanged(QTableWidgetItem *, QTableWidgetItem *);
private slots:
- void populateTree();
+ void populateTable();
void showJobs();
void consoleStatusClient();
void statusClientWindow();
<rect>
<x>0</x>
<y>0</y>
- <width>413</width>
- <height>258</height>
+ <width>492</width>
+ <height>428</height>
</rect>
</property>
<property name="windowTitle" >
<string>Client Tree</string>
</property>
<layout class="QGridLayout" >
- <property name="leftMargin" >
- <number>9</number>
- </property>
- <property name="topMargin" >
- <number>9</number>
- </property>
- <property name="rightMargin" >
- <number>9</number>
- </property>
- <property name="bottomMargin" >
- <number>9</number>
- </property>
- <property name="horizontalSpacing" >
- <number>6</number>
- </property>
- <property name="verticalSpacing" >
- <number>6</number>
- </property>
<item row="0" column="0" >
- <widget class="QTreeWidget" name="mp_treeWidget" >
- <column>
- <property name="text" >
- <string>1</string>
- </property>
- </column>
- </widget>
+ <widget class="QTableWidget" name="tableWidget" />
</item>
</layout>
<action name="actionRefreshClients" >
QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/system-file-manager.png")));
- /* mp_treeWidget, FileSet Tree Tree Widget inherited from ui_fileset.h */
+ /* tableWidget, FileSet Tree Tree Widget inherited from ui_fileset.h */
m_populated = false;
m_checkcurwidget = true;
m_closeable = false;
* The main meat of the class!! The function that querries the director and
* creates the widgets with appropriate values.
*/
-void FileSet::populateTree()
+void FileSet::populateTable()
{
- QTreeWidgetItem *filesetItem, *topItem;
+ QTableWidgetItem *tableItem;
+ QBrush blackBrush(Qt::black);
if (!m_console->preventInUseConnect())
return;
m_checkcurwidget = false;
- mp_treeWidget->clear();
+ tableWidget->clear();
m_checkcurwidget = true;
QStringList headerlist = (QStringList() << tr("FileSet Name") << tr("FileSet Id")
<< tr("Create Time"));
- topItem = new QTreeWidgetItem(mp_treeWidget);
- topItem->setText(0, tr("FileSet"));
- topItem->setData(0, Qt::UserRole, 0);
- topItem->setExpanded(true);
-
- mp_treeWidget->setColumnCount(headerlist.count());
- mp_treeWidget->setHeaderLabels(headerlist);
+ tableWidget->setColumnCount(headerlist.count());
+ tableWidget->setHorizontalHeaderLabels(headerlist);
+ tableWidget->setRowCount(m_console->fileset_list.count());
+ tableWidget->verticalHeader()->hide();
+ int row = 0;
foreach(QString filesetName, m_console->fileset_list) {
- filesetItem = new QTreeWidgetItem(topItem);
- filesetItem->setText(0, filesetName);
- filesetItem->setData(0, Qt::UserRole, 1);
- filesetItem->setExpanded(true);
/* Set up query QString and header QStringList */
QString query("");
" FROM FileSet"
" WHERE ";
query += " FileSet='" + filesetName + "'";
- query += " ORDER BY FileSet";
+ query += " ORDER BY CreateTime DESC LIMIT 1";
QStringList results;
if (mainWin->m_sqlDebug) {
}
if (m_console->sql_cmd(query, results)) {
int resultCount = results.count();
- if (resultCount == 1){
+ if (resultCount) {
QString resultline;
QString field;
QStringList fieldlist;
- /* there will only be one of these */
- foreach (resultline, results) {
- fieldlist = resultline.split("\t");
- int index = 0;
- /* Iterate through fields in the record */
- foreach (field, fieldlist) {
- field = field.trimmed(); /* strip leading & trailing spaces */
- filesetItem->setData(index, Qt::UserRole, 1);
- /* Put media fields under the pool tree item */
- filesetItem->setData(index, Qt::UserRole, 1);
- filesetItem->setText(index, field);
- index++;
- }
+ /* only use the last one */
+ resultline = results[resultCount - 1];
+ fieldlist = resultline.split("\t");
+ int column = 0;
+ /* Iterate through fields in the record */
+ foreach (field, fieldlist) {
+ field = field.trimmed(); /* strip leading & trailing spaces */
+ tableItem = new QTableWidgetItem(field, 1);
+ tableItem->setFlags(Qt::ItemIsSelectable);
+ tableItem->setForeground(blackBrush);
+ tableItem->setData(Qt::UserRole, 1);
+ tableWidget->setItem(row, column, tableItem);
+ column++;
}
}
}
+ row++;
}
/* Resize the columns */
for (int cnter=0; cnter<headerlist.size(); cnter++) {
- mp_treeWidget->resizeColumnToContents(cnter);
+ tableWidget->resizeColumnToContents(cnter);
}
}
void FileSet::PgSeltreeWidgetClicked()
{
if (!m_populated) {
- populateTree();
+ populateTable();
createContextMenu();
m_populated = true;
}
* Added to set the context menu policy based on currently active treeWidgetItem
* signaled by currentItemChanged
*/
-void FileSet::treeItemChanged(QTreeWidgetItem *currentwidgetitem,
- QTreeWidgetItem *previouswidgetitem )
+void FileSet::tableItemChanged(QTableWidgetItem *currentwidgetitem, QTableWidgetItem *previouswidgetitem)
{
/* m_checkcurwidget checks to see if this is during a refresh, which will segfault */
if (m_checkcurwidget) {
+ int currentRow = currentwidgetitem->row();
+ QTableWidgetItem *currentrowzeroitem = tableWidget->item(currentRow, 0);
+ m_currentlyselected = currentrowzeroitem->text();
+
/* The Previous item */
if (previouswidgetitem) { /* avoid a segfault if first time */
- int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt();
- if (treedepth == 1) {
- mp_treeWidget->removeAction(actionStatusFileSetInConsole);
- mp_treeWidget->removeAction(actionShowJobs);
- }
+ tableWidget->removeAction(actionStatusFileSetInConsole);
+ tableWidget->removeAction(actionShowJobs);
}
- int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt();
- if (treedepth == 1){
+ if (m_currentlyselected.length() != 0) {
/* set a hold variable to the fileset name in case the context sensitive
* menu is used */
- m_currentlyselected=currentwidgetitem->text(0);
- mp_treeWidget->addAction(actionStatusFileSetInConsole);
- mp_treeWidget->addAction(actionShowJobs);
+ tableWidget->addAction(actionStatusFileSetInConsole);
+ tableWidget->addAction(actionShowJobs);
}
}
}
*/
void FileSet::createContextMenu()
{
- mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
- mp_treeWidget->addAction(actionRefreshFileSet);
- connect(mp_treeWidget, SIGNAL(
- currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
- this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+ tableWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
+ tableWidget->addAction(actionRefreshFileSet);
+ connect(tableWidget, SIGNAL(
+ currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
+ this, SLOT(tableItemChanged(QTableWidgetItem *, QTableWidgetItem *)));
/* connect to the action specific to this pages class */
connect(actionRefreshFileSet, SIGNAL(triggered()), this,
- SLOT(populateTree()));
+ SLOT(populateTable()));
connect(actionStatusFileSetInConsole, SIGNAL(triggered()), this,
SLOT(consoleStatusFileSet()));
connect(actionShowJobs, SIGNAL(triggered()), this,
void FileSet::currentStackItem()
{
if(!m_populated) {
- populateTree();
- /* Create the context menu for the fileset tree */
+ populateTable();
+ /* Create the context menu for the fileset table */
createContextMenu();
m_populated=true;
}
virtual void currentStackItem();
public slots:
- void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
+ void tableItemChanged(QTableWidgetItem *, QTableWidgetItem *);
private slots:
- void populateTree();
+ void populateTable();
void consoleStatusFileSet();
void showJobs();
<rect>
<x>0</x>
<y>0</y>
- <width>318</width>
- <height>246</height>
+ <width>341</width>
+ <height>277</height>
</rect>
</property>
<property name="windowTitle" >
<string>FileSet Tree</string>
</property>
<layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
<item row="0" column="0" >
- <widget class="QTreeWidget" name="mp_treeWidget" />
+ <widget class="QTableWidget" name="tableWidget" />
</item>
</layout>
<action name="actionRefreshFileSet" >
{
m_isClosing = true;
writeSettings();
- foreach(Console *console, m_consoleHash){
+/* foreach(Console *console, m_consoleHash){
console->writeSettings();
console->terminate();
console->closeStackPage();
- }
+ } */
/* close all non console pages, this will call settings in destructors */
while (m_consoleHash.count() < m_pagehash.count()) {
foreach(Pages *page, m_pagehash) {