treeWidget->setColumnCount(1);
treeWidget->setHeaderLabel( tr("Select Page") );
treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
- // tabWidget->setTabsClosable(true); /* wait for QT 4.5 */
+ tabWidget->setTabsClosable(true); /* wait for QT 4.5 */
createPages();
resetFocus(); /* lineEdit->setFocus() */
* Create instances in alphabetic order of the rest
* of the classes that will by default exist under each Director.
*/
-// new bRestore();
+ new bRestore();
new Clients();
new FileSet();
new Jobs();
new MediaList();
new MediaView();
new Storage();
- if (m_openBrowser) {
- new restoreTree();
- }
+// if (m_openBrowser) {
+// new restoreTree();
+// }
if (m_openDirStat) {
new DirStat();
}
connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
+ connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closePage(int)));
connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked()));
connect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
connect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
connect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
connect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow()));
- connect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage()));
+ connect(actionClosePage, SIGNAL(triggered()), this, SLOT(closeCurrentPage()));
connect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences()));
connect(actionRepopLists, SIGNAL(triggered()), this, SLOT(repopLists()));
connect(actionReloadRepop, SIGNAL(triggered()), this, SLOT(reloadRepopLists()));
disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
disconnect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
+ disconnect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closePage(int)));
disconnect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
disconnect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked()));
disconnect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
disconnect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
disconnect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
disconnect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow()));
- disconnect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage()));
+ disconnect(actionClosePage, SIGNAL(triggered()), this, SLOT(closeCurrentPage()));
disconnect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences()));
disconnect(actionRepopLists, SIGNAL(triggered()), this, SLOT(repopLists()));
disconnect(actionReloadRepop, SIGNAL(triggered()), this, SLOT(reloadRepopLists()));
void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
{
/* Is this a page that has been inserted into the hash */
- if (getFromHash(item)) {
- Pages* page = getFromHash(item);
- int stackindex=tabWidget->indexOf(page);
+ Pages* page = getFromHash(item);
+ if (page) {
+ int stackindex = tabWidget->indexOf(page);
if (stackindex >= 0) {
tabWidget->setCurrentWidget(page);
}
+ page->dockPage();
/* run the virtual function in case this class overrides it */
page->PgSeltreeWidgetClicked();
+ } else {
+ Dmsg0(000, "Page not in hash");
}
}
void MainWin::browseButtonClicked()
{
- new restoreTree();
+// new restoreTree();
}
void MainWin::statusPageButtonClicked()
{
va_list arg_ptr;
char buf[1000];
- int len;
va_start(arg_ptr, fmt);
- len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
+ bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
va_end(arg_ptr);
set_status(buf);
}
void MainWin::undockWindowButton()
{
Pages* page = (Pages*)tabWidget->currentWidget();
- page->togglePageDocking();
+ if (page) {
+ page->togglePageDocking();
+ }
}
/*
/* Is this a page that has been inserted into the hash */
if (getFromHash(currentitem)) {
Pages* page = getFromHash(currentitem);
- page->togglePageDocking();
+ if (page) {
+ page->togglePageDocking();
+ }
}
}
if (m_isClosing) return; /* if closing the application, do nothing here */
Pages* page = (Pages*)tabWidget->currentWidget();
/* run the virtual function in case this class overrides it */
- page->currentStackItem();
+ if (page) {
+ page->currentStackItem();
+ }
if (!m_waitState) {
disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
return m_widgethash.value(page);
}
+void MainWin::closeCurrentPage()
+{
+ closePage(-1);
+}
+
/*
* Function to respond to action on page selector context menu to close the
* current window.
*/
-void MainWin::closePage()
+void MainWin::closePage(int item)
{
- QTreeWidgetItem *currentitem = treeWidget->currentItem();
+ QTreeWidgetItem *currentitem;
+ Pages *page = NULL;
+
+ if (item >= 0) {
+ page = (Pages *)tabWidget->widget(item);
+ } else {
+ currentitem = treeWidget->currentItem();
+ /* Is this a page that has been inserted into the hash */
+ if (getFromHash(currentitem)) {
+ page = getFromHash(currentitem);
+ }
+ }
- /* Is this a page that has been inserted into the hash */
- if (getFromHash(currentitem)) {
- Pages* page = getFromHash(currentitem);
+ if (page) {
if (page->isCloseable()) {
page->closeStackPage();
+ } else {
+ page->hidePage();
}
}
}
}
/* Preferences dialog */
-prefsDialog::prefsDialog()
+prefsDialog::prefsDialog() : QDialog()
{
setupUi(this);
}