From 3016749f301abc92991a9a5eac9597b9267ddb02 Mon Sep 17 00:00:00 2001
From: tuxmaster <frank@bart.netz-von-frank>
Date: Mon, 30 Dec 2013 00:55:58 +0100
Subject: [PATCH 2/3] - make it work under Qt 5

---
 src/qt-console/bcomm/dircomm.cpp       |  586 +++++-----
 src/qt-console/clients/clients.cpp     |    5 +
 src/qt-console/console/console.cpp     |  421 +++----
 src/qt-console/job/job.cpp             |  446 ++++----
 src/qt-console/joblist/joblist.cpp     |    6 +
 src/qt-console/joblist/joblist.h       |    5 +
 src/qt-console/joblog/joblog.cpp       |  117 +-
 src/qt-console/label/label.cpp         |    5 +
 src/qt-console/main.cpp                |    6 +-
 src/qt-console/mainwin.cpp             |  524 ++++-----
 src/qt-console/mediaedit/mediaedit.cpp |    5 +
 src/qt-console/mediainfo/mediainfo.cpp |    9 +
 src/qt-console/medialist/medialist.cpp |    5 +
 src/qt-console/medialist/mediaview.cpp |   13 +
 src/qt-console/mount/mount.cpp         |    5 +
 src/qt-console/pages.cpp               |  138 +--
 src/qt-console/pages.h                 |    5 +
 src/qt-console/relabel/relabel.cpp     |    5 +
 src/qt-console/restore/prerestore.cpp  |  312 ++---
 src/qt-console/restore/restore.cpp     |  422 +++----
 src/qt-console/restore/restoretree.cpp | 1938 ++++++++++++++++----------------
 src/qt-console/run/run.cpp             |   74 +-
 src/qt-console/select/select.cpp       |   19 +-
 src/qt-console/storage/content.cpp     |    5 +
 src/qt-console/storage/storage.h       |    5 +
 src/qt-console/util/comboutil.cpp      |    6 +-
 src/qt-console/util/fmtwidgetitem.cpp  |   17 +-
 src/qt-console/util/fmtwidgetitem.h    |   30 +-
 28 files changed, 2655 insertions(+), 2479 deletions(-)

diff --git a/src/qt-console/bcomm/dircomm.cpp b/src/qt-console/bcomm/dircomm.cpp
index 5900b12..0bdf7c9 100644
--- a/src/qt-console/bcomm/dircomm.cpp
+++ b/src/qt-console/bcomm/dircomm.cpp
@@ -24,6 +24,12 @@
  * Kern Sibbald, January MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
+
 #include "bat.h"
 #include "restore/restore.h"
 #include "select/select.h"
@@ -53,17 +59,17 @@ DirComm::~DirComm()
 void DirComm::terminate()
 {
    if (m_sock) {
-      if (m_notifier) {
-         m_notifier->setEnabled(false);
-         delete m_notifier;
-         m_notifier = NULL;
-         m_notify = false;
-      }
-      if (mainWin->m_connDebug)
-         Pmsg2(000, "DirComm %i terminating connections %s\n", m_conn, m_console->m_dir->name());
-      m_sock->close();
-      delete m_sock;
-      m_sock = NULL;
+	  if (m_notifier) {
+		 m_notifier->setEnabled(false);
+		 delete m_notifier;
+		 m_notifier = NULL;
+		 m_notify = false;
+	  }
+	  if (mainWin->m_connDebug)
+		 Pmsg2(000, "DirComm %i terminating connections %s\n", m_conn, m_console->m_dir->name());
+	  m_sock->close();
+	  delete m_sock;
+	  m_sock = NULL;
    }
 }
 
@@ -80,13 +86,13 @@ bool DirComm::connect_dir()
    buf[0] = 0;
 
    if (m_sock) {
-      mainWin->set_status( tr("Already connected."));
-      m_console->display_textf(_("Already connected\"%s\".\n"),
-            m_console->m_dir->name());
-      if (mainWin->m_connDebug) {
-         Pmsg2(000, "DirComm %i BAILING already connected %s\n", m_conn, m_console->m_dir->name());
-      }
-      goto bail_out;
+	  mainWin->set_status( tr("Already connected."));
+	  m_console->display_textf(_("Already connected\"%s\".\n"),
+			m_console->m_dir->name());
+	  if (mainWin->m_connDebug) {
+		 Pmsg2(000, "DirComm %i BAILING already connected %s\n", m_conn, m_console->m_dir->name());
+	  }
+	  goto bail_out;
    }
 
    if (mainWin->m_connDebug)Pmsg2(000, "DirComm %i connecting %s\n", m_conn, m_console->m_dir->name());
@@ -94,7 +100,7 @@ bool DirComm::connect_dir()
 
    mainWin->set_statusf(_("Connecting to Director %s:%d"), m_console->m_dir->address, m_console->m_dir->DIRport);
    if (m_conn == 0) {
-      m_console->display_textf(_("Connecting to Director %s:%d\n\n"), m_console->m_dir->address, m_console->m_dir->DIRport);
+	  m_console->display_textf(_("Connecting to Director %s:%d\n\n"), m_console->m_dir->address, m_console->m_dir->DIRport);
    }
 
    /* Give GUI a chance */
@@ -107,100 +113,100 @@ bool DirComm::connect_dir()
 
    /* Initialize Console TLS context once */
    if (cons && !cons->tls_ctx && (cons->tls_enable || cons->tls_require)) {
-      /* Generate passphrase prompt */
-      bsnprintf(buf, sizeof(buf), "Passphrase for Console \"%s\" TLS private key: ",
-                cons->name());
-
-      /* Initialize TLS context:
-       * Args: CA certfile, CA certdir, Certfile, Keyfile,
-       * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer
-       */
-      cons->tls_ctx = new_tls_context(cons->tls_ca_certfile,
-         cons->tls_ca_certdir, cons->tls_crlfile, cons->tls_certfile,
-         cons->tls_keyfile, tls_pem_callback, &buf, NULL, cons->tls_verify_peer);
-
-      if (!cons->tls_ctx) {
-         m_console->display_textf(_("Failed to initialize TLS context for Console \"%s\".\n"),
-            m_console->m_dir->name());
-         if (mainWin->m_connDebug) {
-            Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Console %s\n", m_conn, m_console->m_dir->name());
-         }
-         goto bail_out;
-      }
-
-      set_tls_enable(cons->tls_ctx, cons->tls_enable);
-      set_tls_require(cons->tls_ctx, cons->tls_require);
+	  /* Generate passphrase prompt */
+	  bsnprintf(buf, sizeof(buf), "Passphrase for Console \"%s\" TLS private key: ",
+				cons->name());
+
+	  /* Initialize TLS context:
+	   * Args: CA certfile, CA certdir, Certfile, Keyfile,
+	   * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer
+	   */
+	  cons->tls_ctx = new_tls_context(cons->tls_ca_certfile,
+		 cons->tls_ca_certdir, cons->tls_crlfile, cons->tls_certfile,
+		 cons->tls_keyfile, tls_pem_callback, &buf, NULL, cons->tls_verify_peer);
+
+	  if (!cons->tls_ctx) {
+		 m_console->display_textf(_("Failed to initialize TLS context for Console \"%s\".\n"),
+			m_console->m_dir->name());
+		 if (mainWin->m_connDebug) {
+			Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Console %s\n", m_conn, m_console->m_dir->name());
+		 }
+		 goto bail_out;
+	  }
+
+	  set_tls_enable(cons->tls_ctx, cons->tls_enable);
+	  set_tls_require(cons->tls_ctx, cons->tls_require);
    }
 
    /* Initialize Director TLS context once */
    if (!m_console->m_dir->tls_ctx && (m_console->m_dir->tls_enable || m_console->m_dir->tls_require)) {
-      /* Generate passphrase prompt */
-      bsnprintf(buf, sizeof(buf), "Passphrase for Director \"%s\" TLS private key: ",
-                m_console->m_dir->name());
-
-      /* Initialize TLS context:
-       * Args: CA certfile, CA certdir, Certfile, Keyfile,
-       * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
-      m_console->m_dir->tls_ctx = new_tls_context(m_console->m_dir->tls_ca_certfile,
-                          m_console->m_dir->tls_ca_certdir, m_console->m_dir->tls_crlfile,
-                          m_console->m_dir->tls_certfile, m_console->m_dir->tls_keyfile,
-                          tls_pem_callback, &buf, NULL, m_console->m_dir->tls_verify_peer);
-
-      if (!m_console->m_dir->tls_ctx) {
-         m_console->display_textf(_("Failed to initialize TLS context for Director \"%s\".\n"),
-            m_console->m_dir->name());
-         mainWin->set_status("Connection failed");
-         if (mainWin->m_connDebug) {
-            Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Director %s\n", m_conn, m_console->m_dir->name());
-         }
-         goto bail_out;
-      }
-
-      set_tls_enable(m_console->m_dir->tls_ctx, m_console->m_dir->tls_enable);
-      set_tls_require(m_console->m_dir->tls_ctx, m_console->m_dir->tls_require);
+	  /* Generate passphrase prompt */
+	  bsnprintf(buf, sizeof(buf), "Passphrase for Director \"%s\" TLS private key: ",
+				m_console->m_dir->name());
+
+	  /* Initialize TLS context:
+	   * Args: CA certfile, CA certdir, Certfile, Keyfile,
+	   * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
+	  m_console->m_dir->tls_ctx = new_tls_context(m_console->m_dir->tls_ca_certfile,
+						  m_console->m_dir->tls_ca_certdir, m_console->m_dir->tls_crlfile,
+						  m_console->m_dir->tls_certfile, m_console->m_dir->tls_keyfile,
+						  tls_pem_callback, &buf, NULL, m_console->m_dir->tls_verify_peer);
+
+	  if (!m_console->m_dir->tls_ctx) {
+		 m_console->display_textf(_("Failed to initialize TLS context for Director \"%s\".\n"),
+			m_console->m_dir->name());
+		 mainWin->set_status("Connection failed");
+		 if (mainWin->m_connDebug) {
+			Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Director %s\n", m_conn, m_console->m_dir->name());
+		 }
+		 goto bail_out;
+	  }
+
+	  set_tls_enable(m_console->m_dir->tls_ctx, m_console->m_dir->tls_enable);
+	  set_tls_require(m_console->m_dir->tls_ctx, m_console->m_dir->tls_require);
    }
 
    if (m_console->m_dir->heartbeat_interval) {
-      heart_beat = m_console->m_dir->heartbeat_interval;
+	  heart_beat = m_console->m_dir->heartbeat_interval;
    } else if (cons) {
-      heart_beat = cons->heartbeat_interval;
+	  heart_beat = cons->heartbeat_interval;
    } else {
-      heart_beat = 0;
+	  heart_beat = 0;
    }
 
    m_sock = New(BSOCK_TCP);
    if (!m_sock->connect(NULL, 5, 15, heart_beat, "Director daemon",
-                        m_console->m_dir->address, NULL,
-                        m_console->m_dir->DIRport, false)) {
-      mainWin->set_status("Connection failed");
-      if (mainWin->m_connDebug) {
-         Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name());
-      }
-      delete m_sock;
-      m_sock = NULL;
-      goto bail_out;
+						m_console->m_dir->address, NULL,
+						m_console->m_dir->DIRport, false)) {
+	  mainWin->set_status("Connection failed");
+	  if (mainWin->m_connDebug) {
+		 Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name());
+	  }
+	  delete m_sock;
+	  m_sock = NULL;
+	  goto bail_out;
    } else {
-      /* Update page selector to green to indicate that Console is connected */
-      mainWin->actionConnect->setIcon(QIcon(":images/connected.png"));
-      QBrush greenBrush(Qt::green);
-      QTreeWidgetItem *item = mainWin->getFromHash(m_console);
-      if (item) {
-         item->setForeground(0, greenBrush);
-      }
+	  /* Update page selector to green to indicate that Console is connected */
+	  mainWin->actionConnect->setIcon(QIcon(":images/connected.png"));
+	  QBrush greenBrush(Qt::green);
+	  QTreeWidgetItem *item = mainWin->getFromHash(m_console);
+	  if (item) {
+		 item->setForeground(0, greenBrush);
+	  }
    }
 
    jcr->dir_bsock = m_sock;
 
    if (!authenticate_with_director(jcr, m_console->m_dir, cons, buf, sizeof(buf))) {
-      m_console->display_text(buf);
-      if (mainWin->m_connDebug) {
-         Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name());
-      }
-      goto bail_out;
+	  m_console->display_text(buf);
+	  if (mainWin->m_connDebug) {
+		 Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name());
+	  }
+	  goto bail_out;
    }
 
    if (buf[0]) {
-      m_console->display_text(buf);
+	  m_console->display_text(buf);
    }
 
    /* Give GUI a chance */
@@ -209,8 +215,8 @@ bool DirComm::connect_dir()
    mainWin->set_status(_("Initializing ..."));
 
    /*
-    * Set up input notifier
-    */
+	* Set up input notifier
+	*/
    m_notifier = new QSocketNotifier(m_sock->m_fd, QSocketNotifier::Read, 0);
    QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(notify_read_dir(int)));
    m_notifier->setEnabled(true);
@@ -225,13 +231,13 @@ bool DirComm::connect_dir()
    mainWin->set_status(_("Connected"));
 
    if (mainWin->m_connDebug) {
-      Pmsg2(000, "Returning TRUE from DirComm->connect_dir : %i %s\n", m_conn, m_console->m_dir->name());
+	  Pmsg2(000, "Returning TRUE from DirComm->connect_dir : %i %s\n", m_conn, m_console->m_dir->name());
    }
    return true;
 
 bail_out:
    if (mainWin->m_connDebug) {
-      Pmsg2(000, "Returning FALSE from DirComm->connect_dir : %i %s\n", m_conn, m_console->m_dir->name());
+	  Pmsg2(000, "Returning FALSE from DirComm->connect_dir : %i %s\n", m_conn, m_console->m_dir->name());
    }
    delete jcr;
    return false;
@@ -243,7 +249,7 @@ bail_out:
 char *DirComm::msg()
 {
    if (m_sock) {
-      return m_sock->msg;
+	  return m_sock->msg;
    }
    return NULL;
 }
@@ -256,23 +262,23 @@ int DirComm::write(QString msg)
 int DirComm::write(const char *msg)
 {
    if (!m_sock) {
-      return -1;
+	  return -1;
    }
    m_sock->msglen = pm_strcpy(m_sock->msg, msg);
    m_at_prompt = false;
    m_at_main_prompt = false;
    if (mainWin->m_commDebug) Pmsg2(000, "conn %i send: %s\n", m_conn, msg);
    /*
-    * Ensure we send only one blank line.  Multiple blank lines are
-    *  simply discarded, it keeps the console output looking nicer.
-    */
+	* Ensure we send only one blank line.  Multiple blank lines are
+	*  simply discarded, it keeps the console output looking nicer.
+	*/
    if (m_sock->msglen == 0 || (m_sock->msglen == 1 && *m_sock->msg == '\n')) {
-      if (!m_sent_blank) {
-         m_sent_blank = true;
-         return m_sock->send();
-      } else {
-         return -1;             /* discard multiple blanks */
-      }
+	  if (!m_sent_blank) {
+		 m_sent_blank = true;
+		 return m_sock->send();
+	  } else {
+		 return -1;             /* discard multiple blanks */
+	  }
    }
    m_sent_blank = false;        /* clear flag */
    return m_sock->send();
@@ -299,172 +305,172 @@ int DirComm::read()
    int stat = -1;
 
    if (!m_sock) {
-      return -1;
+	  return -1;
    }
    while (m_sock) {
-      for (;;) {
-         if (!m_sock) break;
-         stat = m_sock->wait_data_intr(0, 50000);
-         if (stat > 0) {
-            break;
-         }
-         app->processEvents();
-         if (m_api_set && m_console->is_messagesPending() && is_notify_enabled() && m_console->hasFocus()) {
-            if (mainWin->m_commDebug) Pmsg1(000, "conn %i process_events\n", m_conn);
-            m_console->messagesPending(false);
-            m_console->write_dir(m_conn, ".messages", false);
-         }
-      }
-      if (!m_sock) {
-         return -1;
-      }
-      m_sock->msg[0] = 0;
-      stat = sock_read();
-      if (stat >= 0) {
-         if (mainWin->m_commDebug) Pmsg2(000, "conn %i got: %s\n", m_conn, m_sock->msg);
-         if (m_at_prompt) {
-            m_console->display_text("\n");
-            m_at_prompt = false;
-            m_at_main_prompt = false;
-         }
-      }
-      switch (m_sock->msglen) {
-      case BNET_MSGS_PENDING :
-         if (is_notify_enabled() && m_console->hasFocus()) {
-            m_console->messagesPending(false);
-            if (mainWin->m_commDebug) Pmsg1(000, "conn %i MSGS PENDING\n", m_conn);
-            m_console->write_dir(m_conn, ".messages", false);
-            m_console->displayToPrompt(m_conn);
-            continue;
-         }
-         m_console->messagesPending(true);
-         continue;
-      case BNET_CMD_OK:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i CMD OK\n", m_conn);
-         m_at_prompt = false;
-         m_at_main_prompt = false;
-         if (--m_in_command < 0) {
-            m_in_command = 0;
-         }
-         mainWin->set_status(_("Command completed ..."));
-         continue;
-      case BNET_CMD_BEGIN:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i CMD BEGIN\n", m_conn);
-         m_at_prompt = false;
-         m_at_main_prompt = false;
-         m_in_command++;
-         mainWin->set_status(_("Processing command ..."));
-         continue;
-      case BNET_MAIN_PROMPT:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i MAIN PROMPT\n", m_conn);
-         if (!m_at_prompt && ! m_at_main_prompt) {
-            m_at_prompt = true;
-            m_at_main_prompt = true;
-            mainWin->set_status(_("At main prompt waiting for input ..."));
-         }
-         break;
-      case BNET_SUB_PROMPT:
-         if (mainWin->m_commDebug) Pmsg2(000, "conn %i SUB_PROMPT m_in_select=%d\n", m_conn, m_in_select);
-         m_at_prompt = true;
-         m_at_main_prompt = false;
-         mainWin->set_status(_("At prompt waiting for input ..."));
-         break;
-      case BNET_TEXT_INPUT:
-         if (mainWin->m_commDebug) Pmsg4(000, "conn %i TEXT_INPUT at_prompt=%d  m_in_select=%d notify=%d\n",
-               m_conn, m_at_prompt, m_in_select, is_notify_enabled());
-         //if (!m_in_select && is_notify_enabled()) {
-         if (!m_in_select) {
-            mainWin->waitExit();
-            new textInputDialog(m_console, m_conn);
-         } else {
-            if (mainWin->m_commDebug) Pmsg0(000, "!m_in_select && is_notify_enabled\n");
-            m_at_prompt = true;
-            m_at_main_prompt = false;
-            mainWin->set_status(_("At prompt waiting for input ..."));
-         }
-         break;
-      case BNET_CMD_FAILED:
-         if (mainWin->m_commDebug) Pmsg1(000, "CMD FAILED\n", m_conn);
-         if (--m_in_command < 0) {
-            m_in_command = 0;
-         }
-         mainWin->set_status(_("Command failed."));
-         break;
-      /* We should not get this one */
-      case BNET_EOD:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i EOD\n", m_conn);
-         mainWin->set_status_ready();
-         if (!m_api_set) {
-            break;
-         }
-         continue;
-      case BNET_START_SELECT:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i START SELECT\n", m_conn);
-         m_in_select = true;
-         new selectDialog(m_console, m_conn);
-         m_in_select = false;
-         break;
-      case BNET_YESNO:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i YESNO\n", m_conn);
-         new yesnoPopUp(m_console, m_conn);
-         break;
-      case BNET_RUN_CMD:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i RUN CMD\n", m_conn);
-         new runCmdPage(m_conn);
-         break;
-      case BNET_START_RTREE:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i START RTREE CMD\n", m_conn);
-         new restorePage(m_conn);
-         break;
-      case BNET_END_RTREE:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i END RTREE CMD\n", m_conn);
-         break;
-      case BNET_ERROR_MSG:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i ERROR MSG\n", m_conn);
-         stat = sock_read();          /* get the message */
-         m_console->display_text(msg());
-         QMessageBox::critical(m_console, "Error", msg(), QMessageBox::Ok);
-         m_console->beginNewCommand(m_conn);
-         mainWin->waitExit();
-         break;
-      case BNET_WARNING_MSG:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i WARNING MSG\n", m_conn);
-         stat = sock_read();          /* get the message */
-         if (!m_console->m_warningPrevent) {
-            QMessageBox::critical(m_console, "Warning", msg(), QMessageBox::Ok);
-         }
-         break;
-      case BNET_INFO_MSG:
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i INFO MSG\n", m_conn);
-         stat = sock_read();          /* get the message */
-         m_console->display_text(msg());
-         mainWin->set_status(msg());
-         break;
-      }
-
-      if (!m_sock) {
-         stat = BNET_HARDEOF;
-         return stat;
-      }
-      if (is_bnet_stop(m_sock)) {         /* error or term request */
-         if (mainWin->m_commDebug) Pmsg1(000, "conn %i BNET STOP\n", m_conn);
-         m_console->stopTimer();
-         m_sock->close();
-         m_sock = NULL;
-         mainWin->actionConnect->setIcon(QIcon(":images/disconnected.png"));
-         QBrush redBrush(Qt::red);
-         QTreeWidgetItem *item = mainWin->getFromHash(m_console);
-         item->setForeground(0, redBrush);
-         if (m_notifier) {
-            m_notifier->setEnabled(false);
-            delete m_notifier;
-            m_notifier = NULL;
-            m_notify = false;
-         }
-         mainWin->set_status(_("Director disconnected."));
-         stat = BNET_HARDEOF;
-      }
-      break;
+	  for (;;) {
+		 if (!m_sock) break;
+		 stat = m_sock->wait_data_intr(0, 50000);
+		 if (stat > 0) {
+			break;
+		 }
+		 app->processEvents();
+		 if (m_api_set && m_console->is_messagesPending() && is_notify_enabled() && m_console->hasFocus()) {
+			if (mainWin->m_commDebug) Pmsg1(000, "conn %i process_events\n", m_conn);
+			m_console->messagesPending(false);
+			m_console->write_dir(m_conn, ".messages", false);
+		 }
+	  }
+	  if (!m_sock) {
+		 return -1;
+	  }
+	  m_sock->msg[0] = 0;
+	  stat = sock_read();
+	  if (stat >= 0) {
+		 if (mainWin->m_commDebug) Pmsg2(000, "conn %i got: %s\n", m_conn, m_sock->msg);
+		 if (m_at_prompt) {
+			m_console->display_text("\n");
+			m_at_prompt = false;
+			m_at_main_prompt = false;
+		 }
+	  }
+	  switch (m_sock->msglen) {
+	  case BNET_MSGS_PENDING :
+		 if (is_notify_enabled() && m_console->hasFocus()) {
+			m_console->messagesPending(false);
+			if (mainWin->m_commDebug) Pmsg1(000, "conn %i MSGS PENDING\n", m_conn);
+			m_console->write_dir(m_conn, ".messages", false);
+			m_console->displayToPrompt(m_conn);
+			continue;
+		 }
+		 m_console->messagesPending(true);
+		 continue;
+	  case BNET_CMD_OK:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i CMD OK\n", m_conn);
+		 m_at_prompt = false;
+		 m_at_main_prompt = false;
+		 if (--m_in_command < 0) {
+			m_in_command = 0;
+		 }
+		 mainWin->set_status(_("Command completed ..."));
+		 continue;
+	  case BNET_CMD_BEGIN:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i CMD BEGIN\n", m_conn);
+		 m_at_prompt = false;
+		 m_at_main_prompt = false;
+		 m_in_command++;
+		 mainWin->set_status(_("Processing command ..."));
+		 continue;
+	  case BNET_MAIN_PROMPT:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i MAIN PROMPT\n", m_conn);
+		 if (!m_at_prompt && ! m_at_main_prompt) {
+			m_at_prompt = true;
+			m_at_main_prompt = true;
+			mainWin->set_status(_("At main prompt waiting for input ..."));
+		 }
+		 break;
+	  case BNET_SUB_PROMPT:
+		 if (mainWin->m_commDebug) Pmsg2(000, "conn %i SUB_PROMPT m_in_select=%d\n", m_conn, m_in_select);
+		 m_at_prompt = true;
+		 m_at_main_prompt = false;
+		 mainWin->set_status(_("At prompt waiting for input ..."));
+		 break;
+	  case BNET_TEXT_INPUT:
+		 if (mainWin->m_commDebug) Pmsg4(000, "conn %i TEXT_INPUT at_prompt=%d  m_in_select=%d notify=%d\n",
+			   m_conn, m_at_prompt, m_in_select, is_notify_enabled());
+		 //if (!m_in_select && is_notify_enabled()) {
+		 if (!m_in_select) {
+			mainWin->waitExit();
+			new textInputDialog(m_console, m_conn);
+		 } else {
+			if (mainWin->m_commDebug) Pmsg0(000, "!m_in_select && is_notify_enabled\n");
+			m_at_prompt = true;
+			m_at_main_prompt = false;
+			mainWin->set_status(_("At prompt waiting for input ..."));
+		 }
+		 break;
+	  case BNET_CMD_FAILED:
+		 if (mainWin->m_commDebug) Pmsg1(000, "CMD FAILED\n", m_conn);
+		 if (--m_in_command < 0) {
+			m_in_command = 0;
+		 }
+		 mainWin->set_status(_("Command failed."));
+		 break;
+	  /* We should not get this one */
+	  case BNET_EOD:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i EOD\n", m_conn);
+		 mainWin->set_status_ready();
+		 if (!m_api_set) {
+			break;
+		 }
+		 continue;
+	  case BNET_START_SELECT:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i START SELECT\n", m_conn);
+		 m_in_select = true;
+		 new selectDialog(m_console, m_conn);
+		 m_in_select = false;
+		 break;
+	  case BNET_YESNO:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i YESNO\n", m_conn);
+		 new yesnoPopUp(m_console, m_conn);
+		 break;
+	  case BNET_RUN_CMD:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i RUN CMD\n", m_conn);
+		 new runCmdPage(m_conn);
+		 break;
+	  case BNET_START_RTREE:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i START RTREE CMD\n", m_conn);
+		 new restorePage(m_conn);
+		 break;
+	  case BNET_END_RTREE:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i END RTREE CMD\n", m_conn);
+		 break;
+	  case BNET_ERROR_MSG:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i ERROR MSG\n", m_conn);
+		 stat = sock_read();          /* get the message */
+		 m_console->display_text(msg());
+		 QMessageBox::critical(m_console, "Error", msg(), QMessageBox::Ok);
+		 m_console->beginNewCommand(m_conn);
+		 mainWin->waitExit();
+		 break;
+	  case BNET_WARNING_MSG:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i WARNING MSG\n", m_conn);
+		 stat = sock_read();          /* get the message */
+		 if (!m_console->m_warningPrevent) {
+			QMessageBox::critical(m_console, "Warning", msg(), QMessageBox::Ok);
+		 }
+		 break;
+	  case BNET_INFO_MSG:
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i INFO MSG\n", m_conn);
+		 stat = sock_read();          /* get the message */
+		 m_console->display_text(msg());
+		 mainWin->set_status(msg());
+		 break;
+	  }
+
+	  if (!m_sock) {
+		 stat = BNET_HARDEOF;
+		 return stat;
+	  }
+	  if (is_bnet_stop(m_sock)) {         /* error or term request */
+		 if (mainWin->m_commDebug) Pmsg1(000, "conn %i BNET STOP\n", m_conn);
+		 m_console->stopTimer();
+		 m_sock->close();
+		 m_sock = NULL;
+		 mainWin->actionConnect->setIcon(QIcon(":images/disconnected.png"));
+		 QBrush redBrush(Qt::red);
+		 QTreeWidgetItem *item = mainWin->getFromHash(m_console);
+		 item->setForeground(0, redBrush);
+		 if (m_notifier) {
+			m_notifier->setEnabled(false);
+			delete m_notifier;
+			m_notifier = NULL;
+			m_notify = false;
+		 }
+		 mainWin->set_status(_("Director disconnected."));
+		 stat = BNET_HARDEOF;
+	  }
+	  break;
    }
    return stat;
 }
@@ -474,15 +480,15 @@ void DirComm::notify_read_dir(int /* fd */)
 {
    int stat;
    if (!mainWin->m_notify) {
-      return;
+	  return;
    }
    if (mainWin->m_commDebug) Pmsg1(000, "enter read_dir conn %i read_dir\n", m_conn);
    stat = m_sock->wait_data(0, 5000);
    if (stat > 0) {
-      if (mainWin->m_commDebug) Pmsg2(000, "read_dir conn %i stat=%d\n", m_conn, stat);
-      while (read() >= 0) {
-         m_console->display_text(msg());
-      }
+	  if (mainWin->m_commDebug) Pmsg2(000, "read_dir conn %i stat=%d\n", m_conn, stat);
+	  while (read() >= 0) {
+		 m_console->display_text(msg());
+	  }
    }
    if (mainWin->m_commDebug) Pmsg2(000, "exit read_dir conn %i stat=%d\n", m_conn, stat);
 }
@@ -503,12 +509,12 @@ bool DirComm::notify(bool enable)
    /* Set global flag */
    mainWin->m_notify = enable;
    if (m_notifier) {
-      prev_enabled = m_notifier->isEnabled();
-      m_notifier->setEnabled(enable);
-      m_notify = enable;
-      if (mainWin->m_connDebug) Pmsg3(000, "conn=%i set_notify=%d prev=%d\n", m_conn, enable, prev_enabled);
+	  prev_enabled = m_notifier->isEnabled();
+	  m_notifier->setEnabled(enable);
+	  m_notify = enable;
+	  if (mainWin->m_connDebug) Pmsg3(000, "conn=%i set_notify=%d prev=%d\n", m_conn, enable, prev_enabled);
    } else if (mainWin->m_connDebug) {
-      Pmsg2(000, "m_notifier does not exist: %i %s\n", m_conn, m_console->m_dir->name());
+	  Pmsg2(000, "m_notifier does not exist: %i %s\n", m_conn, m_console->m_dir->name());
    }
    return prev_enabled;
 }
@@ -531,10 +537,10 @@ static int tls_pem_callback(char *buf, int size, const void *userdata)
 # if defined(HAVE_WIN32)
    //sendit(prompt);
    if (win32_cgets(buf, size) == NULL) {
-      buf[0] = 0;
-      return 0;
+	  buf[0] = 0;
+	  return 0;
    } else {
-      return strlen(buf);
+	  return strlen(buf);
    }
 # else
    const char *prompt = (const char *)userdata;
@@ -551,7 +557,7 @@ static int tls_pem_callback(char *buf, int size, const void *userdata)
 }
 
 bool DirComm::authenticate_with_director(JCR *jcr, DIRRES *director, CONRES *cons,
-                                         char *errmsg, int errmsg_len)
+										 char *errmsg, int errmsg_len)
 {
    const char *name;
    char *password;
@@ -560,13 +566,13 @@ bool DirComm::authenticate_with_director(JCR *jcr, DIRRES *director, CONRES *con
 
    errmsg[0] = 0;
    if (cons) {
-      name = cons->hdr.name;
-      password = cons->password;
-      tls_ctx = cons->tls_ctx;
+	  name = cons->hdr.name;
+	  password = cons->password;
+	  tls_ctx = cons->tls_ctx;
    } else {
-      name = "*UserAgent*";
-      password = director->password;
-      tls_ctx = director->tls_ctx;
+	  name = "*UserAgent*";
+	  password = director->password;
+	  tls_ctx = director->tls_ctx;
    }
 
    return dir->authenticate_with_director(name, password, tls_ctx, errmsg, errmsg_len);
diff --git a/src/qt-console/clients/clients.cpp b/src/qt-console/clients/clients.cpp
index 4a00fc9..ab867aa 100644
--- a/src/qt-console/clients/clients.cpp
+++ b/src/qt-console/clients/clients.cpp
@@ -25,6 +25,11 @@
  * Dirk Bartley, March 2007
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
diff --git a/src/qt-console/console/console.cpp b/src/qt-console/console/console.cpp
index b357402..7399fce 100644
--- a/src/qt-console/console/console.cpp
+++ b/src/qt-console/console/console.cpp
@@ -24,6 +24,13 @@
  * Kern Sibbald, January MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+	#include <QFontDialog>
+#endif
+
 #include "bat.h"
 #include "console.h"
 #include "restore/restore.h"
@@ -42,8 +49,8 @@ Console::Console(QTabWidget *parent) : Pages()
    m_dircommCounter = 0;
 
    /*
-    * Create a connection to the Director and put it in a hash table
-    */
+	* Create a connection to the Director and put it in a hash table
+	*/
    m_dircommHash.insert(m_dircommCounter, new DirComm(this, m_dircommCounter));
 
    setupUi(this);
@@ -76,10 +83,10 @@ void Console::startTimer()
 void Console::stopTimer()
 {
    if (m_timer) {
-      QWidget::disconnect(m_timer, SIGNAL(timeout()), this, SLOT(poll_messages()));
-      m_timer->stop();
-      delete m_timer;
-      m_timer = NULL;
+	  QWidget::disconnect(m_timer, SIGNAL(timeout()), this, SLOT(poll_messages()));
+	  m_timer->stop();
+	  delete m_timer;
+	  m_timer = NULL;
    }
 }
 
@@ -91,22 +98,22 @@ void Console::poll_messages()
 
    /* Do not poll if notifier off */
    if (!mainWin->m_notify) {
-      return;
+	  return;
    }
 
    /*
-    * Note if we call getDirComm here, we continuously consume
-    *  file descriptors.
-    */
+	* Note if we call getDirComm here, we continuously consume
+	*  file descriptors.
+	*/
    if (!findDirComm(conn)) {    /* find a free DirComm */
-      return;                   /* try later */
+	  return;                   /* try later */
    }
 
    DirComm *dircomm = m_dircommHash.value(conn);
    if (mainWin->m_checkMessages && dircomm->m_at_main_prompt && hasFocus() && !mainWin->getWaitState()){
-      dircomm->write(".messages");
-      displayToPrompt(conn);
-      messagesPending(false);
+	  dircomm->write(".messages");
+	  displayToPrompt(conn);
+	  messagesPending(false);
    }
 }
 
@@ -119,17 +126,17 @@ void Console::connect_dir()
    DirComm *dircomm = m_dircommHash.value(0);
 
    if (!m_console->m_dir) {
-      mainWin->set_status( tr("No Director found."));
-      return;
+	  mainWin->set_status( tr("No Director found."));
+	  return;
    }
 
    m_textEdit = textEdit;   /* our console screen */
 
    if (dircomm->connect_dir()) {
-      if (mainWin->m_connDebug) {
-         Pmsg1(000, "DirComm 0 Seems to have Connected %s\n", m_dir->name());
-      }
-      beginNewCommand(0);
+	  if (mainWin->m_connDebug) {
+		 Pmsg1(000, "DirComm 0 Seems to have Connected %s\n", m_dir->name());
+	  }
+	  beginNewCommand(0);
    }
    mainWin->set_status(_("Connected"));
 
@@ -144,12 +151,12 @@ void Console::populateLists(bool /*forcenew*/)
 {
    int conn;
    if (!getDirComm(conn)) {
-      if (mainWin->m_connDebug) Pmsg0(000, "call newDirComm\n");
-      if (!newDirComm(conn)) {
-         Emsg1(M_ABORT, 0, _("Failed to connect to director %s for populateLists."
-                             " Check, if director's address or hostname is configured properly\n"), m_dir->name());
-         return;
-      }
+	  if (mainWin->m_connDebug) Pmsg0(000, "call newDirComm\n");
+	  if (!newDirComm(conn)) {
+		 Emsg1(M_ABORT, 0, _("Failed to connect to director %s for populateLists."
+							 " Check, if director's address or hostname is configured properly\n"), m_dir->name());
+		 return;
+	  }
    }
    populateLists(conn);
    notify(conn, true);
@@ -182,11 +189,11 @@ void Console::populateLists(int conn)
    dir_cmd(conn, ".locations", location_list);
 
    if (mainWin->m_connDebug) {
-      QString dbgmsg = QString("jobs=%1 clients=%2 filesets=%3 msgs=%4 pools=%5 storage=%6 types=%7 levels=%8 conn=%9 %10\n")
-        .arg(job_list.count()).arg(client_list.count()).arg(fileset_list.count()).arg(messages_list.count())
-        .arg(pool_list.count()).arg(storage_list.count()).arg(type_list.count()).arg(level_list.count())
-        .arg(conn).arg(m_dir->name());
-      Pmsg1(000, "%s", dbgmsg.toUtf8().data());
+	  QString dbgmsg = QString("jobs=%1 clients=%2 filesets=%3 msgs=%4 pools=%5 storage=%6 types=%7 levels=%8 conn=%9 %10\n")
+		.arg(job_list.count()).arg(client_list.count()).arg(fileset_list.count()).arg(messages_list.count())
+		.arg(pool_list.count()).arg(storage_list.count()).arg(type_list.count()).arg(level_list.count())
+		.arg(conn).arg(m_dir->name());
+	  Pmsg1(000, "%s", dbgmsg.toUtf8().data());
    }
    job_list.sort();
    client_list.sort();
@@ -214,11 +221,11 @@ bool Console::dir_cmd(const char *cmd, QStringList &results)
 {
    int conn;
    if (getDirComm(conn)) {
-      dir_cmd(conn, cmd, results);
-      return true;
+	  dir_cmd(conn, cmd, results);
+	  return true;
    } else {
-      Pmsg1(000, "dir_cmd failed to connect to %s\n", m_dir->name());
-      return false;
+	  Pmsg1(000, "dir_cmd failed to connect to %s\n", m_dir->name());
+	  return false;
    }
 }
 
@@ -234,21 +241,21 @@ bool Console::dir_cmd(int conn, const char *cmd, QStringList &results)
    bool prev_notify = is_notify_enabled(conn);
 
    if (mainWin->m_connDebug) {
-      QString dbgmsg = QString("dir_cmd conn %1 %2 %3\n").arg(conn).arg(m_dir->name()).arg(cmd);
-      Pmsg1(000, "%s", dbgmsg.toUtf8().data());
+	  QString dbgmsg = QString("dir_cmd conn %1 %2 %3\n").arg(conn).arg(m_dir->name()).arg(cmd);
+	  Pmsg1(000, "%s", dbgmsg.toUtf8().data());
    }
    if (prev_notify) {
-      notify(conn, false);
+	  notify(conn, false);
    }
    dircomm->write(cmd);
    while ((stat = dircomm->read()) > 0 && dircomm->is_in_command()) {
-      if (mainWin->m_displayAll) display_text(dircomm->msg());
-      strip_trailing_newline(dircomm->msg());
-      results << dircomm->msg();
+	  if (mainWin->m_displayAll) display_text(dircomm->msg());
+	  strip_trailing_newline(dircomm->msg());
+	  results << dircomm->msg();
    }
    if (stat > 0 && mainWin->m_displayAll) display_text(dircomm->msg());
    if (prev_notify) {
-      notify(conn, true);         /* turn it back on */
+	  notify(conn, true);         /* turn it back on */
    }
    discardToPrompt(conn);
    mainWin->waitExit();
@@ -267,7 +274,7 @@ bool Console::sql_cmd(QString &query, QStringList &results)
 {
    int conn;
    if (!getDirComm(conn)) {
-      return false;
+	  return false;
    }
    return sql_cmd(conn, query.toUtf8().data(), results, true);
 }
@@ -276,7 +283,7 @@ bool Console::sql_cmd(const char *query, QStringList &results)
 {
    int conn;
    if (!getDirComm(conn)) {
-      return false;
+	  return false;
    }
    return sql_cmd(conn, query, results, true);
 }
@@ -293,12 +300,12 @@ bool Console::sql_cmd(int &conn, const char *query, QStringList &results, bool d
    bool prev_notify = is_notify_enabled(conn);
 
    if (!is_connectedGui()) {
-      return false;
+	  return false;
    }
 
    if (mainWin->m_connDebug) Pmsg2(000, "sql_cmd conn %i %s\n", conn, query);
    if (donotify) {
-      dircomm->notify(false);
+	  dircomm->notify(false);
    }
    mainWin->waitEnter();
 
@@ -307,29 +314,29 @@ bool Console::sql_cmd(int &conn, const char *query, QStringList &results, bool d
    pm_strcat(cmd, "\"");
    dircomm->write(cmd.c_str());
    while ((stat = dircomm->read()) > 0) {
-      bool first = true;
-      if (mainWin->m_displayAll) {
-         display_text(dircomm->msg());
-         display_text("\n");
-      }
-      strip_trailing_newline(dircomm->msg());
-      bool doappend = true;
-      if (first) {
-         QString dum = dircomm->msg();
-         if ((dum.left(6) == "*None*")) doappend = false;
-      }
-      if (doappend) {
-         results << dircomm->msg();
-      }
-      first = false;
+	  bool first = true;
+	  if (mainWin->m_displayAll) {
+		 display_text(dircomm->msg());
+		 display_text("\n");
+	  }
+	  strip_trailing_newline(dircomm->msg());
+	  bool doappend = true;
+	  if (first) {
+		 QString dum = dircomm->msg();
+		 if ((dum.left(6) == "*None*")) doappend = false;
+	  }
+	  if (doappend) {
+		 results << dircomm->msg();
+	  }
+	  first = false;
    }
    if (donotify && prev_notify) {
-      dircomm->notify(true);
+	  dircomm->notify(true);
    }
    discardToPrompt(conn);
    mainWin->waitExit();
    if (donotify && prev_notify) {
-      dircomm->notify(true);
+	  dircomm->notify(true);
    }
    return !mainWin->isClosing();      /* return false if closing */
 }
@@ -342,7 +349,7 @@ int Console::write_dir(const char *msg)
 {
    int conn;
    if (getDirComm(conn)) {
-      write_dir(conn, msg);
+	  write_dir(conn, msg);
    }
    return conn;
 }
@@ -351,7 +358,7 @@ int Console::write_dir(const char *msg, bool dowait)
 {
    int conn;
    if (getDirComm(conn)) {
-      write_dir(conn, msg, dowait);
+	  write_dir(conn, msg, dowait);
    }
    return conn;
 }
@@ -369,20 +376,20 @@ void Console::write_dir(int conn, const char *msg, bool dowait)
    DirComm *dircomm = m_dircommHash.value(conn);
 
    if (dircomm->m_sock) {
-      mainWin->set_status(_("Processing command ..."));
-      if (dowait)
-         mainWin->waitEnter();
-      dircomm->write(msg);
-      if (dowait)
-         mainWin->waitExit();
+	  mainWin->set_status(_("Processing command ..."));
+	  if (dowait)
+		 mainWin->waitEnter();
+	  dircomm->write(msg);
+	  if (dowait)
+		 mainWin->waitExit();
    } else {
-      mainWin->set_status( tr(" Director not connected. Click on connect button."));
-      mainWin->actionConnect->setIcon(QIcon(":images/disconnected.png"));
-      QBrush redBrush(Qt::red);
-      QTreeWidgetItem *item = mainWin->getFromHash(this);
-      item->setForeground(0, redBrush);
-      dircomm->m_at_prompt = false;
-      dircomm->m_at_main_prompt = false;
+	  mainWin->set_status( tr(" Director not connected. Click on connect button."));
+	  mainWin->actionConnect->setIcon(QIcon(":images/disconnected.png"));
+	  QBrush redBrush(Qt::red);
+	  QTreeWidgetItem *item = mainWin->getFromHash(this);
+	  item->setForeground(0, redBrush);
+	  dircomm->m_at_prompt = false;
+	  dircomm->m_at_main_prompt = false;
    }
 }
 
@@ -415,81 +422,81 @@ bool Console::get_job_defaults(int &conn, struct job_defaults &job_defs, bool do
    DirComm *dircomm = m_dircommHash.value(conn);
 
    if (donotify) {
-      dircomm->notify(false);
+	  dircomm->notify(false);
    }
    beginNewCommand(conn);
    bool prevWaitState = mainWin->getWaitState();
    if (!prevWaitState)
-      mainWin->waitEnter();
+	  mainWin->waitEnter();
    if (mainWin->m_connDebug)
-      Pmsg2(000, "job_defaults conn %i %s\n", conn, m_dir->name());
+	  Pmsg2(000, "job_defaults conn %i %s\n", conn, m_dir->name());
    scmd = QString(".defaults job=\"%1\"").arg(job_defs.job_name);
    dircomm->write(scmd);
    while ((stat = dircomm->read()) > 0) {
-      if (mainWin->m_displayAll) display_text(dircomm->msg());
-      def = strchr(dircomm->msg(), '=');
-      if (!def) {
-         continue;
-      }
-      /* Pointer to default value */
-      *def++ = 0;
-      strip_trailing_newline(def);
-
-      if (strcmp(dircomm->msg(), "job") == 0) {
-         if (strcmp(def, job_defs.job_name.toUtf8().data()) != 0) {
-            goto bail_out;
-         }
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "pool") == 0) {
-         job_defs.pool_name = def;
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "messages") == 0) {
-         job_defs.messages_name = def;
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "client") == 0) {
-         job_defs.client_name = def;
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "storage") == 0) {
-         job_defs.store_name = def;
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "where") == 0) {
-         job_defs.where = def;
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "level") == 0) {
-         job_defs.level = def;
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "type") == 0) {
-         job_defs.type = def;
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "fileset") == 0) {
-         job_defs.fileset_name = def;
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "catalog") == 0) {
-         job_defs.catalog_name = def;
-         continue;
-      }
-      if (strcmp(dircomm->msg(), "enabled") == 0) {
-         job_defs.enabled = *def == '1' ? true : false;
-         continue;
-      }
+	  if (mainWin->m_displayAll) display_text(dircomm->msg());
+	  def = strchr(dircomm->msg(), '=');
+	  if (!def) {
+		 continue;
+	  }
+	  /* Pointer to default value */
+	  *def++ = 0;
+	  strip_trailing_newline(def);
+
+	  if (strcmp(dircomm->msg(), "job") == 0) {
+		 if (strcmp(def, job_defs.job_name.toUtf8().data()) != 0) {
+			goto bail_out;
+		 }
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "pool") == 0) {
+		 job_defs.pool_name = def;
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "messages") == 0) {
+		 job_defs.messages_name = def;
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "client") == 0) {
+		 job_defs.client_name = def;
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "storage") == 0) {
+		 job_defs.store_name = def;
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "where") == 0) {
+		 job_defs.where = def;
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "level") == 0) {
+		 job_defs.level = def;
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "type") == 0) {
+		 job_defs.type = def;
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "fileset") == 0) {
+		 job_defs.fileset_name = def;
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "catalog") == 0) {
+		 job_defs.catalog_name = def;
+		 continue;
+	  }
+	  if (strcmp(dircomm->msg(), "enabled") == 0) {
+		 job_defs.enabled = *def == '1' ? true : false;
+		 continue;
+	  }
    }
    rtn = true;
    /* Fall through wanted */
 bail_out:
    if (donotify && prev_notify) {
-      notify(conn, true);
+	  notify(conn, true);
    }
    if (!prevWaitState) {
-      mainWin->waitExit();
+	  mainWin->waitExit();
    }
    return rtn;
 }
@@ -534,7 +541,7 @@ void Console::set_font()
    bool ok;
    QFont font = QFontDialog::getFont(&ok, QFont(m_textEdit->font()), this);
    if (ok) {
-      m_textEdit->setFont(font);
+	  m_textEdit->setFont(font);
    }
 }
 
@@ -582,8 +589,8 @@ void Console::display_textf(const char *fmt, ...)
 void Console::display_text(const QString buf)
 {
    if (buf.size() != 0) {
-      m_cursor->insertText(buf);
-      update_cursor();
+	  m_cursor->insertText(buf);
+	  update_cursor();
    }
 }
 
@@ -591,16 +598,16 @@ void Console::display_text(const QString buf)
 void Console::display_text(const char *buf)
 {
    if (*buf != 0) {
-      m_cursor->insertText(buf);
-      update_cursor();
+	  m_cursor->insertText(buf);
+	  update_cursor();
    }
 }
 
 void Console::display_html(const QString buf)
 {
    if (buf.size() != 0) {
-      m_cursor->insertHtml(buf);
-      update_cursor();
+	  m_cursor->insertHtml(buf);
+	  update_cursor();
    }
 }
 
@@ -616,14 +623,14 @@ void Console::beginNewCommand(int conn)
    DirComm *dircomm = m_dircommHash.value(conn);
 
    for (int i=0; i < 3; i++) {
-      dircomm->write(".");
-      while (dircomm->read() > 0) {
-         if (mainWin->m_commDebug) Pmsg2(000, "begin new command loop %i %s\n", i, m_dir->name());
-         if (mainWin->m_displayAll) display_text(dircomm->msg());
-      }
-      if (dircomm->m_at_main_prompt) {
-         break;
-      }
+	  dircomm->write(".");
+	  while (dircomm->read() > 0) {
+		 if (mainWin->m_commDebug) Pmsg2(000, "begin new command loop %i %s\n", i, m_dir->name());
+		 if (mainWin->m_displayAll) display_text(dircomm->msg());
+	  }
+	  if (dircomm->m_at_main_prompt) {
+		 break;
+	  }
    }
    display_text("\n");
 }
@@ -636,14 +643,14 @@ void Console::displayToPrompt(int conn)
    QString buf;
    if (mainWin->m_commDebug) Pmsg1(000, "DisplaytoPrompt %s\n", m_dir->name());
    while (!dircomm->m_at_prompt) {
-      if ((stat=dircomm->read()) > 0) {
-         buf += dircomm->msg();
-         if (buf.size() >= 8196 || m_messages_pending) {
-            display_text(buf);
-            buf.clear();
-            messagesPending(false);
-         }
-      }
+	  if ((stat=dircomm->read()) > 0) {
+		 buf += dircomm->msg();
+		 if (buf.size() >= 8196 || m_messages_pending) {
+			display_text(buf);
+			buf.clear();
+			messagesPending(false);
+		 }
+	  }
    }
    display_text(buf);
    if (mainWin->m_commDebug) Pmsg2(000, "endDisplaytoPrompt=%d %s\n", stat, m_dir->name());
@@ -656,17 +663,17 @@ void Console::discardToPrompt(int conn)
    int stat = 0;
    if (mainWin->m_commDebug) Pmsg1(000, "discardToPrompt %s\n", m_dir->name());
    if (mainWin->m_displayAll) {
-      displayToPrompt(conn);
+	  displayToPrompt(conn);
    } else {
-      while (!dircomm->m_at_prompt) {
-         stat = dircomm->read();
-         if (stat < 0) {
-            break;
-         }
-      }
+	  while (!dircomm->m_at_prompt) {
+		 stat = dircomm->read();
+		 if (stat < 0) {
+			break;
+		 }
+	  }
    }
    if (mainWin->m_commDebug) {
-      Pmsg2(000, "endDiscardToPrompt conn=%i %s\n", conn, m_dir->name());
+	  Pmsg2(000, "endDiscardToPrompt conn=%i %s\n", conn, m_dir->name());
    }
 }
 
@@ -681,9 +688,9 @@ QString Console::returnFromPrompt(int conn)
    text += dircomm->msg();
    if (mainWin->m_commDebug) Pmsg1(000, "returnFromPrompt %s\n", m_dir->name());
    while (!dircomm->m_at_prompt) {
-      if ((stat=dircomm->read()) > 0) {
-         text += dircomm->msg();
-      }
+	  if ((stat=dircomm->read()) > 0) {
+		 text += dircomm->msg();
+	  }
    }
    if (mainWin->m_commDebug) Pmsg2(000, "endreturnFromPrompt=%d %s\n", stat, m_dir->name());
    return text;
@@ -705,7 +712,7 @@ int Console::notifyOff()
 {
    int conn = 0;
    if (getDirComm(conn)) {
-      notify(conn, false);
+	  notify(conn, false);
    }
    return conn;
 }
@@ -715,9 +722,9 @@ bool Console::notify(int conn, bool enable)
 {
    DirComm *dircomm = m_dircommHash.value(conn);
    if (dircomm) {
-      return dircomm->notify(enable);
+	  return dircomm->notify(enable);
    } else {
-      return false;
+	  return false;
    }
 }
 
@@ -726,9 +733,9 @@ bool Console::is_notify_enabled(int conn) const
 {
    DirComm *dircomm = m_dircommHash.value(conn);
    if (dircomm) {
-      return dircomm->is_notify_enabled();
+	  return dircomm->is_notify_enabled();
    } else {
-      return false;
+	  return false;
    }
 }
 
@@ -769,9 +776,9 @@ void Console::consoleReload()
 bool Console::hasFocus()
 {
    if (mainWin->tabWidget->currentIndex() == mainWin->tabWidget->indexOf(this))
-      return true;
+	  return true;
    else
-      return false;
+	  return false;
 }
 
 /* For adding feature to have the gui's messages button change when
@@ -788,7 +795,7 @@ bool Console::messagesPending(bool pend)
 void Console::terminate()
 {
    foreach(DirComm* dircomm,  m_dircommHash) {
-      dircomm->terminate();
+	  dircomm->terminate();
    }
    m_console->stopTimer();
 }
@@ -797,11 +804,11 @@ void Console::terminate()
 bool Console::is_connectedGui()
 {
    if (is_connected(0)) {
-      return true;
+	  return true;
    } else {
-      QString message = tr("Director is currently disconnected\nPlease reconnect!");
-      QMessageBox::warning(this, "Bat", message, QMessageBox::Ok );
-      return false;
+	  QString message = tr("Director is currently disconnected\nPlease reconnect!");
+	  QMessageBox::warning(this, "Bat", message, QMessageBox::Ok );
+	  return false;
    }
 }
 
@@ -840,8 +847,8 @@ bool Console::is_connected()
 {
    bool connected = false;
    foreach(DirComm* dircomm,  m_dircommHash) {
-      if (dircomm->is_connected())
-         return true;
+	  if (dircomm->is_connected())
+		 return true;
    }
    return connected;
 }
@@ -859,7 +866,7 @@ bool Console::is_connected(int conn)
 bool Console::getDirComm(int &conn)
 {
    if (findDirComm(conn)) {
-      return true;
+	  return true;
    }
    if (mainWin->m_connDebug) Pmsg0(000, "call newDirComm\n");
    return newDirComm(conn);
@@ -881,16 +888,16 @@ bool Console::findDirComm(int &conn)
 {
    QHash<int, DirComm*>::const_iterator iter = m_dircommHash.constBegin();
    while (iter != m_dircommHash.constEnd()) {
-      DirComm *dircomm = iter.value();
-      if (dircomm->m_at_prompt && dircomm->m_at_main_prompt && dircomm->is_notify_enabled()) {
-         conn = dircomm->m_conn;
-         return true;
-      }
-      if (mainWin->m_connDebug) {
-         Pmsg4(000, "currentDirComm=%d at_prompt=%d at_main=%d && notify=%d\n",
-            dircomm->m_conn, dircomm->m_at_prompt, dircomm->m_at_main_prompt, dircomm->is_notify_enabled());
-      }
-      ++iter;
+	  DirComm *dircomm = iter.value();
+	  if (dircomm->m_at_prompt && dircomm->m_at_main_prompt && dircomm->is_notify_enabled()) {
+		 conn = dircomm->m_conn;
+		 return true;
+	  }
+	  if (mainWin->m_connDebug) {
+		 Pmsg4(000, "currentDirComm=%d at_prompt=%d at_main=%d && notify=%d\n",
+			dircomm->m_conn, dircomm->m_at_prompt, dircomm->m_at_main_prompt, dircomm->is_notify_enabled());
+	  }
+	  ++iter;
    }
    return false;
 }
@@ -902,23 +909,23 @@ bool Console::newDirComm(int &conn)
 {
    m_dircommCounter++;
    if (mainWin->m_connDebug) {
-      Pmsg2(000, "newDirComm=%i to: %s\n", m_dircommCounter, m_dir->name());
+	  Pmsg2(000, "newDirComm=%i to: %s\n", m_dircommCounter, m_dir->name());
    }
    DirComm *dircomm = new DirComm(this, m_dircommCounter);
    m_dircommHash.insert(m_dircommCounter, dircomm);
    bool success = dircomm->connect_dir();
    if (mainWin->m_connDebug) {
-      if (success) {
-         Pmsg2(000, "newDirComm=%i Connected %s\n", m_dircommCounter, m_dir->name());
-      } else {
-         Emsg2(M_ERROR, 0, "DirComm=%i. Unable to connect to %s\n",
-               m_dircommCounter, m_dir->name());
-      }
+	  if (success) {
+		 Pmsg2(000, "newDirComm=%i Connected %s\n", m_dircommCounter, m_dir->name());
+	  } else {
+		 Emsg2(M_ERROR, 0, "DirComm=%i. Unable to connect to %s\n",
+			   m_dircommCounter, m_dir->name());
+	  }
    }
    if (!success) {
-      m_dircommHash.remove(m_dircommCounter);
-      delete dircomm;
-      m_dircommCounter--;
+	  m_dircommHash.remove(m_dircommCounter);
+	  delete dircomm;
+	  m_dircommCounter--;
    }
    conn = m_dircommCounter;
    return success;
diff --git a/src/qt-console/job/job.cpp b/src/qt-console/job/job.cpp
index 61b4c9d..5f87612 100644
--- a/src/qt-console/job/job.cpp
+++ b/src/qt-console/job/job.cpp
@@ -19,6 +19,11 @@
    02110-1301, USA.
 */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include "bat.h"
 #include "job.h"
 #include "util/fmtwidgetitem.h"
@@ -51,11 +56,11 @@ Job::Job(QString &jobId, QTreeWidgetItem *parentTreeWidgetItem) : Pages()
 void Job::rerun()
 {
    new runPage(label_Name->text(),
-               label_Level->text(),
-               label_Pool->text(),
-               QString(""),              // storage
-               label_Client->text(),
-               label_FileSet->text());
+			   label_Level->text(),
+			   label_Pool->text(),
+			   QString(""),              // storage
+			   label_Client->text(),
+			   label_FileSet->text());
 }
 
 void Job::showInfoVolume(QListWidgetItem *item)
@@ -70,16 +75,16 @@ void Job::showInfoVolume(QListWidgetItem *item)
 void Job::deleteJob()
 {
    if (QMessageBox::warning(this, "Bat",
-      tr("Are you sure you want to delete??  !!!.\n"
+	  tr("Are you sure you want to delete??  !!!.\n"
 "This delete command is used to delete a Job record and all associated catalog"
 " records that were created. This command operates only on the Catalog"
 " database and has no effect on the actual data written to a Volume. This"
 " command can be dangerous and we strongly recommend that you do not use"
 " it unless you know what you are doing.  The Job and all its associated"
 " records (File and JobMedia) will be deleted from the catalog."
-      "Press OK to proceed with delete operation.?"),
-      QMessageBox::Ok | QMessageBox::Cancel)
-      == QMessageBox::Cancel) { return; }
+	  "Press OK to proceed with delete operation.?"),
+	  QMessageBox::Ok | QMessageBox::Cancel)
+	  == QMessageBox::Cancel) { return; }
 
    QString cmd("delete job jobid=");
    cmd += m_jobId;
@@ -90,9 +95,9 @@ void Job::deleteJob()
 void Job::cancelJob()
 {
    if (QMessageBox::warning(this, "Bat",
-                            tr("Are you sure you want to cancel this job?"),
-                            QMessageBox::Ok | QMessageBox::Cancel)
-       == QMessageBox::Cancel) { return; }
+							tr("Are you sure you want to cancel this job?"),
+							QMessageBox::Ok | QMessageBox::Cancel)
+	   == QMessageBox::Cancel) { return; }
 
    QString cmd("cancel jobid=");
    cmd += m_jobId;
@@ -134,83 +139,83 @@ void Job::populateText()
 
    /* This could be a log item */
    if (mainWin->m_sqlDebug) {
-      Pmsg1(000, "Log query cmd : %s\n", query.toUtf8().data());
+	  Pmsg1(000, "Log query cmd : %s\n", query.toUtf8().data());
    }
 
    QStringList results;
    if (m_console->sql_cmd(query, results)) {
 
-      if (!results.size()) {
-         QMessageBox::warning(this, tr("Bat"),
-            tr("There were no results!\n"
-               "It is possible you may need to add \"catalog = all\" "
-               "to the Messages resource for this job.\n"), QMessageBox::Ok);
-         return;
-      }
-
-      QString jobstr("JobId "); /* FIXME: should this be translated ? */
-      jobstr += m_jobId;
-
-      QString htmlbuf("<html><body><pre>");
-
-      /* Iterate through the lines of results. */
-      QString field;
-      QStringList fieldlist;
-      QString lastTime;
-      QString lastSvc;
-      foreach (QString resultline, results) {
-         fieldlist = resultline.split("\t");
-
-         if (fieldlist.size() < 2)
-            continue;
-
-         QString curTime = fieldlist[0].trimmed();
-
-         field = fieldlist[1].trimmed();
-         int colon = field.indexOf(":");
-         if (colon > 0) {
-            /* string is like <service> <jobId xxxx>: ..."
-             * we split at ':' then remove the jobId xxxx string (always the same) */
-            QString curSvc(field.left(colon).replace(jobstr,"").trimmed());
-            if (curSvc == lastSvc  && curTime == lastTime) {
-               curTime.clear();
-               curSvc.clear();
-            } else {
-               lastTime = curTime;
-               lastSvc = curSvc;
-            }
+	  if (!results.size()) {
+		 QMessageBox::warning(this, tr("Bat"),
+			tr("There were no results!\n"
+			   "It is possible you may need to add \"catalog = all\" "
+			   "to the Messages resource for this job.\n"), QMessageBox::Ok);
+		 return;
+	  }
+
+	  QString jobstr("JobId "); /* FIXME: should this be translated ? */
+	  jobstr += m_jobId;
+
+	  QString htmlbuf("<html><body><pre>");
+
+	  /* Iterate through the lines of results. */
+	  QString field;
+	  QStringList fieldlist;
+	  QString lastTime;
+	  QString lastSvc;
+	  foreach (QString resultline, results) {
+		 fieldlist = resultline.split("\t");
+
+		 if (fieldlist.size() < 2)
+			continue;
+
+		 QString curTime = fieldlist[0].trimmed();
+
+		 field = fieldlist[1].trimmed();
+		 int colon = field.indexOf(":");
+		 if (colon > 0) {
+			/* string is like <service> <jobId xxxx>: ..."
+			 * we split at ':' then remove the jobId xxxx string (always the same) */
+			QString curSvc(field.left(colon).replace(jobstr,"").trimmed());
+			if (curSvc == lastSvc  && curTime == lastTime) {
+			   curTime.clear();
+			   curSvc.clear();
+			} else {
+			   lastTime = curTime;
+			   lastSvc = curSvc;
+			}
 //          htmlbuf += "<td>" + curTime + "</td>";
-            htmlbuf += "\n" + curSvc + " ";
-
-            /* rest of string is marked as pre-formatted (here trimming should
-             * be avoided, to preserve original formatting) */
-            QString msg(field.mid(colon+2));
-            if (msg.startsWith( tr("Error:")) ) { /* FIXME: should really be translated ? */
-               /* error msg, use a specific class */
-               htmlbuf += "</pre><pre class=err>" + msg + "</pre><pre>";
-            } else {
-               htmlbuf += msg ;
-            }
-         } else {
-            /* non standard string, place as-is */
-            if (curTime == lastTime) {
-               curTime.clear();
-            } else {
-               lastTime = curTime;
-            }
+			htmlbuf += "\n" + curSvc + " ";
+
+			/* rest of string is marked as pre-formatted (here trimming should
+			 * be avoided, to preserve original formatting) */
+			QString msg(field.mid(colon+2));
+			if (msg.startsWith( tr("Error:")) ) { /* FIXME: should really be translated ? */
+			   /* error msg, use a specific class */
+			   htmlbuf += "</pre><pre class=err>" + msg + "</pre><pre>";
+			} else {
+			   htmlbuf += msg ;
+			}
+		 } else {
+			/* non standard string, place as-is */
+			if (curTime == lastTime) {
+			   curTime.clear();
+			} else {
+			   lastTime = curTime;
+			}
 //          htmlbuf += "<td>" + curTime + "</td>";
-            htmlbuf += "\n" + field ;
-         }
+			htmlbuf += "\n" + field ;
+		 }
 
-      } /* foreach resultline */
+	  } /* foreach resultline */
 
-      htmlbuf += "</pre></body></html>";
+	  htmlbuf += "</pre></body></html>";
 
-      /* full text ready. Here a custom sheet is used to align columns */
-      QString logSheet(".err {color:#FF0000;}");
-      textJobLog->document()->setDefaultStyleSheet(logSheet);
-      textJobLog->document()->setHtml(htmlbuf);
-      textJobLog->moveCursor(QTextCursor::Start);
+	  /* full text ready. Here a custom sheet is used to align columns */
+	  QString logSheet(".err {color:#FF0000;}");
+	  textJobLog->document()->setDefaultStyleSheet(logSheet);
+	  textJobLog->document()->setHtml(htmlbuf);
+	  textJobLog->moveCursor(QTextCursor::Start);
 
    } /* if results from query */
 
@@ -248,46 +253,46 @@ void Job::updateRunInfo()
    QString empty("");
 
    if (m_console->dir_cmd(cmd, results)) {
-      foreach (QString mline, results) {
-         foreach (QString line, mline.split("\n")) {
-            line = line.trimmed();
-            if (oldline.indexIn(line) >= 0) {
-               if (parseit) {
-                  lst = oldline.capturedTexts();
-                  label_JobErrors->setText(lst[4]);
-                  label_Speed->setText(convertBytesSI(lst[3].replace(com, empty).toULongLong())+"/s");
-                  label_JobFiles->setText(lst[1]);
-                  label_JobBytes->setText(convertBytesSI(lst[2].replace(com, empty).toULongLong()));
-               }
-               continue;
-
-            } else if (jobline.indexIn(line) >= 0) {
-               lst = jobline.capturedTexts();
-               lst.removeFirst();
-
-            } else if (itemline.indexIn(line) >= 0) {
-               lst = itemline.capturedTexts();
-               lst.removeFirst();
-
-            } else {
-               if (mainWin->m_miscDebug)
-                  Pmsg1(0, "bad line=%s\n", line.toUtf8().data());
-               continue;
-            }
-            if (lst.count() < 2) {
-               if (mainWin->m_miscDebug)
-                  Pmsg2(0, "bad line=%s count=%d\n", line.toUtf8().data(), lst.count());
-            }
-            if (lst[0] == "JobId") {
-               if (lst[1] == m_jobId) {
-                  parseit = true;
-               } else {
-                  parseit = false;
-               }
-            }
-            if (!parseit) {
-               continue;
-            }
+	  foreach (QString mline, results) {
+		 foreach (QString line, mline.split("\n")) {
+			line = line.trimmed();
+			if (oldline.indexIn(line) >= 0) {
+			   if (parseit) {
+				  lst = oldline.capturedTexts();
+				  label_JobErrors->setText(lst[4]);
+				  label_Speed->setText(convertBytesSI(lst[3].replace(com, empty).toULongLong())+"/s");
+				  label_JobFiles->setText(lst[1]);
+				  label_JobBytes->setText(convertBytesSI(lst[2].replace(com, empty).toULongLong()));
+			   }
+			   continue;
+
+			} else if (jobline.indexIn(line) >= 0) {
+			   lst = jobline.capturedTexts();
+			   lst.removeFirst();
+
+			} else if (itemline.indexIn(line) >= 0) {
+			   lst = itemline.capturedTexts();
+			   lst.removeFirst();
+
+			} else {
+			   if (mainWin->m_miscDebug)
+				  Pmsg1(0, "bad line=%s\n", line.toUtf8().data());
+			   continue;
+			}
+			if (lst.count() < 2) {
+			   if (mainWin->m_miscDebug)
+				  Pmsg2(0, "bad line=%s count=%d\n", line.toUtf8().data(), lst.count());
+			}
+			if (lst[0] == "JobId") {
+			   if (lst[1] == m_jobId) {
+				  parseit = true;
+			   } else {
+				  parseit = false;
+			   }
+			}
+			if (!parseit) {
+			   continue;
+			}
 
 //         } else if (lst[0] == "Job") {
 //            grpRun->setTitle(lst[1]);
@@ -303,26 +308,26 @@ void Job::updateRunInfo()
 //         } else if (lst[0] == "JobStarted") {
 //            Started->setText(lst[1]);
 
-            if (lst[0] == "Errors") {
-               label_JobErrors->setText(lst[1]);
+			if (lst[0] == "Errors") {
+			   label_JobErrors->setText(lst[1]);
 
-            } else if (lst[0] == "Bytes/sec") {
-               label_Speed->setText(convertBytesSI(lst[1].toULongLong())+"/s");
+			} else if (lst[0] == "Bytes/sec") {
+			   label_Speed->setText(convertBytesSI(lst[1].toULongLong())+"/s");
 
-            } else if (lst[0] == "Files") {
-               label_JobFiles->setText(lst[1]);
+			} else if (lst[0] == "Files") {
+			   label_JobFiles->setText(lst[1]);
 
-            } else if (lst[0] == "Bytes") {
-               label_JobBytes->setText(convertBytesSI(lst[1].toULongLong()));
+			} else if (lst[0] == "Bytes") {
+			   label_JobBytes->setText(convertBytesSI(lst[1].toULongLong()));
 
-            } else if (lst[0] == "Files Examined") {
-               label_FilesExamined->setText(lst[1]);
+			} else if (lst[0] == "Files Examined") {
+			   label_FilesExamined->setText(lst[1]);
 
-            } else if (lst[0] == "Processing file") {
-               label_CurrentFile->setText(lst[1]);
-            }
-         }
-      }
+			} else if (lst[0] == "Processing file") {
+			   label_CurrentFile->setText(lst[1]);
+			}
+		 }
+	  }
    }
 }
 
@@ -334,80 +339,87 @@ void Job::populateForm()
    QString stat, err;
    char buf[256];
    QString query =
-      "SELECT JobId, Job.Name, Level, Client.Name, Pool.Name, FileSet,"
-      "SchedTime, StartTime, EndTime, EndTime-StartTime AS Duration, "
-      "JobBytes, JobFiles, JobErrors, JobStatus, PurgedFiles "
-      "FROM Job JOIN Client USING (ClientId) "
-        "LEFT JOIN Pool ON (Job.PoolId = Pool.PoolId) "
-        "LEFT JOIN FileSet ON (Job.FileSetId = FileSet.FileSetId)"
-      "WHERE JobId=" + m_jobId;
+	  "SELECT JobId, Job.Name, Level, Client.Name, Pool.Name, FileSet,"
+	  "SchedTime, StartTime, EndTime, EndTime-StartTime AS Duration, "
+	  "JobBytes, JobFiles, JobErrors, JobStatus, PurgedFiles "
+	  "FROM Job JOIN Client USING (ClientId) "
+		"LEFT JOIN Pool ON (Job.PoolId = Pool.PoolId) "
+		"LEFT JOIN FileSet ON (Job.FileSetId = FileSet.FileSetId)"
+	  "WHERE JobId=" + m_jobId;
    QStringList results;
    if (m_console->sql_cmd(query, results)) {
-      QString resultline, duration;
-      QStringList fieldlist;
-
-      foreach (resultline, results) { // should have only one result
-         fieldlist = resultline.split("\t");
-         QStringListIterator fld(fieldlist);
-         label_JobId->setText(fld.next());
-         label_Name->setText(fld.next());
-
-         label_Level->setText(job_level_to_str(fld.next()[0].toAscii()));
-
-         m_client = fld.next();
-         label_Client->setText(m_client);
-         label_Pool->setText(fld.next());
-         label_FileSet->setText(fld.next());
-         label_SchedTime->setText(fld.next());
-         label_StartTime->setText(fld.next());
-         label_EndTime->setText(fld.next());
-         duration = fld.next();
-         /*
-          * Note: if we have a negative duration, it is because the EndTime
-          *  is zero (i.e. the Job is still running).  We should use
-          *  duration = StartTime - current_time
-          */
-         if (duration.left(1) == "-") {
-            duration = "0.0";
-         }
-         label_Duration->setText(duration);
-
-         label_JobBytes->setText(convertBytesSI(fld.next().toULongLong()));
-         label_JobFiles->setText(fld.next());
-         err = fld.next();
-         label_JobErrors->setText(err);
-
-         stat = fld.next();
-         if (stat == "T" && err.toInt() > 0) {
-            stat = "W";
-         }
-         if (stat == "R") {
-            pbDelete->setVisible(false);
-            pbCancel->setVisible(true);
-            grpRun->setVisible(true);
-            if (!m_timer) {
-               m_timer = new QTimer(this);
-               connect(m_timer, SIGNAL(timeout()), this, SLOT(populateAll()));
-               m_timer->start(30000);
-            }
-            updateRunInfo();
-         } else {
-            pbDelete->setVisible(true);
-            pbCancel->setVisible(false);
-            grpRun->setVisible(false);
-            if (m_timer) {
-               m_timer->stop();
-               delete m_timer;
-               m_timer = NULL;
-            }
-         }
-         label_JobStatus->setPixmap(QPixmap(":/images/" + stat + ".png"));
-         jobstatus_to_ascii_gui(stat[0].toAscii(), buf, sizeof(buf));
-         stat = buf;
-         label_JobStatus->setToolTip(stat);
-
-         chkbox_PurgedFiles->setCheckState(fld.next().toInt()?Qt::Checked:Qt::Unchecked);
-      }
+	  QString resultline, duration;
+	  QStringList fieldlist;
+
+	  foreach (resultline, results) { // should have only one result
+		 fieldlist = resultline.split("\t");
+		 QStringListIterator fld(fieldlist);
+		 label_JobId->setText(fld.next());
+		 label_Name->setText(fld.next());
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+		label_Level->setText(job_level_to_str(fld.next()[0].toLatin1()));
+#else
+		 label_Level->setText(job_level_to_str(fld.next()[0].toAscii()));
+#endif
+
+		 m_client = fld.next();
+		 label_Client->setText(m_client);
+		 label_Pool->setText(fld.next());
+		 label_FileSet->setText(fld.next());
+		 label_SchedTime->setText(fld.next());
+		 label_StartTime->setText(fld.next());
+		 label_EndTime->setText(fld.next());
+		 duration = fld.next();
+		 /*
+		  * Note: if we have a negative duration, it is because the EndTime
+		  *  is zero (i.e. the Job is still running).  We should use
+		  *  duration = StartTime - current_time
+		  */
+		 if (duration.left(1) == "-") {
+			duration = "0.0";
+		 }
+		 label_Duration->setText(duration);
+
+		 label_JobBytes->setText(convertBytesSI(fld.next().toULongLong()));
+		 label_JobFiles->setText(fld.next());
+		 err = fld.next();
+		 label_JobErrors->setText(err);
+
+		 stat = fld.next();
+		 if (stat == "T" && err.toInt() > 0) {
+			stat = "W";
+		 }
+		 if (stat == "R") {
+			pbDelete->setVisible(false);
+			pbCancel->setVisible(true);
+			grpRun->setVisible(true);
+			if (!m_timer) {
+			   m_timer = new QTimer(this);
+			   connect(m_timer, SIGNAL(timeout()), this, SLOT(populateAll()));
+			   m_timer->start(30000);
+			}
+			updateRunInfo();
+		 } else {
+			pbDelete->setVisible(true);
+			pbCancel->setVisible(false);
+			grpRun->setVisible(false);
+			if (m_timer) {
+			   m_timer->stop();
+			   delete m_timer;
+			   m_timer = NULL;
+			}
+		 }
+		 label_JobStatus->setPixmap(QPixmap(":/images/" + stat + ".png"));
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+		 jobstatus_to_ascii_gui(stat[0].toLatin1(), buf, sizeof(buf));
+#else
+		 jobstatus_to_ascii_gui(stat[0].toAscii(), buf, sizeof(buf));
+#endif
+		 stat = buf;
+		 label_JobStatus->setToolTip(stat);
+
+		 chkbox_PurgedFiles->setCheckState(fld.next().toInt()?Qt::Checked:Qt::Unchecked);
+	  }
    }
 }
 
@@ -415,24 +427,24 @@ void Job::populateVolumes()
 {
 
    QString query =
-      "SELECT DISTINCT VolumeName, InChanger, Slot "
-      "FROM Job JOIN JobMedia USING (JobId) JOIN Media USING (MediaId) "
-      "WHERE JobId=" + m_jobId + " ORDER BY VolumeName ";
+	  "SELECT DISTINCT VolumeName, InChanger, Slot "
+	  "FROM Job JOIN JobMedia USING (JobId) JOIN Media USING (MediaId) "
+	  "WHERE JobId=" + m_jobId + " ORDER BY VolumeName ";
    if (mainWin->m_sqlDebug) Pmsg1(0, "Query cmd : %s\n",query.toUtf8().data());
 
 
    QStringList results;
    if (m_console->sql_cmd(query, results)) {
-      QString resultline;
-      QStringList fieldlist;
-      list_Volume->clear();
-      foreach (resultline, results) { // should have only one result
-         fieldlist = resultline.split("\t");
-         QStringListIterator fld(fieldlist);
+	  QString resultline;
+	  QStringList fieldlist;
+	  list_Volume->clear();
+	  foreach (resultline, results) { // should have only one result
+		 fieldlist = resultline.split("\t");
+		 QStringListIterator fld(fieldlist);
 //         QListWidgetItem(QIcon(":/images/inchanger" + fld.next() + ".png"),
 //                         fld.next(), list_Volume);
-         list_Volume->addItem(fld.next());
-      }
+		 list_Volume->addItem(fld.next());
+	  }
    }
 }
 
diff --git a/src/qt-console/joblist/joblist.cpp b/src/qt-console/joblist/joblist.cpp
index 33e578b..47d5752 100644
--- a/src/qt-console/joblist/joblist.cpp
+++ b/src/qt-console/joblist/joblist.cpp
@@ -22,6 +22,12 @@
  * Dirk Bartley, March 2007
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+	#include <QScrollArea>
+#endif
 #include <QtGui>
 
 #include "bat.h"
diff --git a/src/qt-console/joblist/joblist.h b/src/qt-console/joblist/joblist.h
index cc53dd5..25de706 100644
--- a/src/qt-console/joblist/joblist.h
+++ b/src/qt-console/joblist/joblist.h
@@ -24,6 +24,11 @@
 #ifndef _JOBLIST_H_
 #define _JOBLIST_H_
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QSplitter>
+#endif
 #include <QtGui>
 
 #include "ui_joblist.h"
diff --git a/src/qt-console/joblog/joblog.cpp b/src/qt-console/joblog/joblog.cpp
index 7476630..8f868c4 100644
--- a/src/qt-console/joblog/joblog.cpp
+++ b/src/qt-console/joblog/joblog.cpp
@@ -25,6 +25,11 @@
  * Dirk Bartley, March 2007
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include "bat.h"
 #include "joblog.h"
 
@@ -69,36 +74,36 @@ void JobLog::populateText()
 
    /* This could be a log item */
    if (mainWin->m_sqlDebug) {
-      Pmsg1(000, "Log query cmd : %s\n", query.toUtf8().data());
+	  Pmsg1(000, "Log query cmd : %s\n", query.toUtf8().data());
    }
 
    QStringList results;
    if (m_console->sql_cmd(query, results)) {
 
-      if (!results.size()) {
-         QMessageBox::warning(this, tr("Bat"),
-            tr("There were no results!\n"
-	       "It is possible you may need to add \"catalog = all\" "
-	       "to the Messages resource for this job.\n"), QMessageBox::Ok);
+	  if (!results.size()) {
+		 QMessageBox::warning(this, tr("Bat"),
+			tr("There were no results!\n"
+		   "It is possible you may need to add \"catalog = all\" "
+		   "to the Messages resource for this job.\n"), QMessageBox::Ok);
 	 return;
-      }
+	  }
 
-      QString jobstr("JobId "); /* FIXME: should this be translated ? */
-      jobstr += m_jobId;
+	  QString jobstr("JobId "); /* FIXME: should this be translated ? */
+	  jobstr += m_jobId;
 
-      QString htmlbuf("<html><body><b>" + tr("Log records for job %1").arg(m_jobId) );
-      htmlbuf += "</b><table>";
+	  QString htmlbuf("<html><body><b>" + tr("Log records for job %1").arg(m_jobId) );
+	  htmlbuf += "</b><table>";
 
-      /* Iterate through the lines of results. */
-      QString field;
-      QStringList fieldlist;
-      QString lastTime;
-      QString lastSvc;
-      foreach (QString resultline, results) {
-         fieldlist = resultline.split("\t");
+	  /* Iterate through the lines of results. */
+	  QString field;
+	  QStringList fieldlist;
+	  QString lastTime;
+	  QString lastSvc;
+	  foreach (QString resultline, results) {
+		 fieldlist = resultline.split("\t");
 
 	 if (fieldlist.size() < 2)
-	    continue;
+		continue;
 
 	 htmlbuf +="<tr>";
 
@@ -107,50 +112,50 @@ void JobLog::populateText()
 	 field = fieldlist[1].trimmed();
 	 int colon = field.indexOf(":");
 	 if (colon > 0) {
-	    /* string is like <service> <jobId xxxx>: ..."
-	     * we split at ':' then remove the jobId xxxx string (always the same) */
-	    QString curSvc(field.left(colon).replace(jobstr,"").trimmed());
-	    if (curSvc == lastSvc  && curTime == lastTime) {
-	       curTime.clear();
-	       curSvc.clear();
-	    } else {
-	       lastTime = curTime;
-	       lastSvc = curSvc;
-	    }
-	    htmlbuf += "<td>" + curTime + "</td>";
-	    htmlbuf += "<td><p>" + curSvc + "</p></td>";
-
-	    /* rest of string is marked as pre-formatted (here trimming should
-	     * be avoided, to preserve original formatting) */
-	    QString msg(field.mid(colon+2));
-	    if (msg.startsWith( tr("Error:")) ) { /* FIXME: should really be translated ? */
-	       /* error msg, use a specific class */
-	       htmlbuf += "<td><pre class=err>" + msg + "</pre></td>";
-	    } else {
-	       htmlbuf += "<td><pre>" + msg + "</pre></td>";
-	    }
+		/* string is like <service> <jobId xxxx>: ..."
+		 * we split at ':' then remove the jobId xxxx string (always the same) */
+		QString curSvc(field.left(colon).replace(jobstr,"").trimmed());
+		if (curSvc == lastSvc  && curTime == lastTime) {
+		   curTime.clear();
+		   curSvc.clear();
+		} else {
+		   lastTime = curTime;
+		   lastSvc = curSvc;
+		}
+		htmlbuf += "<td>" + curTime + "</td>";
+		htmlbuf += "<td><p>" + curSvc + "</p></td>";
+
+		/* rest of string is marked as pre-formatted (here trimming should
+		 * be avoided, to preserve original formatting) */
+		QString msg(field.mid(colon+2));
+		if (msg.startsWith( tr("Error:")) ) { /* FIXME: should really be translated ? */
+		   /* error msg, use a specific class */
+		   htmlbuf += "<td><pre class=err>" + msg + "</pre></td>";
+		} else {
+		   htmlbuf += "<td><pre>" + msg + "</pre></td>";
+		}
 	 } else {
-	    /* non standard string, place as-is */
-	    if (curTime == lastTime) {
-	       curTime.clear();
-	    } else {
-	       lastTime = curTime;
-	    }
-	    htmlbuf += "<td>" + curTime + "</td>";
-	    htmlbuf += "<td><pre>" + field + "</pre></td>";
+		/* non standard string, place as-is */
+		if (curTime == lastTime) {
+		   curTime.clear();
+		} else {
+		   lastTime = curTime;
+		}
+		htmlbuf += "<td>" + curTime + "</td>";
+		htmlbuf += "<td><pre>" + field + "</pre></td>";
 	 }
 
 	 htmlbuf += "</tr>";
 
-      } /* foreach resultline */
+	  } /* foreach resultline */
 
-      htmlbuf += "</table></body></html>";
+	  htmlbuf += "</table></body></html>";
 
-      /* full text ready. Here a custom sheet is used to align columns */
-      QString logSheet("p,pre,.err {margin-left: 10px} .err {color:#FF0000;}");
-      textEdit->document()->setDefaultStyleSheet(logSheet);
-      textEdit->document()->setHtml(htmlbuf);
-      textEdit->moveCursor(QTextCursor::Start);
+	  /* full text ready. Here a custom sheet is used to align columns */
+	  QString logSheet("p,pre,.err {margin-left: 10px} .err {color:#FF0000;}");
+	  textEdit->document()->setDefaultStyleSheet(logSheet);
+	  textEdit->document()->setHtml(htmlbuf);
+	  textEdit->moveCursor(QTextCursor::Start);
 
    } /* if results from query */
 
diff --git a/src/qt-console/label/label.cpp b/src/qt-console/label/label.cpp
index 963388a..45b4ac3 100644
--- a/src/qt-console/label/label.cpp
+++ b/src/qt-console/label/label.cpp
@@ -25,6 +25,11 @@
  * Kern Sibbald, February MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
diff --git a/src/qt-console/main.cpp b/src/qt-console/main.cpp
index e1cb48a..df90165 100644
--- a/src/qt-console/main.cpp
+++ b/src/qt-console/main.cpp
@@ -35,6 +35,8 @@
 #error "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
 #error "You need Qt version 4.6.2 or later to build Bat"
 #error "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+#else
+	#include <QtCore>
 #endif
 
 MainWin *mainWin;
@@ -64,7 +66,9 @@ int main(int argc, char *argv[])
 
    app = new QApplication(argc, argv);
    app->setQuitOnLastWindowClosed(true);
-   QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
+	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+#endif
 
    QTranslator qtTranslator;
    QTranslator batTranslator;
diff --git a/src/qt-console/mainwin.cpp b/src/qt-console/mainwin.cpp
index 805ab60..8472caf 100644
--- a/src/qt-console/mainwin.cpp
+++ b/src/qt-console/mainwin.cpp
@@ -25,6 +25,12 @@
  * Kern Sibbald, January MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
+
 #include "bat.h"
 #include "version.h"
 #include "joblist/joblist.h"
@@ -78,23 +84,23 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
    readSettings();
 
    foreach(Console *console, m_consoleHash) {
-      console->connect_dir();
+	  console->connect_dir();
    }
    /*
-    * Note, the notifier is now a global flag, although each notifier
-    *  can be individually turned on and off at a socket level.  Once
-    *  the notifier is turned off, we don't accept anything from anyone
-    *  this prevents unwanted messages from getting into the input
-    *  dialogs such as restore that read from the director and "know"
-    *  what to expect.
-    */
+	* Note, the notifier is now a global flag, although each notifier
+	*  can be individually turned on and off at a socket level.  Once
+	*  the notifier is turned off, we don't accept anything from anyone
+	*  this prevents unwanted messages from getting into the input
+	*  dialogs such as restore that read from the director and "know"
+	*  what to expect.
+	*/
    m_notify = true;
    m_currentConsole = (Console*)getFromHash(m_firstItem);
    QTimer::singleShot(2000, this, SLOT(popLists()));
    if (m_miscDebug) {
-      QString directoryResourceName;
-      m_currentConsole->getDirResName(directoryResourceName);
-      Pmsg1(100, "Setting initial window to %s\n", directoryResourceName.toUtf8().data());
+	  QString directoryResourceName;
+	  m_currentConsole->getDirResName(directoryResourceName);
+	  Pmsg1(100, "Setting initial window to %s\n", directoryResourceName.toUtf8().data());
    }
    app->restoreOverrideCursor();
 }
@@ -102,7 +108,7 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
 void MainWin::popLists()
 {
    foreach(Console *console, m_consoleHash) {
-      console->populateLists(true);
+	  console->populateLists(true);
    }
    m_doConnect = true;
    connectConsoleSignals();
@@ -120,57 +126,57 @@ void MainWin::createPages()
    LockRes();
    foreach_res(dir, R_DIRECTOR) {
 
-      /* Create console tree stacked widget item */
-      m_currentConsole = new Console(tabWidget);
-      m_currentConsole->setDirRes(dir);
-      m_currentConsole->readSettings();
-
-      /* The top tree item representing the director */
-      topItem = new QTreeWidgetItem(treeWidget);
-      topItem->setText(0, dir->name());
-      topItem->setIcon(0, QIcon(":images/server.png"));
-      /* Set background to grey for ease of identification of inactive Director */
-      QBrush greyBrush(Qt::lightGray);
-      topItem->setBackground(0, greyBrush);
-      m_currentConsole->setDirectorTreeItem(topItem);
-      m_consoleHash.insert(topItem, m_currentConsole);
-
-      /* Create Tree Widget Item */
-      item = new QTreeWidgetItem(topItem);
-      item->setText(0, tr("Console"));
-      if (!m_firstItem){ m_firstItem = item; }
-      item->setIcon(0,QIcon(QString::fromUtf8(":images/utilities-terminal.png")));
-
-      /* insert the cosole and tree widget item into the hashes */
-      hashInsert(item, m_currentConsole);
-      m_currentConsole->dockPage();
-
-      /* Set Color of treeWidgetItem for the console
-      * It will be set to green in the console class if the connection is made.
-      */
-      QBrush redBrush(Qt::red);
-      item->setForeground(0, redBrush);
-
-      /*
-       * Create instances in alphabetic order of the rest
-       *  of the classes that will by default exist under each Director.
-       */
-      new bRestore();
-      new Clients();
-      new FileSet();
-      new Jobs();
-      createPageJobList("", "", "", "", NULL);
-      new MediaList();
-      new MediaView();
-      new Storage();
-      if (m_openBrowser) {
-         new restoreTree();
-      }
-      if (m_openDirStat) {
-         new DirStat();
-      }
-      treeWidget->expandItem(topItem);
-      tabWidget->setCurrentWidget(m_currentConsole);
+	  /* Create console tree stacked widget item */
+	  m_currentConsole = new Console(tabWidget);
+	  m_currentConsole->setDirRes(dir);
+	  m_currentConsole->readSettings();
+
+	  /* The top tree item representing the director */
+	  topItem = new QTreeWidgetItem(treeWidget);
+	  topItem->setText(0, dir->name());
+	  topItem->setIcon(0, QIcon(":images/server.png"));
+	  /* Set background to grey for ease of identification of inactive Director */
+	  QBrush greyBrush(Qt::lightGray);
+	  topItem->setBackground(0, greyBrush);
+	  m_currentConsole->setDirectorTreeItem(topItem);
+	  m_consoleHash.insert(topItem, m_currentConsole);
+
+	  /* Create Tree Widget Item */
+	  item = new QTreeWidgetItem(topItem);
+	  item->setText(0, tr("Console"));
+	  if (!m_firstItem){ m_firstItem = item; }
+	  item->setIcon(0,QIcon(QString::fromUtf8(":images/utilities-terminal.png")));
+
+	  /* insert the cosole and tree widget item into the hashes */
+	  hashInsert(item, m_currentConsole);
+	  m_currentConsole->dockPage();
+
+	  /* Set Color of treeWidgetItem for the console
+	  * It will be set to green in the console class if the connection is made.
+	  */
+	  QBrush redBrush(Qt::red);
+	  item->setForeground(0, redBrush);
+
+	  /*
+	   * Create instances in alphabetic order of the rest
+	   *  of the classes that will by default exist under each Director.
+	   */
+	  new bRestore();
+	  new Clients();
+	  new FileSet();
+	  new Jobs();
+	  createPageJobList("", "", "", "", NULL);
+	  new MediaList();
+	  new MediaView();
+	  new Storage();
+	  if (m_openBrowser) {
+		 new restoreTree();
+	  }
+	  if (m_openDirStat) {
+		 new DirStat();
+	  }
+	  treeWidget->expandItem(topItem);
+	  tabWidget->setCurrentWidget(m_currentConsole);
    }
    UnlockRes();
 }
@@ -179,7 +185,7 @@ void MainWin::createPages()
  * create an instance of the the joblist class on the stack
  */
 void MainWin::createPageJobList(const QString &media, const QString &client,
-              const QString &job, const QString &fileset, QTreeWidgetItem *parentTreeWidgetItem)
+			  const QString &job, const QString &fileset, QTreeWidgetItem *parentTreeWidgetItem)
 {
    QTreeWidgetItem *holdItem;
 
@@ -188,12 +194,12 @@ void MainWin::createPageJobList(const QString &media, const QString &client,
    JobList* joblist = new JobList(media, client, job, fileset, parentTreeWidgetItem);
    /* If this is a query of jobs on a specific media */
    if ((media != "") || (client != "") || (job != "") || (fileset != "")) {
-      joblist->setCurrent();
-      /* did query produce results, if not close window and set back to hold */
-      if (joblist->m_resultCount == 0) {
-         joblist->closeStackPage();
-         treeWidget->setCurrentItem(holdItem);
-      }
+	  joblist->setCurrent();
+	  /* did query produce results, if not close window and set back to hold */
+	  if (joblist->m_resultCount == 0) {
+		 joblist->closeStackPage();
+		 treeWidget->setCurrentItem(holdItem);
+	  }
    }
 }
 
@@ -204,31 +210,31 @@ void MainWin::createPageJobList(const QString &media, const QString &client,
 void MainWin::keyPressEvent(QKeyEvent *event)
 {
    if (m_cmd_history.size() == 0) {
-      event->ignore();
-      return;
+	  event->ignore();
+	  return;
    }
    switch (event->key()) {
    case Qt::Key_Down:
-      if (m_cmd_last < 0 || m_cmd_last >= (m_cmd_history.size()-1)) {
-         event->ignore();
-         return;
-      }
-      m_cmd_last++;
-      break;
+	  if (m_cmd_last < 0 || m_cmd_last >= (m_cmd_history.size()-1)) {
+		 event->ignore();
+		 return;
+	  }
+	  m_cmd_last++;
+	  break;
    case Qt::Key_Up:
-      if (m_cmd_last == 0) {
-         event->ignore();
-         return;
-      }
-      if (m_cmd_last < 0 || m_cmd_last > (m_cmd_history.size()-1)) {
-         m_cmd_last = m_cmd_history.size() - 1;
-      } else {
-         m_cmd_last--;
-      }
-      break;
+	  if (m_cmd_last == 0) {
+		 event->ignore();
+		 return;
+	  }
+	  if (m_cmd_last < 0 || m_cmd_last > (m_cmd_history.size()-1)) {
+		 m_cmd_last = m_cmd_history.size() - 1;
+	  } else {
+		 m_cmd_last--;
+	  }
+	  break;
    default:
-      event->ignore();
-      return;
+	  event->ignore();
+	  return;
    }
    lineEdit->setText(m_cmd_history[m_cmd_last]);
 }
@@ -289,7 +295,7 @@ void MainWin::disconnectSignals()
 void MainWin::waitEnter()
 {
    if (m_waitState || m_isClosing) {
-      return;
+	  return;
    }
    m_waitState = true;
    if (mainWin->m_connDebug) Pmsg0(000, "Entering Wait State\n");
@@ -305,15 +311,15 @@ void MainWin::waitEnter()
 void MainWin::waitExit()
 {
    if (!m_waitState || m_isClosing) {
-      return;
+	  return;
    }
    if (mainWin->m_connDebug) Pmsg0(000, "Exiting Wait State\n");
    if (m_waitTreeItem && (m_waitTreeItem != treeWidget->currentItem())) {
-      treeWidget->setCurrentItem(m_waitTreeItem);
+	  treeWidget->setCurrentItem(m_waitTreeItem);
    }
    if (m_doConnect) {
-      connectSignals();
-      connectConsoleSignals();
+	  connectSignals();
+	  connectConsoleSignals();
    }
    app->restoreOverrideCursor();
    m_waitState = false;
@@ -358,27 +364,27 @@ void MainWin::closeEvent(QCloseEvent *event)
    writeSettings();
    /* Remove all groups from settings for OpenOnExit so that we can start some of the status windows */
    foreach(Console *console, m_consoleHash){
-      QSettings settings(console->m_dir->name(), "bat");
-      settings.beginGroup("OpenOnExit");
-      settings.remove("");
-      settings.endGroup();
+	  QSettings settings(console->m_dir->name(), "bat");
+	  settings.beginGroup("OpenOnExit");
+	  settings.remove("");
+	  settings.endGroup();
    }
    /* close all non console pages, this will call settings in destructors */
    while (m_consoleHash.count() < m_pagehash.count()) {
-      foreach(Pages *page, m_pagehash) {
-         if (page !=  page->console()) {
-            QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(page);
-            if (pageSelectorTreeWidgetItem->childCount() == 0) {
-               page->console()->setCurrent();
-               page->closeStackPage();
-            }
-         }
-      }
+	  foreach(Pages *page, m_pagehash) {
+		 if (page !=  page->console()) {
+			QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(page);
+			if (pageSelectorTreeWidgetItem->childCount() == 0) {
+			   page->console()->setCurrent();
+			   page->closeStackPage();
+			}
+		 }
+	  }
    }
    foreach(Console *console, m_consoleHash){
-      console->writeSettings();
-      console->terminate();
-      console->closeStackPage();
+	  console->writeSettings();
+	  console->terminate();
+	  console->closeStackPage();
    }
    event->accept();
 }
@@ -415,16 +421,16 @@ void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
    /* Is this a page that has been inserted into the hash  */
    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();
+	  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");
+	  Dmsg0(000, "Page not in hash");
    }
 }
 
@@ -441,7 +447,7 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre
 
    /* remove all actions before adding actions appropriate for new page */
    foreach(QAction* pageAction, treeWidget->actions()) {
-      treeWidget->removeAction(pageAction);
+	  treeWidget->removeAction(pageAction);
    }
 
    /* first determine the next item */
@@ -451,79 +457,79 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre
    nextConsole = m_consoleHash.value(currentitem);
    /* Is this a page that has been inserted into the hash  */
    if (nextPage) {
-      nextConsole = nextPage->console();
-      /* then is it a treeWidgetItem representing a director */
+	  nextConsole = nextPage->console();
+	  /* then is it a treeWidgetItem representing a director */
    } else if (nextConsole) {
-      /* let the next page BE the console */
-      nextPage = nextConsole;
+	  /* let the next page BE the console */
+	  nextPage = nextConsole;
    } else {
-      /* Should never get here */
-      nextPage = NULL;
-      nextConsole = NULL;
+	  /* Should never get here */
+	  nextPage = NULL;
+	  nextConsole = NULL;
    }
 
    /* The Previous item */
 
    /* this condition prevents a segfault.  The first time there is no previousitem*/
    if (previousitem) {
-      if (m_treeStackTrap == false) { /* keep track of previous items for going Back */
-         m_treeWidgetStack.append(previousitem);
-      }
-      /* knowing the treeWidgetItem, get the page from the hash */
-      previousPage = getFromHash(previousitem);
-      previousConsole = m_consoleHash.value(previousitem);
-      if (previousPage) {
-         previousConsole = previousPage->console();
-      } else if (previousConsole) {
-         previousPage = previousConsole;
-      }
-      if ((previousPage) || (previousConsole)) {
-         if (nextConsole != previousConsole) {
-            /* remove connections to the current console */
-            disconnectConsoleSignals(previousConsole);
-            QTreeWidgetItem *dirItem = previousConsole->directorTreeItem();
-            QBrush greyBrush(Qt::lightGray);
-            dirItem->setBackground(0, greyBrush);
-         }
-      }
+	  if (m_treeStackTrap == false) { /* keep track of previous items for going Back */
+		 m_treeWidgetStack.append(previousitem);
+	  }
+	  /* knowing the treeWidgetItem, get the page from the hash */
+	  previousPage = getFromHash(previousitem);
+	  previousConsole = m_consoleHash.value(previousitem);
+	  if (previousPage) {
+		 previousConsole = previousPage->console();
+	  } else if (previousConsole) {
+		 previousPage = previousConsole;
+	  }
+	  if ((previousPage) || (previousConsole)) {
+		 if (nextConsole != previousConsole) {
+			/* remove connections to the current console */
+			disconnectConsoleSignals(previousConsole);
+			QTreeWidgetItem *dirItem = previousConsole->directorTreeItem();
+			QBrush greyBrush(Qt::lightGray);
+			dirItem->setBackground(0, greyBrush);
+		 }
+	  }
    }
 
    /* process the current (next) item */
 
    if ((nextPage) || (nextConsole)) {
-      if (nextConsole != previousConsole) {
-         /* make connections to the current console */
-         m_currentConsole = nextConsole;
-         connectConsoleSignals();
-         setMessageIcon();
-         /* Set director's tree widget background to magenta for ease of identification */
-         QTreeWidgetItem *dirItem = m_currentConsole->directorTreeItem();
-         QBrush magentaBrush(Qt::magenta);
-         dirItem->setBackground(0, magentaBrush);
-      }
-      /* set the value for the currently active console */
-      int stackindex = tabWidget->indexOf(nextPage);
-      nextPage->firstUseDock();
-
-      /* Is this page currently on the stack or is it undocked */
-      if (stackindex >= 0) {
-         /* put this page on the top of the stack */
-         tabWidget->setCurrentIndex(stackindex);
-      } else {
-         /* it is undocked, raise it to the front */
-         nextPage->raise();
-      }
-      /* for the page selectors menu action to dock or undock, set the text */
-      nextPage->setContextMenuDockText();
-
-      treeWidget->addAction(actionToggleDock);
-      /* if this page is closeable, and it has no childern, then add that action */
-      if ((nextPage->isCloseable()) && (currentitem->child(0) == NULL))
-         treeWidget->addAction(actionClosePage);
-
-      /* Add the actions to the Page Selectors tree widget that are part of the
-       * current items list of desired actions regardless of whether on top of stack*/
-      treeWidget->addActions(nextPage->m_contextActions);
+	  if (nextConsole != previousConsole) {
+		 /* make connections to the current console */
+		 m_currentConsole = nextConsole;
+		 connectConsoleSignals();
+		 setMessageIcon();
+		 /* Set director's tree widget background to magenta for ease of identification */
+		 QTreeWidgetItem *dirItem = m_currentConsole->directorTreeItem();
+		 QBrush magentaBrush(Qt::magenta);
+		 dirItem->setBackground(0, magentaBrush);
+	  }
+	  /* set the value for the currently active console */
+	  int stackindex = tabWidget->indexOf(nextPage);
+	  nextPage->firstUseDock();
+
+	  /* Is this page currently on the stack or is it undocked */
+	  if (stackindex >= 0) {
+		 /* put this page on the top of the stack */
+		 tabWidget->setCurrentIndex(stackindex);
+	  } else {
+		 /* it is undocked, raise it to the front */
+		 nextPage->raise();
+	  }
+	  /* for the page selectors menu action to dock or undock, set the text */
+	  nextPage->setContextMenuDockText();
+
+	  treeWidget->addAction(actionToggleDock);
+	  /* if this page is closeable, and it has no childern, then add that action */
+	  if ((nextPage->isCloseable()) && (currentitem->child(0) == NULL))
+		 treeWidget->addAction(actionClosePage);
+
+	  /* Add the actions to the Page Selectors tree widget that are part of the
+	   * current items list of desired actions regardless of whether on top of stack*/
+	  treeWidget->addActions(nextPage->m_contextActions);
    }
 }
 
@@ -552,15 +558,15 @@ void MainWin::statusPageButtonClicked()
    /* if one exists, then just set it current */
    bool found = false;
    foreach(Pages *page, m_pagehash) {
-      if (m_currentConsole == page->console()) {
-         if (page->name() == tr("Director Status")) {
-            found = true;
-            page->setCurrent();
-         }
-      }
+	  if (m_currentConsole == page->console()) {
+		 if (page->name() == tr("Director Status")) {
+			found = true;
+			page->setCurrent();
+		 }
+	  }
    }
    if (!found) {
-      new DirStat();
+	  new DirStat();
    }
 }
 
@@ -579,32 +585,32 @@ void MainWin::input_line()
    QString cmdStr = lineEdit->text();    /* Get the text */
    lineEdit->clear();                    /* clear the lineEdit box */
    if (m_currentConsole->is_connected()) {
-      if (m_currentConsole->findDirComm(conn)) {
-         m_currentConsole->consoleCommand(cmdStr, conn);
-      } else {
-         /* Use consoleCommand to allow typing anything */
-         m_currentConsole->consoleCommand(cmdStr);
-      }
+	  if (m_currentConsole->findDirComm(conn)) {
+		 m_currentConsole->consoleCommand(cmdStr, conn);
+	  } else {
+		 /* Use consoleCommand to allow typing anything */
+		 m_currentConsole->consoleCommand(cmdStr);
+	  }
    } else {
-      set_status(tr("Director not connected. Click on connect button."));
+	  set_status(tr("Director not connected. Click on connect button."));
    }
    m_cmd_history.append(cmdStr);
    m_cmd_last = -1;
    if (treeWidget->currentItem() != getFromHash(m_currentConsole))
-      m_currentConsole->setCurrent();
+	  m_currentConsole->setCurrent();
 }
 
 
 void MainWin::about()
 {
    QString fmt = QString("<br><h2>Bareos Administration Tool %1</h2>"
-                         "<p>Original by Dirk H Bartley and Kern Sibbald</p>"
-                         "<p>For more information, see: www.bareos.com"
-                         "<p>Copyright &copy; 2007-2010 Free Software Foundation Europe e.V."
-                         "<p>Copyright &copy; 2011-2012 Planets Communications B.V."
-                         "<p>Copyright &copy; 2013-%2 Bareos GmbH & Co. KG"
-                         "<p>BAREOS &reg; is a registered trademark of Bareos GmbH & Co. KG"
-                         "<p>Licensed under GNU AGPLv3.").arg(VERSION).arg(BYEAR);
+						 "<p>Original by Dirk H Bartley and Kern Sibbald</p>"
+						 "<p>For more information, see: www.bareos.com"
+						 "<p>Copyright &copy; 2007-2010 Free Software Foundation Europe e.V."
+						 "<p>Copyright &copy; 2011-2012 Planets Communications B.V."
+						 "<p>Copyright &copy; 2013-%2 Bareos GmbH & Co. KG"
+						 "<p>BAREOS &reg; is a registered trademark of Bareos GmbH & Co. KG"
+						 "<p>Licensed under GNU AGPLv3.").arg(VERSION).arg(BYEAR);
 
    QMessageBox::about(this, tr("About Bareos Administration Tool"), fmt);
 }
@@ -646,7 +652,7 @@ void MainWin::undockWindowButton()
 {
    Pages* page = (Pages*)tabWidget->currentWidget();
    if (page) {
-      page->togglePageDocking();
+	  page->togglePageDocking();
    }
 }
 
@@ -661,10 +667,10 @@ void MainWin::toggleDockContextWindow()
 
    /* Is this a page that has been inserted into the hash  */
    if (getFromHash(currentitem)) {
-      Pages* page = getFromHash(currentitem);
-      if (page) {
-         page->togglePageDocking();
-      }
+	  Pages* page = getFromHash(currentitem);
+	  if (page) {
+		 page->togglePageDocking();
+	  }
    }
 }
 
@@ -679,14 +685,14 @@ void MainWin::stackItemChanged(int)
    Pages* page = (Pages*)tabWidget->currentWidget();
    /* run the virtual function in case this class overrides it */
    if (page) {
-      page->currentStackItem();
+	  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 *)));
-      treeWidget->setCurrentItem(getFromHash(page));
-      connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
-      connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+	  disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+	  disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+	  treeWidget->setCurrentItem(getFromHash(page));
+	  connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+	  connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
    }
 }
 
@@ -707,9 +713,9 @@ void MainWin::hashInsert(QTreeWidgetItem *item, Pages *page)
 void MainWin::hashRemove(QTreeWidgetItem *item, Pages *page)
 {
    /* I had all sorts of return status checking code here.  Do we have a log
-    * level capability in bat.  I would have left it in but it used printf's
-    * and it should really be some kind of log level facility ???
-    * ******FIXME********/
+	* level capability in bat.  I would have left it in but it used printf's
+	* and it should really be some kind of log level facility ???
+	* ******FIXME********/
    m_pagehash.remove(item);
    m_widgethash.remove(page);
 }
@@ -747,21 +753,21 @@ void MainWin::closePage(int item)
    Pages *page = NULL;
 
    if (item >= 0) {
-     page = (Pages *)tabWidget->widget(item);
+	 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);
-      }
+	  currentitem = treeWidget->currentItem();
+	  /* Is this a page that has been inserted into the hash  */
+	  if (getFromHash(currentitem)) {
+		 page = getFromHash(currentitem);
+	  }
    }
 
    if (page) {
-      if (page->isCloseable()) {
-         page->closeStackPage();
-      } else {
-         page->hidePage();
-      }
+	  if (page->isCloseable()) {
+		 page->closeStackPage();
+	  } else {
+		 page->hidePage();
+	  }
    }
 }
 
@@ -808,14 +814,14 @@ void MainWin::setPreferences()
    prefs.rtRestore3CheckBox->setCheckState(m_rtRestore3Debug ? Qt::Checked : Qt::Unchecked);
    switch (ItemFormatterBase::getBytesConversion()) {
    case ItemFormatterBase::BYTES_CONVERSION_NONE:
-      prefs.radioConvertOff->setChecked(Qt::Checked);
-      break;
+	  prefs.radioConvertOff->setChecked(Qt::Checked);
+	  break;
    case ItemFormatterBase::BYTES_CONVERSION_IEC:
-      prefs.radioConvertIEC->setChecked(Qt::Checked);
-      break;
+	  prefs.radioConvertIEC->setChecked(Qt::Checked);
+	  break;
    default:
-      prefs.radioConvertStandard->setChecked(Qt::Checked);
-      break;
+	  prefs.radioConvertStandard->setChecked(Qt::Checked);
+	  break;
    }
    prefs.openPlotCheckBox->setCheckState(m_openPlot ? Qt::Checked : Qt::Unchecked);
    prefs.openBrowserCheckBox->setCheckState(m_openBrowser ? Qt::Checked : Qt::Unchecked);
@@ -859,11 +865,11 @@ void prefsDialog::accept()
    mainWin->m_rtRestore2Debug = this->rtRestore2CheckBox->checkState() == Qt::Checked;
    mainWin->m_rtRestore3Debug = this->rtRestore3CheckBox->checkState() == Qt::Checked;
    if (this->radioConvertOff->isChecked()) {
-      ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_NONE);
+	  ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_NONE);
    } else if (this->radioConvertIEC->isChecked()){
-      ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_IEC);
+	  ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_IEC);
    } else {
-      ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_SI);
+	  ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_SI);
    }
    mainWin->m_openPlot = this->openPlotCheckBox->checkState() == Qt::Checked;
    mainWin->m_openBrowser = this->openBrowserCheckBox->checkState() == Qt::Checked;
@@ -942,8 +948,8 @@ void MainWin::readPreferences()
    settings.beginGroup("Misc");
    m_longList = settings.value("longList", false).toBool();
    ItemFormatterBase::setBytesConversion(
-         (ItemFormatterBase::BYTES_CONVERSION) settings.value("byteConvert",
-         ItemFormatterBase::BYTES_CONVERSION_IEC).toInt());
+		 (ItemFormatterBase::BYTES_CONVERSION) settings.value("byteConvert",
+		 ItemFormatterBase::BYTES_CONVERSION_IEC).toInt());
    m_openPlot = settings.value("openplot", false).toBool();
    m_openBrowser = settings.value("openbrowser", false).toBool();
    m_openDirStat = settings.value("opendirstat", false).toBool();
@@ -967,9 +973,9 @@ void MainWin::readPreferences()
 void MainWin::setMessageIcon()
 {
    if (m_currentConsole->is_messagesPending())
-      actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-pending.png")));
+	  actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-pending.png")));
    else
-      actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-new.png")));
+	  actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-new.png")));
 }
 
 void MainWin::goToPreviousPage()
@@ -977,24 +983,24 @@ void MainWin::goToPreviousPage()
    m_treeStackTrap = true;
    bool done = false;
    while (!done) {
-      /* If stack list is emtpty, then done */
-      if (m_treeWidgetStack.isEmpty()) {
-         done = true;
-      } else {
-         QTreeWidgetItem* testItem = m_treeWidgetStack.takeLast();
-         QTreeWidgetItemIterator it(treeWidget);
-         /* lets avoid a segfault by setting an item current that no longer exists */
-         while (*it) {
-            if (*it == testItem) {
-               if (testItem != treeWidget->currentItem()) {
-                  treeWidget->setCurrentItem(testItem);
-                  done = true;
-               }
-               break;
-            }
-            ++it;
-         }
-      }
+	  /* If stack list is emtpty, then done */
+	  if (m_treeWidgetStack.isEmpty()) {
+		 done = true;
+	  } else {
+		 QTreeWidgetItem* testItem = m_treeWidgetStack.takeLast();
+		 QTreeWidgetItemIterator it(treeWidget);
+		 /* lets avoid a segfault by setting an item current that no longer exists */
+		 while (*it) {
+			if (*it == testItem) {
+			   if (testItem != treeWidget->currentItem()) {
+				  treeWidget->setCurrentItem(testItem);
+				  done = true;
+			   }
+			   break;
+			}
+			++it;
+		 }
+	  }
    }
    m_treeStackTrap = false;
 }
diff --git a/src/qt-console/mediaedit/mediaedit.cpp b/src/qt-console/mediaedit/mediaedit.cpp
index 119166d..c8373c5 100644
--- a/src/qt-console/mediaedit/mediaedit.cpp
+++ b/src/qt-console/mediaedit/mediaedit.cpp
@@ -22,6 +22,11 @@
  * Dirk Bartley, March 2007
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
diff --git a/src/qt-console/mediainfo/mediainfo.cpp b/src/qt-console/mediainfo/mediainfo.cpp
index b174410..ff753e2 100644
--- a/src/qt-console/mediainfo/mediainfo.cpp
+++ b/src/qt-console/mediainfo/mediainfo.cpp
@@ -19,6 +19,11 @@
    02110-1301, USA.
 */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
@@ -210,7 +215,11 @@ void MediaInfo::populateForm()
 		 label_VolRetention->setText(QString(buf));
 
 		 if (LastWritten != "") {
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+			t = str_to_utime(LastWritten.toLatin1().data());
+#else
 			t = str_to_utime(LastWritten.toAscii().data());
+#endif
 			t = t + stat.toULongLong();
 			ttime = t;
 			localtime_r(&ttime, &tm);
diff --git a/src/qt-console/medialist/medialist.cpp b/src/qt-console/medialist/medialist.cpp
index 8ee7cbb..8966ea0 100644
--- a/src/qt-console/medialist/medialist.cpp
+++ b/src/qt-console/medialist/medialist.cpp
@@ -27,6 +27,11 @@
  * Dirk Bartley, March 2007
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
diff --git a/src/qt-console/medialist/mediaview.cpp b/src/qt-console/medialist/mediaview.cpp
index e43529f..b12a95d 100644
--- a/src/qt-console/medialist/mediaview.cpp
+++ b/src/qt-console/medialist/mediaview.cpp
@@ -21,6 +21,11 @@
    02110-1301, USA.
 */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
@@ -309,7 +314,11 @@ void MediaView::filterExipired(QStringList &list)
 
 		 } else {
 			stat = fieldlist.at(8);
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+			t = str_to_utime(LastWritten.toLatin1().data());
+#else
 			t = str_to_utime(LastWritten.toAscii().data());
+#endif
 			t = t + stat.toULongLong();
 			if (t > now) {
 			   list.removeAt(i);
@@ -465,7 +474,11 @@ void MediaView::populateTable()
 		 buf[0] = 0;
 		 if (LastWritten != "") {
 			stat = fld.next();  // VolUseDuration
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+			t = str_to_utime(LastWritten.toLatin1().data());
+#else
 			t = str_to_utime(LastWritten.toAscii().data());
+#endif
 			t = t + stat.toULongLong();
 			ttime = t;
 			localtime_r(&ttime, &tm);
diff --git a/src/qt-console/mount/mount.cpp b/src/qt-console/mount/mount.cpp
index 0e8b235..145ef7c 100644
--- a/src/qt-console/mount/mount.cpp
+++ b/src/qt-console/mount/mount.cpp
@@ -25,6 +25,11 @@
  * Kern Sibbald, February MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
diff --git a/src/qt-console/pages.cpp b/src/qt-console/pages.cpp
index 5972d94..2939b6e 100644
--- a/src/qt-console/pages.cpp
+++ b/src/qt-console/pages.cpp
@@ -22,6 +22,8 @@
  * Dirk Bartley, March 2007
  */
 
+#include <QtCore>
+
 #include "bat.h"
 #include "pages.h"
 
@@ -29,15 +31,19 @@
 bool isWin32Path(QString &fullPath)
 {
    if (fullPath.size()<2) {
-      return false;
+	  return false;
    }
-
-   bool toret = fullPath[1].toAscii() == ':' && fullPath[0].isLetter();
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+   bool toret = fullPath[1].toLatin1() == ':' && fullPath[0].isLetter();
+#else
+	bool toret = fullPath[1].toAscii() == ':' && fullPath[0].isLetter();
+#endif
    if (mainWin->m_miscDebug) {
-      if (toret)
-         Pmsg1(000, "returning from isWin32Path true %s\n", fullPath.toUtf8().data());
-      else
-         Pmsg1(000, "returning from isWin32Path false %s\n", fullPath.toUtf8().data());
+	  if (toret)
+		 Pmsg1(000, "returning from isWin32Path true %s\n", fullPath.toUtf8().data());
+	  else
+		 Pmsg1(000, "returning from isWin32Path false %s\n", fullPath.toUtf8().data());
    }
    return toret;
 }
@@ -57,7 +63,7 @@ Pages::Pages() : QWidget()
 void Pages::firstUseDock()
 {
    if (!m_onceDocked && m_dockOnFirstUse) {
-      dockPage();
+	  dockPage();
    }
 }
 
@@ -70,26 +76,26 @@ void Pages::firstUseDock()
 void Pages::dockPage()
 {
    if (isDocked()) {
-      return;
+	  return;
    }
 
    /* These two lines are for making sure if it is being changed from a window
-    * that it has the proper window flag and parent.
-    */
+	* that it has the proper window flag and parent.
+	*/
    setWindowFlags(Qt::Widget);
 
    /* calculate the index that the tab should be inserted into */
    int tabPos = 0;
    QTreeWidgetItemIterator it(mainWin->treeWidget);
    while (*it) {
-      Pages *somepage = mainWin->getFromHash(*it);
-      if (this == somepage) {
-         tabPos += 1;
-         break;
-      }
-      int pageindex = mainWin->tabWidget->indexOf(somepage);
-      if (pageindex != -1) { tabPos = pageindex; }
-      ++it;
+	  Pages *somepage = mainWin->getFromHash(*it);
+	  if (this == somepage) {
+		 tabPos += 1;
+		 break;
+	  }
+	  int pageindex = mainWin->tabWidget->indexOf(somepage);
+	  if (pageindex != -1) { tabPos = pageindex; }
+	  ++it;
    }
 
    /* This was being done already */
@@ -112,7 +118,7 @@ void Pages::dockPage()
 void Pages::undockPage()
 {
    if (!isDocked()) {
-      return;
+	  return;
    }
 
    /* Change from a stacked widget to a normal window */
@@ -135,9 +141,9 @@ void Pages::undockPage()
 void Pages::togglePageDocking()
 {
    if (m_docked) {
-      undockPage();
+	  undockPage();
    } else {
-      dockPage();
+	  dockPage();
    }
 }
 
@@ -172,7 +178,7 @@ bool Pages::isCloseable()
 void Pages::hidePage()
 {
    if (!m_parent || (m_parent->indexOf(this) <= 0)) {
-      return;
+	  return;
    }
    /* Remove any tab that may exist */
    m_parent->removeTab(m_parent->indexOf(this));
@@ -200,8 +206,8 @@ void Pages::closeEvent(QCloseEvent* event)
    event->ignore();
 
    /* Set the current tree widget item in the Page Selector window to the item
-    * which represents "this"
-    * Which will also bring "this" to the top of the stacked widget */
+	* which represents "this"
+	* Which will also bring "this" to the top of the stacked widget */
    setCurrent();
 }
 
@@ -233,9 +239,9 @@ void Pages::closeStackPage()
    QTreeWidgetItem *item=mainWin->getFromHash(this);
    /* remove the QTreeWidgetItem <-> page from the hash */
    if (item) {
-      mainWin->hashRemove(item, this);
-      /* remove the item from the page selector by destroying it */
-      delete item;
+	  mainWin->hashRemove(item, this);
+	  /* remove the item from the page selector by destroying it */
+	  delete item;
    }
    /* remove this */
    delete this;
@@ -260,13 +266,13 @@ void Pages::pgInitialize(const QString &tname, QTreeWidgetItem *parentTreeWidget
    m_docked = false;
    m_onceDocked = false;
    if (tname.size()) {
-      m_name = tname;
+	  m_name = tname;
    }
    m_parent = mainWin->tabWidget;
    m_console = mainWin->currentConsole();
 
    if (!parentTreeWidgetItem) {
-      parentTreeWidgetItem = m_console->directorTreeItem();
+	  parentTreeWidgetItem = m_console->directorTreeItem();
    }
 
    QTreeWidgetItem *item = new QTreeWidgetItem(parentTreeWidgetItem);
@@ -300,12 +306,12 @@ void Pages::consoleCommand(QString &command, bool setCurrent)
    int conn;
    bool donotify = false;
    if (m_console->getDirComm(conn))  {
-      if (m_console->is_notify_enabled(conn)) {
-         donotify = true;
-         m_console->notify(conn, false);
-      }
-      consoleCommand(command, conn, setCurrent);
-      if (donotify) { m_console->notify(conn, true); }
+	  if (m_console->is_notify_enabled(conn)) {
+		 donotify = true;
+		 m_console->notify(conn, false);
+	  }
+	  consoleCommand(command, conn, setCurrent);
+	  if (donotify) { m_console->notify(conn, true); }
    }
 }
 
@@ -337,7 +343,7 @@ void Pages::consoleCommand(QString &command, int conn, bool setCurrent)
 void Pages::changeEvent(QEvent *event)
 {
    if ((event->type() ==  QEvent::ActivationChange) && (isActiveWindow())) {
-      setCurrent();
+	  setCurrent();
    }
 }
 
@@ -379,9 +385,9 @@ void Pages::setContextMenuDockText()
    QTreeWidgetItem *item = mainWin->getFromHash(this);
    QString docktext;
    if (isDocked()) {
-      docktext = tr("UnDock %1 Window").arg(item->text(0));
+	  docktext = tr("UnDock %1 Window").arg(item->text(0));
    } else {
-      docktext = tr("ReDock %1 Window").arg(item->text(0));
+	  docktext = tr("ReDock %1 Window").arg(item->text(0));
    }
 
    mainWin->actionToggleDock->setText(docktext);
@@ -396,17 +402,17 @@ void Pages::setTreeWidgetItemDockColor()
 {
    QTreeWidgetItem* item = mainWin->getFromHash(this);
    if (item) {
-      if (item->text(0) != tr("Console")) {
-         if (isDocked()) {
-         /* Set the brush to blue if undocked */
-            QBrush blackBrush(Qt::black);
-            item->setForeground(0, blackBrush);
-         } else {
-         /* Set the brush back to black if docked */
-            QBrush blueBrush(Qt::blue);
-            item->setForeground(0, blueBrush);
-         }
-      }
+	  if (item->text(0) != tr("Console")) {
+		 if (isDocked()) {
+		 /* Set the brush to blue if undocked */
+			QBrush blackBrush(Qt::black);
+			item->setForeground(0, blackBrush);
+		 } else {
+		 /* Set the brush back to black if docked */
+			QBrush blueBrush(Qt::blue);
+			item->setForeground(0, blueBrush);
+		 }
+	  }
    }
 }
 
@@ -415,17 +421,17 @@ void Pages::getVolumeList(QStringList &volumeList)
 {
    QString query("SELECT VolumeName AS Media FROM Media ORDER BY Media");
    if (mainWin->m_sqlDebug) {
-      Pmsg1(000, "Query cmd : %s\n",query.toUtf8().data());
+	  Pmsg1(000, "Query cmd : %s\n",query.toUtf8().data());
    }
    QStringList results;
    if (m_console->sql_cmd(query, results)) {
-      QString field;
-      QStringList fieldlist;
-      /* Iterate through the lines of results. */
-      foreach (QString resultline, results) {
-         fieldlist = resultline.split("\t");
-         volumeList.append(fieldlist[0]);
-      } /* foreach resultline */
+	  QString field;
+	  QStringList fieldlist;
+	  /* Iterate through the lines of results. */
+	  foreach (QString resultline, results) {
+		 fieldlist = resultline.split("\t");
+		 volumeList.append(fieldlist[0]);
+	  } /* foreach resultline */
    } /* if results from query */
 }
 
@@ -434,16 +440,16 @@ void Pages::getStatusList(QStringList &statusLongList)
 {
    QString statusQuery("SELECT JobStatusLong FROM Status");
    if (mainWin->m_sqlDebug) {
-      Pmsg1(000, "Query cmd : %s\n",statusQuery.toUtf8().data());
+	  Pmsg1(000, "Query cmd : %s\n",statusQuery.toUtf8().data());
    }
    QStringList statusResults;
    if (m_console->sql_cmd(statusQuery, statusResults)) {
-      QString field;
-      QStringList fieldlist;
-      /* Iterate through the lines of results. */
-      foreach (QString resultline, statusResults) {
-         fieldlist = resultline.split("\t");
-         statusLongList.append(fieldlist[0]);
-      } /* foreach resultline */
+	  QString field;
+	  QStringList fieldlist;
+	  /* Iterate through the lines of results. */
+	  foreach (QString resultline, statusResults) {
+		 fieldlist = resultline.split("\t");
+		 statusLongList.append(fieldlist[0]);
+	  } /* foreach resultline */
    } /* if results from statusquery */
 }
diff --git a/src/qt-console/pages.h b/src/qt-console/pages.h
index f1012ac..c700c19 100644
--- a/src/qt-console/pages.h
+++ b/src/qt-console/pages.h
@@ -26,6 +26,11 @@
 #ifndef _PAGES_H_
 #define _PAGES_H_
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QTreeWidgetItem>
+#endif
 #include <QtGui>
 
 /*
diff --git a/src/qt-console/relabel/relabel.cpp b/src/qt-console/relabel/relabel.cpp
index 345cba7..78d618d 100644
--- a/src/qt-console/relabel/relabel.cpp
+++ b/src/qt-console/relabel/relabel.cpp
@@ -25,6 +25,11 @@
  * Kern Sibbald, February MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
diff --git a/src/qt-console/restore/prerestore.cpp b/src/qt-console/restore/prerestore.cpp
index 255cca5..b6fe94b 100644
--- a/src/qt-console/restore/prerestore.cpp
+++ b/src/qt-console/restore/prerestore.cpp
@@ -25,6 +25,12 @@
  * Kern Sibbald, February MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
+
 #include "bat.h"
 #include "restore.h"
 
@@ -69,35 +75,35 @@ void prerestorePage::buildPage()
    beforeDateTime->setEnabled(false);
    selectFilesRadio->setChecked(true);
    if (m_dataInType == R_NONE) {
-      selectJobRadio->setChecked(true);
-      selectJobIdsRadio->setChecked(false);
-      jobIdEdit->setText(tr("Comma separted list of Job Ids"));
-      jobIdEdit->setEnabled(false);
+	  selectJobRadio->setChecked(true);
+	  selectJobIdsRadio->setChecked(false);
+	  jobIdEdit->setText(tr("Comma separted list of Job Ids"));
+	  jobIdEdit->setEnabled(false);
    } else if (m_dataInType == R_JOBIDLIST) {
-      selectJobIdsRadio->setChecked(true);
-      selectJobRadio->setChecked(false);
-      jobIdEdit->setText(m_dataIn);
-      jobRadioClicked(false);
-      QStringList fieldlist;
-      if (jobdefsFromJob(fieldlist, m_dataIn) == 1) {
-         filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly));
-         clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly));
-         jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly));
-      }
+	  selectJobIdsRadio->setChecked(true);
+	  selectJobRadio->setChecked(false);
+	  jobIdEdit->setText(m_dataIn);
+	  jobRadioClicked(false);
+	  QStringList fieldlist;
+	  if (jobdefsFromJob(fieldlist, m_dataIn) == 1) {
+		 filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly));
+		 clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly));
+		 jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly));
+	  }
    } else if (m_dataInType == R_JOBDATETIME) {
-      selectJobRadio->setChecked(true);
-      selectJobIdsRadio->setChecked(false);
-      jobIdEdit->setText(tr("Comma separted list of Job Ids"));
-      jobIdEdit->setEnabled(false);
-      recentCheckBox->setCheckState(Qt::Unchecked);
-      jobRadioClicked(true);
-      QStringList fieldlist;
-      if (jobdefsFromJob(fieldlist, m_dataIn) == 1) {
-         filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly));
-         clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly));
-         jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly));
-         beforeDateTime->setDateTime(QDateTime::fromString(fieldlist[3], mainWin->m_dtformat));
-     }
+	  selectJobRadio->setChecked(true);
+	  selectJobIdsRadio->setChecked(false);
+	  jobIdEdit->setText(tr("Comma separted list of Job Ids"));
+	  jobIdEdit->setEnabled(false);
+	  recentCheckBox->setCheckState(Qt::Unchecked);
+	  jobRadioClicked(true);
+	  QStringList fieldlist;
+	  if (jobdefsFromJob(fieldlist, m_dataIn) == 1) {
+		 filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly));
+		 clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly));
+		 jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly));
+		 beforeDateTime->setDateTime(QDateTime::fromString(fieldlist[3], mainWin->m_dtformat));
+	 }
    }
    job_name_change(0);
    connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int)));
@@ -122,9 +128,9 @@ void prerestorePage::buildPage()
 void prerestorePage::okButtonPushed()
 {
    if (!selectJobRadio->isChecked()) {
-      if (!checkJobIdList()) {
-         return;
-      }
+	  if (!checkJobIdList()) {
+		 return;
+	  }
    }
    QString cmd;
 
@@ -135,47 +141,47 @@ void prerestorePage::okButtonPushed()
    cmd += " fileset=\"" + filesetCombo->currentText() + "\"";
    cmd += " client=\"" + clientCombo->currentText() + "\"";
    if (selectJobRadio->isChecked()) {
-      if (poolCombo->currentText() != tr("Any") ){
-         cmd += " pool=\"" + poolCombo->currentText() + "\"";
-      }
-      cmd += " storage=\"" + storageCombo->currentText() + "\"";
-      if (recentCheckBox->checkState() == Qt::Checked) {
-         cmd += " current";
-      } else {
-         QDateTime stamp = beforeDateTime->dateTime();
-         QString before = stamp.toString(mainWin->m_dtformat);
-         cmd += " before=\"" + before + "\"";
-      }
+	  if (poolCombo->currentText() != tr("Any") ){
+		 cmd += " pool=\"" + poolCombo->currentText() + "\"";
+	  }
+	  cmd += " storage=\"" + storageCombo->currentText() + "\"";
+	  if (recentCheckBox->checkState() == Qt::Checked) {
+		 cmd += " current";
+	  } else {
+		 QDateTime stamp = beforeDateTime->dateTime();
+		 QString before = stamp.toString(mainWin->m_dtformat);
+		 cmd += " before=\"" + before + "\"";
+	  }
    } else {
-      cmd += " jobid=\"" + jobIdEdit->text() + "\"";
+	  cmd += " jobid=\"" + jobIdEdit->text() + "\"";
    }
    if (selectFilesRadio->isChecked()) {
-      if (!selectJobIdsRadio->isChecked())
-         cmd += " select";
+	  if (!selectJobIdsRadio->isChecked())
+		 cmd += " select";
    } else {
-      cmd += " all done";
+	  cmd += " all done";
    }
 
    if (mainWin->m_commandDebug) {
-      Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data());
+	  Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data());
    }
    /*
-    * Send off command that looks something like:
-    *
-    * restore fileset="Full Set" client="timmy-fd"
-    *        storage="File" current select
-    */
+	* Send off command that looks something like:
+	*
+	* restore fileset="Full Set" client="timmy-fd"
+	*        storage="File" current select
+	*/
    m_console->write_dir(m_conn, cmd.toUtf8().data());
 
    /* Note, do not turn notifier back on here ... */
    if (selectFilesRadio->isChecked()) {
-      setConsoleCurrent();
-      closeStackPage();
-      /* wait will be exited in the restore page constructor */
-      mainWin->waitEnter();
+	  setConsoleCurrent();
+	  closeStackPage();
+	  /* wait will be exited in the restore page constructor */
+	  mainWin->waitEnter();
    } else {
-      closeStackPage();
-      mainWin->resetFocus();
+	  closeStackPage();
+	  mainWin->resetFocus();
    }
    m_console->notify(m_conn, true);
    if (mainWin->m_miscDebug) Pmsg0(000, "preRestore OK pressed\n");
@@ -204,10 +210,10 @@ void prerestorePage::job_name_change(int index)
    (void)index;
    job_defs.job_name = jobCombo->currentText();
    if (m_console->get_job_defaults(m_conn, job_defs)) {
-      filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
-      clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
-      poolCombo->setCurrentIndex(poolCombo->findText(tr("Any"), Qt::MatchExactly));
-      storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
+	  filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
+	  clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
+	  poolCombo->setCurrentIndex(poolCombo->findText(tr("Any"), Qt::MatchExactly));
+	  storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
    }
 }
 
@@ -218,9 +224,9 @@ void prerestorePage::job_name_change(int index)
 void prerestorePage::recentChanged(int state)
 {
    if ((state == Qt::Unchecked) && (selectJobRadio->isChecked())) {
-      beforeDateTime->setEnabled(true);
+	  beforeDateTime->setEnabled(true);
    } else {
-      beforeDateTime->setEnabled(false);
+	  beforeDateTime->setEnabled(false);
    }
 }
 
@@ -242,12 +248,12 @@ int prerestorePage::jobdefsFromJob(QStringList &fieldlist, QString &jobId)
    if (mainWin->m_sqlDebug) { Pmsg1(000, "query = %s\n", query.toUtf8().data()); }
    QStringList results;
    if (m_console->sql_cmd(m_conn, query, results)) {
-      QString field;
+	  QString field;
 
-      /* Iterate through the lines of results, there should only be one. */
-      foreach (QString resultline, results) {
-         fieldlist = resultline.split("\t");
-      } /* foreach resultline */
+	  /* Iterate through the lines of results, there should only be one. */
+	  foreach (QString resultline, results) {
+		 fieldlist = resultline.split("\t");
+	  } /* foreach resultline */
    } /* if results from query */
 
    /* ***FIXME*** This should not ever be getting more than one */
@@ -267,54 +273,54 @@ bool prerestorePage::checkJobIdList()
    /* Need to check and make sure the text is a comma separated list of integers */
    QString line = jobIdEdit->text();
    if (line.contains(" ")) {
-      QMessageBox::warning(this, "Bat",
-         tr("There can be no spaces in the text for the joblist.\n"
-         "Press OK to continue?"), QMessageBox::Ok );
-      return false;
+	  QMessageBox::warning(this, "Bat",
+		 tr("There can be no spaces in the text for the joblist.\n"
+		 "Press OK to continue?"), QMessageBox::Ok );
+	  return false;
    }
    QStringList joblist = line.split(",", QString::SkipEmptyParts);
    bool allintokay = true, alljobok = true, allisjob = true;
    QString jobName(""), clientName("");
    foreach (QString job, joblist) {
-      bool intok;
-      job.toInt(&intok, 10);
-      if (intok) {
-         /* are the integers representing a list of jobs all with the same job
-          * and client */
-         QStringList fields;
-         if (jobdefsFromJob(fields, job) == 1) {
-            if (jobName == "")
-               jobName = fields[0];
-            else if (jobName != fields[0])
-               alljobok = false;
-            if (clientName == "")
-               clientName = fields[1];
-            else if (clientName != fields[1])
-               alljobok = false;
-         } else {
-            allisjob = false;
-         }
-      } else {
-         allintokay = false;
-      }
+	  bool intok;
+	  job.toInt(&intok, 10);
+	  if (intok) {
+		 /* are the integers representing a list of jobs all with the same job
+		  * and client */
+		 QStringList fields;
+		 if (jobdefsFromJob(fields, job) == 1) {
+			if (jobName == "")
+			   jobName = fields[0];
+			else if (jobName != fields[0])
+			   alljobok = false;
+			if (clientName == "")
+			   clientName = fields[1];
+			else if (clientName != fields[1])
+			   alljobok = false;
+		 } else {
+			allisjob = false;
+		 }
+	  } else {
+		 allintokay = false;
+	  }
    }
    if (!allintokay){
-      QMessageBox::warning(this, "Bat",
-         tr("The string is not a comma separated list of integers.\n"
-         "Press OK to continue?"), QMessageBox::Ok );
-      return false;
+	  QMessageBox::warning(this, "Bat",
+		 tr("The string is not a comma separated list of integers.\n"
+		 "Press OK to continue?"), QMessageBox::Ok );
+	  return false;
    }
    if (!allisjob){
-      QMessageBox::warning(this, tr("Bat"),
-         tr("At least one of the jobs is not a valid job of type \"Backup\".\n"
-         "Press OK to continue?"), QMessageBox::Ok );
-      return false;
+	  QMessageBox::warning(this, tr("Bat"),
+		 tr("At least one of the jobs is not a valid job of type \"Backup\".\n"
+		 "Press OK to continue?"), QMessageBox::Ok );
+	  return false;
    }
    if (!alljobok){
-      QMessageBox::warning(this, "Bat",
-         tr("All jobs in the list must be of the same jobName and same client.\n"
-         "Press OK to continue?"), QMessageBox::Ok );
-      return false;
+	  QMessageBox::warning(this, "Bat",
+		 tr("All jobs in the list must be of the same jobName and same client.\n"
+		 "Press OK to continue?"), QMessageBox::Ok );
+	  return false;
    }
    return true;
 }
@@ -326,65 +332,65 @@ bool prerestorePage::checkJobIdList()
 void prerestorePage::jobRadioClicked(bool checked)
 {
    if (checked) {
-      jobCombo->setEnabled(true);
-      filesetCombo->setEnabled(true);
-      clientCombo->setEnabled(true);
-      poolCombo->setEnabled(true);
-      storageCombo->setEnabled(true);
-      recentCheckBox->setEnabled(true);
-      if (!recentCheckBox->isChecked()) {
-         beforeDateTime->setEnabled(true);
-      }
-      jobIdEdit->setEnabled(false);
-      selectJobRadio->setChecked(true);
-      selectJobIdsRadio->setChecked(false);
+	  jobCombo->setEnabled(true);
+	  filesetCombo->setEnabled(true);
+	  clientCombo->setEnabled(true);
+	  poolCombo->setEnabled(true);
+	  storageCombo->setEnabled(true);
+	  recentCheckBox->setEnabled(true);
+	  if (!recentCheckBox->isChecked()) {
+		 beforeDateTime->setEnabled(true);
+	  }
+	  jobIdEdit->setEnabled(false);
+	  selectJobRadio->setChecked(true);
+	  selectJobIdsRadio->setChecked(false);
    } else {
-      jobCombo->setEnabled(false);
-      filesetCombo->setEnabled(false);
-      clientCombo->setEnabled(false);
-      poolCombo->setEnabled(false);
-      storageCombo->setEnabled(false);
-      recentCheckBox->setEnabled(false);
-      beforeDateTime->setEnabled(false);
-      jobIdEdit->setEnabled(true);
-      selectJobRadio->setChecked(false);
-      selectJobIdsRadio->setChecked(true);
+	  jobCombo->setEnabled(false);
+	  filesetCombo->setEnabled(false);
+	  clientCombo->setEnabled(false);
+	  poolCombo->setEnabled(false);
+	  storageCombo->setEnabled(false);
+	  recentCheckBox->setEnabled(false);
+	  beforeDateTime->setEnabled(false);
+	  jobIdEdit->setEnabled(true);
+	  selectJobRadio->setChecked(false);
+	  selectJobIdsRadio->setChecked(true);
    }
    if (mainWin->m_miscDebug) {
-      Pmsg2(000, "jobRadio=%d jobidsRadio=%d\n", selectJobRadio->isChecked(),
-         selectJobIdsRadio->isChecked());
+	  Pmsg2(000, "jobRadio=%d jobidsRadio=%d\n", selectJobRadio->isChecked(),
+		 selectJobIdsRadio->isChecked());
    }
 }
 
 void prerestorePage::jobidsRadioClicked(bool checked)
 {
    if (checked) {
-      jobCombo->setEnabled(false);
-      filesetCombo->setEnabled(false);
-      clientCombo->setEnabled(false);
-      poolCombo->setEnabled(false);
-      storageCombo->setEnabled(false);
-      recentCheckBox->setEnabled(false);
-      beforeDateTime->setEnabled(false);
-      jobIdEdit->setEnabled(true);
-      selectJobRadio->setChecked(false);
-      selectJobIdsRadio->setChecked(true);
+	  jobCombo->setEnabled(false);
+	  filesetCombo->setEnabled(false);
+	  clientCombo->setEnabled(false);
+	  poolCombo->setEnabled(false);
+	  storageCombo->setEnabled(false);
+	  recentCheckBox->setEnabled(false);
+	  beforeDateTime->setEnabled(false);
+	  jobIdEdit->setEnabled(true);
+	  selectJobRadio->setChecked(false);
+	  selectJobIdsRadio->setChecked(true);
    } else {
-      jobCombo->setEnabled(true);
-      filesetCombo->setEnabled(true);
-      clientCombo->setEnabled(true);
-      poolCombo->setEnabled(true);
-      storageCombo->setEnabled(true);
-      recentCheckBox->setEnabled(true);
-      if (!recentCheckBox->isChecked()) {
-         beforeDateTime->setEnabled(true);
-      }
-      jobIdEdit->setEnabled(false);
-      selectJobRadio->setChecked(true);
-      selectJobIdsRadio->setChecked(false);
+	  jobCombo->setEnabled(true);
+	  filesetCombo->setEnabled(true);
+	  clientCombo->setEnabled(true);
+	  poolCombo->setEnabled(true);
+	  storageCombo->setEnabled(true);
+	  recentCheckBox->setEnabled(true);
+	  if (!recentCheckBox->isChecked()) {
+		 beforeDateTime->setEnabled(true);
+	  }
+	  jobIdEdit->setEnabled(false);
+	  selectJobRadio->setChecked(true);
+	  selectJobIdsRadio->setChecked(false);
    }
    if (mainWin->m_miscDebug) {
-      Pmsg2(000, "jobRadio=%d jobidsRadio=%d\n", selectJobRadio->isChecked(),
-         selectJobIdsRadio->isChecked());
+	  Pmsg2(000, "jobRadio=%d jobidsRadio=%d\n", selectJobRadio->isChecked(),
+		 selectJobIdsRadio->isChecked());
    }
 }
diff --git a/src/qt-console/restore/restore.cpp b/src/qt-console/restore/restore.cpp
index f333ad0..280d9e5 100644
--- a/src/qt-console/restore/restore.cpp
+++ b/src/qt-console/restore/restore.cpp
@@ -25,6 +25,12 @@
  * Kern Sibbald, February MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
+
 #include "bat.h"
 #include "restore.h"
 
@@ -45,10 +51,10 @@ restorePage::restorePage(int conn) : Pages()
    m_console->notify(m_conn, false);          /* this should already be off */
 
    connect(fileWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
-           this, SLOT(fileDoubleClicked(QTreeWidgetItem *, int)));
+		   this, SLOT(fileDoubleClicked(QTreeWidgetItem *, int)));
    connect(directoryWidget, SIGNAL(
-           currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
-           this, SLOT(directoryItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+		   currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
+		   this, SLOT(directoryItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
    connect(upButton, SIGNAL(pressed()), this, SLOT(upButtonPushed()));
    connect(markButton, SIGNAL(pressed()), this, SLOT(markButtonPushed()));
    connect(unmarkButton, SIGNAL(pressed()), this, SLOT(unmarkButtonPushed()));
@@ -65,14 +71,14 @@ restorePage::restorePage(int conn) : Pages()
    m_console->displayToPrompt(m_conn);
 
    titles << tr("Mark") << tr("File") << tr("Mode") << tr("User")
-          << tr("Group") << tr("Size") << tr("Date");
+		  << tr("Group") << tr("Size") << tr("Date");
    fileWidget->setHeaderLabels(titles);
 
    get_cwd();
 
    readSettings();
    /* wait was entered from pre-restore
-    * will exit, but will reenter in fillDirectory */
+	* will exit, but will reenter in fillDirectory */
    mainWin->waitExit();
    fillDirectory();
    dockPage();
@@ -105,71 +111,71 @@ void restorePage::fillDirectory()
    m_rx.setPattern("has no children\\.$");
    bool first = true;
    while (m_console->read(m_conn) > 0) {
-      char *p = m_console->msg(m_conn);
-      char *l;
-      strip_trailing_newline(p);
-      if (*p == '$' || !*p) { continue; }
-      if (first) {
-         if (m_rx.indexIn(QString(p)) != -1) { continue; }
-         first = false;
-      }
-      l = p;
-      skip_nonspaces(&p);             /* permissions */
-      *p++ = 0;
-      bstrncpy(modes, l, sizeof(modes));
-      skip_spaces(&p);
-      skip_nonspaces(&p);             /* link count */
-      *p++ = 0;
-      skip_spaces(&p);
-      l = p;
-      skip_nonspaces(&p);             /* user */
-      *p++ = 0;
-      skip_spaces(&p);
-      bstrncpy(user, l, sizeof(user));
-      l = p;
-      skip_nonspaces(&p);             /* group */
-      *p++ = 0;
-      bstrncpy(group, l, sizeof(group));
-      skip_spaces(&p);
-      l = p;
-      skip_nonspaces(&p);             /* size */
-      *p++ = 0;
-      bstrncpy(size, l, sizeof(size));
-      skip_spaces(&p);
-      l = p;
-      skip_nonspaces(&p);             /* date/time */
-      skip_spaces(&p);
-      skip_nonspaces(&p);
-      *p++ = 0;
-      bstrncpy(date, l, sizeof(date));
-      skip_spaces(&p);
-      if (*p == '*') {
-         bstrncpy(marked, "*", sizeof(marked));
-         p++;
-      } else {
-         bstrncpy(marked, " ", sizeof(marked));
-      }
-      split_path_and_filename(p, &path, &pnl, &file, &fnl);
-      item.clear();
-      item << "" << file << modes << user << group << size << date;
-      if (item[1].endsWith("/")) {
-         addDirectory(item[1]);
-      }
-      QTreeWidgetItem *ti = new QTreeWidgetItem((QTreeWidget *)0, item);
-      ti->setTextAlignment(5, Qt::AlignRight); /* right align size */
-      if (strcmp(marked, "*") == 0) {
-         ti->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
-         ti->setData(0, Qt::UserRole, true);
-      } else {
-         ti->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
-         ti->setData(0, Qt::UserRole, false);
-      }
-      treeItemList.append(ti);
+	  char *p = m_console->msg(m_conn);
+	  char *l;
+	  strip_trailing_newline(p);
+	  if (*p == '$' || !*p) { continue; }
+	  if (first) {
+		 if (m_rx.indexIn(QString(p)) != -1) { continue; }
+		 first = false;
+	  }
+	  l = p;
+	  skip_nonspaces(&p);             /* permissions */
+	  *p++ = 0;
+	  bstrncpy(modes, l, sizeof(modes));
+	  skip_spaces(&p);
+	  skip_nonspaces(&p);             /* link count */
+	  *p++ = 0;
+	  skip_spaces(&p);
+	  l = p;
+	  skip_nonspaces(&p);             /* user */
+	  *p++ = 0;
+	  skip_spaces(&p);
+	  bstrncpy(user, l, sizeof(user));
+	  l = p;
+	  skip_nonspaces(&p);             /* group */
+	  *p++ = 0;
+	  bstrncpy(group, l, sizeof(group));
+	  skip_spaces(&p);
+	  l = p;
+	  skip_nonspaces(&p);             /* size */
+	  *p++ = 0;
+	  bstrncpy(size, l, sizeof(size));
+	  skip_spaces(&p);
+	  l = p;
+	  skip_nonspaces(&p);             /* date/time */
+	  skip_spaces(&p);
+	  skip_nonspaces(&p);
+	  *p++ = 0;
+	  bstrncpy(date, l, sizeof(date));
+	  skip_spaces(&p);
+	  if (*p == '*') {
+		 bstrncpy(marked, "*", sizeof(marked));
+		 p++;
+	  } else {
+		 bstrncpy(marked, " ", sizeof(marked));
+	  }
+	  split_path_and_filename(p, &path, &pnl, &file, &fnl);
+	  item.clear();
+	  item << "" << file << modes << user << group << size << date;
+	  if (item[1].endsWith("/")) {
+		 addDirectory(item[1]);
+	  }
+	  QTreeWidgetItem *ti = new QTreeWidgetItem((QTreeWidget *)0, item);
+	  ti->setTextAlignment(5, Qt::AlignRight); /* right align size */
+	  if (strcmp(marked, "*") == 0) {
+		 ti->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
+		 ti->setData(0, Qt::UserRole, true);
+	  } else {
+		 ti->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
+		 ti->setData(0, Qt::UserRole, false);
+	  }
+	  treeItemList.append(ti);
    }
    fileWidget->clear();
    fileWidget->insertTopLevelItems(0, treeItemList);
    for (int i=0; i<7; i++) {
-      fileWidget->resizeColumnToContents(i);
+	  fileWidget->resizeColumnToContents(i);
    }
 
    free_pool_memory(file);
@@ -188,84 +194,84 @@ void restorePage::addDirectory(QString &newdirr)
    bool ok = true;
 
    if (mainWin->m_miscDebug) {
-      QString msg = QString(tr("In addDirectory cwd \"%1\" newdir \"%2\" fullpath \"%3\"\n"))
-                    .arg(m_cwd)
-                    .arg(newdir)
-                    .arg(fullpath);
-      Pmsg1(dbglvl, "%s\n", msg.toUtf8().data());
+	  QString msg = QString(tr("In addDirectory cwd \"%1\" newdir \"%2\" fullpath \"%3\"\n"))
+					.arg(m_cwd)
+					.arg(newdir)
+					.arg(fullpath);
+	  Pmsg1(dbglvl, "%s\n", msg.toUtf8().data());
    }
 
    if (isWin32Path(fullpath)) {
-      if (mainWin->m_miscDebug) Pmsg0(dbglvl, "Windows drive\n");
-      if (fullpath.left(1) == "/") {
-         fullpath.replace(0, 1, "");           /* strip leading / */
-      }
-      /* If drive and not already in add it */
-      if (fullpath.length() == 3 && !m_dirPaths.contains(fullpath)) {
-         QTreeWidgetItem *item = new QTreeWidgetItem(directoryWidget);
-         item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
-         item->setText(0, fullpath.toUtf8().data());
-         if (mainWin->m_miscDebug) {
-            Pmsg1(dbglvl, "Pre Inserting %s\n",fullpath.toUtf8().data());
-         }
-         m_dirPaths.insert(fullpath, item);
-         m_dirTreeItems.insert(item, fullpath);
-         directoryWidget->setCurrentItem(NULL);
-      }
+	  if (mainWin->m_miscDebug) Pmsg0(dbglvl, "Windows drive\n");
+	  if (fullpath.left(1) == "/") {
+		 fullpath.replace(0, 1, "");           /* strip leading / */
+	  }
+	  /* If drive and not already in add it */
+	  if (fullpath.length() == 3 && !m_dirPaths.contains(fullpath)) {
+		 QTreeWidgetItem *item = new QTreeWidgetItem(directoryWidget);
+		 item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
+		 item->setText(0, fullpath.toUtf8().data());
+		 if (mainWin->m_miscDebug) {
+			Pmsg1(dbglvl, "Pre Inserting %s\n",fullpath.toUtf8().data());
+		 }
+		 m_dirPaths.insert(fullpath, item);
+		 m_dirTreeItems.insert(item, fullpath);
+		 directoryWidget->setCurrentItem(NULL);
+	  }
    } else {
-      // Unix add / first if not already there
-      if (m_dirPaths.empty()) {
-         QTreeWidgetItem *item = new QTreeWidgetItem(directoryWidget);
-         item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
-
-         QString text("/");
-         item->setText(0, text.toUtf8().data());
-         if (mainWin->m_miscDebug) {
-            Pmsg1(dbglvl, "Pre Inserting %s\n",text.toUtf8().data());
-         }
-         m_dirPaths.insert(text, item);
-         m_dirTreeItems.insert(item, text);
-      }
+	  // Unix add / first if not already there
+	  if (m_dirPaths.empty()) {
+		 QTreeWidgetItem *item = new QTreeWidgetItem(directoryWidget);
+		 item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
+
+		 QString text("/");
+		 item->setText(0, text.toUtf8().data());
+		 if (mainWin->m_miscDebug) {
+			Pmsg1(dbglvl, "Pre Inserting %s\n",text.toUtf8().data());
+		 }
+		 m_dirPaths.insert(text, item);
+		 m_dirTreeItems.insert(item, text);
+	  }
    }
 
    /* Does it already exist ?? */
    if (!m_dirPaths.contains(fullpath)) {
-      QTreeWidgetItem *item = NULL;
-      if (isWin32Path(fullpath)) {
-         /* this is the base widget */
-         item = new QTreeWidgetItem(directoryWidget);
-         item->setText(0, fullpath.toUtf8().data());
-         if (mainWin->m_miscDebug) Pmsg1(dbglvl, "Windows: %s\n", fullpath.toUtf8().data());
-         item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
-      } else {
-         QTreeWidgetItem *parent = m_dirPaths.value(m_cwd);
-         if (parent) {
-            /* new directories to add */
-            item = new QTreeWidgetItem(parent);
-            item->setText(0, newdir.toUtf8().data());
-            item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
-            directoryWidget->expandItem(parent);
-            if (mainWin->m_miscDebug) {
-               Pmsg1(dbglvl, "%s\n", newdir.toUtf8().data());
-            }
-         } else {
-            ok = false;
-            if (mainWin->m_miscDebug) {
-               QString msg = QString(tr("In else of if parent cwd \"%1\" newdir \"%2\"\n"))
-                    .arg(m_cwd)
-                    .arg(newdir);
-               Pmsg1(dbglvl, "%s\n", msg.toUtf8().data());
-            }
-         }
-      }
-      /* insert into both forward and reverse hash */
-      if (ok) {
-         if (mainWin->m_miscDebug) {
-            Pmsg1(dbglvl, "Inserting %s\n",fullpath.toUtf8().data());
-         }
-         m_dirPaths.insert(fullpath, item);
-         m_dirTreeItems.insert(item, fullpath);
-      }
+	  QTreeWidgetItem *item = NULL;
+	  if (isWin32Path(fullpath)) {
+		 /* this is the base widget */
+		 item = new QTreeWidgetItem(directoryWidget);
+		 item->setText(0, fullpath.toUtf8().data());
+		 if (mainWin->m_miscDebug) Pmsg1(dbglvl, "Windows: %s\n", fullpath.toUtf8().data());
+		 item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
+	  } else {
+		 QTreeWidgetItem *parent = m_dirPaths.value(m_cwd);
+		 if (parent) {
+			/* new directories to add */
+			item = new QTreeWidgetItem(parent);
+			item->setText(0, newdir.toUtf8().data());
+			item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
+			directoryWidget->expandItem(parent);
+			if (mainWin->m_miscDebug) {
+			   Pmsg1(dbglvl, "%s\n", newdir.toUtf8().data());
+			}
+		 } else {
+			ok = false;
+			if (mainWin->m_miscDebug) {
+			   QString msg = QString(tr("In else of if parent cwd \"%1\" newdir \"%2\"\n"))
+					.arg(m_cwd)
+					.arg(newdir);
+			   Pmsg1(dbglvl, "%s\n", msg.toUtf8().data());
+			}
+		 }
+	  }
+	  /* insert into both forward and reverse hash */
+	  if (ok) {
+		 if (mainWin->m_miscDebug) {
+			Pmsg1(dbglvl, "Inserting %s\n",fullpath.toUtf8().data());
+		 }
+		 m_dirPaths.insert(fullpath, item);
+		 m_dirTreeItems.insert(item, fullpath);
+	  }
    }
 }
 
@@ -274,13 +280,13 @@ void restorePage::addDirectory(QString &newdirr)
  * allow us to populate the file pane and make this the cwd.
  */
 void restorePage::directoryItemChanged(QTreeWidgetItem *currentitem,
-                                         QTreeWidgetItem * /*previousitem*/)
+										 QTreeWidgetItem * /*previousitem*/)
 {
    QString fullpath = m_dirTreeItems.value(currentitem);
    statusLine->setText("");
    if (fullpath != "") {
-      cwd(fullpath.toUtf8().data());
-      fillDirectory();
+	  cwd(fullpath.toUtf8().data());
+	  fillDirectory();
    }
 }
 
@@ -311,43 +317,43 @@ void restorePage::fileDoubleClicked(QTreeWidgetItem *item, int column)
    char cmd[1000];
    statusLine->setText("");
    if (column == 0) {                 /* mark/unmark */
-      mainWin->waitEnter();
-      if (item->data(0, Qt::UserRole).toBool()) {
-         bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
-         item->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
-         item->setData(0, Qt::UserRole, false);
-      } else {
-         bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
-         item->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
-         item->setData(0, Qt::UserRole, true);
-      }
-      m_console->write_dir(m_conn, cmd, false);
-      if (m_console->read(m_conn) > 0) {
-         strip_trailing_newline(m_console->msg(m_conn));
-         statusLine->setText(m_console->msg(m_conn));
-      }
-      m_console->displayToPrompt(m_conn);
-      mainWin->waitExit();
-      return;
+	  mainWin->waitEnter();
+	  if (item->data(0, Qt::UserRole).toBool()) {
+		 bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
+		 item->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
+		 item->setData(0, Qt::UserRole, false);
+	  } else {
+		 bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
+		 item->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
+		 item->setData(0, Qt::UserRole, true);
+	  }
+	  m_console->write_dir(m_conn, cmd, false);
+	  if (m_console->read(m_conn) > 0) {
+		 strip_trailing_newline(m_console->msg(m_conn));
+		 statusLine->setText(m_console->msg(m_conn));
+	  }
+	  m_console->displayToPrompt(m_conn);
+	  mainWin->waitExit();
+	  return;
    }
    /*
-    * Double clicking other than column 0 means to decend into
-    *  the directory -- or nothing if it is not a directory.
-    */
+	* Double clicking other than column 0 means to decend into
+	*  the directory -- or nothing if it is not a directory.
+	*/
    if (item->text(1).endsWith("/")) {
-      QString fullpath = m_cwd + item->text(1);
-      QTreeWidgetItem *item = m_dirPaths.value(fullpath);
-      if (mainWin->m_miscDebug) {
-         Pmsg1(dbglvl, "%s\n", fullpath.toUtf8().data());
-      }
-      if (item) {
-         directoryWidget->setCurrentItem(item);
-      } else {
-         QString msg = QString("DoubleClick else of item column %1 fullpath %2\n")
-              .arg(column,10)
-              .arg(fullpath);
-         if (mainWin->m_miscDebug) Pmsg1(dbglvl, "%s\n", msg.toUtf8().data());
-      }
+	  QString fullpath = m_cwd + item->text(1);
+	  QTreeWidgetItem *item = m_dirPaths.value(fullpath);
+	  if (mainWin->m_miscDebug) {
+		 Pmsg1(dbglvl, "%s\n", fullpath.toUtf8().data());
+	  }
+	  if (item) {
+		 directoryWidget->setCurrentItem(item);
+	  } else {
+		 QString msg = QString("DoubleClick else of item column %1 fullpath %2\n")
+			  .arg(column,10)
+			  .arg(fullpath);
+		 if (mainWin->m_miscDebug) Pmsg1(dbglvl, "%s\n", msg.toUtf8().data());
+	  }
    }
 }
 
@@ -360,7 +366,7 @@ void restorePage::upButtonPushed()
    cwd("..");
    QTreeWidgetItem *item = m_dirPaths.value(m_cwd);
    if (item) {
-      directoryWidget->setCurrentItem(item);
+	  directoryWidget->setCurrentItem(item);
    }
    statusLine->setText("");
 }
@@ -377,20 +383,20 @@ void restorePage::markButtonPushed()
    int count = 0;
    statusLine->setText("");
    foreach (item, treeItemList) {
-      count++;
-      bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
-      item->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
-      m_console->write_dir(m_conn, cmd, false);
-      if (m_console->read(m_conn) > 0) {
-         strip_trailing_newline(m_console->msg(m_conn));
-         statusLine->setText(m_console->msg(m_conn));
-      }
-      Dmsg1(dbglvl, "cmd=%s\n", cmd);
-      m_console->discardToPrompt(m_conn);
+	  count++;
+	  bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
+	  item->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
+	  m_console->write_dir(m_conn, cmd, false);
+	  if (m_console->read(m_conn) > 0) {
+		 strip_trailing_newline(m_console->msg(m_conn));
+		 statusLine->setText(m_console->msg(m_conn));
+	  }
+	  Dmsg1(dbglvl, "cmd=%s\n", cmd);
+	  m_console->discardToPrompt(m_conn);
    }
    if (count == 0) {
-      mainWin->set_status("Nothing selected, nothing done");
-      statusLine->setText("Nothing selected, nothing done");
+	  mainWin->set_status("Nothing selected, nothing done");
+	  statusLine->setText("Nothing selected, nothing done");
    }
    mainWin->waitExit();
 }
@@ -407,20 +413,20 @@ void restorePage::unmarkButtonPushed()
    int count = 0;
    statusLine->setText("");
    foreach (item, treeItemList) {
-      count++;
-      bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
-      item->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
-      m_console->write_dir(m_conn, cmd, false);
-      if (m_console->read(m_conn) > 0) {
-         strip_trailing_newline(m_console->msg(m_conn));
-         statusLine->setText(m_console->msg(m_conn));
-      }
-      Dmsg1(dbglvl, "cmd=%s\n", cmd);
-      m_console->discardToPrompt(m_conn);
+	  count++;
+	  bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
+	  item->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
+	  m_console->write_dir(m_conn, cmd, false);
+	  if (m_console->read(m_conn) > 0) {
+		 strip_trailing_newline(m_console->msg(m_conn));
+		 statusLine->setText(m_console->msg(m_conn));
+	  }
+	  Dmsg1(dbglvl, "cmd=%s\n", cmd);
+	  m_console->discardToPrompt(m_conn);
    }
    if (count == 0) {
-      mainWin->set_status(tr("Nothing selected, nothing done"));
-      statusLine->setText(tr("Nothing selected, nothing done"));
+	  mainWin->set_status(tr("Nothing selected, nothing done"));
+	  statusLine->setText(tr("Nothing selected, nothing done"));
    }
    mainWin->waitExit();
 }
@@ -440,12 +446,12 @@ bool restorePage::cwd(const char *dir)
    m_console->write_dir(m_conn, cd_cmd, false);
    lineEdit->clear();
    if ((stat = m_console->read(m_conn)) > 0) {
-      m_cwd = m_console->msg(m_conn);
-      lineEdit->insert(m_cwd);
-      Dmsg2(dbglvl, "cwd=%s msg=%s\n", m_cwd.toUtf8().data(), m_console->msg(m_conn));
+	  m_cwd = m_console->msg(m_conn);
+	  lineEdit->insert(m_cwd);
+	  Dmsg2(dbglvl, "cwd=%s msg=%s\n", m_cwd.toUtf8().data(), m_console->msg(m_conn));
    } else {
-      Dmsg1(dbglvl, "stat=%d\n", stat);
-      QMessageBox::critical(this, "Error", tr("cd command failed"), QMessageBox::Ok);
+	  Dmsg1(dbglvl, "stat=%d\n", stat);
+	  QMessageBox::critical(this, "Error", tr("cd command failed"), QMessageBox::Ok);
    }
    m_console->discardToPrompt(m_conn);
    mainWin->waitExit();
@@ -462,11 +468,11 @@ char *restorePage::get_cwd()
    m_console->write_dir(m_conn, ".pwd", false);
    Dmsg0(dbglvl, "send: .pwd\n");
    if ((stat = m_console->read(m_conn)) > 0) {
-      m_cwd = m_console->msg(m_conn);
-      Dmsg2(dbglvl, "cwd=%s msg=%s\n", m_cwd.toUtf8().data(), m_console->msg(m_conn));
+	  m_cwd = m_console->msg(m_conn);
+	  Dmsg2(dbglvl, "cwd=%s msg=%s\n", m_cwd.toUtf8().data(), m_console->msg(m_conn));
    } else {
-      Dmsg1(dbglvl, "Something went wrong read stat=%d\n", stat);
-      QMessageBox::critical(this, "Error", tr(".pwd command failed"), QMessageBox::Ok);
+	  Dmsg1(dbglvl, "Something went wrong read stat=%d\n", stat);
+	  QMessageBox::critical(this, "Error", tr(".pwd command failed"), QMessageBox::Ok);
    }
    m_console->discardToPrompt(m_conn);
    mainWin->waitExit();
@@ -493,7 +499,7 @@ void restorePage::readSettings()
    QSettings settings(m_console->m_dir->name(), "bat");
    settings.beginGroup("RestorePage");
    if (settings.contains(m_splitText)) {
-      splitter->restoreState(settings.value(m_splitText).toByteArray());
+	  splitter->restoreState(settings.value(m_splitText).toByteArray());
    }
    settings.endGroup();
 }
diff --git a/src/qt-console/restore/restoretree.cpp b/src/qt-console/restore/restoretree.cpp
index f80cc55..c3015b2 100644
--- a/src/qt-console/restore/restoretree.cpp
+++ b/src/qt-console/restore/restoretree.cpp
@@ -25,6 +25,12 @@
  * Kern Sibbald, February MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+	#include <QScrollArea>
+#endif
 #include "bat.h"
 #include "restoretree.h"
 #include "pages.h"
@@ -96,15 +102,15 @@ void restoreTree::setupPage()
    connect(daysSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateRefresh()));
    connect(limitSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateRefresh()));
    connect(directoryTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
-           this, SLOT(directoryCurrentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+		   this, SLOT(directoryCurrentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
    connect(directoryTree, SIGNAL(itemExpanded(QTreeWidgetItem *)),
-           this, SLOT(directoryItemExpanded(QTreeWidgetItem *)));
+		   this, SLOT(directoryItemExpanded(QTreeWidgetItem *)));
    connect(directoryTree, SIGNAL(itemChanged(QTreeWidgetItem *, int)),
-           this, SLOT(directoryItemChanged(QTreeWidgetItem *, int)));
+		   this, SLOT(directoryItemChanged(QTreeWidgetItem *, int)));
    connect(fileTable, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
-           this, SLOT(fileCurrentItemChanged(QTableWidgetItem *, QTableWidgetItem *)));
+		   this, SLOT(fileCurrentItemChanged(QTableWidgetItem *, QTableWidgetItem *)));
    connect(jobTable, SIGNAL(cellClicked(int, int)),
-           this, SLOT(jobTableCellClicked(int, int)));
+		   this, SLOT(jobTableCellClicked(int, int)));
 
    QStringList titles = QStringList() << tr("Directories");
    directoryTree->setHeaderLabels(titles);
@@ -121,19 +127,19 @@ void restoreTree::updateRefresh()
 {
    if (mainWin->m_rtPopDirDebug) Pmsg2(000, "testing prev=\"%s\" current=\"%s\"\n", m_prevJobCombo.toUtf8().data(), jobCombo->currentText().toUtf8().data());
    m_dropdownChanged = (m_prevJobCombo != jobCombo->currentText())
-                       || (m_prevClientCombo != clientCombo->currentText())
-                       || (m_prevFileSetCombo != fileSetCombo->currentText()
-                       || (m_prevLimitSpinBox != limitSpinBox->value())
-                       || (m_prevDaysSpinBox != daysSpinBox->value())
-                       || (m_prevLimitCheckState != limitCheckBox->checkState())
-                       || (m_prevDaysCheckState != daysCheckBox->checkState())
+					   || (m_prevClientCombo != clientCombo->currentText())
+					   || (m_prevFileSetCombo != fileSetCombo->currentText()
+					   || (m_prevLimitSpinBox != limitSpinBox->value())
+					   || (m_prevDaysSpinBox != daysSpinBox->value())
+					   || (m_prevLimitCheckState != limitCheckBox->checkState())
+					   || (m_prevDaysCheckState != daysCheckBox->checkState())
    );
    if (m_dropdownChanged) {
-      if (mainWin->m_rtPopDirDebug) Pmsg0(000, "In restoreTree::updateRefresh Is CHANGED\n");
-      refreshLabel->setText(tr("Refresh From Re-Select"));
+	  if (mainWin->m_rtPopDirDebug) Pmsg0(000, "In restoreTree::updateRefresh Is CHANGED\n");
+	  refreshLabel->setText(tr("Refresh From Re-Select"));
    } else {
-      if (mainWin->m_rtPopDirDebug) Pmsg0(000, "In restoreTree::updateRefresh Is not Changed\n");
-      refreshLabel->setText(tr("Refresh From JobChecks"));
+	  if (mainWin->m_rtPopDirDebug) Pmsg0(000, "In restoreTree::updateRefresh Is not Changed\n");
+	  refreshLabel->setText(tr("Refresh From JobChecks"));
    }
 }
 
@@ -176,103 +182,103 @@ void restoreTree::populateDirectoryTree()
    repaint();
 
    if (m_dropdownChanged) {
-      m_prevJobCombo = jobCombo->currentText();
-      m_prevClientCombo = clientCombo->currentText();
-      m_prevFileSetCombo = fileSetCombo->currentText();
-      m_prevLimitSpinBox = limitSpinBox->value();
-      m_prevDaysSpinBox = daysSpinBox->value();
-      m_prevLimitCheckState = limitCheckBox->checkState();
-      m_prevDaysCheckState = daysCheckBox->checkState();
-      updateRefresh();
-      prBar1->setValue(ontask++);
-      prLabel1->setText(tr("Task %1 of %2").arg(ontask).arg(taskcount));
-      prBar2->setValue(0);
-      prBar2->setRange(0,0);
-      prLabel2->setText(tr("Querying Jobs"));
-      repaint();
-      populateJobTable();
+	  m_prevJobCombo = jobCombo->currentText();
+	  m_prevClientCombo = clientCombo->currentText();
+	  m_prevFileSetCombo = fileSetCombo->currentText();
+	  m_prevLimitSpinBox = limitSpinBox->value();
+	  m_prevDaysSpinBox = daysSpinBox->value();
+	  m_prevLimitCheckState = limitCheckBox->checkState();
+	  m_prevDaysCheckState = daysCheckBox->checkState();
+	  updateRefresh();
+	  prBar1->setValue(ontask++);
+	  prLabel1->setText(tr("Task %1 of %2").arg(ontask).arg(taskcount));
+	  prBar2->setValue(0);
+	  prBar2->setRange(0,0);
+	  prLabel2->setText(tr("Querying Jobs"));
+	  repaint();
+	  populateJobTable();
    }
    setJobsCheckedList();
    if (mainWin->m_rtPopDirDebug) Pmsg0(000, "Repopulating from checks in Job Table\n");
 
    if (m_checkedJobs != "") {
-      /* First get the filenameid of where the nae is null.  These will be the directories
-       * This could be done in a subquery but postgres's query analyzer won't do the right
-       * thing like I want */
-      if (m_nullFileNameId == -1) {
-         QString cmd = "SELECT FilenameId FROM Filename WHERE name=''";
-         if (mainWin->m_sqlDebug)
-            Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
-         QStringList qres;
-         if (m_console->sql_cmd(cmd, qres)) {
-            if (qres.count()) {
-               QStringList fieldlist = qres[0].split("\t");
-               QString field = fieldlist[0];
-               bool ok;
-               int val = field.toInt(&ok, 10);
-               if (ok) m_nullFileNameId = val;
-            }
-         }
-      }
-      /* now create the query to get the list of paths */
-      QString cmd =
-         "SELECT DISTINCT Path.Path AS Path, File.PathId AS PathId"
-         " FROM File"
-         " INNER JOIN Path ON (File.PathId=Path.PathId)";
-      if (m_nullFileNameId != -1)
-         cmd += " WHERE File.FilenameId=" + QString("%1").arg(m_nullFileNameId);
-      else
-         cmd += " WHERE File.FilenameId IN (SELECT FilenameId FROM Filename WHERE Name='')";
-      cmd += " AND File.Jobid IN (" + m_checkedJobs + ")";
-      if (mainWin->m_sqlDebug)
-         Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
-      prBar1->setValue(ontask++);
-      prLabel1->setText(tr("Task %1 of %2").arg(ontask).arg(taskcount));
-      prBar2->setValue(0);
-      prBar2->setRange(0,0);
-      prLabel2->setText(tr("Querying for Directories"));
-      repaint();
-      QStringList results;
-      m_directoryPathIdHash.clear();
-      bool querydone = false;
-      if (m_console->sql_cmd(cmd, results)) {
-         if (!querydone) {
-            querydone = true;
-            prLabel2->setText(tr("Processing Directories"));
-            prBar2->setRange(0,results.count());
-            repaint();
-         }
-         if (mainWin->m_miscDebug)
-            Pmsg1(000, "Done with query %i results\n", results.count());
-         QStringList fieldlist;
-         foreach(const QString &resultline, results) {
-            /* Update progress bar periodically */
-            if ((++m_debugCnt && 0x3FF) == 0) {
-               prBar2->setValue(m_debugCnt);
-            }
-            fieldlist = resultline.split("\t");
-            int fieldcnt = 0;
-            /* Iterate through fields in the record */
-            foreach (const QString &field, fieldlist) {
-               if (fieldcnt == 0 ) {
-                  parseDirectory(field);
-               } else if (fieldcnt == 1) {
-                  bool ok;
-                  int pathid = field.toInt(&ok, 10);
-                  if (ok)
-                     m_directoryPathIdHash.insert(fieldlist[0], pathid);
-               }
-               fieldcnt += 1;
-            }
-         }
-      } else {
-         return;
-      }
+	  /* First get the filenameid of where the nae is null.  These will be the directories
+	   * This could be done in a subquery but postgres's query analyzer won't do the right
+	   * thing like I want */
+	  if (m_nullFileNameId == -1) {
+		 QString cmd = "SELECT FilenameId FROM Filename WHERE name=''";
+		 if (mainWin->m_sqlDebug)
+			Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
+		 QStringList qres;
+		 if (m_console->sql_cmd(cmd, qres)) {
+			if (qres.count()) {
+			   QStringList fieldlist = qres[0].split("\t");
+			   QString field = fieldlist[0];
+			   bool ok;
+			   int val = field.toInt(&ok, 10);
+			   if (ok) m_nullFileNameId = val;
+			}
+		 }
+	  }
+	  /* now create the query to get the list of paths */
+	  QString cmd =
+		 "SELECT DISTINCT Path.Path AS Path, File.PathId AS PathId"
+		 " FROM File"
+		 " INNER JOIN Path ON (File.PathId=Path.PathId)";
+	  if (m_nullFileNameId != -1)
+		 cmd += " WHERE File.FilenameId=" + QString("%1").arg(m_nullFileNameId);
+	  else
+		 cmd += " WHERE File.FilenameId IN (SELECT FilenameId FROM Filename WHERE Name='')";
+	  cmd += " AND File.Jobid IN (" + m_checkedJobs + ")";
+	  if (mainWin->m_sqlDebug)
+		 Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
+	  prBar1->setValue(ontask++);
+	  prLabel1->setText(tr("Task %1 of %2").arg(ontask).arg(taskcount));
+	  prBar2->setValue(0);
+	  prBar2->setRange(0,0);
+	  prLabel2->setText(tr("Querying for Directories"));
+	  repaint();
+	  QStringList results;
+	  m_directoryPathIdHash.clear();
+	  bool querydone = false;
+	  if (m_console->sql_cmd(cmd, results)) {
+		 if (!querydone) {
+			querydone = true;
+			prLabel2->setText(tr("Processing Directories"));
+			prBar2->setRange(0,results.count());
+			repaint();
+		 }
+		 if (mainWin->m_miscDebug)
+			Pmsg1(000, "Done with query %i results\n", results.count());
+		 QStringList fieldlist;
+		 foreach(const QString &resultline, results) {
+			/* Update progress bar periodically */
+			if ((++m_debugCnt && 0x3FF) == 0) {
+			   prBar2->setValue(m_debugCnt);
+			}
+			fieldlist = resultline.split("\t");
+			int fieldcnt = 0;
+			/* Iterate through fields in the record */
+			foreach (const QString &field, fieldlist) {
+			   if (fieldcnt == 0 ) {
+				  parseDirectory(field);
+			   } else if (fieldcnt == 1) {
+				  bool ok;
+				  int pathid = field.toInt(&ok, 10);
+				  if (ok)
+					 m_directoryPathIdHash.insert(fieldlist[0], pathid);
+			   }
+			   fieldcnt += 1;
+			}
+		 }
+	  } else {
+		 return;
+	  }
    } else {
-     QMessageBox::warning(this, "Bat",
-        tr("No jobs were selected in the job query !!!.\n"
-      "Press OK to continue"),
-      QMessageBox::Ok );
+	 QMessageBox::warning(this, "Bat",
+		tr("No jobs were selected in the job query !!!.\n"
+	  "Press OK to continue"),
+	  QMessageBox::Ok );
    }
    prBar1->setVisible(false);
    prBar2->setVisible(false);
@@ -291,19 +297,19 @@ void restoreTree::setJobsCheckedList()
    /* Update the items in the version table */
    int cnt = jobTable->rowCount();
    for (int row=0; row<cnt; row++) {
-      QTableWidgetItem* jobItem = jobTable->item(row, 0);
-      if (jobItem->checkState() == Qt::Checked) {
-         if (!first)
-            m_JobsCheckedList += ",";
-         m_JobsCheckedList += jobItem->text();
-         first = false;
-         jobItem->setBackground(Qt::green);
-      } else {
-         if (jobItem->flags())
-            jobItem->setBackground(Qt::gray);
-         else
-            jobItem->setBackground(Qt::darkYellow);
-      }
+	  QTableWidgetItem* jobItem = jobTable->item(row, 0);
+	  if (jobItem->checkState() == Qt::Checked) {
+		 if (!first)
+			m_JobsCheckedList += ",";
+		 m_JobsCheckedList += jobItem->text();
+		 first = false;
+		 jobItem->setBackground(Qt::green);
+	  } else {
+		 if (jobItem->flags())
+			jobItem->setBackground(Qt::gray);
+		 else
+			jobItem->setBackground(Qt::darkYellow);
+	  }
    }
    m_checkedJobs = m_JobsCheckedList;
 }
@@ -316,42 +322,42 @@ void restoreTree::parseDirectory(const QString &dir_in)
 {
    // bail out if already processed
    if (m_dirPaths.contains(dir_in))
-     return;
+	 return;
    // search for parent...
    int pos=dir_in.lastIndexOf("/",-2);
 
    if (pos != -1)
    {
-     QString parent=dir_in.left(pos+1);
-     QString subdir=dir_in.mid(pos+1);
-
-     QTreeWidgetItem *item       = NULL;
-     QTreeWidgetItem *parentItem = m_dirPaths.value(parent);
-
-     if (parentItem==0) {
-       // recurse to build parent...
-       parseDirectory(parent);
-       parentItem = m_dirPaths.value(parent);
-     }
-
-     /* new directories to add */
-     item = new QTreeWidgetItem(parentItem);
-     item->setText(0, subdir);
-     item->setData(0, Qt::UserRole, QVariant(dir_in));
-     item->setCheckState(0, Qt::Unchecked);
-     /* Store the current state of the check status in column 1, which at
-      * this point has no text*/
-     item->setData(1, Qt::UserRole, QVariant(Qt::Unchecked));
-     m_dirPaths.insert(dir_in,item);
+	 QString parent=dir_in.left(pos+1);
+	 QString subdir=dir_in.mid(pos+1);
+
+	 QTreeWidgetItem *item       = NULL;
+	 QTreeWidgetItem *parentItem = m_dirPaths.value(parent);
+
+	 if (parentItem==0) {
+	   // recurse to build parent...
+	   parseDirectory(parent);
+	   parentItem = m_dirPaths.value(parent);
+	 }
+
+	 /* new directories to add */
+	 item = new QTreeWidgetItem(parentItem);
+	 item->setText(0, subdir);
+	 item->setData(0, Qt::UserRole, QVariant(dir_in));
+	 item->setCheckState(0, Qt::Unchecked);
+	 /* Store the current state of the check status in column 1, which at
+	  * this point has no text*/
+	 item->setData(1, Qt::UserRole, QVariant(Qt::Unchecked));
+	 m_dirPaths.insert(dir_in,item);
    }
    else
    {
-     QTreeWidgetItem *item = new QTreeWidgetItem(directoryTree);
-     item->setText(0, dir_in);
-     item->setData(0, Qt::UserRole, QVariant(dir_in));
-     item->setData(1, Qt::UserRole, QVariant(Qt::Unchecked));
-     item->setIcon(0, QIcon(QString::fromUtf8(":images/folder.png")));
-     m_dirPaths.insert(dir_in,item);
+	 QTreeWidgetItem *item = new QTreeWidgetItem(directoryTree);
+	 item->setText(0, dir_in);
+	 item->setData(0, Qt::UserRole, QVariant(dir_in));
+	 item->setData(1, Qt::UserRole, QVariant(Qt::Unchecked));
+	 item->setIcon(0, QIcon(QString::fromUtf8(":images/folder.png")));
+	 m_dirPaths.insert(dir_in,item);
    }
 }
 
@@ -361,8 +367,8 @@ void restoreTree::parseDirectory(const QString &dir_in)
 void restoreTree::currentStackItem()
 {
    if(!m_populated) {
-      setupPage();
-      m_populated = true;
+	  setupPage();
+	  m_populated = true;
    }
 }
 
@@ -380,16 +386,16 @@ void restoreTree::refreshButtonPushed()
 void restoreTree::jobComboChanged(int)
 {
    if (jobCombo->currentText() == tr("Any")) {
-      fileSetCombo->setCurrentIndex(fileSetCombo->findText(tr("Any"), Qt::MatchExactly));
-      return;
+	  fileSetCombo->setCurrentIndex(fileSetCombo->findText(tr("Any"), Qt::MatchExactly));
+	  return;
    }
    job_defaults job_defs;
 
    //(void)index;
    job_defs.job_name = jobCombo->currentText();
    if (m_console->get_job_defaults(job_defs)) {
-      fileSetCombo->setCurrentIndex(fileSetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
-      clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
+	  fileSetCombo->setCurrentIndex(fileSetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
+	  clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
    }
 }
 
@@ -399,7 +405,7 @@ void restoreTree::jobComboChanged(int)
 void restoreTree::directoryCurrentItemChanged(QTreeWidgetItem *item, QTreeWidgetItem *)
 {
    if (item == NULL)
-      return;
+	  return;
 
    fileTable->clear();
    /* Also clear the version table here */
@@ -415,77 +421,77 @@ void restoreTree::directoryCurrentItemChanged(QTreeWidgetItem *item, QTreeWidget
 
    m_fileCheckStateList.clear();
    disconnect(fileTable, SIGNAL(itemChanged(QTableWidgetItem *)),
-           this, SLOT(fileTableItemChanged(QTableWidgetItem *)));
+		   this, SLOT(fileTableItemChanged(QTableWidgetItem *)));
    QBrush blackBrush(Qt::black);
    QString directory = item->data(0, Qt::UserRole).toString();
    directoryLabel->setText(tr("Present Working Directory: %1").arg(directory));
    int pathid = m_directoryPathIdHash.value(directory, -1);
    if (pathid != -1) {
-      QString cmd =
-         "SELECT DISTINCT Filename.Name AS FileName, Filename.FilenameId AS FilenameId"
-         " FROM File "
-         " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
-         " WHERE File.PathId=" + QString("%1").arg(pathid) +
-         " AND File.Jobid IN (" + m_checkedJobs + ")"
-         " AND Filename.Name!=''"
-         " ORDER BY FileName";
-      if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
-
-      QStringList results;
-      if (m_console->sql_cmd(cmd, results)) {
-
-         QTableWidgetItem* tableItem;
-         QString field;
-         QStringList fieldlist;
-         fileTable->setRowCount(results.size());
-
-         int row = 0;
-         /* Iterate through the record returned from the query */
-         foreach (QString resultline, results) {
-            /* Iterate through fields in the record */
-            int column = 0;
-            fieldlist = resultline.split("\t");
-            foreach (field, fieldlist) {
-               field = field.trimmed();  /* strip leading & trailing spaces */
-               tableItem = new QTableWidgetItem(field, 1);
-               /* Possible flags are Qt::ItemFlags flag = Qt::ItemIsSelectable | Qt::ItemIsEditablex
-                *  | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable
-                *  | Qt::ItemIsEnabled | Qt::ItemIsTristate; */
-               tableItem->setForeground(blackBrush);
-               /* Just in case a column ever gets added */
-               if (mainWin->m_sqlDebug) Pmsg1(000, "Column=%d\n", column);
-               if (column == 0) {
-                  Qt::ItemFlags flag = Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate;
-                  tableItem->setFlags(flag);
-                  tableItem->setData(Qt::UserRole, QVariant(directory));
-                  fileTable->setItem(row, column, tableItem);
-                  m_fileCheckStateList.append(Qt::Unchecked);
-                  tableItem->setCheckState(Qt::Unchecked);
-               } else if (column == 1) {
-                  Qt::ItemFlags flag = Qt::ItemIsEnabled;
-                  tableItem->setFlags(flag);
-                  bool ok;
-                  int filenameid = field.toInt(&ok, 10);
-                  if (!ok) filenameid = -1;
-                  tableItem->setData(Qt::UserRole, QVariant(filenameid));
-                  fileTable->setItem(row, column, tableItem);
-               }
-               column++;
-            }
-            row++;
-         }
-         fileTable->setRowCount(row);
-      }
-      fileTable->resizeColumnsToContents();
-      fileTable->resizeRowsToContents();
-      fileTable->verticalHeader()->hide();
-      fileTable->hideColumn(1);
-      if (mainWin->m_rtDirCurICDebug) Pmsg0(000, "will update file table checks\n");
-      updateFileTableChecks();
+	  QString cmd =
+		 "SELECT DISTINCT Filename.Name AS FileName, Filename.FilenameId AS FilenameId"
+		 " FROM File "
+		 " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
+		 " WHERE File.PathId=" + QString("%1").arg(pathid) +
+		 " AND File.Jobid IN (" + m_checkedJobs + ")"
+		 " AND Filename.Name!=''"
+		 " ORDER BY FileName";
+	  if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
+
+	  QStringList results;
+	  if (m_console->sql_cmd(cmd, results)) {
+
+		 QTableWidgetItem* tableItem;
+		 QString field;
+		 QStringList fieldlist;
+		 fileTable->setRowCount(results.size());
+
+		 int row = 0;
+		 /* Iterate through the record returned from the query */
+		 foreach (QString resultline, results) {
+			/* Iterate through fields in the record */
+			int column = 0;
+			fieldlist = resultline.split("\t");
+			foreach (field, fieldlist) {
+			   field = field.trimmed();  /* strip leading & trailing spaces */
+			   tableItem = new QTableWidgetItem(field, 1);
+			   /* Possible flags are Qt::ItemFlags flag = Qt::ItemIsSelectable | Qt::ItemIsEditablex
+				*  | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable
+				*  | Qt::ItemIsEnabled | Qt::ItemIsTristate; */
+			   tableItem->setForeground(blackBrush);
+			   /* Just in case a column ever gets added */
+			   if (mainWin->m_sqlDebug) Pmsg1(000, "Column=%d\n", column);
+			   if (column == 0) {
+				  Qt::ItemFlags flag = Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate;
+				  tableItem->setFlags(flag);
+				  tableItem->setData(Qt::UserRole, QVariant(directory));
+				  fileTable->setItem(row, column, tableItem);
+				  m_fileCheckStateList.append(Qt::Unchecked);
+				  tableItem->setCheckState(Qt::Unchecked);
+			   } else if (column == 1) {
+				  Qt::ItemFlags flag = Qt::ItemIsEnabled;
+				  tableItem->setFlags(flag);
+				  bool ok;
+				  int filenameid = field.toInt(&ok, 10);
+				  if (!ok) filenameid = -1;
+				  tableItem->setData(Qt::UserRole, QVariant(filenameid));
+				  fileTable->setItem(row, column, tableItem);
+			   }
+			   column++;
+			}
+			row++;
+		 }
+		 fileTable->setRowCount(row);
+	  }
+	  fileTable->resizeColumnsToContents();
+	  fileTable->resizeRowsToContents();
+	  fileTable->verticalHeader()->hide();
+	  fileTable->hideColumn(1);
+	  if (mainWin->m_rtDirCurICDebug) Pmsg0(000, "will update file table checks\n");
+	  updateFileTableChecks();
    } else if (mainWin->m_sqlDebug)
-      Pmsg1(000, "did not perform query, pathid=%i not found\n", pathid);
+	  Pmsg1(000, "did not perform query, pathid=%i not found\n", pathid);
    connect(fileTable, SIGNAL(itemChanged(QTableWidgetItem *)),
-          this, SLOT(fileTableItemChanged(QTableWidgetItem *)));
+		  this, SLOT(fileTableItemChanged(QTableWidgetItem *)));
 }
 
 /*
@@ -494,7 +500,7 @@ void restoreTree::directoryCurrentItemChanged(QTreeWidgetItem *item, QTreeWidget
 void restoreTree::fileCurrentItemChanged(QTableWidgetItem *currentFileTableItem, QTableWidgetItem *)
 {
    if (currentFileTableItem == NULL)
-      return;
+	  return;
 
    int currentRow = fileTable->row(currentFileTableItem);
    QTableWidgetItem *fileTableItem = fileTable->item(currentRow, 0);
@@ -503,7 +509,7 @@ void restoreTree::fileCurrentItemChanged(QTableWidgetItem *currentFileTableItem,
 
    m_versionCheckStateList.clear();
    disconnect(versionTable, SIGNAL(itemChanged(QTableWidgetItem *)),
-           this, SLOT(versionTableItemChanged(QTableWidgetItem *)));
+		   this, SLOT(versionTableItemChanged(QTableWidgetItem *)));
 
    QString file = fileTableItem->text();
    versionFileLabel->setText(file);
@@ -512,7 +518,7 @@ void restoreTree::fileCurrentItemChanged(QTableWidgetItem *currentFileTableItem,
    QBrush blackBrush(Qt::black);
 
    QStringList headerlist = (QStringList()
-      << tr("Job Id") << tr("Type") << tr("End Time") << tr("Hash") << tr("FileId") << tr("Job Type") << tr("First Volume"));
+	  << tr("Job Id") << tr("Type") << tr("End Time") << tr("Hash") << tr("FileId") << tr("Job Type") << tr("First Volume"));
    versionTable->clear();
    versionTable->setColumnCount(headerlist.size());
    versionTable->setHorizontalHeaderLabels(headerlist);
@@ -520,74 +526,78 @@ void restoreTree::fileCurrentItemChanged(QTableWidgetItem *currentFileTableItem,
 
    int pathid = m_directoryPathIdHash.value(directory, -1);
    if ((pathid != -1) && (fileNameId != -1)) {
-      QString cmd =
-         "SELECT Job.JobId AS JobId, Job.Level AS Type,"
-           " Job.EndTime AS EndTime, File.MD5 AS MD5,"
-           " File.FileId AS FileId, Job.Type AS JobType,"
-           " (SELECT Media.VolumeName FROM JobMedia JOIN Media ON JobMedia.MediaId=Media.MediaId WHERE JobMedia.JobId=Job.JobId ORDER BY JobMediaId LIMIT 1) AS FirstVolume"
-         " FROM File"
-         " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
-         " INNER JOIN Path ON (Path.PathId=File.PathId)"
-         " INNER JOIN Job ON (File.JobId=Job.JobId)"
-         " WHERE Path.PathId=" + QString("%1").arg(pathid) +
-         //" AND Filename.Name='" + file + "'"
-         " AND Filename.FilenameId=" + QString("%1").arg(fileNameId) +
-         " AND Job.Jobid IN (" + m_checkedJobs + ")"
-         " ORDER BY Job.EndTime DESC";
-
-      if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
-      QStringList results;
-      if (m_console->sql_cmd(cmd, results)) {
-
-         QTableWidgetItem* tableItem;
-         QString field;
-         QStringList fieldlist;
-         versionTable->setRowCount(results.size());
-
-         int row = 0;
-         /* Iterate through the record returned from the query */
-         foreach (QString resultline, results) {
-            fieldlist = resultline.split("\t");
-            int column = 0;
-            /* remove directory */
-            if (fieldlist[0].trimmed() != "") {
-               /* Iterate through fields in the record */
-               foreach (field, fieldlist) {
-                  field = field.trimmed();  /* strip leading & trailing spaces */
-                  if (column == 5 ) {
-                     QByteArray jtype(field.trimmed().toAscii());
-                     if (jtype.size()) {
-                        field = job_type_to_str(jtype[0]);
-                     }
-                  }
-                  tableItem = new QTableWidgetItem(field, 1);
-                  tableItem->setFlags(0);
-                  tableItem->setForeground(blackBrush);
-                  tableItem->setData(Qt::UserRole, QVariant(directory));
-                  versionTable->setItem(row, column, tableItem);
-                  if (mainWin->m_sqlDebug) Pmsg1(000, "Column=%d\n", column);
-                  if (column == 0) {
-                     Qt::ItemFlags flag = Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate;
-                     tableItem->setFlags(flag);
-                     m_versionCheckStateList.append(Qt::Unchecked);
-                     tableItem->setCheckState(Qt::Unchecked);
-                  }
-                  column++;
-               }
-               row++;
-            }
-         }
-      }
-      versionTable->resizeColumnsToContents();
-      versionTable->resizeRowsToContents();
-      versionTable->verticalHeader()->hide();
-      updateVersionTableChecks();
+	  QString cmd =
+		 "SELECT Job.JobId AS JobId, Job.Level AS Type,"
+		   " Job.EndTime AS EndTime, File.MD5 AS MD5,"
+		   " File.FileId AS FileId, Job.Type AS JobType,"
+		   " (SELECT Media.VolumeName FROM JobMedia JOIN Media ON JobMedia.MediaId=Media.MediaId WHERE JobMedia.JobId=Job.JobId ORDER BY JobMediaId LIMIT 1) AS FirstVolume"
+		 " FROM File"
+		 " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
+		 " INNER JOIN Path ON (Path.PathId=File.PathId)"
+		 " INNER JOIN Job ON (File.JobId=Job.JobId)"
+		 " WHERE Path.PathId=" + QString("%1").arg(pathid) +
+		 //" AND Filename.Name='" + file + "'"
+		 " AND Filename.FilenameId=" + QString("%1").arg(fileNameId) +
+		 " AND Job.Jobid IN (" + m_checkedJobs + ")"
+		 " ORDER BY Job.EndTime DESC";
+
+	  if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
+	  QStringList results;
+	  if (m_console->sql_cmd(cmd, results)) {
+
+		 QTableWidgetItem* tableItem;
+		 QString field;
+		 QStringList fieldlist;
+		 versionTable->setRowCount(results.size());
+
+		 int row = 0;
+		 /* Iterate through the record returned from the query */
+		 foreach (QString resultline, results) {
+			fieldlist = resultline.split("\t");
+			int column = 0;
+			/* remove directory */
+			if (fieldlist[0].trimmed() != "") {
+			   /* Iterate through fields in the record */
+			   foreach (field, fieldlist) {
+				  field = field.trimmed();  /* strip leading & trailing spaces */
+				  if (column == 5 ) {
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+					 QByteArray jtype(field.trimmed().toLatin1());
+#else
+					 QByteArray jtype(field.trimmed().toAscii());
+#endif
+					 if (jtype.size()) {
+						field = job_type_to_str(jtype[0]);
+					 }
+				  }
+				  tableItem = new QTableWidgetItem(field, 1);
+				  tableItem->setFlags(0);
+				  tableItem->setForeground(blackBrush);
+				  tableItem->setData(Qt::UserRole, QVariant(directory));
+				  versionTable->setItem(row, column, tableItem);
+				  if (mainWin->m_sqlDebug) Pmsg1(000, "Column=%d\n", column);
+				  if (column == 0) {
+					 Qt::ItemFlags flag = Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate;
+					 tableItem->setFlags(flag);
+					 m_versionCheckStateList.append(Qt::Unchecked);
+					 tableItem->setCheckState(Qt::Unchecked);
+				  }
+				  column++;
+			   }
+			   row++;
+			}
+		 }
+	  }
+	  versionTable->resizeColumnsToContents();
+	  versionTable->resizeRowsToContents();
+	  versionTable->verticalHeader()->hide();
+	  updateVersionTableChecks();
    } else {
-      if (mainWin->m_sqlDebug)
-         Pmsg2(000, "not querying : pathid=%i fileNameId=%i\n", pathid, fileNameId);
+	  if (mainWin->m_sqlDebug)
+		 Pmsg2(000, "not querying : pathid=%i fileNameId=%i\n", pathid, fileNameId);
    }
    connect(versionTable, SIGNAL(itemChanged(QTableWidgetItem *)),
-           this, SLOT(versionTableItemChanged(QTableWidgetItem *)));
+		   this, SLOT(versionTableItemChanged(QTableWidgetItem *)));
 }
 
 /*
@@ -626,9 +636,9 @@ void restoreTree::directoryItemExpanded(QTreeWidgetItem *item)
 {
    int childCount = item->childCount();
    for (int i=0; i<childCount; i++) {
-      QTreeWidgetItem *child = item->child(i);
-      if (child->icon(0).isNull())
-         child->setIcon(0, QIcon(QString::fromUtf8(":images/folder.png")));
+	  QTreeWidgetItem *child = item->child(i);
+	  if (child->icon(0).isNull())
+		 child->setIcon(0, QIcon(QString::fromUtf8(":images/folder.png")));
    }
 }
 
@@ -642,8 +652,8 @@ void restoreTree::populateJobTable()
 
    if (mainWin->m_rtPopDirDebug) Pmsg0(000, "Repopulating the Job Table\n");
    QStringList headerlist = (QStringList()
-      << tr("Job Id") << tr("End Time") << tr("Level") << tr("Type")
-      << tr("Name") << tr("Purged") << tr("TU") << tr("TD"));
+	  << tr("Job Id") << tr("End Time") << tr("Level") << tr("Type")
+	  << tr("Name") << tr("Purged") << tr("TU") << tr("TD"));
    m_toggleUpIndex = headerlist.indexOf(tr("TU"));
    m_toggleDownIndex = headerlist.indexOf(tr("TD"));
    int purgedIndex = headerlist.indexOf(tr("Purged"));
@@ -652,35 +662,35 @@ void restoreTree::populateJobTable()
    jobTable->setColumnCount(headerlist.size());
    jobTable->setHorizontalHeaderLabels(headerlist);
    QString jobQuery =
-      "SELECT Job.Jobid AS Id, Job.EndTime AS EndTime,"
-      " Job.Level AS Level, Job.Type AS Type,"
-      " Job.Name AS JobName, Job.purgedfiles AS Purged"
-      " FROM Job"
-      /* INNER JOIN FileSet eliminates all restore jobs */
-      " INNER JOIN Client ON (Job.ClientId=Client.ClientId)"
-      " INNER JOIN FileSet ON (Job.FileSetId=FileSet.FileSetId)"
-      " WHERE"
-      " Job.JobStatus IN ('T','W') AND Job.Type='B' AND"
-      " Client.Name='" + clientCombo->currentText() + "'";
+	  "SELECT Job.Jobid AS Id, Job.EndTime AS EndTime,"
+	  " Job.Level AS Level, Job.Type AS Type,"
+	  " Job.Name AS JobName, Job.purgedfiles AS Purged"
+	  " FROM Job"
+	  /* INNER JOIN FileSet eliminates all restore jobs */
+	  " INNER JOIN Client ON (Job.ClientId=Client.ClientId)"
+	  " INNER JOIN FileSet ON (Job.FileSetId=FileSet.FileSetId)"
+	  " WHERE"
+	  " Job.JobStatus IN ('T','W') AND Job.Type='B' AND"
+	  " Client.Name='" + clientCombo->currentText() + "'";
    if ((jobCombo->currentIndex() >= 0) && (jobCombo->currentText() != tr("Any"))) {
-      jobQuery += " AND Job.name = '" + jobCombo->currentText() + "'";
+	  jobQuery += " AND Job.name = '" + jobCombo->currentText() + "'";
    }
    if ((fileSetCombo->currentIndex() >= 0) && (fileSetCombo->currentText() != tr("Any"))) {
-      jobQuery += " AND FileSet.FileSet='" + fileSetCombo->currentText() + "'";
+	  jobQuery += " AND FileSet.FileSet='" + fileSetCombo->currentText() + "'";
    }
    /* If Limit check box For limit by days is checked  */
    if (daysCheckBox->checkState() == Qt::Checked) {
-      QDateTime stamp = QDateTime::currentDateTime().addDays(-daysSpinBox->value());
-      QString since = stamp.toString(Qt::ISODate);
-      jobQuery += " AND Job.Starttime>'" + since + "'";
+	  QDateTime stamp = QDateTime::currentDateTime().addDays(-daysSpinBox->value());
+	  QString since = stamp.toString(Qt::ISODate);
+	  jobQuery += " AND Job.Starttime>'" + since + "'";
    }
    //jobQuery += " AND Job.purgedfiles=0";
    jobQuery += " ORDER BY Job.EndTime DESC";
    /* If Limit check box for limit records returned is checked  */
    if (limitCheckBox->checkState() == Qt::Checked) {
-      QString limit;
-      limit.setNum(limitSpinBox->value());
-      jobQuery += " LIMIT " + limit;
+	  QString limit;
+	  limit.setNum(limitSpinBox->value());
+	  jobQuery += " LIMIT " + limit;
    }
    if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", jobQuery.toUtf8().data());
 
@@ -688,61 +698,65 @@ void restoreTree::populateJobTable()
    QStringList results;
    if (m_console->sql_cmd(jobQuery, results)) {
 
-      QTableWidgetItem* tableItem;
-      QString field;
-      QStringList fieldlist;
-      jobTable->setRowCount(results.size());
-
-      int row = 0;
-      /* Iterate through the record returned from the query */
-      foreach (QString resultline, results) {
-         fieldlist = resultline.split("\t");
-         int column = 0;
-         /* remove directory */
-         if (fieldlist[0].trimmed() != "") {
-            /* Iterate through fields in the record */
-            foreach (field, fieldlist) {
-               field = field.trimmed();  /* strip leading & trailing spaces */
-               if (field != "") {
-                  if (column == typeIndex) {
-                     QByteArray jtype(field.trimmed().toAscii());
-                     if (jtype.size()) {
-                        field = job_type_to_str(jtype[0]);
-                     }
-                  }
-                  tableItem = new QTableWidgetItem(field, 1);
-                  tableItem->setFlags(0);
-                  tableItem->setForeground(blackBrush);
-                  jobTable->setItem(row, column, tableItem);
-                  if (mainWin->m_sqlDebug) Pmsg1(000, "Column=%d\n", column);
-                  if (column == 0) {
-                     bool ok;
-                     int purged = fieldlist[purgedIndex].toInt(&ok, 10);
-                     if (!((ok) && (purged == 1))) {
-                        Qt::ItemFlags flag = Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate;
-                        tableItem->setFlags(flag);
-                        tableItem->setCheckState(Qt::Checked);
-                        tableItem->setBackground(Qt::green);
-                     } else {
-                        tableItem->setFlags(0);
-                        tableItem->setCheckState(Qt::Unchecked);
-                     }
-                  }
-                  column++;
-               }
-            }
-            tableItem = new QTableWidgetItem(QIcon(QString::fromUtf8(":images/go-up.png")), "", 1);
-            tableItem->setFlags(0);
-            tableItem->setForeground(blackBrush);
-            jobTable->setItem(row, column, tableItem);
-            column++;
-            tableItem = new QTableWidgetItem(QIcon(QString::fromUtf8(":images/go-down.png")), "", 1);
-            tableItem->setFlags(0);
-            tableItem->setForeground(blackBrush);
-            jobTable->setItem(row, column, tableItem);
-            row++;
-         }
-      }
+	  QTableWidgetItem* tableItem;
+	  QString field;
+	  QStringList fieldlist;
+	  jobTable->setRowCount(results.size());
+
+	  int row = 0;
+	  /* Iterate through the record returned from the query */
+	  foreach (QString resultline, results) {
+		 fieldlist = resultline.split("\t");
+		 int column = 0;
+		 /* remove directory */
+		 if (fieldlist[0].trimmed() != "") {
+			/* Iterate through fields in the record */
+			foreach (field, fieldlist) {
+			   field = field.trimmed();  /* strip leading & trailing spaces */
+			   if (field != "") {
+				  if (column == typeIndex) {
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+					  QByteArray jtype(field.trimmed().toLatin1());
+#else
+					 QByteArray jtype(field.trimmed().toAscii());
+#endif
+					 if (jtype.size()) {
+						field = job_type_to_str(jtype[0]);
+					 }
+				  }
+				  tableItem = new QTableWidgetItem(field, 1);
+				  tableItem->setFlags(0);
+				  tableItem->setForeground(blackBrush);
+				  jobTable->setItem(row, column, tableItem);
+				  if (mainWin->m_sqlDebug) Pmsg1(000, "Column=%d\n", column);
+				  if (column == 0) {
+					 bool ok;
+					 int purged = fieldlist[purgedIndex].toInt(&ok, 10);
+					 if (!((ok) && (purged == 1))) {
+						Qt::ItemFlags flag = Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate;
+						tableItem->setFlags(flag);
+						tableItem->setCheckState(Qt::Checked);
+						tableItem->setBackground(Qt::green);
+					 } else {
+						tableItem->setFlags(0);
+						tableItem->setCheckState(Qt::Unchecked);
+					 }
+				  }
+				  column++;
+			   }
+			}
+			tableItem = new QTableWidgetItem(QIcon(QString::fromUtf8(":images/go-up.png")), "", 1);
+			tableItem->setFlags(0);
+			tableItem->setForeground(blackBrush);
+			jobTable->setItem(row, column, tableItem);
+			column++;
+			tableItem = new QTableWidgetItem(QIcon(QString::fromUtf8(":images/go-down.png")), "", 1);
+			tableItem->setFlags(0);
+			tableItem->setForeground(blackBrush);
+			jobTable->setItem(row, column, tableItem);
+			row++;
+		 }
+	  }
    }
    jobTable->resizeColumnsToContents();
    jobTable->resizeRowsToContents();
@@ -753,30 +767,30 @@ void restoreTree::populateJobTable()
 void restoreTree::jobTableCellClicked(int row, int column)
 {
    if (column == m_toggleUpIndex){
-      int cnt;
-      for (cnt=0; cnt<row+1; cnt++) {
-         QTableWidgetItem *item = jobTable->item(cnt, 0);
-         if (item->flags()) {
-            Qt::CheckState state = item->checkState();
-            if (state == Qt::Checked)
-               item->setCheckState(Qt::Unchecked);
-            else if (state == Qt::Unchecked)
-               item->setCheckState(Qt::Checked);
-         }
-      }
+	  int cnt;
+	  for (cnt=0; cnt<row+1; cnt++) {
+		 QTableWidgetItem *item = jobTable->item(cnt, 0);
+		 if (item->flags()) {
+			Qt::CheckState state = item->checkState();
+			if (state == Qt::Checked)
+			   item->setCheckState(Qt::Unchecked);
+			else if (state == Qt::Unchecked)
+			   item->setCheckState(Qt::Checked);
+		 }
+	  }
    }
    if (column == m_toggleDownIndex){
-      int cnt, max = jobTable->rowCount();
-      for (cnt=row; cnt<max; cnt++) {
-         QTableWidgetItem *item = jobTable->item(cnt, 0);
-         if (item->flags()) {
-            Qt::CheckState state = item->checkState();
-            if (state == Qt::Checked)
-               item->setCheckState(Qt::Unchecked);
-            else if (state == Qt::Unchecked)
-               item->setCheckState(Qt::Checked);
-         }
-      }
+	  int cnt, max = jobTable->rowCount();
+	  for (cnt=row; cnt<max; cnt++) {
+		 QTableWidgetItem *item = jobTable->item(cnt, 0);
+		 if (item->flags()) {
+			Qt::CheckState state = item->checkState();
+			if (state == Qt::Checked)
+			   item->setCheckState(Qt::Unchecked);
+			else if (state == Qt::Unchecked)
+			   item->setCheckState(Qt::Checked);
+		 }
+	  }
    }
 }
 
@@ -794,65 +808,65 @@ void restoreTree::directoryItemChanged(QTreeWidgetItem *item, int /*column*/)
    if (parent) parState = parent->checkState(0);
    else parState = (Qt::CheckState)3;
    if (mainWin->m_rtDirICDebug) {
-      QString msg = QString("directory item OBJECT has changed prev=%1 cur=%2 par=%3 dir=%4\n")
-         .arg(prevState).arg(curState).arg(parState).arg(item->text(0));
-      Pmsg1(000, "%s", msg.toUtf8().data()); }
+	  QString msg = QString("directory item OBJECT has changed prev=%1 cur=%2 par=%3 dir=%4\n")
+		 .arg(prevState).arg(curState).arg(parState).arg(item->text(0));
+	  Pmsg1(000, "%s", msg.toUtf8().data()); }
    /* I only care when the check state changes */
    if (prevState == curState) {
-      if (mainWin->m_rtDirICDebug) Pmsg0(000, "Returning Early\n");
-      return;
+	  if (mainWin->m_rtDirICDebug) Pmsg0(000, "Returning Early\n");
+	  return;
    }
 
    if ((prevState == Qt::Unchecked) && (curState == Qt::Checked) && (parState != Qt::Unchecked)) {
-      if (mainWin->m_rtDirICDebug) Pmsg0(000, "Disconnected Setting to Qt::PartiallyChecked\n");
-      directoryTreeDisconnectedSet(item, Qt::PartiallyChecked);
-      curState = Qt::PartiallyChecked;
+	  if (mainWin->m_rtDirICDebug) Pmsg0(000, "Disconnected Setting to Qt::PartiallyChecked\n");
+	  directoryTreeDisconnectedSet(item, Qt::PartiallyChecked);
+	  curState = Qt::PartiallyChecked;
    }
    if ((prevState == Qt::PartiallyChecked) && (curState == Qt::Checked)) {
-      if (mainWin->m_rtDirICDebug) Pmsg0(000, "Disconnected Setting to Qt::Unchecked\n");
-      directoryTreeDisconnectedSet(item, Qt::Unchecked);
-      curState = Qt::Unchecked;
+	  if (mainWin->m_rtDirICDebug) Pmsg0(000, "Disconnected Setting to Qt::Unchecked\n");
+	  directoryTreeDisconnectedSet(item, Qt::Unchecked);
+	  curState = Qt::Unchecked;
    }
    if (mainWin->m_rtDirICDebug) {
-      QString msg = QString("directory item CHECKSTATE has changed prev=%1 cur=%2 par=%3 dir=%4\n")
-         .arg(prevState).arg(curState).arg(parState).arg(item->text(0));
-      Pmsg1(000, "%s", msg.toUtf8().data()); }
+	  QString msg = QString("directory item CHECKSTATE has changed prev=%1 cur=%2 par=%3 dir=%4\n")
+		 .arg(prevState).arg(curState).arg(parState).arg(item->text(0));
+	  Pmsg1(000, "%s", msg.toUtf8().data()); }
 
    item->setData(1, Qt::UserRole, QVariant(curState));
    Qt::CheckState childState = curState;
    if (childState == Qt::Checked)
-      childState = Qt::PartiallyChecked;
+	  childState = Qt::PartiallyChecked;
    setCheckofChildren(item, childState);
 
    /* Remove items from the exception lists.  The multi exception list is my index
-    * of what exceptions can be removed when the directory is known*/
+	* of what exceptions can be removed when the directory is known*/
    QString directory = item->data(0, Qt::UserRole).toString();
    QStringList fullPathList = m_fileExceptionMulti.values(directory);
    int fullPathListCount = fullPathList.count();
    if ((mainWin->m_rtDirICDebug) && fullPathListCount) Pmsg2(000, "Will attempt to remove file exceptions for %s count %i\n", directory.toUtf8().data(), fullPathListCount);
    foreach (QString fullPath, fullPathList) {
-      /* If there is no value in the hash for the key fullPath a value of 3 will be returned
-       * which will match no Qt::xxx values */
-      Qt::CheckState hashState = m_fileExceptionHash.value(fullPath, (Qt::CheckState)3);
-      if (mainWin->m_rtDirICDebug) Pmsg2(000, "hashState=%i childState=%i\n", hashState, childState);
-      if (hashState == Qt::Unchecked) {
-         fileExceptionRemove(fullPath, directory);
-         m_versionExceptionHash.remove(fullPath);
-         if (mainWin->m_rtDirICDebug) Pmsg0(000, "Attempted Removal A\n");
-      }
-      if (hashState == Qt::Checked) {
-         fileExceptionRemove(fullPath, directory);
-         m_versionExceptionHash.remove(fullPath);
-         if (mainWin->m_rtDirICDebug) Pmsg0(000, "Attempted Removal B\n");
-      }
+	  /* If there is no value in the hash for the key fullPath a value of 3 will be returned
+	   * which will match no Qt::xxx values */
+	  Qt::CheckState hashState = m_fileExceptionHash.value(fullPath, (Qt::CheckState)3);
+	  if (mainWin->m_rtDirICDebug) Pmsg2(000, "hashState=%i childState=%i\n", hashState, childState);
+	  if (hashState == Qt::Unchecked) {
+		 fileExceptionRemove(fullPath, directory);
+		 m_versionExceptionHash.remove(fullPath);
+		 if (mainWin->m_rtDirICDebug) Pmsg0(000, "Attempted Removal A\n");
+	  }
+	  if (hashState == Qt::Checked) {
+		 fileExceptionRemove(fullPath, directory);
+		 m_versionExceptionHash.remove(fullPath);
+		 if (mainWin->m_rtDirICDebug) Pmsg0(000, "Attempted Removal B\n");
+	  }
    }
 
    if (item == directoryTree->currentItem()) {
-      if (mainWin->m_rtDirICDebug) Pmsg0(000, "Will attempt to update File Table Checks\n");
-      updateFileTableChecks();
-      versionTable->clear();
-      versionTable->setRowCount(0);
-      versionTable->setColumnCount(0);
+	  if (mainWin->m_rtDirICDebug) Pmsg0(000, "Will attempt to update File Table Checks\n");
+	  updateFileTableChecks();
+	  versionTable->clear();
+	  versionTable->setRowCount(0);
+	  versionTable->setColumnCount(0);
    }
    if (mainWin->m_rtDirICDebug) Pmsg0(000, "Returning At End\n");
 }
@@ -867,10 +881,10 @@ void restoreTree::setCheckofChildren(QTreeWidgetItem *item, Qt::CheckState state
    int childCount;
    childCount = item->childCount();
    for (int i=0; i<childCount; i++) {
-      QTreeWidgetItem *child = item->child(i);
-      child->setData(1, Qt::UserRole, QVariant(state));
-      child->setCheckState(0, state);
-      setCheckofChildren(child, state);
+	  QTreeWidgetItem *child = item->child(i);
+	  child->setData(1, Qt::UserRole, QVariant(state));
+	  child->setCheckState(0, state);
+	  setCheckofChildren(child, state);
    }
 }
 
@@ -904,47 +918,47 @@ void restoreTree::fileTableItemChanged(QTableWidgetItem *item)
    int verJobNum = m_versionExceptionHash.value(fullPath, 0);
 
    if (mainWin->m_rtFileTabICDebug) {
-      QString msg = QString("filerow=%1 prev=%2 cur=%3 def=%4 hash=%5 dir=%6 verJobNum=%7\n")
-         .arg(row).arg(prevState).arg(curState).arg(defState).arg(hashState).arg(dirState).arg(verJobNum);
-      Pmsg1(000, "%s", msg.toUtf8().data()); }
+	  QString msg = QString("filerow=%1 prev=%2 cur=%3 def=%4 hash=%5 dir=%6 verJobNum=%7\n")
+		 .arg(row).arg(prevState).arg(curState).arg(defState).arg(hashState).arg(dirState).arg(verJobNum);
+	  Pmsg1(000, "%s", msg.toUtf8().data()); }
 
    /* Remove the hash if currently checked previously unchecked and directory is checked or partial */
    if ((prevState == Qt::Checked) && (curState == Qt::Unchecked) && (dirState == Qt::Unchecked)) {
-      /* it can behave as defaulted so current of unchecked is fine */
-      if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will fileExceptionRemove and m_versionExceptionHash.remove here\n");
-      fileExceptionRemove(fullPath, directory);
-      m_versionExceptionHash.remove(fullPath);
+	  /* it can behave as defaulted so current of unchecked is fine */
+	  if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will fileExceptionRemove and m_versionExceptionHash.remove here\n");
+	  fileExceptionRemove(fullPath, directory);
+	  m_versionExceptionHash.remove(fullPath);
    } else if ((prevState == Qt::PartiallyChecked) && (curState == Qt::Checked) && (dirState != Qt::Unchecked) && (verJobNum == 0)) {
-      if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will fileExceptionInsert here\n");
-      fileExceptionInsert(fullPath, directory, Qt::Unchecked);
+	  if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will fileExceptionInsert here\n");
+	  fileExceptionInsert(fullPath, directory, Qt::Unchecked);
    } else if ((prevState == Qt::Unchecked) && (curState == Qt::Checked) && (dirState != Qt::Unchecked) && (verJobNum == 0) && (defState == Qt::PartiallyChecked)) {
-      /* filerow=2 prev=0 cur=2 def=1 hash=0 dir=2 verJobNum=0 */
-      if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will fileExceptionRemove here\n");
-      fileExceptionRemove(fullPath, directory);
+	  /* filerow=2 prev=0 cur=2 def=1 hash=0 dir=2 verJobNum=0 */
+	  if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will fileExceptionRemove here\n");
+	  fileExceptionRemove(fullPath, directory);
    } else if ((prevState == Qt::Checked) && (curState == Qt::Unchecked) && (defState == Qt::PartiallyChecked) && (verJobNum != 0) && (hashState == Qt::Checked)) {
-      /* Check dir, check version, attempt uncheck in file
-       * filerow=4 prev=2 cur=0 def=1 hash=2 dir=2 verJobNum=53 */
-      if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will fileExceptionRemove and m_versionExceptionHash.remove here\n");
-      fileExceptionRemove(fullPath, directory);
-      m_versionExceptionHash.remove(fullPath);
+	  /* Check dir, check version, attempt uncheck in file
+	   * filerow=4 prev=2 cur=0 def=1 hash=2 dir=2 verJobNum=53 */
+	  if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will fileExceptionRemove and m_versionExceptionHash.remove here\n");
+	  fileExceptionRemove(fullPath, directory);
+	  m_versionExceptionHash.remove(fullPath);
    } else if ((prevState == Qt::Unchecked) && (curState == Qt::Checked) && (dirState != Qt::Unchecked) && (verJobNum == 0)) {
-      /* filerow=0 prev=0 cur=2 def=1 hash=0 dirState=2 verJobNum */
-      if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will Not remove here\n");
+	  /* filerow=0 prev=0 cur=2 def=1 hash=0 dirState=2 verJobNum */
+	  if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "Will Not remove here\n");
    } else if (prevState != curState) {
-      if (mainWin->m_rtFileTabICDebug) Pmsg2(000, "  THE STATE OF THE Check has changed, Setting StateList[%i] to %i\n", row, curState);
-      /* A user did not set the check state to Partially checked, ignore if so */
-      if (curState != Qt::PartiallyChecked) {
-         if ((defState == Qt::Unchecked) && (prevState == Qt::PartiallyChecked) && (curState == Qt::Unchecked)) {
-            if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "  got here\n");
-         } else {
-            if (mainWin->m_rtFileTabICDebug) Pmsg2(000, "  Inserting into m_fileExceptionHash %s, %i\n", fullPath.toUtf8().data(), curState);
-            fileExceptionInsert(fullPath, directory, curState);
-         }
-      } else {
-         if (mainWin->m_rtFileTabICDebug) Pmsg1(000, "Removing version hash for %s\n", fullPath.toUtf8().data());
-         /* programattically been changed back to a default state of Qt::PartiallyChecked remove the version hash here */
-         m_versionExceptionHash.remove(fullPath);
-      }
+	  if (mainWin->m_rtFileTabICDebug) Pmsg2(000, "  THE STATE OF THE Check has changed, Setting StateList[%i] to %i\n", row, curState);
+	  /* A user did not set the check state to Partially checked, ignore if so */
+	  if (curState != Qt::PartiallyChecked) {
+		 if ((defState == Qt::Unchecked) && (prevState == Qt::PartiallyChecked) && (curState == Qt::Unchecked)) {
+			if (mainWin->m_rtFileTabICDebug) Pmsg0(000, "  got here\n");
+		 } else {
+			if (mainWin->m_rtFileTabICDebug) Pmsg2(000, "  Inserting into m_fileExceptionHash %s, %i\n", fullPath.toUtf8().data(), curState);
+			fileExceptionInsert(fullPath, directory, curState);
+		 }
+	  } else {
+		 if (mainWin->m_rtFileTabICDebug) Pmsg1(000, "Removing version hash for %s\n", fullPath.toUtf8().data());
+		 /* programattically been changed back to a default state of Qt::PartiallyChecked remove the version hash here */
+		 m_versionExceptionHash.remove(fullPath);
+	  }
    }
 
    updateFileTableChecks();
@@ -972,14 +986,14 @@ void restoreTree::fileExceptionRemove(QString &fullPath, QString &directory)
    /* get the index of the fullpath to remove */
    int index = fullPathList.indexOf(fullPath);
    if (index != -1) {
-      /* remove the desired item in the list */
-      fullPathList.removeAt(index);
-      /* remove the entire list from the multi */
-      m_fileExceptionMulti.remove(directory);
-      /* readd the remaining */
-      foreach (QString fp, fullPathList) {
-         m_fileExceptionMulti.insert(directory, fp);
-      }
+	  /* remove the desired item in the list */
+	  fullPathList.removeAt(index);
+	  /* remove the entire list from the multi */
+	  m_fileExceptionMulti.remove(directory);
+	  /* readd the remaining */
+	  foreach (QString fp, fullPathList) {
+		 m_fileExceptionMulti.insert(directory, fp);
+	  }
    }
    directoryIconStateRemove();
 }
@@ -1005,11 +1019,11 @@ void restoreTree::versionTableItemChanged(QTableWidgetItem *item)
    Qt::CheckState defState;
    if (mainWin->m_sqlDebug) Pmsg1(000, "row=%d\n", row);
    if (row == 0) {
-      defState = Qt::PartiallyChecked;
-      if (fileState == Qt::Unchecked)
-         defState = Qt::Unchecked;
+	  defState = Qt::PartiallyChecked;
+	  if (fileState == Qt::Unchecked)
+		 defState = Qt::Unchecked;
    } else {
-      defState = Qt::Unchecked;
+	  defState = Qt::Unchecked;
    }
 
    /* determine if it is already in the versionExceptionHash */
@@ -1021,40 +1035,40 @@ void restoreTree::versionTableItemChanged(QTableWidgetItem *item)
    int hashJobNum = m_versionExceptionHash.value(fullPath, 0);
 
    if (mainWin->m_rtVerTabICDebug) {
-      QString msg = QString("versrow=%1 prev=%2 cur=%3 def=%4 dir=%5 hashJobNum=%6 thisJobNum=%7 filestate=%8 fec=%9 vec=%10\n")
-         .arg(row).arg(prevState).arg(curState).arg(defState).arg(dirState).arg(hashJobNum).arg(thisJobNum).arg(fileState)
-         .arg(m_fileExceptionHash.count()).arg(m_versionExceptionHash.count());
-      Pmsg1(000, "%s", msg.toUtf8().data()); }
+	  QString msg = QString("versrow=%1 prev=%2 cur=%3 def=%4 dir=%5 hashJobNum=%6 thisJobNum=%7 filestate=%8 fec=%9 vec=%10\n")
+		 .arg(row).arg(prevState).arg(curState).arg(defState).arg(dirState).arg(hashJobNum).arg(thisJobNum).arg(fileState)
+		 .arg(m_fileExceptionHash.count()).arg(m_versionExceptionHash.count());
+	  Pmsg1(000, "%s", msg.toUtf8().data()); }
    /* if changed from partially checked to checked, make it unchecked */
    if ((curState == Qt::Checked) && (row == 0) && (fileState == Qt::Unchecked)) {
-      if (mainWin->m_rtVerTabICDebug) Pmsg0(000, "Setting to Qt::Checked\n");
-      fileTableItem->setCheckState(Qt::Checked);
+	  if (mainWin->m_rtVerTabICDebug) Pmsg0(000, "Setting to Qt::Checked\n");
+	  fileTableItem->setCheckState(Qt::Checked);
    } else if ((prevState == Qt::PartiallyChecked) && (curState == Qt::Checked) && (row == 0) && (fileState == Qt::Checked) && (dirState == Qt::Unchecked)) {
-      //versrow=0 prev=1 cur=2 def=1 dir=0 hashJobNum=0 thisJobNum=64 filestate=2 fec=1 vec=0
-      if (mainWin->m_rtVerTabICDebug) Pmsg1(000, "fileExceptionRemove %s, %i\n", fullPath.toUtf8().data());
-      fileExceptionRemove(fullPath, directory);
+	  //versrow=0 prev=1 cur=2 def=1 dir=0 hashJobNum=0 thisJobNum=64 filestate=2 fec=1 vec=0
+	  if (mainWin->m_rtVerTabICDebug) Pmsg1(000, "fileExceptionRemove %s, %i\n", fullPath.toUtf8().data());
+	  fileExceptionRemove(fullPath, directory);
    } else if ((curState == Qt::Checked) && (row == 0) && (hashJobNum != 0) && (dirState != Qt::Unchecked)) {
-      //versrow=0 prev=0 cur=2 def=1 dir=2 hashJobNum=53 thisJobNum=64 filestate=2 fec=1 vec=1
-      if (mainWin->m_rtVerTabICDebug) Pmsg1(000, "m_versionExceptionHash.remove %s\n", fullPath.toUtf8().data());
-      m_versionExceptionHash.remove(fullPath);
-      fileExceptionRemove(fullPath, directory);
+	  //versrow=0 prev=0 cur=2 def=1 dir=2 hashJobNum=53 thisJobNum=64 filestate=2 fec=1 vec=1
+	  if (mainWin->m_rtVerTabICDebug) Pmsg1(000, "m_versionExceptionHash.remove %s\n", fullPath.toUtf8().data());
+	  m_versionExceptionHash.remove(fullPath);
+	  fileExceptionRemove(fullPath, directory);
    } else if ((curState == Qt::Checked) && (row == 0)) {
-      if (mainWin->m_rtVerTabICDebug) Pmsg1(000, "m_versionExceptionHash.remove %s\n", fullPath.toUtf8().data());
-      m_versionExceptionHash.remove(fullPath);
+	  if (mainWin->m_rtVerTabICDebug) Pmsg1(000, "m_versionExceptionHash.remove %s\n", fullPath.toUtf8().data());
+	  m_versionExceptionHash.remove(fullPath);
    } else if (prevState != curState) {
-      if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "  THE STATE OF THE version Check has changed, Setting StateList[%i] to %i\n", row, curState);
-      if ((curState == Qt::Checked) || (curState == Qt::PartiallyChecked)) {
-         if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "Inserting into m_versionExceptionHash %s, %i\n", fullPath.toUtf8().data(), thisJobNum);
-         m_versionExceptionHash.insert(fullPath, thisJobNum);
-         if (fileState != Qt::Checked) {
-            if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "Inserting into m_fileExceptionHash %s, %i\n", fullPath.toUtf8().data(), curState);
-            fileExceptionInsert(fullPath, directory, curState);
-         }
-      } else {
-         if (mainWin->m_rtVerTabICDebug) Pmsg0(000, "got here\n");
-      }
+	  if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "  THE STATE OF THE version Check has changed, Setting StateList[%i] to %i\n", row, curState);
+	  if ((curState == Qt::Checked) || (curState == Qt::PartiallyChecked)) {
+		 if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "Inserting into m_versionExceptionHash %s, %i\n", fullPath.toUtf8().data(), thisJobNum);
+		 m_versionExceptionHash.insert(fullPath, thisJobNum);
+		 if (fileState != Qt::Checked) {
+			if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "Inserting into m_fileExceptionHash %s, %i\n", fullPath.toUtf8().data(), curState);
+			fileExceptionInsert(fullPath, directory, curState);
+		 }
+	  } else {
+		 if (mainWin->m_rtVerTabICDebug) Pmsg0(000, "got here\n");
+	  }
    } else {
-     if (mainWin->m_rtVerTabICDebug) Pmsg0(000, "no conditions met\n");
+	 if (mainWin->m_rtVerTabICDebug) Pmsg0(000, "no conditions met\n");
    }
 
    updateFileTableChecks();
@@ -1068,12 +1082,12 @@ void restoreTree::versionTableItemChanged(QTableWidgetItem *item)
 void restoreTree::fileTableDisconnectedSet(QTableWidgetItem *item, Qt::CheckState state, bool color)
 {
    disconnect(fileTable, SIGNAL(itemChanged(QTableWidgetItem *)),
-           this, SLOT(fileTableItemChanged(QTableWidgetItem *)));
+		   this, SLOT(fileTableItemChanged(QTableWidgetItem *)));
    item->setCheckState(state);
    if (color) item->setBackground(Qt::yellow);
    else item->setBackground(Qt::white);
    connect(fileTable, SIGNAL(itemChanged(QTableWidgetItem *)),
-           this, SLOT(fileTableItemChanged(QTableWidgetItem *)));
+		   this, SLOT(fileTableItemChanged(QTableWidgetItem *)));
 }
 
 /*
@@ -1083,10 +1097,10 @@ void restoreTree::fileTableDisconnectedSet(QTableWidgetItem *item, Qt::CheckStat
 void restoreTree::versionTableDisconnectedSet(QTableWidgetItem *item, Qt::CheckState state)
 {
    disconnect(versionTable, SIGNAL(itemChanged(QTableWidgetItem *)),
-           this, SLOT(versionTableItemChanged(QTableWidgetItem *)));
+		   this, SLOT(versionTableItemChanged(QTableWidgetItem *)));
    item->setCheckState(state);
    connect(versionTable, SIGNAL(itemChanged(QTableWidgetItem *)),
-           this, SLOT(versionTableItemChanged(QTableWidgetItem *)));
+		   this, SLOT(versionTableItemChanged(QTableWidgetItem *)));
 }
 
 /*
@@ -1096,10 +1110,10 @@ void restoreTree::versionTableDisconnectedSet(QTableWidgetItem *item, Qt::CheckS
 void restoreTree::directoryTreeDisconnectedSet(QTreeWidgetItem *item, Qt::CheckState state)
 {
    disconnect(directoryTree, SIGNAL(itemChanged(QTreeWidgetItem *, int)),
-           this, SLOT(directoryItemChanged(QTreeWidgetItem *, int)));
+		   this, SLOT(directoryItemChanged(QTreeWidgetItem *, int)));
    item->setCheckState(0, state);
    connect(directoryTree, SIGNAL(itemChanged(QTreeWidgetItem *, int)),
-           this, SLOT(directoryItemChanged(QTreeWidgetItem *, int)));
+		   this, SLOT(directoryItemChanged(QTreeWidgetItem *, int)));
 }
 
 /*
@@ -1119,33 +1133,33 @@ void restoreTree::updateFileTableChecks()
    /* Update the items in the version table */
    int rcnt = fileTable->rowCount();
    for (int row=0; row<rcnt; row++) {
-      QTableWidgetItem* item = fileTable->item(row, 0);
-      if (!item) { return; }
-
-      Qt::CheckState curState = item->checkState();
-      Qt::CheckState newState = Qt::PartiallyChecked;
-      if (dirState == Qt::Unchecked) newState = Qt::Unchecked;
-
-      /* determine if it is already in the m_fileExceptionHash */
-      QString file = item->text();
-      QString fullPath = dirName + file;
-      Qt::CheckState hashState = m_fileExceptionHash.value(fullPath, (Qt::CheckState)3);
-      int hashJobNum = m_versionExceptionHash.value(fullPath, 0);
-
-      if (hashState != 3) newState = hashState;
-
-      if (mainWin->m_rtUpdateFTDebug) {
-         QString msg = QString("file row=%1 cur=%2 hash=%3 new=%4 dirState=%5\n")
-            .arg(row).arg(curState).arg(hashState).arg(newState).arg(dirState);
-         Pmsg1(000, "%s", msg.toUtf8().data());
-      }
-
-      bool docolor = false;
-      if (hashJobNum != 0) docolor = true;
-      bool isyellow = item->background().color() == QColor(Qt::yellow);
-      if ((newState != curState) || (hashState == 3) || ((isyellow && !docolor) || (!isyellow && docolor)))
-         fileTableDisconnectedSet(item, newState, docolor);
-      m_fileCheckStateList[row] = newState;
+	  QTableWidgetItem* item = fileTable->item(row, 0);
+	  if (!item) { return; }
+
+	  Qt::CheckState curState = item->checkState();
+	  Qt::CheckState newState = Qt::PartiallyChecked;
+	  if (dirState == Qt::Unchecked) newState = Qt::Unchecked;
+
+	  /* determine if it is already in the m_fileExceptionHash */
+	  QString file = item->text();
+	  QString fullPath = dirName + file;
+	  Qt::CheckState hashState = m_fileExceptionHash.value(fullPath, (Qt::CheckState)3);
+	  int hashJobNum = m_versionExceptionHash.value(fullPath, 0);
+
+	  if (hashState != 3) newState = hashState;
+
+	  if (mainWin->m_rtUpdateFTDebug) {
+		 QString msg = QString("file row=%1 cur=%2 hash=%3 new=%4 dirState=%5\n")
+			.arg(row).arg(curState).arg(hashState).arg(newState).arg(dirState);
+		 Pmsg1(000, "%s", msg.toUtf8().data());
+	  }
+
+	  bool docolor = false;
+	  if (hashJobNum != 0) docolor = true;
+	  bool isyellow = item->background().color() == QColor(Qt::yellow);
+	  if ((newState != curState) || (hashState == 3) || ((isyellow && !docolor) || (!isyellow && docolor)))
+		 fileTableDisconnectedSet(item, newState, docolor);
+	  m_fileCheckStateList[row] = newState;
    }
 }
 
@@ -1171,28 +1185,28 @@ void restoreTree::updateVersionTableChecks()
    /* Update the items in the version table */
    int cnt = versionTable->rowCount();
    for (int row=0; row<cnt; row++) {
-      QTableWidgetItem* item = versionTable->item(row, 0);
-      if (!item) { break; }
-
-      Qt::CheckState curState = item->checkState();
-      Qt::CheckState newState = Qt::Unchecked;
-
-      if ((row == 0) && (fileState != Qt::Unchecked) && (hashJobNum == 0))
-         newState = Qt::PartiallyChecked;
-      /* determine if it is already in the versionExceptionHash */
-      if (hashJobNum) {
-         int thisJobNum = item->text().toInt();
-         if (thisJobNum == hashJobNum)
-            newState = Qt::Checked;
-      }
-      if (mainWin->m_rtChecksDebug) {
-         QString msg = QString("ver row=%1 cur=%2 hashJobNum=%3 new=%4 dirState=%5\n")
-            .arg(row).arg(curState).arg(hashJobNum).arg(newState).arg(dirState);
-         Pmsg1(000, "%s", msg.toUtf8().data());
-      }
-      if (newState != curState)
-         versionTableDisconnectedSet(item, newState);
-      m_versionCheckStateList[row] = newState;
+	  QTableWidgetItem* item = versionTable->item(row, 0);
+	  if (!item) { break; }
+
+	  Qt::CheckState curState = item->checkState();
+	  Qt::CheckState newState = Qt::Unchecked;
+
+	  if ((row == 0) && (fileState != Qt::Unchecked) && (hashJobNum == 0))
+		 newState = Qt::PartiallyChecked;
+	  /* determine if it is already in the versionExceptionHash */
+	  if (hashJobNum) {
+		 int thisJobNum = item->text().toInt();
+		 if (thisJobNum == hashJobNum)
+			newState = Qt::Checked;
+	  }
+	  if (mainWin->m_rtChecksDebug) {
+		 QString msg = QString("ver row=%1 cur=%2 hashJobNum=%3 new=%4 dirState=%5\n")
+			.arg(row).arg(curState).arg(hashJobNum).arg(newState).arg(dirState);
+		 Pmsg1(000, "%s", msg.toUtf8().data());
+	  }
+	  if (newState != curState)
+		 versionTableDisconnectedSet(item, newState);
+	  m_versionCheckStateList[row] = newState;
    }
 }
 
@@ -1206,16 +1220,16 @@ void restoreTree::fullPathtoSubPaths(QStringList &subPaths, QString &fullPath_in
    QString fullPath = fullPath_in;
    QString direct, path;
    while (((index = fullPath.lastIndexOf("/", -2)) != -1) && (!done)) {
-      direct = path = fullPath;
-      path.replace(index+1, fullPath.length()-index-1, "");
-      direct.replace(0, index+1, "");
-      if (false) {
-         QString msg = QString("length = \"%1\" index = \"%2\" Considering \"%3\" \"%4\"\n")
-                    .arg(fullPath.length()).arg(index).arg(path).arg(direct);
-         Pmsg0(000, msg.toUtf8().data());
-      }
-      fullPath = path;
-      subPaths.append(fullPath);
+	  direct = path = fullPath;
+	  path.replace(index+1, fullPath.length()-index-1, "");
+	  direct.replace(0, index+1, "");
+	  if (false) {
+		 QString msg = QString("length = \"%1\" index = \"%2\" Considering \"%3\" \"%4\"\n")
+					.arg(fullPath.length()).arg(index).arg(path).arg(direct);
+		 Pmsg0(000, msg.toUtf8().data());
+	  }
+	  fullPath = path;
+	  subPaths.append(fullPath);
    }
 }
 
@@ -1229,59 +1243,59 @@ void restoreTree::directoryIconStateInsert(QString &fullPath, Qt::CheckState exc
    fullPathtoSubPaths(paths, fullPath);
    /* an exception that causes the item in the file table to be "Checked" has occured */
    if (excpState == Qt::Checked) {
-      bool foundAsUnChecked = false;
-      QTreeWidgetItem *firstItem = m_dirPaths.value(paths[0]);
-      if (firstItem) {
-         if (firstItem->checkState(0) == Qt::Unchecked)
-            foundAsUnChecked = true;
-      }
-      if (foundAsUnChecked) {
-          /* as long as directory item is Unchecked, set icon state to "green check" */
-         bool done = false;
-         QListIterator<QString> siter(paths);
-         while (siter.hasNext() && !done) {
-            QString path = siter.next();
-            QTreeWidgetItem *item = m_dirPaths.value(path);
-            if (item) {
-               if (item->checkState(0) != Qt::Unchecked)
-                  done = true;
-               else {
-                  directorySetIcon(1, FolderGreenChecked, path, item);
-                  if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert inserting %s\n", path.toUtf8().data());
-               }
-            }
-         }
-      } else {
-         /* if it is partially checked or fully checked insert green Check until a unchecked is found in the path */
-         if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert Aqua %s\n", paths[0].toUtf8().data());
-         bool done = false;
-         QListIterator<QString> siter(paths);
-         while (siter.hasNext() && !done) {
-            QString path = siter.next();
-            QTreeWidgetItem *item = m_dirPaths.value(path);
-            if (item) {  /* if the directory item is checked, set icon state to unchecked "green check" */
-               if (item->checkState(0) == Qt::Checked)
-                  done = true;
-               directorySetIcon(1, FolderGreenChecked, path, item);
-               if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert boogie %s\n", path.toUtf8().data());
-            }
-         }
-      }
+	  bool foundAsUnChecked = false;
+	  QTreeWidgetItem *firstItem = m_dirPaths.value(paths[0]);
+	  if (firstItem) {
+		 if (firstItem->checkState(0) == Qt::Unchecked)
+			foundAsUnChecked = true;
+	  }
+	  if (foundAsUnChecked) {
+		  /* as long as directory item is Unchecked, set icon state to "green check" */
+		 bool done = false;
+		 QListIterator<QString> siter(paths);
+		 while (siter.hasNext() && !done) {
+			QString path = siter.next();
+			QTreeWidgetItem *item = m_dirPaths.value(path);
+			if (item) {
+			   if (item->checkState(0) != Qt::Unchecked)
+				  done = true;
+			   else {
+				  directorySetIcon(1, FolderGreenChecked, path, item);
+				  if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert inserting %s\n", path.toUtf8().data());
+			   }
+			}
+		 }
+	  } else {
+		 /* if it is partially checked or fully checked insert green Check until a unchecked is found in the path */
+		 if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert Aqua %s\n", paths[0].toUtf8().data());
+		 bool done = false;
+		 QListIterator<QString> siter(paths);
+		 while (siter.hasNext() && !done) {
+			QString path = siter.next();
+			QTreeWidgetItem *item = m_dirPaths.value(path);
+			if (item) {  /* if the directory item is checked, set icon state to unchecked "green check" */
+			   if (item->checkState(0) == Qt::Checked)
+				  done = true;
+			   directorySetIcon(1, FolderGreenChecked, path, item);
+			   if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert boogie %s\n", path.toUtf8().data());
+			}
+		 }
+	  }
    }
    /* an exception that causes the item in the file table to be "Unchecked" has occured */
    if (excpState == Qt::Unchecked) {
-      bool done = false;
-      QListIterator<QString> siter(paths);
-      while (siter.hasNext() && !done) {
-         QString path = siter.next();
-         QTreeWidgetItem *item = m_dirPaths.value(path);
-         if (item) {  /* if the directory item is checked, set icon state to unchecked "white check" */
-            if (item->checkState(0) == Qt::Checked)
-               done = true;
-            directorySetIcon(1, FolderWhiteChecked, path, item);
-            if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert boogie %s\n", path.toUtf8().data());
-         }
-      }
+	  bool done = false;
+	  QListIterator<QString> siter(paths);
+	  while (siter.hasNext() && !done) {
+		 QString path = siter.next();
+		 QTreeWidgetItem *item = m_dirPaths.value(path);
+		 if (item) {  /* if the directory item is checked, set icon state to unchecked "white check" */
+			if (item->checkState(0) == Qt::Checked)
+			   done = true;
+			directorySetIcon(1, FolderWhiteChecked, path, item);
+			if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert boogie %s\n", path.toUtf8().data());
+		 }
+	  }
    }
 }
 
@@ -1296,100 +1310,100 @@ void restoreTree::directoryIconStateRemove()
    /* Use iterator tera to iterate through m_fileExceptionHash */
    QHashIterator<QString, Qt::CheckState> tera(m_fileExceptionHash);
    while (tera.hasNext()) {
-      tera.next();
-      if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Alpha Key %s value %i\n", tera.key().toUtf8().data(), tera.value());
-
-      QString keyPath = tera.key();
-      Qt::CheckState state = tera.value();
-
-      QStringList paths;
-      fullPathtoSubPaths(paths, keyPath);
-      /* if the state of the item in m_fileExceptionHash is checked
-       * each of the subpaths should be "Checked Green" */
-      if (state == Qt::Checked) {
-
-         bool foundAsUnChecked = false;
-         QTreeWidgetItem *firstItem = m_dirPaths.value(paths[0]);
-         if (firstItem) {
-            if (firstItem->checkState(0) == Qt::Unchecked)
-               foundAsUnChecked = true;
-         }
-         if (foundAsUnChecked) {
-            /* The right most directory is Unchecked, iterate leftwards
-             * as long as directory item is Unchecked, set icon state to "green check" */
-            bool done = false;
-            QListIterator<QString> siter(paths);
-            while (siter.hasNext() && !done) {
-               QString path = siter.next();
-               QTreeWidgetItem *item = m_dirPaths.value(path);
-               if (item) {
-                  if (item->checkState(0) != Qt::Unchecked)
-                     done = true;
-                  else {
-                     shouldBeIconStateHash.insert(path, FolderGreenChecked);
-                     if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert inserting %s\n", path.toUtf8().data());
-                  }
-               }
-            }
-         }
-         else {
-            /* The right most directory is Unchecked, iterate leftwards
-             * until directory item is Checked, set icon state to "green check" */
-            bool done = false;
-            QListIterator<QString> siter(paths);
-            while (siter.hasNext() && !done) {
-               QString path = siter.next();
-               QTreeWidgetItem *item = m_dirPaths.value(path);
-               if (item) {
-                  if (item->checkState(0) == Qt::Checked)
-                     done = true;
-                  shouldBeIconStateHash.insert(path, FolderGreenChecked);
-               }
-            }
-         }
-      }
-      /* if the state of the item in m_fileExceptionHash is UNChecked
-       * each of the subpaths should be "Checked white" until the tree item
-       * which represents that path is Qt::Checked */
-      if (state == Qt::Unchecked) {
-         bool done = false;
-         QListIterator<QString> siter(paths);
-         while (siter.hasNext() && !done) {
-            QString path = siter.next();
-            QTreeWidgetItem *item = m_dirPaths.value(path);
-            if (item) {
-               if (item->checkState(0) == Qt::Checked)
-                  done = true;
-               shouldBeIconStateHash.insert(path, FolderWhiteChecked);
-            }
-         }
-      }
+	  tera.next();
+	  if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Alpha Key %s value %i\n", tera.key().toUtf8().data(), tera.value());
+
+	  QString keyPath = tera.key();
+	  Qt::CheckState state = tera.value();
+
+	  QStringList paths;
+	  fullPathtoSubPaths(paths, keyPath);
+	  /* if the state of the item in m_fileExceptionHash is checked
+	   * each of the subpaths should be "Checked Green" */
+	  if (state == Qt::Checked) {
+
+		 bool foundAsUnChecked = false;
+		 QTreeWidgetItem *firstItem = m_dirPaths.value(paths[0]);
+		 if (firstItem) {
+			if (firstItem->checkState(0) == Qt::Unchecked)
+			   foundAsUnChecked = true;
+		 }
+		 if (foundAsUnChecked) {
+			/* The right most directory is Unchecked, iterate leftwards
+			 * as long as directory item is Unchecked, set icon state to "green check" */
+			bool done = false;
+			QListIterator<QString> siter(paths);
+			while (siter.hasNext() && !done) {
+			   QString path = siter.next();
+			   QTreeWidgetItem *item = m_dirPaths.value(path);
+			   if (item) {
+				  if (item->checkState(0) != Qt::Unchecked)
+					 done = true;
+				  else {
+					 shouldBeIconStateHash.insert(path, FolderGreenChecked);
+					 if (mainWin->m_rtIconStateDebug) Pmsg1(000, "In restoreTree::directoryIconStateInsert inserting %s\n", path.toUtf8().data());
+				  }
+			   }
+			}
+		 }
+		 else {
+			/* The right most directory is Unchecked, iterate leftwards
+			 * until directory item is Checked, set icon state to "green check" */
+			bool done = false;
+			QListIterator<QString> siter(paths);
+			while (siter.hasNext() && !done) {
+			   QString path = siter.next();
+			   QTreeWidgetItem *item = m_dirPaths.value(path);
+			   if (item) {
+				  if (item->checkState(0) == Qt::Checked)
+					 done = true;
+				  shouldBeIconStateHash.insert(path, FolderGreenChecked);
+			   }
+			}
+		 }
+	  }
+	  /* if the state of the item in m_fileExceptionHash is UNChecked
+	   * each of the subpaths should be "Checked white" until the tree item
+	   * which represents that path is Qt::Checked */
+	  if (state == Qt::Unchecked) {
+		 bool done = false;
+		 QListIterator<QString> siter(paths);
+		 while (siter.hasNext() && !done) {
+			QString path = siter.next();
+			QTreeWidgetItem *item = m_dirPaths.value(path);
+			if (item) {
+			   if (item->checkState(0) == Qt::Checked)
+				  done = true;
+			   shouldBeIconStateHash.insert(path, FolderWhiteChecked);
+			}
+		 }
+	  }
    }
    /* now iterate through m_directoryIconStateHash which are the items that are checked
-    * and remove all of those that are not in shouldBeIconStateHash */
+	* and remove all of those that are not in shouldBeIconStateHash */
    QHashIterator<QString, int> iter(m_directoryIconStateHash);
    while (iter.hasNext()) {
-      iter.next();
-      if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Beta Key %s value %i\n", iter.key().toUtf8().data(), iter.value());
-
-      QString keyPath = iter.key();
-      if (shouldBeIconStateHash.value(keyPath)) {
-         if (mainWin->m_rtIconStateDebug) Pmsg1(000, "WAS found in shouldBeStateHash %s\n", keyPath.toUtf8().data());
-         //newval = m_directoryIconStateHash.value(path, FolderUnchecked) & (~change);
-         int newval = shouldBeIconStateHash.value(keyPath);
-         newval = ~newval;
-         newval = newval & FolderBothChecked;
-         QTreeWidgetItem *item = m_dirPaths.value(keyPath);
-         if (item)
-            directorySetIcon(0, newval, keyPath, item);
-      } else {
-         if (mainWin->m_rtIconStateDebug) Pmsg1(000, "NOT found in shouldBeStateHash %s\n", keyPath.toUtf8().data());
-         QTreeWidgetItem *item = m_dirPaths.value(keyPath);
-         if (item)
-            directorySetIcon(0, FolderBothChecked, keyPath, item);
-            //item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
-            //m_directoryIconStateHash.remove(keyPath);
-      }
+	  iter.next();
+	  if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Beta Key %s value %i\n", iter.key().toUtf8().data(), iter.value());
+
+	  QString keyPath = iter.key();
+	  if (shouldBeIconStateHash.value(keyPath)) {
+		 if (mainWin->m_rtIconStateDebug) Pmsg1(000, "WAS found in shouldBeStateHash %s\n", keyPath.toUtf8().data());
+		 //newval = m_directoryIconStateHash.value(path, FolderUnchecked) & (~change);
+		 int newval = shouldBeIconStateHash.value(keyPath);
+		 newval = ~newval;
+		 newval = newval & FolderBothChecked;
+		 QTreeWidgetItem *item = m_dirPaths.value(keyPath);
+		 if (item)
+			directorySetIcon(0, newval, keyPath, item);
+	  } else {
+		 if (mainWin->m_rtIconStateDebug) Pmsg1(000, "NOT found in shouldBeStateHash %s\n", keyPath.toUtf8().data());
+		 QTreeWidgetItem *item = m_dirPaths.value(keyPath);
+		 if (item)
+			directorySetIcon(0, FolderBothChecked, keyPath, item);
+			//item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
+			//m_directoryIconStateHash.remove(keyPath);
+	  }
    }
 }
 
@@ -1397,30 +1411,30 @@ void restoreTree::directorySetIcon(int operation, int change, QString &path, QTr
    int newval;
    /* we are adding a check type white or green */
    if (operation > 0) {
-      /* get the old val and "bitwise OR" with the change */
-      newval = m_directoryIconStateHash.value(path, FolderUnchecked) | change;
-      if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Inserting into m_directoryIconStateHash path=%s newval=%i\n", path.toUtf8().data(), newval);
-      m_directoryIconStateHash.insert(path, newval);
+	  /* get the old val and "bitwise OR" with the change */
+	  newval = m_directoryIconStateHash.value(path, FolderUnchecked) | change;
+	  if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Inserting into m_directoryIconStateHash path=%s newval=%i\n", path.toUtf8().data(), newval);
+	  m_directoryIconStateHash.insert(path, newval);
    } else {
    /* we are removing a check type white or green */
-      newval = m_directoryIconStateHash.value(path, FolderUnchecked) & (~change);
-      if (newval == 0) {
-         if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Removing from m_directoryIconStateHash path=%s newval=%i\n", path.toUtf8().data(), newval);
-         m_directoryIconStateHash.remove(path);
-      }
-      else {
-         if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Inserting into m_directoryIconStateHash path=%s newval=%i\n", path.toUtf8().data(), newval);
-         m_directoryIconStateHash.insert(path, newval);
-      }
+	  newval = m_directoryIconStateHash.value(path, FolderUnchecked) & (~change);
+	  if (newval == 0) {
+		 if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Removing from m_directoryIconStateHash path=%s newval=%i\n", path.toUtf8().data(), newval);
+		 m_directoryIconStateHash.remove(path);
+	  }
+	  else {
+		 if (mainWin->m_rtIconStateDebug) Pmsg2(000, "Inserting into m_directoryIconStateHash path=%s newval=%i\n", path.toUtf8().data(), newval);
+		 m_directoryIconStateHash.insert(path, newval);
+	  }
    }
    if (newval == FolderUnchecked)
-      item->setIcon(0, QIcon(QString::fromUtf8(":images/folder.png")));
+	  item->setIcon(0, QIcon(QString::fromUtf8(":images/folder.png")));
    else if (newval == FolderGreenChecked)
-      item->setIcon(0, QIcon(QString::fromUtf8(":images/folderchecked.png")));
+	  item->setIcon(0, QIcon(QString::fromUtf8(":images/folderchecked.png")));
    else if (newval == FolderWhiteChecked)
-      item->setIcon(0, QIcon(QString::fromUtf8(":images/folderunchecked.png")));
+	  item->setIcon(0, QIcon(QString::fromUtf8(":images/folderunchecked.png")));
    else if (newval == FolderBothChecked)
-      item->setIcon(0, QIcon(QString::fromUtf8(":images/folderbothchecked.png")));
+	  item->setIcon(0, QIcon(QString::fromUtf8(":images/folderbothchecked.png")));
 }
 
 /*
@@ -1444,13 +1458,13 @@ void restoreTree::restoreButtonPushed()
    QHash <QString, bool> fullPathDone;
    QHash <QString, int> fileIndexHash;
    if ((mainWin->m_rtRestore1Debug) || (mainWin->m_rtRestore2Debug) || (mainWin->m_rtRestore3Debug))
-      Pmsg0(000, "In restoreTree::restoreButtonPushed\n");
+	  Pmsg0(000, "In restoreTree::restoreButtonPushed\n");
    /* Use a tree widget item iterator to count directories for the progress bar */
    QTreeWidgetItemIterator diterc(directoryTree, QTreeWidgetItemIterator::Checked);
    int ditcount = 0;
    while (*diterc) {
-      ditcount += 1;
-      ++diterc;
+	  ditcount += 1;
+	  ++diterc;
    } /* while (*diterc) */
    prBar2->setRange(0, ditcount);
    prBar2->setValue(0);
@@ -1458,82 +1472,82 @@ void restoreTree::restoreButtonPushed()
    /* Use a tree widget item iterator filtering for Checked Items */
    QTreeWidgetItemIterator diter(directoryTree, QTreeWidgetItemIterator::Checked);
    while (*diter) {
-      QString directory = (*diter)->data(0, Qt::UserRole).toString();
-      int pathid = m_directoryPathIdHash.value(directory, -1);
-      if (pathid != -1) {
-         if (mainWin->m_rtRestore1Debug)
-            Pmsg1(000, "Directory Checked=\"%s\"\n", directory.toUtf8().data());
-         /* With a checked directory, query for the files in the directory */
-
-         QString cmd =
-            "SELECT Filename.Name AS Filename, t1.JobId AS JobId, File.FileIndex AS FileIndex"
-            " FROM"
-            " ( SELECT File.FilenameId AS FilenameId, MAX(Job.JobId) AS JobId"
-              " FROM File"
-              " INNER JOIN Job ON (Job.JobId=File.JobId)"
-              " WHERE File.PathId=" + QString("%1").arg(pathid) +
-              " AND Job.Jobid IN (" + m_checkedJobs + ")"
-              " GROUP BY File.FilenameId"
-            ") t1, File "
-              " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
-              " INNER JOIN Job ON (Job.JobId=File.JobId)"
-              " WHERE File.PathId=" + QString("%1").arg(pathid) +
-              " AND File.FilenameId=t1.FilenameId"
-              " AND Job.Jobid=t1.JobId"
-            " ORDER BY Filename";
-
-         if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
-         QStringList results;
-         if (m_console->sql_cmd(cmd, results)) {
-            QStringList fieldlist;
-
-            int row = 0;
-            /* Iterate through the record returned from the query */
-            foreach (QString resultline, results) {
-               /* Iterate through fields in the record */
-               int column = 0;
-               QString fullPath = "";
-               Qt::CheckState fileExcpState = (Qt::CheckState)4;
-               fieldlist = resultline.split("\t");
-               int version = 0;
-               int fileIndex = 0;
-               foreach (QString field, fieldlist) {
-                  if (column == 0) {
-                     fullPath = directory + field;
-                  }
-                  if (column == 1) {
-                     version = field.toInt();
-                  }
-                  if (column == 2) {
-                     fileIndex = field.toInt();
-                  }
-                  column++;
-               }
-               fileExcpState = m_fileExceptionHash.value(fullPath, (Qt::CheckState)3);
-
-               int excpVersion = m_versionExceptionHash.value(fullPath, 0);
-               if (fileExcpState != Qt::Unchecked) {
-                  QString debugtext;
-                  if (excpVersion != 0) {
-                     debugtext = QString("*E* version=%1").arg(excpVersion);
-                     version = excpVersion;
-                     fileIndex = queryFileIndex(fullPath, excpVersion);
-                  } else
-                     debugtext = QString("___ version=%1").arg(version);
-                  if (mainWin->m_rtRestore1Debug)
-                     Pmsg2(000, "Restoring %s File %s\n", debugtext.toUtf8().data(), fullPath.toUtf8().data());
-                  fullPathDone.insert(fullPath, 1);
-                  fileIndexHash.insert(fullPath, fileIndex);
-                  versionFilesMulti.insert(version, fullPath);
-                  vFMCounter += 1;
-               }
-               row++;
-            }
-         }
-      }
-      ditcount += 1;
-      prBar2->setValue(ditcount);
-      ++diter;
+	  QString directory = (*diter)->data(0, Qt::UserRole).toString();
+	  int pathid = m_directoryPathIdHash.value(directory, -1);
+	  if (pathid != -1) {
+		 if (mainWin->m_rtRestore1Debug)
+			Pmsg1(000, "Directory Checked=\"%s\"\n", directory.toUtf8().data());
+		 /* With a checked directory, query for the files in the directory */
+
+		 QString cmd =
+			"SELECT Filename.Name AS Filename, t1.JobId AS JobId, File.FileIndex AS FileIndex"
+			" FROM"
+			" ( SELECT File.FilenameId AS FilenameId, MAX(Job.JobId) AS JobId"
+			  " FROM File"
+			  " INNER JOIN Job ON (Job.JobId=File.JobId)"
+			  " WHERE File.PathId=" + QString("%1").arg(pathid) +
+			  " AND Job.Jobid IN (" + m_checkedJobs + ")"
+			  " GROUP BY File.FilenameId"
+			") t1, File "
+			  " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
+			  " INNER JOIN Job ON (Job.JobId=File.JobId)"
+			  " WHERE File.PathId=" + QString("%1").arg(pathid) +
+			  " AND File.FilenameId=t1.FilenameId"
+			  " AND Job.Jobid=t1.JobId"
+			" ORDER BY Filename";
+
+		 if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
+		 QStringList results;
+		 if (m_console->sql_cmd(cmd, results)) {
+			QStringList fieldlist;
+
+			int row = 0;
+			/* Iterate through the record returned from the query */
+			foreach (QString resultline, results) {
+			   /* Iterate through fields in the record */
+			   int column = 0;
+			   QString fullPath = "";
+			   Qt::CheckState fileExcpState = (Qt::CheckState)4;
+			   fieldlist = resultline.split("\t");
+			   int version = 0;
+			   int fileIndex = 0;
+			   foreach (QString field, fieldlist) {
+				  if (column == 0) {
+					 fullPath = directory + field;
+				  }
+				  if (column == 1) {
+					 version = field.toInt();
+				  }
+				  if (column == 2) {
+					 fileIndex = field.toInt();
+				  }
+				  column++;
+			   }
+			   fileExcpState = m_fileExceptionHash.value(fullPath, (Qt::CheckState)3);
+
+			   int excpVersion = m_versionExceptionHash.value(fullPath, 0);
+			   if (fileExcpState != Qt::Unchecked) {
+				  QString debugtext;
+				  if (excpVersion != 0) {
+					 debugtext = QString("*E* version=%1").arg(excpVersion);
+					 version = excpVersion;
+					 fileIndex = queryFileIndex(fullPath, excpVersion);
+				  } else
+					 debugtext = QString("___ version=%1").arg(version);
+				  if (mainWin->m_rtRestore1Debug)
+					 Pmsg2(000, "Restoring %s File %s\n", debugtext.toUtf8().data(), fullPath.toUtf8().data());
+				  fullPathDone.insert(fullPath, 1);
+				  fileIndexHash.insert(fullPath, fileIndex);
+				  versionFilesMulti.insert(version, fullPath);
+				  vFMCounter += 1;
+			   }
+			   row++;
+			}
+		 }
+	  }
+	  ditcount += 1;
+	  prBar2->setValue(ditcount);
+	  ++diter;
    } /* while (*diter) */
    prBar1->setValue(1);
    prLabel1->setText( tr("Task 2 of 3"));
@@ -1544,33 +1558,33 @@ void restoreTree::restoreButtonPushed()
    /* There may be some exceptions not accounted for yet with fullPathDone */
    QHashIterator<QString, Qt::CheckState> ftera(m_fileExceptionHash);
    while (ftera.hasNext()) {
-      ftera.next();
-      QString fullPath = ftera.key();
-      Qt::CheckState state = ftera.value();
-      if (state != 0) {
-         /* now we don't want the ones already done */
-         if (fullPathDone.value(fullPath, 0) == 0) {
-            int version = m_versionExceptionHash.value(fullPath, 0);
-            int fileIndex = 0;
-            QString debugtext = "";
-            if (version != 0) {
-               fileIndex = queryFileIndex(fullPath, version);
-               debugtext = QString("E1* version=%1 fileid=%2").arg(version).arg(fileIndex);
-            } else {
-               version = mostRecentVersionfromFullPath(fullPath);
-               if (version) {
-                  fileIndex = queryFileIndex(fullPath, version);
-                  debugtext = QString("E2* version=%1 fileid=%2").arg(version).arg(fileIndex);
-               } else
-                  debugtext = QString("Error det vers").arg(version);
-            }
-            if (mainWin->m_rtRestore1Debug)
-               Pmsg2(000, "Restoring %s file %s\n", debugtext.toUtf8().data(), fullPath.toUtf8().data());
-            versionFilesMulti.insert(version, fullPath);
-            vFMCounter += 1;
-            fileIndexHash.insert(fullPath, fileIndex);
-         } /* if fullPathDone.value(fullPath, 0) == 0 */
-      } /* if state != 0 */
+	  ftera.next();
+	  QString fullPath = ftera.key();
+	  Qt::CheckState state = ftera.value();
+	  if (state != 0) {
+		 /* now we don't want the ones already done */
+		 if (fullPathDone.value(fullPath, 0) == 0) {
+			int version = m_versionExceptionHash.value(fullPath, 0);
+			int fileIndex = 0;
+			QString debugtext = "";
+			if (version != 0) {
+			   fileIndex = queryFileIndex(fullPath, version);
+			   debugtext = QString("E1* version=%1 fileid=%2").arg(version).arg(fileIndex);
+			} else {
+			   version = mostRecentVersionfromFullPath(fullPath);
+			   if (version) {
+				  fileIndex = queryFileIndex(fullPath, version);
+				  debugtext = QString("E2* version=%1 fileid=%2").arg(version).arg(fileIndex);
+			   } else
+				  debugtext = QString("Error det vers").arg(version);
+			}
+			if (mainWin->m_rtRestore1Debug)
+			   Pmsg2(000, "Restoring %s file %s\n", debugtext.toUtf8().data(), fullPath.toUtf8().data());
+			versionFilesMulti.insert(version, fullPath);
+			vFMCounter += 1;
+			fileIndexHash.insert(fullPath, fileIndex);
+		 } /* if fullPathDone.value(fullPath, 0) == 0 */
+	  } /* if state != 0 */
    } /* while ftera.hasNext */
    /* The progress bars for the next step */
    prBar1->setValue(2);
@@ -1587,61 +1601,61 @@ void restoreTree::restoreButtonPushed()
    QString tempTable = "";
    QList<int> jobList;
    while (vFMiter.hasNext()) {
-      vFMiter.next();
-      int fversion = vFMiter.key();
-      /* did not succeed in getting an iterator to work as expected on versionFilesMulti so use doneKeys */
-      if (doneKeys.value(fversion, 0) == 0) {
-         if (tempTable == "") {
-            QSettings settings("www.bareos.org", "bat");
-            settings.beginGroup("Restore");
-            int counter = settings.value("Counter", 1).toInt();
-            settings.setValue("Counter", counter+1);
-            settings.endGroup();
-            tempTable = "restore_" + QString("%1").arg(qrand()) + "_" + QString("%1").arg(counter);
-            QString sqlcmd = "CREATE TEMPORARY TABLE " + tempTable + " (JobId INTEGER, FileIndex INTEGER)";
-            if (mainWin->m_sqlDebug)
-               Pmsg1(000, "Query cmd : %s ;\n", sqlcmd.toUtf8().data());
-            QStringList results;
-            if (!m_console->sql_cmd(sqlcmd, results))
-               Pmsg1(000, "CREATE TABLE FAILED!!!! %s\n", sqlcmd.toUtf8().data());
-         }
-
-         if (mainWin->m_rtRestore2Debug) Pmsg1(000, "Version->%i\n", fversion);
-         QStringList fullPathList = versionFilesMulti.values(fversion);
-         /* create the command to perform the restore */
-         foreach(QString ffullPath, fullPathList) {
-            int fileIndex = fileIndexHash.value(ffullPath);
-            if (mainWin->m_rtRestore2Debug) Pmsg2(000, "  file->%s id %i\n", ffullPath.toUtf8().data(), fileIndex);
-            QString sqlcmd = "INSERT INTO " + tempTable + " (JobId, FileIndex) VALUES (" + QString("%1").arg(fversion) + ", " + QString("%1").arg(fileIndex) + ")";
-            if (mainWin->m_rtRestore3Debug)
-               Pmsg1(000, "Insert cmd : %s\n", sqlcmd.toUtf8().data());
-            QStringList results;
-            if (!m_console->sql_cmd(sqlcmd, results))
-               Pmsg1(000, "INSERT INTO FAILED!!!! %s\n", sqlcmd.toUtf8().data());
-            prBar2->setValue(++vFMCounter);
-         } /* foreach fullPathList */
-         doneKeys.insert(fversion,1);
-         jobList.append(fversion);
-      } /*  if (doneKeys.value(fversion, 0) == 0) */
+	  vFMiter.next();
+	  int fversion = vFMiter.key();
+	  /* did not succeed in getting an iterator to work as expected on versionFilesMulti so use doneKeys */
+	  if (doneKeys.value(fversion, 0) == 0) {
+		 if (tempTable == "") {
+			QSettings settings("www.bareos.org", "bat");
+			settings.beginGroup("Restore");
+			int counter = settings.value("Counter", 1).toInt();
+			settings.setValue("Counter", counter+1);
+			settings.endGroup();
+			tempTable = "restore_" + QString("%1").arg(qrand()) + "_" + QString("%1").arg(counter);
+			QString sqlcmd = "CREATE TEMPORARY TABLE " + tempTable + " (JobId INTEGER, FileIndex INTEGER)";
+			if (mainWin->m_sqlDebug)
+			   Pmsg1(000, "Query cmd : %s ;\n", sqlcmd.toUtf8().data());
+			QStringList results;
+			if (!m_console->sql_cmd(sqlcmd, results))
+			   Pmsg1(000, "CREATE TABLE FAILED!!!! %s\n", sqlcmd.toUtf8().data());
+		 }
+
+		 if (mainWin->m_rtRestore2Debug) Pmsg1(000, "Version->%i\n", fversion);
+		 QStringList fullPathList = versionFilesMulti.values(fversion);
+		 /* create the command to perform the restore */
+		 foreach(QString ffullPath, fullPathList) {
+			int fileIndex = fileIndexHash.value(ffullPath);
+			if (mainWin->m_rtRestore2Debug) Pmsg2(000, "  file->%s id %i\n", ffullPath.toUtf8().data(), fileIndex);
+			QString sqlcmd = "INSERT INTO " + tempTable + " (JobId, FileIndex) VALUES (" + QString("%1").arg(fversion) + ", " + QString("%1").arg(fileIndex) + ")";
+			if (mainWin->m_rtRestore3Debug)
+			   Pmsg1(000, "Insert cmd : %s\n", sqlcmd.toUtf8().data());
+			QStringList results;
+			if (!m_console->sql_cmd(sqlcmd, results))
+			   Pmsg1(000, "INSERT INTO FAILED!!!! %s\n", sqlcmd.toUtf8().data());
+			prBar2->setValue(++vFMCounter);
+		 } /* foreach fullPathList */
+		 doneKeys.insert(fversion,1);
+		 jobList.append(fversion);
+	  } /*  if (doneKeys.value(fversion, 0) == 0) */
    } /* while (vFMiter.hasNext()) */
    if (tempTable != "") {
-      /* a table was made, lets run the job */
-      QString jobOption = " jobid=\"";
-      bool first = true;
-      /* create a list of jobs comma separated */
-      foreach (int job, jobList) {
-         if (first) first = false;
-         else jobOption += ",";
-         jobOption += QString("%1").arg(job);
-      }
-      jobOption += "\"";
-      QString cmd = QString("restore");
-      cmd += jobOption +
-             " client=\"" + m_prevClientCombo + "\"" +
-             " file=\"?" + tempTable + "\" done";
-      if (mainWin->m_commandDebug)
-         Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data());
-      consoleCommand(cmd);
+	  /* a table was made, lets run the job */
+	  QString jobOption = " jobid=\"";
+	  bool first = true;
+	  /* create a list of jobs comma separated */
+	  foreach (int job, jobList) {
+		 if (first) first = false;
+		 else jobOption += ",";
+		 jobOption += QString("%1").arg(job);
+	  }
+	  jobOption += "\"";
+	  QString cmd = QString("restore");
+	  cmd += jobOption +
+			 " client=\"" + m_prevClientCombo + "\"" +
+			 " file=\"?" + tempTable + "\" done";
+	  if (mainWin->m_commandDebug)
+		 Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data());
+	  consoleCommand(cmd);
    }
    /* turn off the progress widgets */
    prBar1->setVisible(false);
@@ -1656,48 +1670,48 @@ int restoreTree::mostRecentVersionfromFullPath(QString &fullPath)
    QString directory, fileName;
    int index = fullPath.lastIndexOf("/", -2);
    if (index != -1) {
-      directory = fileName = fullPath;
-      directory.replace(index+1, fullPath.length()-index-1, "");
-      fileName.replace(0, index+1, "");
-      if (false) {
-         QString msg = QString("length = \"%1\" index = \"%2\" Considering \"%3\" \"%4\"\n")
-                    .arg(fullPath.length()).arg(index).arg(fileName).arg(directory);
-         Pmsg0(000, msg.toUtf8().data());
-      }
-      int pathid = m_directoryPathIdHash.value(directory, -1);
-      if (pathid != -1) {
-         /* so now we need the latest version from the database */
-         QString cmd =
-            "SELECT MAX(Job.JobId)"
-            " FROM File "
-            " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
-            " INNER JOIN Job ON (File.JobId=Job.JobId)"
-            " WHERE File.PathId=" + QString("%1").arg(pathid) +
-            " AND Job.Jobid IN (" + m_checkedJobs + ")"
-            " AND Filename.Name='" + fileName + "'"
-            " AND File.FilenameId!=" + QString("%1").arg(m_nullFileNameId) +
-            " GROUP BY Filename.Name";
-
-         if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
-         QStringList results;
-         if (m_console->sql_cmd(cmd, results)) {
-            QStringList fieldlist;
-            int row = 0;
-            /* Iterate through the record returned from the query */
-            foreach (QString resultline, results) {
-               /* Iterate through fields in the record */
-               int column = 0;
-               fieldlist = resultline.split("\t");
-               foreach (QString field, fieldlist) {
-                  if (column == 0) {
-                     qversion = field.toInt();
-                  }
-                  column++;
-               }
-               row++;
-            }
-         }
-      }
+	  directory = fileName = fullPath;
+	  directory.replace(index+1, fullPath.length()-index-1, "");
+	  fileName.replace(0, index+1, "");
+	  if (false) {
+		 QString msg = QString("length = \"%1\" index = \"%2\" Considering \"%3\" \"%4\"\n")
+					.arg(fullPath.length()).arg(index).arg(fileName).arg(directory);
+		 Pmsg0(000, msg.toUtf8().data());
+	  }
+	  int pathid = m_directoryPathIdHash.value(directory, -1);
+	  if (pathid != -1) {
+		 /* so now we need the latest version from the database */
+		 QString cmd =
+			"SELECT MAX(Job.JobId)"
+			" FROM File "
+			" INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
+			" INNER JOIN Job ON (File.JobId=Job.JobId)"
+			" WHERE File.PathId=" + QString("%1").arg(pathid) +
+			" AND Job.Jobid IN (" + m_checkedJobs + ")"
+			" AND Filename.Name='" + fileName + "'"
+			" AND File.FilenameId!=" + QString("%1").arg(m_nullFileNameId) +
+			" GROUP BY Filename.Name";
+
+		 if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
+		 QStringList results;
+		 if (m_console->sql_cmd(cmd, results)) {
+			QStringList fieldlist;
+			int row = 0;
+			/* Iterate through the record returned from the query */
+			foreach (QString resultline, results) {
+			   /* Iterate through fields in the record */
+			   int column = 0;
+			   fieldlist = resultline.split("\t");
+			   foreach (QString field, fieldlist) {
+				  if (column == 0) {
+					 qversion = field.toInt();
+				  }
+				  column++;
+			   }
+			   row++;
+			}
+		 }
+	  }
    } /* if (index != -1) */
    return qversion;
 }
@@ -1710,47 +1724,47 @@ int restoreTree::queryFileIndex(QString &fullPath, int jobId)
    int index = fullPath.lastIndexOf("/", -2);
    if (mainWin->m_sqlDebug) Pmsg1(000, "Index=%d\n", index);
    if (index != -1) {
-      directory = fileName = fullPath;
-      directory.replace(index+1, fullPath.length()-index-1, "");
-      fileName.replace(0, index+1, "");
-      if (false) {
-         QString msg = QString("length = \"%1\" index = \"%2\" Considering \"%3\" \"%4\"\n")
-                    .arg(fullPath.length()).arg(index).arg(fileName).arg(directory);
-         Pmsg0(000, msg.toUtf8().data());
-      }
-      int pathid = m_directoryPathIdHash.value(directory, -1);
-      if (pathid != -1) {
-         /* so now we need the latest version from the database */
-         QString cmd =
-            "SELECT"
-             " File.FileIndex"
-            " FROM File"
-             " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
-             " INNER JOIN Job ON (File.JobId=Job.JobId)"
-            " WHERE File.PathId=" + QString("%1").arg(pathid) +
-             " AND Filename.Name='" + fileName + "'"
-             " AND Job.Jobid='" + QString("%1").arg(jobId) + "'"
-            " GROUP BY File.FileIndex";
-         if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
-         QStringList results;
-         if (m_console->sql_cmd(cmd, results)) {
-            QStringList fieldlist;
-            int row = 0;
-            /* Iterate through the record returned from the query */
-            foreach (QString resultline, results) {
-               /* Iterate through fields in the record */
-               int column = 0;
-               fieldlist = resultline.split("\t");
-               foreach (QString field, fieldlist) {
-                  if (column == 0) {
-                     qfileIndex = field.toInt();
-                  }
-                  column++;
-               }
-               row++;
-            }
-         }
-      }
+	  directory = fileName = fullPath;
+	  directory.replace(index+1, fullPath.length()-index-1, "");
+	  fileName.replace(0, index+1, "");
+	  if (false) {
+		 QString msg = QString("length = \"%1\" index = \"%2\" Considering \"%3\" \"%4\"\n")
+					.arg(fullPath.length()).arg(index).arg(fileName).arg(directory);
+		 Pmsg0(000, msg.toUtf8().data());
+	  }
+	  int pathid = m_directoryPathIdHash.value(directory, -1);
+	  if (pathid != -1) {
+		 /* so now we need the latest version from the database */
+		 QString cmd =
+			"SELECT"
+			 " File.FileIndex"
+			" FROM File"
+			 " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
+			 " INNER JOIN Job ON (File.JobId=Job.JobId)"
+			" WHERE File.PathId=" + QString("%1").arg(pathid) +
+			 " AND Filename.Name='" + fileName + "'"
+			 " AND Job.Jobid='" + QString("%1").arg(jobId) + "'"
+			" GROUP BY File.FileIndex";
+		 if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
+		 QStringList results;
+		 if (m_console->sql_cmd(cmd, results)) {
+			QStringList fieldlist;
+			int row = 0;
+			/* Iterate through the record returned from the query */
+			foreach (QString resultline, results) {
+			   /* Iterate through fields in the record */
+			   int column = 0;
+			   fieldlist = resultline.split("\t");
+			   foreach (QString field, fieldlist) {
+				  if (column == 0) {
+					 qfileIndex = field.toInt();
+				  }
+				  column++;
+			   }
+			   row++;
+			}
+		 }
+	  }
    } /* if (index != -1) */
    if (mainWin->m_sqlDebug) Pmsg1(000, "qfileIndex=%d\n", qfileIndex);
    return qfileIndex;
@@ -1760,6 +1774,6 @@ int restoreTree::queryFileIndex(QString &fullPath, int jobId)
 void restoreTree::PgSeltreeWidgetClicked()
 {
    if (!isOnceDocked()) {
-      dockPage();
+	  dockPage();
    }
 }
diff --git a/src/qt-console/run/run.cpp b/src/qt-console/run/run.cpp
index 6cbe77a..7a49057 100644
--- a/src/qt-console/run/run.cpp
+++ b/src/qt-console/run/run.cpp
@@ -25,6 +25,12 @@
  * Kern Sibbald, February MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QDesktopWidget>
+#endif
+
 #include "bat.h"
 #include "run.h"
 
@@ -40,14 +46,14 @@ runPage::runPage(const QString &defJob) : Pages()
    m_dockOnFirstUse = false;
    init();
    if (defJob != "")
-      jobCombo->setCurrentIndex(jobCombo->findText(defJob, Qt::MatchExactly));
+	  jobCombo->setCurrentIndex(jobCombo->findText(defJob, Qt::MatchExactly));
    show();
 }
 
 
 runPage::runPage(const QString &defJob, const QString &level,
-                 const QString &pool, const QString &storage,
-                 const QString &client, const QString &fileset)
+				 const QString &pool, const QString &storage,
+				 const QString &client, const QString &fileset)
    : Pages()
 {
    m_dockOnFirstUse = false;
@@ -55,14 +61,14 @@ runPage::runPage(const QString &defJob, const QString &level,
    jobCombo->setCurrentIndex(jobCombo->findText(defJob, Qt::MatchExactly));
    job_name_change(0);
    filesetCombo->setCurrentIndex(filesetCombo->findText(fileset,
-                                                        Qt::MatchExactly));
+														Qt::MatchExactly));
    levelCombo->setCurrentIndex(levelCombo->findText(level, Qt::MatchExactly));
    clientCombo->setCurrentIndex(clientCombo->findText(client,Qt::MatchExactly));
    poolCombo->setCurrentIndex(poolCombo->findText(pool, Qt::MatchExactly));
 
    if (storage != "") {         // TODO: enable storage
-      storageCombo->setCurrentIndex(storageCombo->findText(storage,
-                                                           Qt::MatchExactly));
+	  storageCombo->setCurrentIndex(storageCombo->findText(storage,
+														   Qt::MatchExactly));
    }
    show();
 }
@@ -99,7 +105,7 @@ void runPage::init()
    dateTimeEdit->setDateTime(dt.currentDateTime());
    /*printf("listing messages resources");  ***FIME ***
    foreach(QString mes, m_console->messages_list) {
-      printf("%s\n", mes.toUtf8().data());
+	  printf("%s\n", mes.toUtf8().data());
    }*/
    messagesCombo->addItems(m_console->messages_list);
    messagesCombo->setEnabled(false);
@@ -119,26 +125,26 @@ void runPage::okButtonPushed()
    this->hide();
    QString cmd;
    QTextStream(&cmd) << "run" <<
-      " job=\"" << jobCombo->currentText() << "\"" <<
-      " fileset=\"" << filesetCombo->currentText() << "\"" <<
-      " level=\"" << levelCombo->currentText() << "\"" <<
-      " client=\"" << clientCombo->currentText() << "\"" <<
-      " pool=\"" << poolCombo->currentText() << "\"" <<
-      " storage=\"" << storageCombo->currentText() << "\"" <<
-      " priority=\"" << prioritySpin->value() << "\""
-      " when=\"" << dateTimeEdit->dateTime().toString(mainWin->m_dtformat) << "\"";
+	  " job=\"" << jobCombo->currentText() << "\"" <<
+	  " fileset=\"" << filesetCombo->currentText() << "\"" <<
+	  " level=\"" << levelCombo->currentText() << "\"" <<
+	  " client=\"" << clientCombo->currentText() << "\"" <<
+	  " pool=\"" << poolCombo->currentText() << "\"" <<
+	  " storage=\"" << storageCombo->currentText() << "\"" <<
+	  " priority=\"" << prioritySpin->value() << "\""
+	  " when=\"" << dateTimeEdit->dateTime().toString(mainWin->m_dtformat) << "\"";
 #ifdef xxx
-      " messages=\"" << messagesCombo->currentText() << "\"";
-     /* FIXME when there is an option to modify the messages resource associated
-      * with a  job */
+	  " messages=\"" << messagesCombo->currentText() << "\"";
+	 /* FIXME when there is an option to modify the messages resource associated
+	  * with a  job */
 #endif
    if (bootstrap->text() != "") {
-      cmd += " bootstrap=\"" + bootstrap->text() + "\"";
+	  cmd += " bootstrap=\"" + bootstrap->text() + "\"";
    }
    cmd += " yes";
 
    if (mainWin->m_commandDebug) {
-      Pmsg1(000, "command : %s\n", cmd.toUtf8().data());
+	  Pmsg1(000, "command : %s\n", cmd.toUtf8().data());
    }
 
    consoleCommand(cmd);
@@ -168,19 +174,19 @@ void runPage::job_name_change(int index)
    (void)index;
    job_defs.job_name = jobCombo->currentText();
    if (m_console->get_job_defaults(job_defs)) {
-      QString cmd;
-      typeLabel->setText("<H3>"+job_defs.type+"</H3>");
-      filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
-      levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
-      clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
-      poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
-      storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
-      messagesCombo->setCurrentIndex(messagesCombo->findText(job_defs.messages_name, Qt::MatchExactly));
-      m_console->level_list.clear();
-      cmd = ".levels " + job_defs.type;
-      m_console->dir_cmd(cmd, m_console->level_list);
-      levelCombo->clear();
-      levelCombo->addItems(m_console->level_list);
-      levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, 0 /*Qt::MatchExactly*/));
+	  QString cmd;
+	  typeLabel->setText("<H3>"+job_defs.type+"</H3>");
+	  filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
+	  levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
+	  clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
+	  poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
+	  storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
+	  messagesCombo->setCurrentIndex(messagesCombo->findText(job_defs.messages_name, Qt::MatchExactly));
+	  m_console->level_list.clear();
+	  cmd = ".levels " + job_defs.type;
+	  m_console->dir_cmd(cmd, m_console->level_list);
+	  levelCombo->clear();
+	  levelCombo->addItems(m_console->level_list);
+	  levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, 0 /*Qt::MatchExactly*/));
    }
 }
diff --git a/src/qt-console/select/select.cpp b/src/qt-console/select/select.cpp
index 7f74ad6..be2460c 100644
--- a/src/qt-console/select/select.cpp
+++ b/src/qt-console/select/select.cpp
@@ -25,6 +25,11 @@
  * Kern Sibbald, March MMVII
  */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include "bat.h"
 #include "select.h"
 
@@ -47,9 +52,9 @@ selectDialog::selectDialog(Console *console, int conn) : QDialog()
    m_console->read(m_conn);                 /* get title */
    labelWidget->setText(m_console->msg(m_conn));
    while ((stat=m_console->read(m_conn)) > 0) {
-      item = new QListWidgetItem;
-      item->setText(m_console->msg(m_conn));
-      listBox->insertItem(row++, item);
+	  item = new QListWidgetItem;
+	  item->setText(m_console->msg(m_conn));
+	  listBox->insertItem(row++, item);
    }
    m_console->displayToPrompt(m_conn);
    this->show();
@@ -108,11 +113,11 @@ yesnoPopUp::yesnoPopUp(Console *console, int conn)  : QDialog()
    console->displayToPrompt(conn);
    switch (msgBox.exec()) {
    case QMessageBox::Yes:
-      console->write_dir(conn, "yes");
-      break;
+	  console->write_dir(conn, "yes");
+	  break;
    case QMessageBox::No:
-      console->write_dir(conn, "no");
-      break;
+	  console->write_dir(conn, "no");
+	  break;
    }
    console->displayToPrompt(conn);
    mainWin->resetFocus();
diff --git a/src/qt-console/storage/content.cpp b/src/qt-console/storage/content.cpp
index f461cac..fe2e124 100644
--- a/src/qt-console/storage/content.cpp
+++ b/src/qt-console/storage/content.cpp
@@ -21,6 +21,11 @@
    02110-1301, USA.
 */
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QMessageBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
diff --git a/src/qt-console/storage/storage.h b/src/qt-console/storage/storage.h
index be731a9..2d8ec49 100644
--- a/src/qt-console/storage/storage.h
+++ b/src/qt-console/storage/storage.h
@@ -26,6 +26,11 @@
 #ifndef _STORAGE_H_
 #define _STORAGE_H_
 
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QTableWidget>
+#endif
 #include <QtGui>
 
 #include "ui_storage.h"
diff --git a/src/qt-console/util/comboutil.cpp b/src/qt-console/util/comboutil.cpp
index ce8acea..b9c606c 100644
--- a/src/qt-console/util/comboutil.cpp
+++ b/src/qt-console/util/comboutil.cpp
@@ -24,7 +24,11 @@
  *
  * Riccardo Ghetta, May 2008
  */
-
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+	#include <QComboBox>
+#endif
 #include <QtGui>
 
 #include "bat.h"
diff --git a/src/qt-console/util/fmtwidgetitem.cpp b/src/qt-console/util/fmtwidgetitem.cpp
index de78be0..b909f7d 100644
--- a/src/qt-console/util/fmtwidgetitem.cpp
+++ b/src/qt-console/util/fmtwidgetitem.cpp
@@ -24,7 +24,10 @@
  *
  * Riccardo Ghetta, May 2008
  */
-
+#include <QtCore>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	#include <QWidget>
+#endif
 #include <QtGui>
 
 #include "bat.h"
@@ -45,7 +48,11 @@ QString convertJobStatus(const QString &sts)
    }
 
    char buf[256];
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+   jobstatus_to_ascii_gui( code[0].toLatin1(), buf, sizeof(buf));
+#else
    jobstatus_to_ascii_gui( code[0].toAscii(), buf, sizeof(buf));
+#endif
    return QString(buf);
 }
 
@@ -381,7 +388,11 @@ void ItemFormatterBase::setJobStatusFld(int index, const QString &status, bool c
 
 void ItemFormatterBase::setJobTypeFld(int index, const QString &fld, bool center)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	QByteArray jtype(fld.trimmed().toLatin1());
+#else
    QByteArray jtype(fld.trimmed().toAscii());
+#endif
    if (jtype.size()) {
 	  setTextFld(index, job_type_to_str(jtype[0]), center);
    } else {
@@ -391,7 +402,11 @@ void ItemFormatterBase::setJobTypeFld(int index, const QString &fld, bool center
 
 void ItemFormatterBase::setJobLevelFld(int index, const QString &fld, bool center)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+	QByteArray lvl(fld.trimmed().toLatin1());
+#else
    QByteArray lvl(fld.trimmed().toAscii());
+#endif
    if (lvl.size()) {
 	  setTextFld(index, job_level_to_str(lvl[0]), center);
    } else {
diff --git a/src/qt-console/util/fmtwidgetitem.h b/src/qt-console/util/fmtwidgetitem.h
index ebf32e8..3a2eab5 100644
--- a/src/qt-console/util/fmtwidgetitem.h
+++ b/src/qt-console/util/fmtwidgetitem.h
@@ -26,12 +26,8 @@
 #ifndef _FMTWIDGETITEM_H_
 #define _FMTWIDGETITEM_H_
 
-class QWidget;
-class QTreeWidgetItem;
-class QTableWidget;
-class QTableWidgetItem;
-class QString;
-class QBrush;
+#include <QtGui>
+#include <QTableWidgetItem>
 
 
 /*
@@ -69,9 +65,9 @@ class ItemFormatterBase
 {
 public:
    enum BYTES_CONVERSION {
-      BYTES_CONVERSION_NONE,
-      BYTES_CONVERSION_IEC,
-      BYTES_CONVERSION_SI
+	  BYTES_CONVERSION_NONE,
+	  BYTES_CONVERSION_IEC,
+	  BYTES_CONVERSION_SI
    };
 
 public:
@@ -122,10 +118,10 @@ public:
    void setFileType(int index, const QString &type);
 
    static void setBytesConversion(BYTES_CONVERSION b) {
-      cnvFlag = b;
+	  cnvFlag = b;
    }
    static BYTES_CONVERSION getBytesConversion() {
-      return cnvFlag;
+	  return cnvFlag;
    }
 
 protected:
@@ -185,15 +181,15 @@ private:
    class BatSortingTableItem : public QTableWidgetItem
    {
    private:
-      static const int SORTDATA_ROLE = Qt::UserRole + 100;
+	  static const int SORTDATA_ROLE = Qt::UserRole + 100;
    public:
-      BatSortingTableItem();
+	  BatSortingTableItem();
 
-      /* uses the sort data if available, reverts to default behavior othervise */
-      virtual bool operator< ( const QTableWidgetItem & o ) const;
+	  /* uses the sort data if available, reverts to default behavior othervise */
+	  virtual bool operator< ( const QTableWidgetItem & o ) const;
 
-      /* set the value used for sorting - MUST BE A NUMERIC TYPE */
-      void setSortData(const QVariant &d);
+	  /* set the value used for sorting - MUST BE A NUMERIC TYPE */
+	  void setSortData(const QVariant &d);
    };
 
 public:
-- 
1.8.3.1

